fern-api 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +4 -4
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1450,7 +1450,7 @@ ${ZXs.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&wyi(th
|
|
|
1450
1450
|
`+UNe.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?UNe.default.cyan(uZs(t,this.opt.mask)):UNe.default.italic(UNe.default.dim("[hidden]")):this.opt.mask?uZs(t,this.opt.mask):UNe.default.italic(UNe.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 bir=Ce(rw(),1);var aea=Ce(ibi(),1),Air=require("child_process"),$$e=require("fs"),gir=Ce(require("path"),1),uea=Ce(require("os"),1),cea=require("crypto"),zbi=Ce(oea(),1);var dir=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var gOt=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var mir=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var hir=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function yir(e="",t,r){let n=new Vbi(e,r);n.runAsync((i,o)=>{if(i)setImmediate(t,i,void 0);else try{n.cleanup(),setImmediate(t,void 0,o)}catch(s){setImmediate(t,s,void 0)}})}function sea(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function yqp(e){let t=[],r="";for(let n=0;n<e.length;n++){let i=e.charAt(n);n>0&&i===" "&&e[n-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${i}`}return r.length>0&&t.push(r),t}var Vbi=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=yqp(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??uea.default.tmpdir(),r=(0,cea.randomUUID)(),n=sea(this.fileOptions.prefix),i=sea(this.fileOptions.postfix),o=`${n}${r}${i}`,s=gir.default.resolve(t,o),a=gir.default.resolve(t)+gir.default.sep;if(!s.startsWith(a))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=s;let u={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(u.mode=this.fileOptions.mode),(0,$$e.writeFileSync)(this.tempFile,this.text,u)}catch(t){throw new dir(t)}}readTemporaryFile(){try{let t=(0,$$e.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,aea.detect)(t)??"utf8";zbi.default.encodingExists(r)||(r="utf8"),this.text=zbi.default.decode(t,r)}}catch(t){throw new mir(t)}}removeTemporaryFile(){try{(0,$$e.unlinkSync)(this.tempFile)}catch(t){throw new hir(t)}}launchEditor(){try{let t=(0,Air.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new gOt(t)}}launchEditorAsync(t){try{(0,Air.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new gOt(r)}}};var lea=Ce(YN(),1);var AOt=class extends nw{_run(t){this.done=t,this.editorResult=new lea.Subject;let r=aS(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?bir.default.dim("Received"):bir.default.dim("Press <enter> to launch your preferred editor."),t&&(r=bir.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),yir(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 hea=require("stream");var dea=Ce(require("readline"),1),mea=Ce(fea(),1),GNe=class{constructor(t){this.rl||=dea.default.createInterface(vqp(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 vqp(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new mea.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var yOt=class extends GNe{constructor(t={}){super(t),this.log=new hea.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return tOt(this.rl,this.bottomBar.split(`
|
|
1451
1451
|
`).length),this}updateBottomBar(t){return tOt(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+`
|
|
1452
1452
|
`}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&&Unr(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var Sf=Ce(YN(),1),yea=Ce(I1t(),1);var vir=Ce(YN(),1),gea=Ce(I1t(),1),Eir=function(e,t,r){return typeof e[t]!="function"?(0,vir.of)(e):(0,vir.from)((0,gea.default)(e[t])(r).then(n=>(e[t]=n,e)))};var Aea={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,o,s)=>{i==="__proto__"||i==="constructor"||(o===s.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=o=>String.prototype.split.call(t,o).filter(Boolean).reduce((s,a)=>s!=null?s[a]:s,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},H$e=class extends GNe{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let n;return Array.isArray(t)?n=(0,Sf.from)(t):(0,Sf.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,Sf.from)(Object.entries(t).map(([i,o])=>({name:i,...o}))):n=(0,Sf.from)([t]),this.process=n.pipe((0,Sf.concatMap)(this.processQuestion.bind(this)),(0,Sf.publish)()),this.process.connect(),this.process.pipe((0,Sf.reduce)((i,o)=>(Aea.set(i,o.name,o.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,Sf.defer)(()=>(0,Sf.of)(t).pipe((0,Sf.concatMap)(this.setDefaultType.bind(this)),(0,Sf.concatMap)(this.filterIfRunnable.bind(this)),(0,Sf.concatMap)(()=>Eir(t,"message",this.answers)),(0,Sf.concatMap)(()=>Eir(t,"default",this.answers)),(0,Sf.concatMap)(()=>Eir(t,"choices",this.answers)),(0,Sf.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,Sf.defer)(()=>(0,Sf.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,Sf.defer)(()=>(0,Sf.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&Aea.get(this.answers,t.name)!==void 0)return Sf.EMPTY;if(t.when===!1)return Sf.EMPTY;if(typeof t.when!="function")return(0,Sf.of)(t);let{answers:r}=this;return(0,Sf.defer)(()=>(0,Sf.from)((0,yea.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,Sf.filter)(n=>n!=null)))}};function bea(e){let t=function(r,n){let i;try{i=new H$e(t.prompts,e)}catch(s){return Promise.reject(s)}let o=i.run(r,n);return o.ui=i,o};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",nOt),this.registerPrompt("input",LNe),this.registerPrompt("number",iOt),this.registerPrompt("confirm",oOt),this.registerPrompt("rawlist",sOt),this.registerPrompt("expand",aOt),this.registerPrompt("checkbox",uOt),this.registerPrompt("password",cOt),this.registerPrompt("editor",AOt)},t.restoreDefaultPrompts(),t}var Gbi=bea();function Iqp(e,t){Gbi.registerPrompt(e,t)}function wqp(){Gbi.restoreDefaultPrompts()}var Cqp={prompt:Gbi,ui:{BottomBar:yOt,Prompt:H$e},createPromptModule:bea,registerPrompt:Iqp,restoreDefaultPrompts:wqp,Separator:oF},Of=Cqp;var K$e=require("path");function Eea(){let e=_qp();return async t=>{for(let r of t)r.module=e(r.filename);return t}}function _qp(e=process.argv[1]?(0,K$e.dirname)(process.argv[1]):process.cwd(),t=K$e.sep==="\\"){let r=t?vea(e):e;return n=>{if(!n)return;let i=t?vea(n):n,{dir:o,base:s,ext:a}=K$e.posix.parse(i);(a===".js"||a===".mjs"||a===".cjs")&&(s=s.slice(0,-1*a.length));let u=decodeURIComponent(s);o||(o=".");let c=o.lastIndexOf("/node_modules");if(c>-1)return`${o.slice(c+14).replace(/\//g,".")}:${u}`;if(o.startsWith(r)){let l=o.slice(r.length+1).replace(/\//g,".");return l?`${l}:${u}`:u}return u}}function vea(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var Wbi=e=>{if("flags"in e){let t=Iea(e.flags),r=wea(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,o])=>[i,Cea(o)])),n=Object.fromEntries(Object.entries(t).map(([i,o])=>[i,xqp(i,o,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function xqp(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 Iea=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,bOt(r)]).filter(([,t])=>t!==void 0)),wea=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let n=t[r];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(r=>{let n=t[r].metadata?.payload;return[r,n?Cea(n):void 0]}))};var bOt=e=>e===void 0?void 0:e.variant??e.enabled,Cea=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};var Iir="0123456789abcdef",wir=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,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let o=new Uint8Array(16);return o[0]=t/2**40,o[1]=t/2**32,o[2]=t/2**24,o[3]=t/2**16,o[4]=t/256,o[5]=t,o[6]=112|r>>>8,o[7]=r,o[8]=128|n>>>24,o[9]=n>>>16,o[10]=n>>>8,o[11]=n,o[12]=i>>>24,o[13]=i>>>16,o[14]=i>>>8,o[15]=i,new e(o)}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 n=new Uint8Array(16);for(let i=0;i<16;i+=4){let o=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=o>>>24,n[i+1]=o>>>16,n[i+2]=o>>>8,n[i+3]=o}return new e(n)}throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Iir.charAt(this.bytes[r]>>>4),t+=Iir.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+=Iir.charAt(this.bytes[r]>>>4),t+=Iir.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 n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},$bi=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??Sqp()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}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 wir.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,wir.ofInner(t)}},Sqp=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),_ea,cJ=()=>Oqp().toString(),Oqp=()=>(_ea||(_ea=new $bi)).generate();var Bqp=["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"],xea=function(e,t=[]){if(!e)return!1;let r=e.toLowerCase();return Bqp.concat(t).some(n=>{let i=n.toLowerCase();return r.indexOf(i)!==-1})};var aF=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",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 Tqp=Array.isArray,Sea=Object.prototype,jvA=Sea.hasOwnProperty,Hbi=Sea.toString,Kbi=Tqp||function(e){return Hbi.call(e)==="[object Array]"};var Oea=e=>e===Object(e)&&!Kbi(e);var J$e=e=>e===void 0,vOt=e=>Hbi.call(e)=="[object String]",Bea=e=>vOt(e)&&e.trim().length===0;var Pea=e=>Hbi.call(e)=="[object Number]"&&e===e;var Jbi=e=>e instanceof Error;function EOt(e){return e===null||typeof e!="object"}function WNe(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function Tea(e){return WNe(e,"ErrorEvent")}function Cir(e){return!J$e(Event)&&Dqp(e,Event)}function Dea(e){return WNe(e,"Object")}function Dqp(e,t){try{return e instanceof t}catch{return!1}}function IOt(e,t,r,n,i){return t>r&&(n.warn("min cannot be greater than max."),t=r),Pea(e)?e>r?(n.warn(" cannot be greater than max: "+r+". Using max value instead."),r):e<t?(n.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(n.warn(" must be a number. using max or fallback. max: "+r+", fallback: "+i),IOt(i||r,t,r,n))}var Rqp=864e5,_ir=class{constructor(t){this._buckets={},this._onBucketRateLimited=t._onBucketRateLimited,this._bucketSize=IOt(t.bucketSize,0,100,t._logger),this._refillRate=IOt(t.refillRate,0,this._bucketSize,t._logger),this._refillInterval=IOt(t.refillInterval,0,Rqp,t._logger)}_applyRefill(t,r){let n=r-t.lastAccess,i=Math.floor(n/this._refillInterval);if(i>0){let o=i*this._refillRate;t.tokens=Math.min(t.tokens+o,this._bucketSize),t.lastAccess=t.lastAccess+i*this._refillInterval}}consumeRateLimit(t){let r=Date.now(),n=String(t),i=this._buckets[n];return i?this._applyRefill(i,r):(i={tokens:this._bucketSize,lastAccess:r},this._buckets[n]=i),i.tokens===0?!0:(i.tokens--,i.tokens===0&&this._onBucketRateLimited?.(t),i.tokens===0)}stop(){this._buckets={}}};var xir=class{add(t){let r=cJ();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 Fqp(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}var Rea=(e,t,r)=>{function n(o,...s){t(()=>{let a=r[o];a(e,...s)})}return{info:(...o)=>{n("log",...o)},warn:(...o)=>{n("warn",...o)},error:(...o)=>{n("error",...o)},critical:(...o)=>{r.error(e,...o)},createLogger:o=>Rea(`${e} ${o}`,t,r)}},jqp=e=>e();function Fea(e,t=jqp){return Rea(e,t,Fqp())}var X$e="Mobile",Oir="iOS",Y$e="Android",jea="Tablet",$vA=Y$e+" "+jea;var Qqp="Apple",HvA=Qqp+" Watch",Qea="Safari",Bir="BlackBerry",Nea="Samsung",Nqp=Nea+"Browser",kqp=Nea+" Internet",Pir="Chrome",Mqp=Pir+" OS",Lqp=Pir+" "+Oir,kea="Internet Explorer",Uqp=kea+" "+X$e,Xbi="Opera",KvA=Xbi+" Mini",Mea="Edge",zqp="Microsoft "+Mea,Zbi="Firefox",Vqp=Zbi+" "+Oir,e0i="Nintendo",t0i="PlayStation",Sir="Xbox",qqp=Y$e+" "+X$e,Gqp=X$e+" "+Qea,wOt="Windows",Wqp=wOt+" Phone";var Lea="Generic",JvA=Lea+" "+X$e.toLowerCase(),YvA=Lea+" "+jea.toLowerCase(),$qp="Konqueror",jP="(\\d+(\\.\\d+)?)",Ybi=new RegExp("Version/"+jP),XvA=new RegExp(Sir,"i"),ZvA=new RegExp(t0i+" \\w+","i"),eEA=new RegExp(e0i+" \\w+","i"),Hqp=new RegExp(Bir+"|PlayBook|BB10","i"),Kqp={"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 tEA={[Uqp]:[new RegExp("rv:"+jP)],[zqp]:[new RegExp(Mea+"?\\/"+jP)],[Pir]:[new RegExp("("+Pir+"|CrMo)\\/"+jP)],[Lqp]:[new RegExp("CriOS\\/"+jP)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+jP)],[Qea]:[Ybi],[Gqp]:[Ybi],[Xbi]:[new RegExp("("+Xbi+"|OPR)\\/"+jP)],[Zbi]:[new RegExp(Zbi+"\\/"+jP)],[Vqp]:[new RegExp("FxiOS\\/"+jP)],[$qp]:[new RegExp("Konqueror[:/]?"+jP,"i")],[Bir]:[new RegExp(Bir+" "+jP),Ybi],[qqp]:[new RegExp("android\\s"+jP,"i")],[kqp]:[new RegExp(Nqp+"\\/"+jP)],[kea]:[new RegExp("(rv:|MSIE )"+jP)],Mozilla:[new RegExp("rv:"+jP)]};var rEA=[[new RegExp(Sir+"; "+Sir+" (.*?)[);]","i"),e=>[Sir,e&&e[1]||""]],[new RegExp(e0i,"i"),[e0i,""]],[new RegExp(t0i,"i"),[t0i,""]],[Hqp,[Bir,""]],[new RegExp(wOt,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Wqp,""];if(new RegExp(X$e).test(t)&&!/IEMobile\b/.test(t))return[wOt+" "+X$e,""];let r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){let n=r[1],i=Kqp[n]||"";return/arm/i.test(t)&&(i="RT"),[wOt,i]}return[wOt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){let t=[e[3],e[4],e[5]||"0"];return[Oir,t.join(".")]}return[Oir,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=J$e(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Y$e+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Y$e+")","i"),e=>{if(e&&e[2]){let t=[e[2],e[3],e[4]||"0"];return[Y$e,t.join(".")]}return[Y$e,""]}],[/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/,[Mqp,""]],[/Linux|debian/i,["Linux",""]]];var Uea="utf8";function zea(e,t){if(!e||typeof e!="string"||Jqp(e))throw new Error(t)}function Jqp(e){return e.trim().length===0}function Vea(e){return e?.replace(/\/+$/,"")}async function qea(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function Tir(){return new Date().toISOString()}function $Ne(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Gea=e=>e instanceof Error;function r0i(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var Dir=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(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}};function Wea(){return"CompressionStream"in globalThis}async function n0i(e,t=!0){try{let n=new Blob([e],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return await new Response(n).blob()}catch(r){return t&&console.error("Failed to gzip compress data",r),null}}var HNe=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()}},Z$e=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function $ea(e){if(e instanceof HNe){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 i0i(e){return typeof e=="object"&&(e instanceof HNe||e instanceof Z$e)}function Hea(e){return typeof e=="object"&&e instanceof HNe&&e.status===413}var COt=class{constructor(t,r={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new xir,this._events=new Dir,this._isInitialized=!1,zea(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=Vea(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:i0i},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._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=Fea("[PostHog]",this.logMsgIfDebug.bind(this)),this.evaluationContexts=r?.evaluationContexts??r?.evaluationEnvironments,r?.evaluationEnvironments&&!r?.evaluationContexts&&this._logger.warn("evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version."),this.disableCompression=!Wea()||(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(aF.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(aF.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(aF.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>this._logger.info(n,i));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,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}async identifyStatelessImmediate(t,r,n){let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",i,n)}captureStateless(t,r,n,i){this.wrap(()=>{let o=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",o,i)})}async captureStatelessImmediate(t,r,n,i){let o=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",o,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let o=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",o,i)})}async aliasStatelessImmediate(t,r,n,i){let o=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",o,i)}groupIdentifyStateless(t,r,n,i,o,s){this.wrap(()=>{let a=this.buildPayload({distinct_id:o||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...s||{}}});this.enqueue("capture",a,i)})}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`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(i=>i.json()).catch(i=>{this._logger.error("Remote config could not be loaded",i),this._events.emit("error",i)})}async getFlags(t,r={},n={},i={},o={},s=!0){await this._initPromise;let a=s?"&config=true":"",u=`${this.host}/flags/?v=2${a}`,c={token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...o};this.evaluationContexts&&this.evaluationContexts.length>0&&(c.evaluation_contexts=this.evaluationContexts);let l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify(c)};return this._logger.info("Flags URL",u),this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(p=>p.json()).then(p=>({success:!0,response:Wbi(p)})).catch(p=>(this._events.emit("error",p),{success:!1,error:this.categorizeRequestError(p)}))}categorizeRequestError(t){if(t instanceof HNe)return{type:"api_error",statusCode:t.status};if(t instanceof Z$e){let r=t.error;return r instanceof Error&&(r.name==="AbortError"||r.name==="TimeoutError")?{type:"timeout"}:{type:"connection_error"}}return{type:"unknown_error"}}async getFeatureFlagStateless(t,r,n={},i={},o={},s){await this._initPromise;let a=await this.getFeatureFlagDetailStateless(t,r,n,i,o,s);if(a===void 0)return{response:void 0,requestId:void 0};let u=bOt(a.response);return u===void 0&&(u=!1),{response:u,requestId:a.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},o={},s){await this._initPromise;let a=await this.getFeatureFlagDetailsStateless(r,n,i,o,s,[t]);return a===void 0?void 0:{response:a.flags[t],requestId:a.requestId,evaluatedAt:a.evaluatedAt}}async getFeatureFlagPayloadStateless(t,r,n={},i={},o={},s){await this._initPromise;let a=await this.getFeatureFlagPayloadsStateless(r,n,i,o,s,[t]);if(!a)return;let u=a[t];return u===void 0?null:u}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},o,s){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,o,s)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},o,s){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,o,s)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},o,s){await this._initPromise;let a=await this.getFeatureFlagDetailsStateless(t,r,n,i,o,s);return a?{flags:a.featureFlags,payloads:a.featureFlagPayloads,requestId:a.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},o,s){await this._initPromise;let a={};(o??this.disableGeoip)&&(a.geoip_disable=!0),s&&(a.flag_keys_to_evaluate=s);let u=await this.getFlags(t,r,n,i,a);if(!u.success)return;let c=u.response;return c.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"),c.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:c?.requestId,quotaLimited:c.quotaLimited}):c}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"}},i=(await this.fetchWithRetry(t,r).then(o=>{if(o.status!==200||!o.json){let s=`Surveys API could not be loaded: ${o.status}`,a=new Error(s);this._logger.error(a),this._events.emit("error",new Error(s));return}return o.json()}).catch(o=>{this._logger.error("Surveys API could not be loaded",o),this._events.emit("error",o)}))?.surveys;return i&&this._logger.info("Surveys fetched from API: ",JSON.stringify(i)),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(aF.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(aF.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(aF.Props,this.props)})}processBeforeEnqueue(t){return t}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut)return void this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let i=this.prepareMessage(t,r,n);if(i=this.processBeforeEnqueue(i),i===null)return;let o=this.getPersistedProperty(aF.Queue)||[];o.length>=this.maxQueueSize&&(o.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),o.push({message:i}),this.setPersistedProperty(aF.Queue,o),this._events.emit(t,i),o.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=$Ne(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){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 i=this.prepareMessage(t,r,n);if(i=this.processBeforeEnqueue(i),i===null)return;let o={api_key:this.apiKey,batch:[i],sent_at:Tir()};this.historicalMigration&&(o.historical_migration=!0);let s=JSON.stringify(o),a=`${this.host}/batch/`,u=this.disableCompression?null:await n0i(s,this.isDebug),c={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...u!==null&&{"Content-Encoding":"gzip"}},body:u||s};try{await this.fetchWithRetry(a,c)}catch(l){this._events.emit("error",l)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:Tir(),uuid:n?.uuid?n.uuid:cJ()};return(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId),i}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await $ea(t)})}async flush(){let t=r0i([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),r0i([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(aF.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),o=i.map(f=>f.message),s=()=>{let m=(this.getPersistedProperty(aF.Queue)||[]).slice(i.length);this.setPersistedProperty(aF.Queue,m),t=m},a={api_key:this.apiKey,batch:o,sent_at:Tir()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),c=`${this.host}/batch/`,l=this.disableCompression?null:await n0i(u,this.isDebug),p={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...l!==null&&{"Content-Encoding":"gzip"}},body:l||u},d={retryCheck:f=>Hea(f)?!1:i0i(f)};try{await this.fetchWithRetry(c,p,d)}catch(f){if(Hea(f)&&o.length>1){this.maxBatchSize=Math.max(1,Math.floor(o.length/2)),this._logger.warn(`Received 413 when sending batch of size ${o.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw f instanceof Z$e||s(),this._events.emit("error",f),f}s(),r.push(...o)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){AbortSignal.timeout??=function(a){let u=new AbortController;return setTimeout(()=>u.abort(),a),u.signal};let o=r.body?r.body:"",s=-1;try{s=o instanceof Blob?o.size:Buffer.byteLength(o,Uea)}catch{o instanceof Blob?s=o.size:s=new TextEncoder().encode(o).length}return await qea(async()=>{let a=null;try{a=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(c){throw new Z$e(c)}if(!(r.mode==="no-cors")&&(a.status<200||a.status>=400))throw new HNe(a,s);return a},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await this.promiseQueue.join();!((this.getPersistedProperty(aF.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!i0i(i))throw i;await $ea(i)}};return Promise.race([new Promise((i,o)=>{$Ne(()=>{this._logger.error("Timed out while shutting down PostHog"),r=!0,o("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}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 uF={};X(uF,{DOMExceptionCoercer:()=>u0i,ErrorCoercer:()=>c0i,ErrorEventCoercer:()=>l0i,ErrorPropertiesBuilder:()=>o0i,EventCoercer:()=>d0i,ObjectCoercer:()=>f0i,PrimitiveCoercer:()=>m0i,PromiseRejectionEventCoercer:()=>h0i,ReduceableCache:()=>g0i,StringCoercer:()=>p0i,chromeStackLineParser:()=>s0i,createDefaultStackParser:()=>p9p,createStackParser:()=>ota,geckoStackLineParser:()=>a0i,nodeStackLineParser:()=>tta,opera10StackLineParser:()=>Xea,opera11StackLineParser:()=>Zea,reverseAndStripFrames:()=>ita,winjsStackLineParser:()=>Yea});var Rir,Kea,Fir;function Jea(e){let t=globalThis._posthogChunkIds;if(!t)return;let r=Object.keys(t);return Fir&&r.length===Kea||(Kea=r.length,Fir=r.reduce((n,i)=>{Rir||(Rir={});let o=Rir[i];if(o)n[o[0]]=o[1];else{let s=e(i);for(let a=s.length-1;a>=0;a--){let c=s[a]?.filename,l=t[i];if(c&&l){n[c]=l,Rir[i]=[c,l];break}}}return n},{})),Fir}var Xqp=4,o0i=class{constructor(t,r,n=[]){this.coercers=t,this.stackParser=r,this.modifiers=n}buildFromUnknown(t,r={}){let i=r&&r.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,r,0).apply(t),a=this.buildParsingContext(),u=this.parseStacktrace(s,a);return{$exception_list:this.convertToExceptionList(u,i),$exception_level:"error"}}async modifyFrames(t){for(let r of t)r.stacktrace&&r.stacktrace.frames&&Kbi(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 n;t.cause!=null&&(n=this.parseStacktrace(t.cause,r));let i;return t.stack!=""&&t.stack!=null&&(i=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?1:0),r.chunkIdMap)),{...t,cause:n,stack:i}}applyChunkIds(t,r){return t.map(n=>(n.filename&&r&&(n.chunk_id=r[n.filename]),n))}applyCoercers(t,r){for(let n of this.coercers)if(n.match(t))return n.coerce(t,r);return this.coerceFallback(r)}async applyModifiers(t){let r=t;for(let n of this.modifiers)r=await n(r);return r}convertToExceptionList(t,r){let n={type:t.type,value:t.value,mechanism:{type:r.type??"generic",handled:r.handled??!0,synthetic:t.synthetic??!1}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});let i=[n];return t.cause!=null&&i.push(...this.convertToExceptionList(t.cause,{...r,handled:!0})),i}buildParsingContext(){return{chunkIdMap:Jea(this.stackParser)}}buildCoercingContext(t,r,n=0){let i=(s,a)=>{if(a<=Xqp){let u=this.buildCoercingContext(t,r,a);return this.applyCoercers(s,u)}};return{...r,syntheticException:n==0?r.syntheticException:void 0,mechanism:t,apply:s=>i(s,n),next:s=>i(s,n+1)}}};var cS="?";function lJ(e,t,r,n,i){let o={platform:e,filename:t,function:r==="<anonymous>"?cS:r,in_app:!0};return J$e(n)||(o.lineno=n),J$e(i)||(o.colno=i),o}var jir=(e,t)=>{let r=e.indexOf("safari-extension")!==-1,n=e.indexOf("safari-web-extension")!==-1;return r||n?[e.indexOf("@")!==-1?e.split("@")[0]:cS,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]};var Zqp=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,e9p=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,t9p=/\((\S*)(?::(\d+))(?::(\d+))\)/,s0i=(e,t)=>{let r=Zqp.exec(e);if(r){let[,i,o,s]=r;return lJ(t,i,cS,+o,+s)}let n=e9p.exec(e);if(n){if(n[2]&&n[2].indexOf("eval")===0){let a=t9p.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}let[o,s]=jir(n[1]||cS,n[2]);return lJ(t,s,o,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}};var r9p=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,n9p=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,a0i=(e,t)=>{let r=r9p.exec(e);if(r){if(r[3]&&r[3].indexOf(" > eval")>-1){let s=n9p.exec(r[3]);s&&(r[1]=r[1]||"eval",r[3]=s[1],r[4]=s[2],r[5]="")}let i=r[3],o=r[1]||cS;return[o,i]=jir(o,i),lJ(t,i,o,r[4]?+r[4]:void 0,r[5]?+r[5]:void 0)}};var i9p=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,Yea=(e,t)=>{let r=i9p.exec(e);return r?lJ(t,r[2],r[1]||cS,+r[3],r[4]?+r[4]:void 0):void 0};var o9p=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,Xea=(e,t)=>{let r=o9p.exec(e);return r?lJ(t,r[2],r[3]||cS,+r[1]):void 0},s9p=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,Zea=(e,t)=>{let r=s9p.exec(e);return r?lJ(t,r[5],r[3]||r[4]||cS,+r[1],+r[2]):void 0};var a9p=/^\s*[-]{4,}$/,u9p=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,tta=(e,t)=>{let r=e.match(u9p);if(r){let n,i,o,s,a;if(r[1]){o=r[1];let l=o.lastIndexOf(".");if(o[l-1]==="."&&l--,l>0){n=o.slice(0,l),i=o.slice(l+1);let p=n.indexOf(".Module");p>0&&(o=o.slice(p+1),n=n.slice(0,p))}s=void 0}i&&(s=n,a=i),i==="<anonymous>"&&(a=void 0,o=void 0),o===void 0&&(a=a||cS,o=s?`${s}.${a}`:a);let u=r[2]?.startsWith("file://")?r[2].slice(7):r[2],c=r[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&r[5]&&!c&&(u=r[5]),{filename:u?decodeURI(u):void 0,module:void 0,function:o,lineno:eta(r[3]),colno:eta(r[4]),in_app:c9p(u||"",c),platform:t}}if(e.match(a9p))return{filename:e,platform:t}};function c9p(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 eta(e){return parseInt(e||"",10)||void 0}var rta=/\(error: (.*)\)/,nta=50;function ita(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,nta).map(r=>({...r,filename:r.filename||l9p(t).filename,function:r.function||cS}))}function l9p(e){return e[e.length-1]||{}}function p9p(){return ota("web:javascript",s0i,a0i)}function ota(e,...t){return(r,n=0)=>{let i=[],o=r.split(`
|
|
1453
|
-
`);for(let s=n;s<o.length;s++){let a=o[s];if(a.length>1024)continue;let u=rta.test(a)?a.replace(rta,"$1"):a;if(!u.match(/\S*Error: /)){for(let c of t){let l=c(u,e);if(l){i.push(l);break}}if(i.length>=nta)break}}return ita(i)}}var u0i=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let n=vOt(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:n?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 WNe(t,"DOMException")}isDOMError(t){return WNe(t,"DOMError")}};var c0i=class{match(t){return Jbi(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 n=t.message;return n.error&&typeof n.error.message=="string"?String(n.error.message):String(n)}getStack(t){return t.stacktrace||t.stack||void 0}};var l0i=class{constructor(){}match(t){return Tea(t)&&t.error!=null}coerce(t,r){let n=r.apply(t.error);return n||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var f9p=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,p0i=class{match(t){return typeof t=="string"}coerce(t,r){let[n,i]=this.getInfos(t);return{type:n??"Error",value:i??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",n=t,i=t.match(f9p);return i&&(r=i[1],n=i[2]),[r,n]}};var sta=["fatal","error","warning","log","info","debug"];function Qir(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let n=r.length;n>0;n--){let i=r.slice(0,n).join(", ");if(!(i.length>t))return n===r.length||i.length<=t?i:`${i.slice(0,t)}...`}return""}var f0i=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let n=this.getErrorPropertyFromObject(t);return n?r.apply(n):{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 Cir(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let i=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(i+=` with message: '${t.message}'`),i}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),n=Qir(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${n}`}isSeverityLevel(t){return vOt(t)&&!Bea(t)&&sta.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(Gea(n))return n}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var d0i=class{match(t){return Cir(t)}coerce(t,r){let n=t.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Qir(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var m0i=class{match(t){return EOt(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var h0i=class{match(t){return WNe(t,"PromiseRejectionEvent")}coerce(t,r){let n=this.getUnhandledRejectionReason(t);return EOt(n)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(n)}getUnhandledRejectionReason(t){if(EOt(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 g0i=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 cta=require("fs"),lta=require("readline"),Nir=new uF.ReduceableCache(25),pta=new uF.ReduceableCache(20),A0i=7,d9p=1e3,m9p=1e4;async function fta(e){let t={};for(let i=e.length-1;i>=0;i--){let o=e[i],s=o?.filename;if(!o||typeof s!="string"||typeof o.lineno!="number"||y9p(s)||b9p(o))continue;t[s]||(t[s]=[]),t[s].push(o.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(pta.get(i))continue;let o=t[i];if(!o)continue;o.sort((u,c)=>u-c);let s=E9p(o);if(s.every(u=>v9p(i,u)))continue;let a=I9p(Nir,i,{});n.push(h9p(i,s,a))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&g9p(e,Nir),Nir.reduce(),e}function h9p(e,t,r){return new Promise(n=>{let i=(0,cta.createReadStream)(e),o=(0,lta.createInterface)({input:i});function s(){i.destroy(),n()}let a=0,u=0,c=t[u];if(c===void 0)return void s();let l=c[0],p=c[1];function d(){pta.set(e,1),o.close(),o.removeAllListeners(),s()}i.on("error",d),o.on("error",d),o.on("close",s),o.on("line",f=>{if(a++,!(a<l)&&(r[a]=w9p(f,0),a>=p)){if(u===t.length-1){o.close(),o.removeAllListeners();return}u++;let m=t[u];if(m===void 0){o.close(),o.removeAllListeners();return}l=m[0],p=m[1]}})})}function g9p(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;A9p(r.lineno,r,n)}}function A9p(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=dta(e);i<e;i++){let o=r[i];if(o===void 0)return void ata(t);t.pre_context.push(o)}if(r[e]===void 0)return void ata(t);t.context_line=r[e];let n=mta(e);t.post_context=[];for(let i=e+1;i<=n;i++){let o=r[i];if(o===void 0)break;t.post_context.push(o)}}function ata(e){delete e.pre_context,delete e.context_line,delete e.post_context}function y9p(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function b9p(e){return e.lineno!==void 0&&e.lineno>m9p||e.colno!==void 0&&e.colno>d9p}function v9p(e,t){let r=Nir.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function E9p(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=uta(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let o=e[t+1];if(typeof o!="number")break;o<=n[1]?n[1]=o+A0i:(i.push(n),n=uta(o)),t++}return i}function uta(e){return[dta(e),mta(e)]}function dta(e){return Math.max(1,e-A0i)}function mta(e){return e+A0i}function I9p(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function w9p(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let o=Math.min(i+140,n);return o>n-5&&(o=n),o===n&&(i=Math.max(o-140,0)),r=r.slice(i,o),i>0&&(r=`...${r}`),o<n&&(r+="..."),r}function C9p(e,t){let r=!1;return Object.assign(n=>{let o=global.process.listeners("uncaughtException").filter(s=>s.name!=="domainUncaughtExceptionClear"&&s._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&o&&(r=!0,t(n))},{_posthogErrorHandler:!0})}function hta(e,t){globalThis.process?.on("uncaughtException",C9p(e,t))}function gta(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var _9p=2e3,vq=class e{constructor(t,r,n){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new _ir({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(t){return Oea(t)&&"__posthog_previously_captured_error"in t&&t.__posthog_previously_captured_error===!0}static async buildEventMessage(t,r,n,i){let o={...i};n||(o.$process_person_profile=!1);let s=this.errorPropertiesBuilder.buildFromUnknown(t,r);return s.$exception_list=await this.errorPropertiesBuilder.modifyFrames(s.$exception_list),{event:"$exception",distinctId:n||cJ(),properties:{...s,...o}}}startAutocaptureIfEnabled(){this.isEnabled()&&(hta(this.onException.bind(this),this.onFatalError.bind(this)),gta(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let n=await e.buildEventMessage(t,r),o=n.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(o)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:o}):this.client.capture(n)}})())}async onFatalError(t){console.error(t),await this.client.shutdown(_9p),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var Ata="5.24.7";var _Ot={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function yta(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(i=>i.toString(16).padStart(2,"0")).join("")}var x9p=6e4,S9p=1152921504606847e3,O9p=["is_not"],eHe=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},$h=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},pJ=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},kir=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:o,customHeaders:s,...a}){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=i,this.projectApiKey=n,this.host=o,this.poller=void 0,this.fetch=a.fetch||fetch,this.onError=a.onError,this.customHeaders=s,this.onLoad=a.onLoad,this.cacheProvider=a.cacheProvider,this.strictLocalEvaluation=a.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},o={}){await this.loadFeatureFlags();let s,a;if(!this.loadedSuccessfullyOnce)return s;if(a=this.featureFlagsByKey[t],a!==void 0)try{s=(await this.computeFlagAndPayloadLocally(a,r,n,i,o)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${s}`))}catch(u){u instanceof pJ||u instanceof $h?this.logMsgIfDebug(()=>console.debug(`${u.name} when computing flag locally: ${t}: ${u.message}`)):u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${u}`))}return s}async getAllFlagsAndPayloads(t,r={},n={},i={},o){await this.loadFeatureFlags();let s={},a={},u=this.featureFlags.length==0,c=o?o.map(p=>this.featureFlagsByKey[p]).filter(Boolean):this.featureFlags,l={};return await Promise.all(c.map(async p=>{try{let{value:d,payload:f}=await this.computeFlagAndPayloadLocally(p,t,r,n,i,void 0,l);s[p.key]=d,f&&(a[p.key]=f)}catch(d){d instanceof pJ||d instanceof $h?this.logMsgIfDebug(()=>console.debug(`${d.name} when computing flag locally: ${p.key}: ${d.message}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${p.key}: ${d}`)),u=!0}})),{response:s,payloads:a,fallbackToFlags:u}}async computeFlagAndPayloadLocally(t,r,n={},i={},o={},s,a,u=!1){if(u||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let c;c=s!==void 0?s:await this.computeFlagValueLocally(t,r,n,i,o,a);let l=this.getFeatureFlagPayload(t.key,c);return{value:c,payload:l}}async computeFlagValueLocally(t,r,n={},i={},o={},s={}){if(t.ensure_experience_continuity)throw new $h("Flag has experience continuity enabled");if(!t.active)return!1;let u=(t.filters||{}).aggregation_group_type_index;if(u==null)return await this.matchFeatureFlagProperties(t,r,i,s);{let c=this.groupTypeMapping[String(u)];if(!c)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${u} for feature flag ${t.key}`)),new $h("Flag has unknown group type index");if(!(c in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let l=o[c];return await this.matchFeatureFlagProperties(t,n[c],l,s)}}getFeatureFlagPayload(t,r){let n=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),n!=null)){if(typeof n=="object")return n;if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(t,r,n,i){let o=t.key;if(!this.featureFlagsByKey)throw new $h("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new $h(`Flag dependency property for '${o}' is missing required 'dependency_chain' field`);let s=t.dependency_chain;if(!Array.isArray(s))throw new $h(`Flag dependency property for '${o}' has an invalid 'dependency_chain' (expected array, got ${typeof s})`);if(s.length===0)throw new $h(`Circular dependency detected for flag '${o}' (empty dependency chain)`);for(let u of s){if(!(u in i)){let l=this.featureFlagsByKey[u];if(l)if(l.active)try{let p=await this.matchFeatureFlagProperties(l,r,n,i);i[u]=p}catch(p){throw new $h(`Error evaluating flag dependency '${u}' for flag '${o}': ${p}`)}else i[u]=!1;else throw new $h(`Missing flag dependency '${u}' for flag '${o}'`)}if(i[u]==null)throw new $h(`Dependency '${u}' could not be evaluated`)}let a=i[o];return this.flagEvaluatesToExpectedValue(t.value,a)}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,n,i={}){let o=t.filters||{},s=o.groups||[],a=!1,u;for(let c of s)try{if(await this.isConditionMatch(t,r,c,n,i)){let l=c.variant,p=o.multivariate?.variants||[];u=l&&p.some(d=>d.key===l)?l:await this.getMatchingVariant(t,r)||!0;break}}catch(l){if(l instanceof pJ)throw l;if(l instanceof $h)a=!0;else throw l}if(u!==void 0)return u;if(a)throw new $h("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i,o={}){let s=n.rollout_percentage,a=u=>{this.logMsgIfDebug(()=>console.warn(u))};if((n.properties||[]).length>0){for(let u of n.properties){let c=u.type,l=!1;if(l=c==="cohort"?wta(u,i,this.cohorts,this.debugMode):c==="flag"?await this.evaluateFlagDependency(u,r,i,o):Ita(u,i,a),!l)return!1}if(s==null)return!0}return!(s!=null&&await bta(t.key,r)>s/100)}async getMatchingVariant(t,r){let n=await bta(t.key,r,"variant"),i=this.variantLookupTable(t).find(o=>n>=o.valueMin&&n<o.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(a=>{i=n+a.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:a.key}),n=i}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,n)=>(r[n.key]=n,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(t){if(this.strictLocalEvaluation)return;let r=t.filter(n=>n.ensure_experience_continuity);r.length>0&&console.warn(`[PostHog] You are using local evaluation but ${r.length} flag(s) have experience continuity enabled: ${r.map(n=>n.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}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),this.warnAboutExperienceContinuityFlags(r.flags),!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!t&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(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(x9p,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}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(n){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${n}`))}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.clearBackoff();return;case 401:throw this.beginBackoff(),new eHe(`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.beginBackoff(),new eHe(`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.beginBackoff(),new eHe(`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 n=await r.json()??{};if(!("flags"in n))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let i={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(i),this.clearBackoff(),this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(i)}catch(o){this.onError?.(new Error(`Failed to store in cache: ${o}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(i.flags);break}default:return}}catch(t){t instanceof eHe&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let n={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(n["If-None-Match"]=r),{method:t,headers:n}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=$Ne(()=>{i.abort()},this.timeout),r.signal=i.signal}try{let i=this.fetch;return i(t,r)}finally{clearTimeout(n)}}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((n,i)=>setTimeout(()=>i(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function bta(e,t,r=""){let n=await yta(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/S9p}function Ita(e,t,r){let n=e.key,i=e.value,o=e.operator||"exact";if(n in t){if(o==="is_not_set")throw new $h("Operator is_not_set is not supported")}else throw new $h(`Property ${n} not found in propertyValues`);let s=t[n];if(s==null&&!O9p.includes(o))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${o} operator`),!1;function a(c,l){return Array.isArray(c)?c.map(p=>String(p).toLowerCase()).includes(String(l).toLowerCase()):String(c).toLowerCase()===String(l).toLowerCase()}function u(c,l,p){if(p==="gt")return c>l;if(p==="gte")return c>=l;if(p==="lt")return c<l;if(p==="lte")return c<=l;throw new Error(`Invalid operator: ${p}`)}switch(o){case"exact":return a(i,s);case"is_not":return!a(i,s);case"is_set":return n in t;case"icontains":return String(s).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(s).toLowerCase().includes(String(i).toLowerCase());case"regex":return vta(String(i))&&String(s).match(String(i))!==null;case"not_regex":return vta(String(i))&&String(s).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof i=="number"?i:null;if(typeof i=="string")try{c=parseFloat(i)}catch{}return c==null||s==null?u(String(s),String(i),o):typeof s=="string"?u(s,String(i),o):u(s,c,o)}case"is_date_after":case"is_date_before":{if(typeof i=="boolean")throw new $h("Date operations cannot be performed on boolean values");let c=P9p(String(i));if(c==null&&(c=Eta(i)),c==null)throw new $h(`Invalid date: ${i}`);let l=Eta(s);return["is_date_before"].includes(o)?l<c:l>c}default:throw new $h(`Unknown operator: ${o}`)}}function B9p(e,t){if(!(e in t))throw new pJ(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function wta(e,t,r,n=!1){let i=String(e.value);B9p(i,r);let o=r[i];return Cta(o,t,r,n)}function Cta(e,t,r,n=!1){if(!e)return!0;let i=e.type,o=e.values;if(!o||o.length===0)return!0;let s=!1;if("values"in o[0]){for(let a of o)try{let u=Cta(a,t,r,n);if(i==="AND"){if(!u)return!1}else if(u)return!0}catch(u){if(u instanceof pJ)throw u;if(u instanceof $h)n&&console.debug(`Failed to compute property ${a} locally: ${u}`),s=!0;else throw u}if(s)throw new $h("Can't match cohort without a given cohort property value");return i==="AND"}for(let a of o)try{let u;if(a.type==="cohort")u=wta(a,t,r,n);else if(a.type==="flag"){n&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${a.key||"unknown"}'`);continue}else u=Ita(a,t);let c=a.negation||!1;if(i==="AND"){if(!u&&!c||u&&c)return!1}else if(u&&!c||!u&&c)return!0}catch(u){if(u instanceof pJ)throw u;if(u instanceof $h)n&&console.debug(`Failed to compute property ${a} locally: ${u}`),s=!0;else throw u}if(s)throw new $h("can't match cohort without a given cohort property value");return i==="AND"}function vta(e){try{return new RegExp(e),!0}catch{return!1}}function Eta(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 $h(`${e} is in an invalid date format`)}throw new $h(`The date provided ${e} must be a string, number, or date object`)}function P9p(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(!r)return null;{if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let o=r.groups.interval;if(o=="h")n.setUTCHours(n.getUTCHours()-i);else if(o=="d")n.setUTCDate(n.getUTCDate()-i);else if(o=="w")n.setUTCDate(n.getUTCDate()-7*i);else if(o=="m")n.setUTCMonth(n.getUTCMonth()-i);else{if(o!="y")return null;n.setUTCFullYear(n.getUTCFullYear()-i)}return n}}var Mir=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var T9p=100,_ta=3e4,D9p=5e4,Lir=class extends COt{constructor(t,r={}){if(super(t,r),this._memoryStorage=new Mir,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,T9p):_ta,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 kir({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders(),cacheProvider:r.flagDefinitionCacheProvider,strictLocalEvaluation:r.strictLocalEvaluation}))}this.errorTracking=new vq(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||D9p}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 Ata}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:n,properties:i,options:o})=>super.captureStateless(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.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:n,properties:i,options:o})=>super.captureStatelessImmediate(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStateless(t,l,{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStatelessImmediate(t,l,{disableGeoip:n})}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=_ta){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",o=>{clearTimeout(n),i(),r(o>0)})})}async _getFeatureFlagResult(t,r,n={},i){let o=n.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&t in this._flagOverrides){let I=this._flagOverrides[t];if(I===void 0)return;let w=this._payloadOverrides?.[t];return{key:t,enabled:I!==!1,variant:typeof I=="string"?I:void 0,payload:w}}let{groups:s,disableGeoip:a}=n,{onlyEvaluateLocally:u,personProperties:c,groupProperties:l}=n,p=this.addLocalPersonAndGroupProperties(r,s,c,l);c=p.allPersonProperties,l=p.allGroupProperties,u==null&&(u=this.options.strictLocalEvaluation??!1);let d,f=!1,m,h,A,y,v,E;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let I=this.featureFlagsPoller?.featureFlagsByKey[t];if(I)try{let w=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(I,r,s,c,l,i);if(w){f=!0;let _=w.value;y=I.id,E="Evaluated locally",d={key:t,enabled:_!==!1,variant:typeof _=="string"?_:void 0,payload:w.payload??void 0}}}catch(w){if(w instanceof pJ||w instanceof $h)this._logger?.info(`${w.name} when computing flag locally: ${t}: ${w.message}`);else throw w}}if(!f&&!u){let I=await super.getFeatureFlagDetailsStateless(r,s,c,l,a,[t]);if(I===void 0)A=_Ot.UNKNOWN_ERROR;else{m=I.requestId,h=I.evaluatedAt;let w=[];I.errorsWhileComputingFlags&&w.push(_Ot.ERRORS_WHILE_COMPUTING),I.quotaLimited?.includes("feature_flags")&&w.push(_Ot.QUOTA_LIMITED);let _=I.flags[t];if(_===void 0)w.push(_Ot.FLAG_MISSING);else{y=_.metadata?.id,v=_.metadata?.version,E=_.reason?.description??_.reason?.code;let C;if(_.metadata?.payload!==void 0)try{C=JSON.parse(_.metadata.payload)}catch{C=_.metadata.payload}d={key:t,enabled:_.enabled,variant:_.variant,payload:C}}w.length>0&&(A=w.join(","))}}if(o){let I=d===void 0?void 0:d.enabled===!1?!1:d.variant??!0,w=`${t}_${I}`;if(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(w)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(w):this.distinctIdHasSentFlagCalls[r]=[w];let _={$feature_flag:t,$feature_flag_response:I,$feature_flag_id:y,$feature_flag_version:v,$feature_flag_reason:E,locally_evaluated:f,[`$feature/${t}`]:I,$feature_flag_request_id:m,$feature_flag_evaluated_at:h};A&&(_.$feature_flag_error=A),this.capture({distinctId:r,event:"$feature_flag_called",properties:_,groups:s,disableGeoip:a})}}return d!==void 0&&this._payloadOverrides!==void 0&&t in this._payloadOverrides&&(d={...d,payload:this._payloadOverrides[t]}),d}async getFeatureFlag(t,r,n){let i=await this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(i!==void 0)return i.enabled===!1?!1:i.variant??!0}async getFeatureFlagPayload(t,r,n,i){if(this._payloadOverrides!==void 0&&t in this._payloadOverrides)return this._payloadOverrides[t];let o=await this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:!1},n);if(o!==void 0)return o.payload??null}async getFeatureFlagResult(t,r,n){return this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0})}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 n=await r.json();if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i,flagKeys:o}=r||{},{onlyEvaluateLocally:s,personProperties:a,groupProperties:u}=r||{},c=this.addLocalPersonAndGroupProperties(t,n,a,u);a=c.allPersonProperties,u=c.allGroupProperties,s==null&&(s=this.options.strictLocalEvaluation??!1);let l=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,a,u,o),p={},d={},f=!0;if(l&&(p=l.response,d=l.payloads,f=l.fallbackToFlags),f&&!s){let m=await super.getFeatureFlagsAndPayloadsStateless(t,n,a,u,i,o);p={...p,...m.flags||{}},d={...d,...m.payloads||{}}}return this._flagOverrides!==void 0&&(p={...p,...this._flagOverrides}),this._payloadOverrides!==void 0&&(d={...d,...this._payloadOverrides}),{featureFlags:p,featureFlagPayloads:d}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:o}){super.groupIdentifyStateless(t,r,n,{disableGeoip:o},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(t){let r=n=>Object.fromEntries(n.map(i=>[i,!0]));if(t===!1){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(t)){this._flagOverrides=r(t);return}if(this._isFeatureFlagOverrideOptions(t)){"flags"in t&&(t.flags===!1?this._flagOverrides=void 0:Array.isArray(t.flags)?this._flagOverrides=r(t.flags):t.flags!==void 0&&(this._flagOverrides={...t.flags})),"payloads"in t&&(t.payloads===!1?this._payloadOverrides=void 0:t.payloads!==void 0&&(this._payloadOverrides={...t.payloads}));return}this._flagOverrides={...t}}_isFeatureFlagOverrideOptions(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let r=t;if("flags"in r){let n=r.flags;if(n===!1||Array.isArray(n)||typeof n=="object"&&n!==null)return!0}if("payloads"in r){let n=r.payloads;if(n===!1||typeof n=="object"&&n!==null)return!0}return!1}withContext(t,r,n){return this.context?this.context.run(t,r,n):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)}`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},i=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let o=new AbortController;i=$Ne(()=>{o.abort()},this.options.requestTimeout),n.signal=o.signal}try{return await this.fetch(r,n)}catch(o){this._events.emit("error",o);return}finally{i&&clearTimeout(i)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let n={},i={};for(let[o,s]of Object.entries(t))if(Dea(s)&&r&&o in r){let a={};for(let[u,c]of Object.entries(s))a[String(u)]=String(c);i[String(o)]=a}else n[String(o)]=String(s);return{personProperties:n,groupProperties:i}}async getFeatureFlagsForEvent(t,r,n,i){let o=i?.personProperties||{},s=i?.groupProperties||{},a=i?.flagKeys;if(i?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let c={};for(let[l,p]of Object.entries(r||{}))c[l]=String(p);return await this.getAllFlags(t,{groups:c,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let c={};for(let[l,p]of Object.entries(r||{}))c[l]=String(p);return await this.getAllFlags(t,{groups:c,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}return(await super.getFeatureFlagsStateless(t,r,o,s,n)).flags}addLocalPersonAndGroupProperties(t,r,n,i){let o={distinct_id:t,...n||{}},s={};if(r)for(let a of Object.keys(r))s[a]={$group_key:r[a],...i?.[a]||{}};return{allPersonProperties:o,allGroupProperties:s}}captureException(t,r,n,i){if(!vq.isPreviouslyCapturedError(t)){let o=new Error("PostHog syntheticException");this.addPendingPromise(vq.buildEventMessage(t,{syntheticException:o},r,n).then(s=>this.capture({...s,uuid:i})))}}async captureExceptionImmediate(t,r,n){if(!vq.isPreviouslyCapturedError(t)){let i=new Error("PostHog syntheticException");this.addPendingPromise(vq.buildEventMessage(t,{syntheticException:i},r,n).then(o=>this.captureImmediate(o)))}}async prepareEventMessage(t){let{distinctId:r,event:n,properties:i,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:u,uuid:c}=t,l=this.context?.get(),p=r||l?.distinctId,d={...l?.properties||{},...i||{}};p||(p=cJ(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:p,event:n,properties:d,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:u,uuid:c});if(!f)return Promise.reject(null);let m=await Promise.resolve().then(async()=>{if(s){let h=typeof s=="object"?s:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,o,u,h)}return f.event,{}}).then(h=>{let A={};if(h)for(let[v,E]of Object.entries(h))A[`$feature/${v}`]=E;let y=Object.keys(h||{}).filter(v=>h?.[v]!==!1).sort();return y.length>0&&(A.$active_feature_flags=y),A}).catch(()=>({})).then(h=>({...h,...f.properties||{},$groups:f.groups||o}));return f.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof m.$raw_user_agent=="string"&&xea(m.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event="$bot_pageview",m.$browser_type="bot"),{distinctId:f.distinctId,event:f.event,properties:m,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let n=Array.isArray(r)?r:[r],i=t;for(let o of n){if(i=o(i),!i)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!i.properties||Object.keys(i.properties).length===0){let s=`Event '${i.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(s)}}return i}};var xta=require("async_hooks"),Uir=class{constructor(){this.storage=new xta.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,n){if(n?.fresh===!0)return this.storage.run(t,r);{let o=this.get()||{},s={distinctId:t.distinctId??o.distinctId,sessionId:t.sessionId??o.sessionId,properties:{...o.properties||{},...t.properties||{}}};return this.storage.run(s,r)}}};var Sta="posthog-node";function R9p(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"],sendExceptionsToPostHog:o=!0}={}){return s=>{if(!(i==="*"||i.includes(s.level)))return s;s.tags||(s.tags={});let u=s.tags[y0i.POSTHOG_ID_TAG];if(u===void 0)return s;let c=e.options.host??"https://us.i.posthog.com",l=new URL(`/project/${e.apiKey}/person/${u}`,c).toString();s.tags["PostHog Person URL"]=l;let p=s.exception?.values||[],d=p.map(m=>({...m,stacktrace:m.stacktrace?{...m.stacktrace,type:"raw",frames:(m.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),f={$exception_message:p[0]?.value||s.message,$exception_type:p[0]?.type,$exception_level:s.level,$exception_list:d,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:p[0]?.value||s.message,$sentry_exception_type:p[0]?.type,$sentry_tags:s.tags};return t&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+s.event_id),o&&e.capture({event:"$exception",distinctId:u,properties:f}),s}}var y0i=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,n,i,o){this.name=Sta,this.name=Sta,this.setupOnce=function(s,a){let u=a()?.getClient()?.getDsn()?.projectId;s(R9p(t,{organization:r,projectId:u,prefix:n,severityAllowList:i,sendExceptionsToPostHog:o??!0}))}}};vq.errorPropertiesBuilder=new uF.ErrorPropertiesBuilder([new uF.EventCoercer,new uF.ErrorCoercer,new uF.ObjectCoercer,new uF.StringCoercer,new uF.PrimitiveCoercer],uF.createStackParser("node:javascript",uF.nodeStackLineParser),[Eea(),fta]);var YEe=class extends Lir{getLibraryId(){return"posthog-node"}initializeContext(){return new Uir}};var zir=class{posthog;constructor({posthogApiKey:t}){this.posthog=new YEe(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"4.0.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var xOt=class{async sendEvent(){}async identify(){}async flush(){}};Wt();var tHe=require("fs/promises"),Dta=require("os"),Rta=require("path");var Ota=Ce(require("crypto")),qir=new Uint8Array(256),Vir=qir.length;function b0i(){return Vir>qir.length-16&&(Ota.default.randomFillSync(qir),Vir=0),qir.slice(Vir,Vir+=16)}var Bta=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function F9p(e){return typeof e=="string"&&Bta.test(e)}var v0i=F9p;var lS=[];for(let e=0;e<256;++e)lS.push((e+256).toString(16).slice(1));function Pta(e,t=0){return lS[e[t+0]]+lS[e[t+1]]+lS[e[t+2]]+lS[e[t+3]]+"-"+lS[e[t+4]]+lS[e[t+5]]+"-"+lS[e[t+6]]+lS[e[t+7]]+"-"+lS[e[t+8]]+lS[e[t+9]]+"-"+lS[e[t+10]]+lS[e[t+11]]+lS[e[t+12]]+lS[e[t+13]]+lS[e[t+14]]+lS[e[t+15]]}var Tta=Ce(require("crypto")),E0i={randomUUID:Tta.default.randomUUID};function j9p(e,t,r){if(E0i.randomUUID&&!t&&!e)return E0i.randomUUID();e=e||{};let n=e.random||(e.rng||b0i)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Pta(n)}var yC=j9p;var Q9p="id",N9p=".fern",SOt=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new YEe(r),this.userId=t==null?void 0:ndi(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:"4.0.0",...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 Ib({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=We(Vt.of((0,Dta.homedir)()),Se.of(N9p),Se.of(Q9p));await nr(t)||(await(0,tHe.mkdir)((0,Rta.dirname)(t),{recursive:!0}),await(0,tHe.writeFile)(t,yC())),this.persistedDistinctId=(await(0,tHe.readFile)(t)).toString()}return this.persistedDistinctId}};var I0i;async function rHe(){return I0i==null&&(I0i=await k9p()),I0i}async function k9p(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new xOt;let r=await sXt();return r!=null?new SOt({token:r,posthogApiKey:e}):await qK()!=null?new zir({posthogApiKey:e}):new SOt({token:void 0,posthogApiKey:e})}catch{return new xOt}}var Fta=(e=0)=>t=>`\x1B[${t+e}m`,jta=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Qta=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`,jy={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},oCA=Object.keys(jy.modifier),M9p=Object.keys(jy.color),L9p=Object.keys(jy.bgColor),sCA=[...M9p,...L9p];function U9p(){let e=new Map;for(let[t,r]of Object.entries(jy)){for(let[n,i]of Object.entries(r))jy[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=jy[n],e.set(i[0],i[1]);Object.defineProperty(jy,t,{value:r,enumerable:!1})}return Object.defineProperty(jy,"codes",{value:e,enumerable:!1}),jy.color.close="\x1B[39m",jy.bgColor.close="\x1B[49m",jy.color.ansi=Fta(),jy.color.ansi256=jta(),jy.color.ansi16m=Qta(),jy.bgColor.ansi=Fta(10),jy.bgColor.ansi256=jta(10),jy.bgColor.ansi16m=Qta(10),Object.defineProperties(jy,{rgbToAnsi256:{value(t,r,n){return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:t=>jy.rgbToAnsi256(...jy.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,n,i;if(t>=232)r=((t-232)*10+8)/255,n=r,i=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,n)=>jy.ansi256ToAnsi(jy.rgbToAnsi256(t,r,n)),enumerable:!1},hexToAnsi:{value:t=>jy.ansi256ToAnsi(jy.hexToAnsi256(t)),enumerable:!1}}),jy}var z9p=U9p(),Eq=z9p;var Wir=Ce(require("process"),1),kta=Ce(require("os"),1),w0i=Ce(require("tty"),1);function Z4(e,t=globalThis.Deno?globalThis.Deno.args:Wir.default.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return n!==-1&&(i===-1||n<i)}var{env:Qy}=Wir.default,Gir;Z4("no-color")||Z4("no-colors")||Z4("color=false")||Z4("color=never")?Gir=0:(Z4("color")||Z4("colors")||Z4("color=true")||Z4("color=always"))&&(Gir=1);function V9p(){if("FORCE_COLOR"in Qy)return Qy.FORCE_COLOR==="true"?1:Qy.FORCE_COLOR==="false"?0:Qy.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Qy.FORCE_COLOR,10),3)}function q9p(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function G9p(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n=V9p();n!==void 0&&(Gir=n);let i=r?Gir:n;if(i===0)return 0;if(r){if(Z4("color=16m")||Z4("color=full")||Z4("color=truecolor"))return 3;if(Z4("color=256"))return 2}if("TF_BUILD"in Qy&&"AGENT_NAME"in Qy)return 1;if(e&&!t&&i===void 0)return 0;let o=i||0;if(Qy.TERM==="dumb")return o;if(Wir.default.platform==="win32"){let s=kta.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in Qy)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in Qy)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in Qy)||Qy.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in Qy)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qy.TEAMCITY_VERSION)?1:0;if(Qy.COLORTERM==="truecolor"||Qy.TERM==="xterm-kitty"||Qy.TERM==="xterm-ghostty"||Qy.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Qy){let s=Number.parseInt((Qy.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qy.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Qy.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qy.TERM)||"COLORTERM"in Qy?1:o}function Nta(e,t={}){let r=G9p(e,{streamIsTTY:e&&e.isTTY,...t});return q9p(r)}var W9p={stdout:Nta({isTTY:w0i.default.isatty(1)}),stderr:Nta({isTTY:w0i.default.isatty(2)})},Mta=W9p;function Lta(e,t,r){let n=e.indexOf(t);if(n===-1)return e;let i=t.length,o=0,s="";do s+=e.slice(o,n)+t+r,o=n+i,n=e.indexOf(t,o);while(n!==-1);return s+=e.slice(o),s}function Uta(e,t,r,n){let i=0,o="";do{let s=e[n-1]==="\r";o+=e.slice(i,s?n-1:n)+t+(s?`\r
|
|
1453
|
+
`);for(let s=n;s<o.length;s++){let a=o[s];if(a.length>1024)continue;let u=rta.test(a)?a.replace(rta,"$1"):a;if(!u.match(/\S*Error: /)){for(let c of t){let l=c(u,e);if(l){i.push(l);break}}if(i.length>=nta)break}}return ita(i)}}var u0i=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let n=vOt(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:n?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 WNe(t,"DOMException")}isDOMError(t){return WNe(t,"DOMError")}};var c0i=class{match(t){return Jbi(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 n=t.message;return n.error&&typeof n.error.message=="string"?String(n.error.message):String(n)}getStack(t){return t.stacktrace||t.stack||void 0}};var l0i=class{constructor(){}match(t){return Tea(t)&&t.error!=null}coerce(t,r){let n=r.apply(t.error);return n||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var f9p=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,p0i=class{match(t){return typeof t=="string"}coerce(t,r){let[n,i]=this.getInfos(t);return{type:n??"Error",value:i??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",n=t,i=t.match(f9p);return i&&(r=i[1],n=i[2]),[r,n]}};var sta=["fatal","error","warning","log","info","debug"];function Qir(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let n=r.length;n>0;n--){let i=r.slice(0,n).join(", ");if(!(i.length>t))return n===r.length||i.length<=t?i:`${i.slice(0,t)}...`}return""}var f0i=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let n=this.getErrorPropertyFromObject(t);return n?r.apply(n):{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 Cir(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let i=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(i+=` with message: '${t.message}'`),i}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),n=Qir(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${n}`}isSeverityLevel(t){return vOt(t)&&!Bea(t)&&sta.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let n=t[r];if(Gea(n))return n}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var d0i=class{match(t){return Cir(t)}coerce(t,r){let n=t.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${Qir(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var m0i=class{match(t){return EOt(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var h0i=class{match(t){return WNe(t,"PromiseRejectionEvent")}coerce(t,r){let n=this.getUnhandledRejectionReason(t);return EOt(n)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(n)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(n)}getUnhandledRejectionReason(t){if(EOt(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 g0i=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 cta=require("fs"),lta=require("readline"),Nir=new uF.ReduceableCache(25),pta=new uF.ReduceableCache(20),A0i=7,d9p=1e3,m9p=1e4;async function fta(e){let t={};for(let i=e.length-1;i>=0;i--){let o=e[i],s=o?.filename;if(!o||typeof s!="string"||typeof o.lineno!="number"||y9p(s)||b9p(o))continue;t[s]||(t[s]=[]),t[s].push(o.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(pta.get(i))continue;let o=t[i];if(!o)continue;o.sort((u,c)=>u-c);let s=E9p(o);if(s.every(u=>v9p(i,u)))continue;let a=I9p(Nir,i,{});n.push(h9p(i,s,a))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&g9p(e,Nir),Nir.reduce(),e}function h9p(e,t,r){return new Promise(n=>{let i=(0,cta.createReadStream)(e),o=(0,lta.createInterface)({input:i});function s(){i.destroy(),n()}let a=0,u=0,c=t[u];if(c===void 0)return void s();let l=c[0],p=c[1];function d(){pta.set(e,1),o.close(),o.removeAllListeners(),s()}i.on("error",d),o.on("error",d),o.on("close",s),o.on("line",f=>{if(a++,!(a<l)&&(r[a]=w9p(f,0),a>=p)){if(u===t.length-1){o.close(),o.removeAllListeners();return}u++;let m=t[u];if(m===void 0){o.close(),o.removeAllListeners();return}l=m[0],p=m[1]}})})}function g9p(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;A9p(r.lineno,r,n)}}function A9p(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=dta(e);i<e;i++){let o=r[i];if(o===void 0)return void ata(t);t.pre_context.push(o)}if(r[e]===void 0)return void ata(t);t.context_line=r[e];let n=mta(e);t.post_context=[];for(let i=e+1;i<=n;i++){let o=r[i];if(o===void 0)break;t.post_context.push(o)}}function ata(e){delete e.pre_context,delete e.context_line,delete e.post_context}function y9p(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function b9p(e){return e.lineno!==void 0&&e.lineno>m9p||e.colno!==void 0&&e.colno>d9p}function v9p(e,t){let r=Nir.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function E9p(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=uta(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let o=e[t+1];if(typeof o!="number")break;o<=n[1]?n[1]=o+A0i:(i.push(n),n=uta(o)),t++}return i}function uta(e){return[dta(e),mta(e)]}function dta(e){return Math.max(1,e-A0i)}function mta(e){return e+A0i}function I9p(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function w9p(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let o=Math.min(i+140,n);return o>n-5&&(o=n),o===n&&(i=Math.max(o-140,0)),r=r.slice(i,o),i>0&&(r=`...${r}`),o<n&&(r+="..."),r}function C9p(e,t){let r=!1;return Object.assign(n=>{let o=global.process.listeners("uncaughtException").filter(s=>s.name!=="domainUncaughtExceptionClear"&&s._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&o&&(r=!0,t(n))},{_posthogErrorHandler:!0})}function hta(e,t){globalThis.process?.on("uncaughtException",C9p(e,t))}function gta(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var _9p=2e3,vq=class e{constructor(t,r,n){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new _ir({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(t){return Oea(t)&&"__posthog_previously_captured_error"in t&&t.__posthog_previously_captured_error===!0}static async buildEventMessage(t,r,n,i){let o={...i};n||(o.$process_person_profile=!1);let s=this.errorPropertiesBuilder.buildFromUnknown(t,r);return s.$exception_list=await this.errorPropertiesBuilder.modifyFrames(s.$exception_list),{event:"$exception",distinctId:n||cJ(),properties:{...s,...o}}}startAutocaptureIfEnabled(){this.isEnabled()&&(hta(this.onException.bind(this),this.onFatalError.bind(this)),gta(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let n=await e.buildEventMessage(t,r),o=n.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(o)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:o}):this.client.capture(n)}})())}async onFatalError(t){console.error(t),await this.client.shutdown(_9p),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var Ata="5.24.7";var _Ot={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function yta(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(i=>i.toString(16).padStart(2,"0")).join("")}var x9p=6e4,S9p=1152921504606847e3,O9p=["is_not"],eHe=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},$h=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},pJ=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},kir=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:o,customHeaders:s,...a}){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=i,this.projectApiKey=n,this.host=o,this.poller=void 0,this.fetch=a.fetch||fetch,this.onError=a.onError,this.customHeaders=s,this.onLoad=a.onLoad,this.cacheProvider=a.cacheProvider,this.strictLocalEvaluation=a.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},o={}){await this.loadFeatureFlags();let s,a;if(!this.loadedSuccessfullyOnce)return s;if(a=this.featureFlagsByKey[t],a!==void 0)try{s=(await this.computeFlagAndPayloadLocally(a,r,n,i,o)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${s}`))}catch(u){u instanceof pJ||u instanceof $h?this.logMsgIfDebug(()=>console.debug(`${u.name} when computing flag locally: ${t}: ${u.message}`)):u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${u}`))}return s}async getAllFlagsAndPayloads(t,r={},n={},i={},o){await this.loadFeatureFlags();let s={},a={},u=this.featureFlags.length==0,c=o?o.map(p=>this.featureFlagsByKey[p]).filter(Boolean):this.featureFlags,l={};return await Promise.all(c.map(async p=>{try{let{value:d,payload:f}=await this.computeFlagAndPayloadLocally(p,t,r,n,i,void 0,l);s[p.key]=d,f&&(a[p.key]=f)}catch(d){d instanceof pJ||d instanceof $h?this.logMsgIfDebug(()=>console.debug(`${d.name} when computing flag locally: ${p.key}: ${d.message}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${p.key}: ${d}`)),u=!0}})),{response:s,payloads:a,fallbackToFlags:u}}async computeFlagAndPayloadLocally(t,r,n={},i={},o={},s,a,u=!1){if(u||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let c;c=s!==void 0?s:await this.computeFlagValueLocally(t,r,n,i,o,a);let l=this.getFeatureFlagPayload(t.key,c);return{value:c,payload:l}}async computeFlagValueLocally(t,r,n={},i={},o={},s={}){if(t.ensure_experience_continuity)throw new $h("Flag has experience continuity enabled");if(!t.active)return!1;let u=(t.filters||{}).aggregation_group_type_index;if(u==null)return await this.matchFeatureFlagProperties(t,r,i,s);{let c=this.groupTypeMapping[String(u)];if(!c)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${u} for feature flag ${t.key}`)),new $h("Flag has unknown group type index");if(!(c in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let l=o[c];return await this.matchFeatureFlagProperties(t,n[c],l,s)}}getFeatureFlagPayload(t,r){let n=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),n!=null)){if(typeof n=="object")return n;if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(t,r,n,i){let o=t.key;if(!this.featureFlagsByKey)throw new $h("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new $h(`Flag dependency property for '${o}' is missing required 'dependency_chain' field`);let s=t.dependency_chain;if(!Array.isArray(s))throw new $h(`Flag dependency property for '${o}' has an invalid 'dependency_chain' (expected array, got ${typeof s})`);if(s.length===0)throw new $h(`Circular dependency detected for flag '${o}' (empty dependency chain)`);for(let u of s){if(!(u in i)){let l=this.featureFlagsByKey[u];if(l)if(l.active)try{let p=await this.matchFeatureFlagProperties(l,r,n,i);i[u]=p}catch(p){throw new $h(`Error evaluating flag dependency '${u}' for flag '${o}': ${p}`)}else i[u]=!1;else throw new $h(`Missing flag dependency '${u}' for flag '${o}'`)}if(i[u]==null)throw new $h(`Dependency '${u}' could not be evaluated`)}let a=i[o];return this.flagEvaluatesToExpectedValue(t.value,a)}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,n,i={}){let o=t.filters||{},s=o.groups||[],a=!1,u;for(let c of s)try{if(await this.isConditionMatch(t,r,c,n,i)){let l=c.variant,p=o.multivariate?.variants||[];u=l&&p.some(d=>d.key===l)?l:await this.getMatchingVariant(t,r)||!0;break}}catch(l){if(l instanceof pJ)throw l;if(l instanceof $h)a=!0;else throw l}if(u!==void 0)return u;if(a)throw new $h("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i,o={}){let s=n.rollout_percentage,a=u=>{this.logMsgIfDebug(()=>console.warn(u))};if((n.properties||[]).length>0){for(let u of n.properties){let c=u.type,l=!1;if(l=c==="cohort"?wta(u,i,this.cohorts,this.debugMode):c==="flag"?await this.evaluateFlagDependency(u,r,i,o):Ita(u,i,a),!l)return!1}if(s==null)return!0}return!(s!=null&&await bta(t.key,r)>s/100)}async getMatchingVariant(t,r){let n=await bta(t.key,r,"variant"),i=this.variantLookupTable(t).find(o=>n>=o.valueMin&&n<o.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(a=>{i=n+a.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:a.key}),n=i}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,n)=>(r[n.key]=n,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(t){if(this.strictLocalEvaluation)return;let r=t.filter(n=>n.ensure_experience_continuity);r.length>0&&console.warn(`[PostHog] You are using local evaluation but ${r.length} flag(s) have experience continuity enabled: ${r.map(n=>n.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}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),this.warnAboutExperienceContinuityFlags(r.flags),!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!t&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(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(x9p,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}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(n){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${n}`))}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.clearBackoff();return;case 401:throw this.beginBackoff(),new eHe(`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.beginBackoff(),new eHe(`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.beginBackoff(),new eHe(`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 n=await r.json()??{};if(!("flags"in n))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let i={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(i),this.clearBackoff(),this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(i)}catch(o){this.onError?.(new Error(`Failed to store in cache: ${o}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(i.flags);break}default:return}}catch(t){t instanceof eHe&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let n={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(n["If-None-Match"]=r),{method:t,headers:n}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=$Ne(()=>{i.abort()},this.timeout),r.signal=i.signal}try{let i=this.fetch;return i(t,r)}finally{clearTimeout(n)}}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((n,i)=>setTimeout(()=>i(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function bta(e,t,r=""){let n=await yta(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/S9p}function Ita(e,t,r){let n=e.key,i=e.value,o=e.operator||"exact";if(n in t){if(o==="is_not_set")throw new $h("Operator is_not_set is not supported")}else throw new $h(`Property ${n} not found in propertyValues`);let s=t[n];if(s==null&&!O9p.includes(o))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${o} operator`),!1;function a(c,l){return Array.isArray(c)?c.map(p=>String(p).toLowerCase()).includes(String(l).toLowerCase()):String(c).toLowerCase()===String(l).toLowerCase()}function u(c,l,p){if(p==="gt")return c>l;if(p==="gte")return c>=l;if(p==="lt")return c<l;if(p==="lte")return c<=l;throw new Error(`Invalid operator: ${p}`)}switch(o){case"exact":return a(i,s);case"is_not":return!a(i,s);case"is_set":return n in t;case"icontains":return String(s).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(s).toLowerCase().includes(String(i).toLowerCase());case"regex":return vta(String(i))&&String(s).match(String(i))!==null;case"not_regex":return vta(String(i))&&String(s).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let c=typeof i=="number"?i:null;if(typeof i=="string")try{c=parseFloat(i)}catch{}return c==null||s==null?u(String(s),String(i),o):typeof s=="string"?u(s,String(i),o):u(s,c,o)}case"is_date_after":case"is_date_before":{if(typeof i=="boolean")throw new $h("Date operations cannot be performed on boolean values");let c=P9p(String(i));if(c==null&&(c=Eta(i)),c==null)throw new $h(`Invalid date: ${i}`);let l=Eta(s);return["is_date_before"].includes(o)?l<c:l>c}default:throw new $h(`Unknown operator: ${o}`)}}function B9p(e,t){if(!(e in t))throw new pJ(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function wta(e,t,r,n=!1){let i=String(e.value);B9p(i,r);let o=r[i];return Cta(o,t,r,n)}function Cta(e,t,r,n=!1){if(!e)return!0;let i=e.type,o=e.values;if(!o||o.length===0)return!0;let s=!1;if("values"in o[0]){for(let a of o)try{let u=Cta(a,t,r,n);if(i==="AND"){if(!u)return!1}else if(u)return!0}catch(u){if(u instanceof pJ)throw u;if(u instanceof $h)n&&console.debug(`Failed to compute property ${a} locally: ${u}`),s=!0;else throw u}if(s)throw new $h("Can't match cohort without a given cohort property value");return i==="AND"}for(let a of o)try{let u;if(a.type==="cohort")u=wta(a,t,r,n);else if(a.type==="flag"){n&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${a.key||"unknown"}'`);continue}else u=Ita(a,t);let c=a.negation||!1;if(i==="AND"){if(!u&&!c||u&&c)return!1}else if(u&&!c||!u&&c)return!0}catch(u){if(u instanceof pJ)throw u;if(u instanceof $h)n&&console.debug(`Failed to compute property ${a} locally: ${u}`),s=!0;else throw u}if(s)throw new $h("can't match cohort without a given cohort property value");return i==="AND"}function vta(e){try{return new RegExp(e),!0}catch{return!1}}function Eta(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 $h(`${e} is in an invalid date format`)}throw new $h(`The date provided ${e} must be a string, number, or date object`)}function P9p(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(!r)return null;{if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let o=r.groups.interval;if(o=="h")n.setUTCHours(n.getUTCHours()-i);else if(o=="d")n.setUTCDate(n.getUTCDate()-i);else if(o=="w")n.setUTCDate(n.getUTCDate()-7*i);else if(o=="m")n.setUTCMonth(n.getUTCMonth()-i);else{if(o!="y")return null;n.setUTCFullYear(n.getUTCFullYear()-i)}return n}}var Mir=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var T9p=100,_ta=3e4,D9p=5e4,Lir=class extends COt{constructor(t,r={}){if(super(t,r),this._memoryStorage=new Mir,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,T9p):_ta,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 kir({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders(),cacheProvider:r.flagDefinitionCacheProvider,strictLocalEvaluation:r.strictLocalEvaluation}))}this.errorTracking=new vq(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||D9p}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 Ata}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:n,properties:i,options:o})=>super.captureStateless(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.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:n,properties:i,options:o})=>super.captureStatelessImmediate(r,n,i,{timestamp:o.timestamp,disableGeoip:o.disableGeoip,uuid:o.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStateless(t,l,{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:n}){let{$set:i,$set_once:o,$anon_distinct_id:s,...a}=r,l={$set:i||a,$set_once:o||{},$anon_distinct_id:s??void 0};super.identifyStatelessImmediate(t,l,{disableGeoip:n})}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=_ta){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",o=>{clearTimeout(n),i(),r(o>0)})})}async _getFeatureFlagResult(t,r,n={},i){let o=n.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&t in this._flagOverrides){let I=this._flagOverrides[t];if(I===void 0)return;let w=this._payloadOverrides?.[t];return{key:t,enabled:I!==!1,variant:typeof I=="string"?I:void 0,payload:w}}let{groups:s,disableGeoip:a}=n,{onlyEvaluateLocally:u,personProperties:c,groupProperties:l}=n,p=this.addLocalPersonAndGroupProperties(r,s,c,l);c=p.allPersonProperties,l=p.allGroupProperties,u==null&&(u=this.options.strictLocalEvaluation??!1);let d,f=!1,m,h,A,y,v,E;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let I=this.featureFlagsPoller?.featureFlagsByKey[t];if(I)try{let w=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(I,r,s,c,l,i);if(w){f=!0;let _=w.value;y=I.id,E="Evaluated locally",d={key:t,enabled:_!==!1,variant:typeof _=="string"?_:void 0,payload:w.payload??void 0}}}catch(w){if(w instanceof pJ||w instanceof $h)this._logger?.info(`${w.name} when computing flag locally: ${t}: ${w.message}`);else throw w}}if(!f&&!u){let I=await super.getFeatureFlagDetailsStateless(r,s,c,l,a,[t]);if(I===void 0)A=_Ot.UNKNOWN_ERROR;else{m=I.requestId,h=I.evaluatedAt;let w=[];I.errorsWhileComputingFlags&&w.push(_Ot.ERRORS_WHILE_COMPUTING),I.quotaLimited?.includes("feature_flags")&&w.push(_Ot.QUOTA_LIMITED);let _=I.flags[t];if(_===void 0)w.push(_Ot.FLAG_MISSING);else{y=_.metadata?.id,v=_.metadata?.version,E=_.reason?.description??_.reason?.code;let C;if(_.metadata?.payload!==void 0)try{C=JSON.parse(_.metadata.payload)}catch{C=_.metadata.payload}d={key:t,enabled:_.enabled,variant:_.variant,payload:C}}w.length>0&&(A=w.join(","))}}if(o){let I=d===void 0?void 0:d.enabled===!1?!1:d.variant??!0,w=`${t}_${I}`;if(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(w)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(w):this.distinctIdHasSentFlagCalls[r]=[w];let _={$feature_flag:t,$feature_flag_response:I,$feature_flag_id:y,$feature_flag_version:v,$feature_flag_reason:E,locally_evaluated:f,[`$feature/${t}`]:I,$feature_flag_request_id:m,$feature_flag_evaluated_at:h};A&&(_.$feature_flag_error=A),this.capture({distinctId:r,event:"$feature_flag_called",properties:_,groups:s,disableGeoip:a})}}return d!==void 0&&this._payloadOverrides!==void 0&&t in this._payloadOverrides&&(d={...d,payload:this._payloadOverrides[t]}),d}async getFeatureFlag(t,r,n){let i=await this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(i!==void 0)return i.enabled===!1?!1:i.variant??!0}async getFeatureFlagPayload(t,r,n,i){if(this._payloadOverrides!==void 0&&t in this._payloadOverrides)return this._payloadOverrides[t];let o=await this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:!1},n);if(o!==void 0)return o.payload??null}async getFeatureFlagResult(t,r,n){return this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:n?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0})}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 n=await r.json();if(typeof n=="string")try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i,flagKeys:o}=r||{},{onlyEvaluateLocally:s,personProperties:a,groupProperties:u}=r||{},c=this.addLocalPersonAndGroupProperties(t,n,a,u);a=c.allPersonProperties,u=c.allGroupProperties,s==null&&(s=this.options.strictLocalEvaluation??!1);let l=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,a,u,o),p={},d={},f=!0;if(l&&(p=l.response,d=l.payloads,f=l.fallbackToFlags),f&&!s){let m=await super.getFeatureFlagsAndPayloadsStateless(t,n,a,u,i,o);p={...p,...m.flags||{}},d={...d,...m.payloads||{}}}return this._flagOverrides!==void 0&&(p={...p,...this._flagOverrides}),this._payloadOverrides!==void 0&&(d={...d,...this._payloadOverrides}),{featureFlags:p,featureFlagPayloads:d}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:o}){super.groupIdentifyStateless(t,r,n,{disableGeoip:o},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(t){let r=n=>Object.fromEntries(n.map(i=>[i,!0]));if(t===!1){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(t)){this._flagOverrides=r(t);return}if(this._isFeatureFlagOverrideOptions(t)){"flags"in t&&(t.flags===!1?this._flagOverrides=void 0:Array.isArray(t.flags)?this._flagOverrides=r(t.flags):t.flags!==void 0&&(this._flagOverrides={...t.flags})),"payloads"in t&&(t.payloads===!1?this._payloadOverrides=void 0:t.payloads!==void 0&&(this._payloadOverrides={...t.payloads}));return}this._flagOverrides={...t}}_isFeatureFlagOverrideOptions(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let r=t;if("flags"in r){let n=r.flags;if(n===!1||Array.isArray(n)||typeof n=="object"&&n!==null)return!0}if("payloads"in r){let n=r.payloads;if(n===!1||typeof n=="object"&&n!==null)return!0}return!1}withContext(t,r,n){return this.context?this.context.run(t,r,n):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)}`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},i=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let o=new AbortController;i=$Ne(()=>{o.abort()},this.options.requestTimeout),n.signal=o.signal}try{return await this.fetch(r,n)}catch(o){this._events.emit("error",o);return}finally{i&&clearTimeout(i)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let n={},i={};for(let[o,s]of Object.entries(t))if(Dea(s)&&r&&o in r){let a={};for(let[u,c]of Object.entries(s))a[String(u)]=String(c);i[String(o)]=a}else n[String(o)]=String(s);return{personProperties:n,groupProperties:i}}async getFeatureFlagsForEvent(t,r,n,i){let o=i?.personProperties||{},s=i?.groupProperties||{},a=i?.flagKeys;if(i?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let c={};for(let[l,p]of Object.entries(r||{}))c[l]=String(p);return await this.getAllFlags(t,{groups:c,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let c={};for(let[l,p]of Object.entries(r||{}))c[l]=String(p);return await this.getAllFlags(t,{groups:c,personProperties:o,groupProperties:s,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:a})}return(await super.getFeatureFlagsStateless(t,r,o,s,n)).flags}addLocalPersonAndGroupProperties(t,r,n,i){let o={distinct_id:t,...n||{}},s={};if(r)for(let a of Object.keys(r))s[a]={$group_key:r[a],...i?.[a]||{}};return{allPersonProperties:o,allGroupProperties:s}}captureException(t,r,n,i){if(!vq.isPreviouslyCapturedError(t)){let o=new Error("PostHog syntheticException");this.addPendingPromise(vq.buildEventMessage(t,{syntheticException:o},r,n).then(s=>this.capture({...s,uuid:i})))}}async captureExceptionImmediate(t,r,n){if(!vq.isPreviouslyCapturedError(t)){let i=new Error("PostHog syntheticException");this.addPendingPromise(vq.buildEventMessage(t,{syntheticException:i},r,n).then(o=>this.captureImmediate(o)))}}async prepareEventMessage(t){let{distinctId:r,event:n,properties:i,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:u,uuid:c}=t,l=this.context?.get(),p=r||l?.distinctId,d={...l?.properties||{},...i||{}};p||(p=cJ(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:p,event:n,properties:d,groups:o,sendFeatureFlags:s,timestamp:a,disableGeoip:u,uuid:c});if(!f)return Promise.reject(null);let m=await Promise.resolve().then(async()=>{if(s){let h=typeof s=="object"?s:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,o,u,h)}return f.event,{}}).then(h=>{let A={};if(h)for(let[v,E]of Object.entries(h))A[`$feature/${v}`]=E;let y=Object.keys(h||{}).filter(v=>h?.[v]!==!1).sort();return y.length>0&&(A.$active_feature_flags=y),A}).catch(()=>({})).then(h=>({...h,...f.properties||{},$groups:f.groups||o}));return f.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof m.$raw_user_agent=="string"&&xea(m.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event="$bot_pageview",m.$browser_type="bot"),{distinctId:f.distinctId,event:f.event,properties:m,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let n=Array.isArray(r)?r:[r],i=t;for(let o of n){if(i=o(i),!i)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!i.properties||Object.keys(i.properties).length===0){let s=`Event '${i.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(s)}}return i}};var xta=require("async_hooks"),Uir=class{constructor(){this.storage=new xta.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,n){if(n?.fresh===!0)return this.storage.run(t,r);{let o=this.get()||{},s={distinctId:t.distinctId??o.distinctId,sessionId:t.sessionId??o.sessionId,properties:{...o.properties||{},...t.properties||{}}};return this.storage.run(s,r)}}};var Sta="posthog-node";function R9p(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"],sendExceptionsToPostHog:o=!0}={}){return s=>{if(!(i==="*"||i.includes(s.level)))return s;s.tags||(s.tags={});let u=s.tags[y0i.POSTHOG_ID_TAG];if(u===void 0)return s;let c=e.options.host??"https://us.i.posthog.com",l=new URL(`/project/${e.apiKey}/person/${u}`,c).toString();s.tags["PostHog Person URL"]=l;let p=s.exception?.values||[],d=p.map(m=>({...m,stacktrace:m.stacktrace?{...m.stacktrace,type:"raw",frames:(m.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),f={$exception_message:p[0]?.value||s.message,$exception_type:p[0]?.type,$exception_level:s.level,$exception_list:d,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:p[0]?.value||s.message,$sentry_exception_type:p[0]?.type,$sentry_tags:s.tags};return t&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+s.event_id),o&&e.capture({event:"$exception",distinctId:u,properties:f}),s}}var y0i=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,n,i,o){this.name=Sta,this.name=Sta,this.setupOnce=function(s,a){let u=a()?.getClient()?.getDsn()?.projectId;s(R9p(t,{organization:r,projectId:u,prefix:n,severityAllowList:i,sendExceptionsToPostHog:o??!0}))}}};vq.errorPropertiesBuilder=new uF.ErrorPropertiesBuilder([new uF.EventCoercer,new uF.ErrorCoercer,new uF.ObjectCoercer,new uF.StringCoercer,new uF.PrimitiveCoercer],uF.createStackParser("node:javascript",uF.nodeStackLineParser),[Eea(),fta]);var YEe=class extends Lir{getLibraryId(){return"posthog-node"}initializeContext(){return new Uir}};var zir=class{posthog;constructor({posthogApiKey:t}){this.posthog=new YEe(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"4.0.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var xOt=class{async sendEvent(){}async identify(){}async flush(){}};Wt();var tHe=require("fs/promises"),Dta=require("os"),Rta=require("path");var Ota=Ce(require("crypto")),qir=new Uint8Array(256),Vir=qir.length;function b0i(){return Vir>qir.length-16&&(Ota.default.randomFillSync(qir),Vir=0),qir.slice(Vir,Vir+=16)}var Bta=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function F9p(e){return typeof e=="string"&&Bta.test(e)}var v0i=F9p;var lS=[];for(let e=0;e<256;++e)lS.push((e+256).toString(16).slice(1));function Pta(e,t=0){return lS[e[t+0]]+lS[e[t+1]]+lS[e[t+2]]+lS[e[t+3]]+"-"+lS[e[t+4]]+lS[e[t+5]]+"-"+lS[e[t+6]]+lS[e[t+7]]+"-"+lS[e[t+8]]+lS[e[t+9]]+"-"+lS[e[t+10]]+lS[e[t+11]]+lS[e[t+12]]+lS[e[t+13]]+lS[e[t+14]]+lS[e[t+15]]}var Tta=Ce(require("crypto")),E0i={randomUUID:Tta.default.randomUUID};function j9p(e,t,r){if(E0i.randomUUID&&!t&&!e)return E0i.randomUUID();e=e||{};let n=e.random||(e.rng||b0i)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Pta(n)}var yC=j9p;var Q9p="id",N9p=".fern",SOt=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new YEe(r),this.userId=t==null?void 0:ndi(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:"4.0.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 Ib({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=We(Vt.of((0,Dta.homedir)()),Se.of(N9p),Se.of(Q9p));await nr(t)||(await(0,tHe.mkdir)((0,Rta.dirname)(t),{recursive:!0}),await(0,tHe.writeFile)(t,yC())),this.persistedDistinctId=(await(0,tHe.readFile)(t)).toString()}return this.persistedDistinctId}};var I0i;async function rHe(){return I0i==null&&(I0i=await k9p()),I0i}async function k9p(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new xOt;let r=await sXt();return r!=null?new SOt({token:r,posthogApiKey:e}):await qK()!=null?new zir({posthogApiKey:e}):new SOt({token:void 0,posthogApiKey:e})}catch{return new xOt}}var Fta=(e=0)=>t=>`\x1B[${t+e}m`,jta=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Qta=(e=0)=>(t,r,n)=>`\x1B[${38+e};2;${t};${r};${n}m`,jy={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},oCA=Object.keys(jy.modifier),M9p=Object.keys(jy.color),L9p=Object.keys(jy.bgColor),sCA=[...M9p,...L9p];function U9p(){let e=new Map;for(let[t,r]of Object.entries(jy)){for(let[n,i]of Object.entries(r))jy[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=jy[n],e.set(i[0],i[1]);Object.defineProperty(jy,t,{value:r,enumerable:!1})}return Object.defineProperty(jy,"codes",{value:e,enumerable:!1}),jy.color.close="\x1B[39m",jy.bgColor.close="\x1B[49m",jy.color.ansi=Fta(),jy.color.ansi256=jta(),jy.color.ansi16m=Qta(),jy.bgColor.ansi=Fta(10),jy.bgColor.ansi256=jta(10),jy.bgColor.ansi16m=Qta(10),Object.defineProperties(jy,{rgbToAnsi256:{value(t,r,n){return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(o=>o+o).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:t=>jy.rgbToAnsi256(...jy.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,n,i;if(t>=232)r=((t-232)*10+8)/255,n=r,i=r;else{t-=16;let a=t%36;r=Math.floor(t/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let o=Math.max(r,n,i)*2;if(o===0)return 30;let s=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return o===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(t,r,n)=>jy.ansi256ToAnsi(jy.rgbToAnsi256(t,r,n)),enumerable:!1},hexToAnsi:{value:t=>jy.ansi256ToAnsi(jy.hexToAnsi256(t)),enumerable:!1}}),jy}var z9p=U9p(),Eq=z9p;var Wir=Ce(require("process"),1),kta=Ce(require("os"),1),w0i=Ce(require("tty"),1);function Z4(e,t=globalThis.Deno?globalThis.Deno.args:Wir.default.argv){let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return n!==-1&&(i===-1||n<i)}var{env:Qy}=Wir.default,Gir;Z4("no-color")||Z4("no-colors")||Z4("color=false")||Z4("color=never")?Gir=0:(Z4("color")||Z4("colors")||Z4("color=true")||Z4("color=always"))&&(Gir=1);function V9p(){if("FORCE_COLOR"in Qy)return Qy.FORCE_COLOR==="true"?1:Qy.FORCE_COLOR==="false"?0:Qy.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Qy.FORCE_COLOR,10),3)}function q9p(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function G9p(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n=V9p();n!==void 0&&(Gir=n);let i=r?Gir:n;if(i===0)return 0;if(r){if(Z4("color=16m")||Z4("color=full")||Z4("color=truecolor"))return 3;if(Z4("color=256"))return 2}if("TF_BUILD"in Qy&&"AGENT_NAME"in Qy)return 1;if(e&&!t&&i===void 0)return 0;let o=i||0;if(Qy.TERM==="dumb")return o;if(Wir.default.platform==="win32"){let s=kta.default.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in Qy)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(s=>s in Qy)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in Qy)||Qy.CI_NAME==="codeship"?1:o;if("TEAMCITY_VERSION"in Qy)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qy.TEAMCITY_VERSION)?1:0;if(Qy.COLORTERM==="truecolor"||Qy.TERM==="xterm-kitty"||Qy.TERM==="xterm-ghostty"||Qy.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Qy){let s=Number.parseInt((Qy.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qy.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Qy.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qy.TERM)||"COLORTERM"in Qy?1:o}function Nta(e,t={}){let r=G9p(e,{streamIsTTY:e&&e.isTTY,...t});return q9p(r)}var W9p={stdout:Nta({isTTY:w0i.default.isatty(1)}),stderr:Nta({isTTY:w0i.default.isatty(2)})},Mta=W9p;function Lta(e,t,r){let n=e.indexOf(t);if(n===-1)return e;let i=t.length,o=0,s="";do s+=e.slice(o,n)+t+r,o=n+i,n=e.indexOf(t,o);while(n!==-1);return s+=e.slice(o),s}function Uta(e,t,r,n){let i=0,o="";do{let s=e[n-1]==="\r";o+=e.slice(i,s?n-1:n)+t+(s?`\r
|
|
1454
1454
|
`:`
|
|
1455
1455
|
`)+r,i=n+1,n=e.indexOf(`
|
|
1456
1456
|
`,i)}while(n!==-1);return o+=e.slice(i),o}var{stdout:zta,stderr:Vta}=Mta,C0i=Symbol("GENERATOR"),nHe=Symbol("STYLER"),OOt=Symbol("IS_EMPTY"),qta=["ansi","ansi","ansi256","ansi16m"],iHe=Object.create(null),$9p=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=zta?zta.level:0;e.level=t.level===void 0?r:t.level};var H9p=e=>{let t=(...r)=>r.join(" ");return $9p(t,e),Object.setPrototypeOf(t,BOt.prototype),t};function BOt(e){return H9p(e)}Object.setPrototypeOf(BOt.prototype,Function.prototype);for(let[e,t]of Object.entries(Eq))iHe[e]={get(){let r=$ir(this,x0i(t.open,t.close,this[nHe]),this[OOt]);return Object.defineProperty(this,e,{value:r}),r}};iHe.visible={get(){let e=$ir(this,this[nHe],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var _0i=(e,t,r,...n)=>e==="rgb"?t==="ansi16m"?Eq[r].ansi16m(...n):t==="ansi256"?Eq[r].ansi256(Eq.rgbToAnsi256(...n)):Eq[r].ansi(Eq.rgbToAnsi(...n)):e==="hex"?_0i("rgb",t,r,...Eq.hexToRgb(...n)):Eq[r][e](...n),K9p=["rgb","hex","ansi256"];for(let e of K9p){iHe[e]={get(){let{level:r}=this;return function(...n){let i=x0i(_0i(e,qta[r],"color",...n),Eq.color.close,this[nHe]);return $ir(this,i,this[OOt])}}};let t="bg"+e[0].toUpperCase()+e.slice(1);iHe[t]={get(){let{level:r}=this;return function(...n){let i=x0i(_0i(e,qta[r],"bgColor",...n),Eq.bgColor.close,this[nHe]);return $ir(this,i,this[OOt])}}}}var J9p=Object.defineProperties(()=>{},{...iHe,level:{enumerable:!0,get(){return this[C0i].level},set(e){this[C0i].level=e}}}),x0i=(e,t,r)=>{let n,i;return r===void 0?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},$ir=(e,t,r)=>{let n=(...i)=>Y9p(n,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(n,J9p),n[C0i]=e,n[nHe]=t,n[OOt]=r,n},Y9p=(e,t)=>{if(e.level<=0||!t)return e[OOt]?"":t;let r=e[nHe];if(r===void 0)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1B"))for(;r!==void 0;)t=Lta(t,r.close,r.open),r=r.parent;let o=t.indexOf(`
|
|
@@ -1673,7 +1673,7 @@ ${r}`);return i!=null?i(u):u},eda(n))}var $1i=class{async handle(t,r){let n=r["d
|
|
|
1673
1673
|
`)}var sDt=class extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var Gq={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},BEa={[Gq.Debug]:1,[Gq.Info]:2,[Gq.Warn]:3,[Gq.Error]:4},aDt=class{debug(t,...r){console.debug(t,...r)}info(t,...r){console.info(t,...r)}warn(t,...r){console.warn(t,...r)}error(t,...r){console.error(t,...r)}},xDi=class{level;logger;silent;constructor(t){this.level=BEa[t.level],this.logger=t.logger,this.silent=t.silent}shouldLog(t){return!this.silent&&this.level<=BEa[t]}isDebug(){return this.shouldLog(Gq.Debug)}debug(t,...r){this.isDebug()&&this.logger.debug(t,...r)}isInfo(){return this.shouldLog(Gq.Info)}info(t,...r){this.isInfo()&&this.logger.info(t,...r)}isWarn(){return this.shouldLog(Gq.Warn)}warn(t,...r){this.isWarn()&&this.logger.warn(t,...r)}isError(){return this.shouldLog(Gq.Error)}error(t,...r){this.isError()&&this.logger.error(t,...r)}};var XFy=new xDi({level:Gq.Info,logger:new aDt,silent:!0});var SDi;(function(e){e.LogLevel=Gq,e.ConsoleLogger=aDt})(SDi||(SDi={}));var TF={};X(TF,{AbsoluteProductPath:()=>w0r,AiChatConfig:()=>lDt,AiChatDatasource:()=>_0r,AiChatLocation:()=>x0r,AiChatModel:()=>S0r,AiChatWebsiteDatasource:()=>C0r,AiExamplesConfig:()=>O0r,AnalyticsConfig:()=>j0r,AnnouncementConfig:()=>cwe,ApiReferenceConfiguration:()=>L0r,ApiReferenceEndpointConfiguration:()=>U0r,ApiReferenceLayoutItem:()=>$J,ApiReferenceOperationConfiguration:()=>z0r,ApiReferencePackageConfiguration:()=>V0r,ApiReferencePackageConfigurationWithOptions:()=>G0r,ApiReferenceSectionConfiguration:()=>q0r,Audience:()=>GJ,AudienceId:()=>pDt,Availability:()=>jC,BackgroundImageConfiguration:()=>$0r,BackgroundImageThemedConfig:()=>W0r,BodyThemeConfig:()=>H0r,ChangelogConfiguration:()=>K0r,ChangelogFolderRelativePath:()=>FYe,ColorConfig:()=>_0,ColorThemedConfig:()=>J0r,ColorsConfiguration:()=>Y0r,ContentAlignment:()=>X0r,CssConfig:()=>Z0r,CustomDomain:()=>evr,CustomPageAction:()=>tvr,DocsConfiguration:()=>nIa,DocsInstance:()=>ovr,DocsSettingsConfig:()=>uvr,DocsTypographyConfig:()=>fvr,EditThisPageConfig:()=>ivr,EditThisPageLaunch:()=>rvr,ExperimentalConfig:()=>dvr,ExternalProduct:()=>Hvr,FeatureFlag:()=>fDt,FeatureFlagConfiguration:()=>M0r,FolderConfiguration:()=>sEr,FontConfig:()=>MYe,FontConfigPath:()=>lvr,FontConfigVariant:()=>cvr,FontDisplay:()=>pvr,FontStyle:()=>NYe,FontWeight:()=>kYe,FooterLinksConfig:()=>mvr,FooterNavThemeConfig:()=>Zvr,FullStoryAnalyticsConfig:()=>B0r,GitLibraryInputSchema:()=>_vr,GithubEditThisPageConfig:()=>nvr,GoogleAnalytics4Config:()=>P0r,GtmConfig:()=>T0r,HeaderPosition:()=>vvr,HttpSnippetLanguage:()=>svr,HttpSnippetsConfig:()=>avr,IntegrationsConfig:()=>hvr,IntercomConfig:()=>D0r,InternalProduct:()=>Kvr,JsConfig:()=>bvr,JsConfigOptions:()=>dDt,JsFileConfig:()=>Avr,JsFileConfigSettings:()=>gvr,JsRemoteConfig:()=>yvr,JsScriptStrategy:()=>LYe,Language:()=>jYe,LanguageSwitcherThemeConfig:()=>eEr,LayoutConfig:()=>Cvr,LibraryConfiguration:()=>Pvr,LibraryInputConfiguration:()=>Svr,LibraryLanguage:()=>Ovr,LibraryName:()=>UYe,LibraryOutputConfiguration:()=>Bvr,LibraryReferenceConfiguration:()=>aEr,LinkConfiguration:()=>RYe,LogoConfiguration:()=>Tvr,MetadataConfig:()=>Rvr,NavbarDropdownConfig:()=>Fvr,NavbarGithubConfig:()=>Qvr,NavbarGithubConfigWithOptions:()=>jvr,NavbarLink:()=>Nvr,NavbarLinkConfig:()=>HJ,NavigationConfig:()=>pwe,NavigationItem:()=>KJ,PageActionOption:()=>qvr,PageActionOptions:()=>Gvr,PageActionsConfig:()=>Wvr,PageActionsThemeConfig:()=>tEr,PageConfiguration:()=>DL,PathLibraryInputSchema:()=>xvr,PlaygroundButtonSettings:()=>Q0r,PlaygroundSettings:()=>WJ,PostHogConfig:()=>R0r,ProductConfig:()=>Jvr,ProductConfigBase:()=>VYe,ProductFileConfig:()=>iIa,ProductPath:()=>oIa,ProductSwitcherThemeConfig:()=>rEr,ProgrammingLanguage:()=>Yvr,RedirectConfig:()=>Xvr,RelativeProductPath:()=>cEr,Role:()=>DYe,RoleId:()=>Eke,SearchbarPlacement:()=>Evr,SectionConfiguration:()=>uEr,SegmentConfig:()=>F0r,SidebarThemeConfig:()=>nEr,SnippetLanguageConfiguration:()=>PL,SnippetsConfiguration:()=>k0r,SwitcherPlacement:()=>Ivr,TabConfig:()=>fwe,TabId:()=>RL,TabVariant:()=>Mvr,TabbedNavigationConfig:()=>zvr,TabbedNavigationItem:()=>Uvr,TabbedNavigationItemWithLayout:()=>kvr,TabbedNavigationItemWithVariants:()=>Lvr,TabsPlacement:()=>wvr,TabsThemeConfig:()=>iEr,Target:()=>TL,ThemeConfig:()=>oEr,TitleSource:()=>QYe,TwitterCardSetting:()=>Dvr,UntabbedNavigationConfig:()=>Vvr,VersionAvailability:()=>$vr,VersionConfig:()=>zYe,VersionFileConfig:()=>sIa,VersionedSnippetLanguageConfiguration:()=>N0r,WithFeatureFlags:()=>Fd,WithPermissions:()=>jd,WithViewers:()=>lwe,docs:()=>RDi});var RDi={};X(RDi,{AbsoluteProductPath:()=>w0r,AiChatConfig:()=>lDt,AiChatDatasource:()=>_0r,AiChatLocation:()=>x0r,AiChatModel:()=>S0r,AiChatWebsiteDatasource:()=>C0r,AiExamplesConfig:()=>O0r,AnalyticsConfig:()=>j0r,AnnouncementConfig:()=>cwe,ApiReferenceConfiguration:()=>L0r,ApiReferenceEndpointConfiguration:()=>U0r,ApiReferenceLayoutItem:()=>$J,ApiReferenceOperationConfiguration:()=>z0r,ApiReferencePackageConfiguration:()=>V0r,ApiReferencePackageConfigurationWithOptions:()=>G0r,ApiReferenceSectionConfiguration:()=>q0r,Audience:()=>GJ,AudienceId:()=>pDt,Availability:()=>jC,BackgroundImageConfiguration:()=>$0r,BackgroundImageThemedConfig:()=>W0r,BodyThemeConfig:()=>H0r,ChangelogConfiguration:()=>K0r,ChangelogFolderRelativePath:()=>FYe,ColorConfig:()=>_0,ColorThemedConfig:()=>J0r,ColorsConfiguration:()=>Y0r,ContentAlignment:()=>X0r,CssConfig:()=>Z0r,CustomDomain:()=>evr,CustomPageAction:()=>tvr,DocsConfiguration:()=>nIa,DocsInstance:()=>ovr,DocsSettingsConfig:()=>uvr,DocsTypographyConfig:()=>fvr,EditThisPageConfig:()=>ivr,EditThisPageLaunch:()=>rvr,ExperimentalConfig:()=>dvr,ExternalProduct:()=>Hvr,FeatureFlag:()=>fDt,FeatureFlagConfiguration:()=>M0r,FolderConfiguration:()=>sEr,FontConfig:()=>MYe,FontConfigPath:()=>lvr,FontConfigVariant:()=>cvr,FontDisplay:()=>pvr,FontStyle:()=>NYe,FontWeight:()=>kYe,FooterLinksConfig:()=>mvr,FooterNavThemeConfig:()=>Zvr,FullStoryAnalyticsConfig:()=>B0r,GitLibraryInputSchema:()=>_vr,GithubEditThisPageConfig:()=>nvr,GoogleAnalytics4Config:()=>P0r,GtmConfig:()=>T0r,HeaderPosition:()=>vvr,HttpSnippetLanguage:()=>svr,HttpSnippetsConfig:()=>avr,IntegrationsConfig:()=>hvr,IntercomConfig:()=>D0r,InternalProduct:()=>Kvr,JsConfig:()=>bvr,JsConfigOptions:()=>dDt,JsFileConfig:()=>Avr,JsFileConfigSettings:()=>gvr,JsRemoteConfig:()=>yvr,JsScriptStrategy:()=>LYe,Language:()=>jYe,LanguageSwitcherThemeConfig:()=>eEr,LayoutConfig:()=>Cvr,LibraryConfiguration:()=>Pvr,LibraryInputConfiguration:()=>Svr,LibraryLanguage:()=>Ovr,LibraryName:()=>UYe,LibraryOutputConfiguration:()=>Bvr,LibraryReferenceConfiguration:()=>aEr,LinkConfiguration:()=>RYe,LogoConfiguration:()=>Tvr,MetadataConfig:()=>Rvr,NavbarDropdownConfig:()=>Fvr,NavbarGithubConfig:()=>Qvr,NavbarGithubConfigWithOptions:()=>jvr,NavbarLink:()=>Nvr,NavbarLinkConfig:()=>HJ,NavigationConfig:()=>pwe,NavigationItem:()=>KJ,PageActionOption:()=>qvr,PageActionOptions:()=>Gvr,PageActionsConfig:()=>Wvr,PageActionsThemeConfig:()=>tEr,PageConfiguration:()=>DL,PathLibraryInputSchema:()=>xvr,PlaygroundButtonSettings:()=>Q0r,PlaygroundSettings:()=>WJ,PostHogConfig:()=>R0r,ProductConfig:()=>Jvr,ProductConfigBase:()=>VYe,ProductFileConfig:()=>iIa,ProductPath:()=>oIa,ProductSwitcherThemeConfig:()=>rEr,ProgrammingLanguage:()=>Yvr,RedirectConfig:()=>Xvr,RelativeProductPath:()=>cEr,Role:()=>DYe,RoleId:()=>Eke,SearchbarPlacement:()=>Evr,SectionConfiguration:()=>uEr,SegmentConfig:()=>F0r,SidebarThemeConfig:()=>nEr,SnippetLanguageConfiguration:()=>PL,SnippetsConfiguration:()=>k0r,SwitcherPlacement:()=>Ivr,TabConfig:()=>fwe,TabId:()=>RL,TabVariant:()=>Mvr,TabbedNavigationConfig:()=>zvr,TabbedNavigationItem:()=>Uvr,TabbedNavigationItemWithLayout:()=>kvr,TabbedNavigationItemWithVariants:()=>Lvr,TabsPlacement:()=>wvr,TabsThemeConfig:()=>iEr,Target:()=>TL,ThemeConfig:()=>oEr,TitleSource:()=>QYe,TwitterCardSetting:()=>Dvr,UntabbedNavigationConfig:()=>Vvr,VersionAvailability:()=>$vr,VersionConfig:()=>zYe,VersionFileConfig:()=>sIa,VersionedSnippetLanguageConfiguration:()=>N0r,WithFeatureFlags:()=>Fd,WithPermissions:()=>jd,WithViewers:()=>lwe});var se={};X(se,{JsonError:()=>BYe,ParseError:()=>PYe,any:()=>VEa,bigint:()=>TEa,boolean:()=>qEa,booleanLiteral:()=>UEa,date:()=>DEa,discriminant:()=>eIa,enum_:()=>v0r,getObjectLikeUtils:()=>Wq,getObjectUtils:()=>vke,getSchemaUtils:()=>Rd,isProperty:()=>Ohe,lazy:()=>REa,lazyObject:()=>MEa,list:()=>I0r,never:()=>GEa,number:()=>WEa,object:()=>E0r,objectWithoutOptionalProperties:()=>kEa,optional:()=>ODi,property:()=>jEa,record:()=>JEa,set:()=>YEa,string:()=>$Ea,stringLiteral:()=>zEa,transform:()=>BDi,undiscriminatedUnion:()=>ZEa,union:()=>rIa,unknown:()=>HEa,withParsedProperties:()=>DDi});var fc={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",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function Zf(e,t){return`Expected ${t}. Received ${hmf(e)}.`}function hmf(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 RC(e){return{...e,json:PEa(e.json),parse:PEa(e.parse)}}function PEa(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(o=>" - "+(o.path.length>0?`${o.path.join(".")}: ${o.message}`:o.message))].join(`
|
|
1674
1674
|
`)),{ok:!0,value:t}):n}}function b0r(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var BYe=class e extends Error{errors;constructor(t){super(t.map(b0r).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var PYe=class e extends Error{errors;constructor(t){super(t.map(b0r).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Rd(e){return{nullable:()=>gmf(e),optional:()=>ODi(e),optionalNullable:()=>Amf(e),transform:t=>BDi(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new PYe(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new BYe(n.errors)}}}function gmf(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>fc.NULLABLE};return{...t,...Rd(t)}}function ODi(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>fc.OPTIONAL};return{...t,...Rd(t)}}function Amf(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>fc.OPTIONAL_NULLABLE};return{...t,...Rd(t)}}function BDi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...Rd(r)}}function TEa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:Zf(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:Zf(t,"bigint")}]}:{ok:!0,value:t},getType:()=>fc.BIGINT};return{...RC(e),...Rd(e)}}var ymf=/^([+-]?\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 DEa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Zf(t,"string")}]}:ymf.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Zf(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Zf(t,"Date object")}]},getType:()=>fc.DATE};return{...RC(e),...Rd(e)}}function FC(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...RC(r),...Rd(r)}}}function v0r(e){let t=new Set(e);return FC(fc.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:Zf(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:Zf(n,"enum")}]}:{ok:!0,value:n})()}function REa(e){let t=PDi(e);return{...t,...Rd(t)}}function PDi(e){return{parse:(t,r)=>TYe(e).parse(t,r),json:(t,r)=>TYe(e).json(t,r),getType:()=>TYe(e).getType()}}function TYe(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function TDi(e){return Object.entries(e)}function uDt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function She(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function cDt(e){return Object.keys(e)}function FEa(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var bmf=Object.prototype.hasOwnProperty;function Wq(e){return{withParsedProperties:t=>DDi(e,t)}}function DDi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(bmf.call(t,a)){let u=t[a];s[a]=typeof u=="function"?u(o.value):u}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!She(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Zf(n,"object")}]};let o=new Set(Object.keys(t)),s=uDt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...Rd(r),...Wq(r)}}function jEa(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Ohe(e){return e.isProperty}var vmf=Object.prototype.hasOwnProperty;function E0r(e){let t;function r(){if(t==null){t={};for(let[d,f]of TDi(e)){let m=Ohe(f)?f.rawKey:d,h=Ohe(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of TDi(e)){let m=Ohe(f)?f.rawKey:d,h=Ohe(f)?f.valueSchema:f;Emf(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function u(){return i==null&&a(),i}function c(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>Ohe(f)?f.rawKey:d),_getParsedProperties:()=>cDt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return QEa({value:d,requiredKeys:a(),requiredKeysSet:c(),getProperty:h=>{let A=r()[h];if(A!=null)return{transformedKey:A.parsedKey,transform:y=>{let v=[...m,h];return A.valueSchema.parse(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return QEa({value:d,requiredKeys:u(),requiredKeysSet:l(),getProperty:h=>{let A=e[h];if(A!=null)return Ohe(A)?{transformedKey:A.rawKey,transform:y=>{let v=[...m,h];return A.valueSchema.json(y,{...f,breadcrumbsPrefix:v})}}:{transformedKey:h,transform:y=>{let v=[...m,h];return A.json(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>fc.OBJECT};return{...RC(p),...Rd(p),...Wq(p),...vke(p)}}function QEa({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!She(e))return{ok:!1,errors:[{path:s,message:Zf(e,"object")}]};let a=t.length,u=[],c={};for(let l in e){if(!vmf.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?c[d.transformedKey]=f.value:(c[l]=p,u.push(...f.errors))}else switch(i){case"fail":u.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":c[l]=p;break}}if(a>0)for(let l of t)l in e||u.push({path:s,message:`Missing required key "${l}"`});return u.length===0||o?{ok:!0,value:c}:{ok:!1,errors:u}}function vke(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>NEa({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>NEa({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>fc.OBJECT};return{...r,...Rd(r),...Wq(r),...vke(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))t.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))r.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},getType:()=>fc.OBJECT};return{...n,...Rd(n),...Wq(n),...vke(n)}}}}function NEa({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!She(t))return{ok:!1,errors:[{path:i,message:Zf(t,"object")}]};let o=new Set(e),[s,a]=FEa(cDt(t),l=>o.has(l)),u=r(uDt(t,a)),c=n(uDt(t,s));return u.ok&&c.ok?{ok:!0,value:{...u.value,...c.value}}:{ok:!1,errors:[...u.ok?[]:u.errors,...c.ok?[]:c.errors]}}function Emf(e){return!Imf(e)}function Imf(e){switch(e.getType()){case fc.ANY:case fc.UNKNOWN:case fc.OPTIONAL:case fc.OPTIONAL_NULLABLE:return!0;default:return!1}}function kEa(e){return E0r(e)}function MEa(e){let t={...PDi(e),_getRawProperties:()=>TYe(e)._getRawProperties(),_getParsedProperties:()=>TYe(e)._getParsedProperties()};return{...t,...Rd(t),...Wq(t),...vke(t)}}function I0r(e){let t={parse:(r,n)=>LEa(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>LEa(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>fc.LIST};return{...RC(t),...Rd(t)}}function LEa(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:Zf(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function UEa(e){return FC(fc.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Zf(r,`${e.toString()}`)}]})()}function zEa(e){return FC(fc.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Zf(r,`"${e}"`)}]})()}var VEa=FC(fc.ANY,e=>({ok:!0,value:e}));var qEa=FC(fc.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Zf(e,"boolean")}]});var GEa=FC(fc.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var WEa=FC(fc.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Zf(e,"number")}]});var $Ea=FC(fc.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Zf(e,"string")}]});var HEa=FC(fc.UNKNOWN,e=>({ok:!0,value:e}));var wmf=Object.prototype.hasOwnProperty;function JEa(e,t){let r={parse:(n,i)=>KEa({value:n,isKeyNumeric:e.getType()===fc.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>KEa({value:n,isKeyNumeric:e.getType()===fc.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>fc.RECORD};return{...RC(r),...Rd(r)}}function KEa({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!She(e))return{ok:!1,errors:[{path:i,message:Zf(e,"object")}]};let o={},s=[];for(let a in e){if(!wmf.call(e,a))continue;let u=e[a];if(u===void 0)continue;let c=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(c=d)}let l=r(c),p=n(u,c);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function YEa(e){let t=I0r(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Zf(n,"Set")}]},getType:()=>fc.SET};return{...RC(r),...Rd(r)}}function ZEa(e){let t={parse:(r,n)=>XEa((i,o)=>i.parse(r,o),e,n),json:(r,n)=>XEa((i,o)=>i.json(r,o),e,n),getType:()=>fc.UNDISCRIMINATED_UNION};return{...RC(t),...Rd(t)}}function XEa(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function eIa(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var Cmf=Object.prototype.hasOwnProperty;function rIa(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=v0r(cDt(t)),o={parse:(s,a)=>tIa({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:u=>i.parse(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.parse(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>tIa({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:u=>i.json(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.json(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>fc.UNION};return{...RC(o),...Rd(o),...Wq(o)}}function tIa({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!She(e))return{ok:!1,errors:[{path:a,message:Zf(e,"object")}]};let u=e[t],c={};for(let f in e)Cmf.call(e,f)&&f!==t&&(c[f]=e[f]);if(u==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(u);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...c}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(c,p);return d.ok?{ok:!0,value:{[r]:u,...d.value}}:d}var w0r=se.object({href:se.string()});var C0r=se.object({url:se.string(),title:se.string().optional()});var _0r=se.undiscriminatedUnion([C0r]);var x0r=se.enum_(["docs","slack","discord"]);var S0r=se.enum_(["claude-3.7","claude-4","command-a"]);var lDt=se.object({model:S0r.optional(),systemPrompt:se.property("system-prompt",se.string().optional()),location:se.list(x0r).optional(),datasources:se.list(_0r).optional()});var O0r=se.object({enabled:se.boolean().optional(),style:se.string().optional()});var B0r=se.object({orgId:se.property("org-id",se.string())});var P0r=se.object({measurementId:se.property("measurement-id",se.string())});var T0r=se.object({containerId:se.property("container-id",se.string())});var D0r=se.object({appId:se.property("app-id",se.string()),apiBase:se.property("api-base",se.string().optional())});var R0r=se.object({apiKey:se.property("api-key",se.string()),endpoint:se.string().optional()});var F0r=se.object({writeKey:se.property("write-key",se.string())});var j0r=se.object({segment:F0r.optional(),fullstory:B0r.optional(),intercom:D0r.optional(),posthog:R0r.optional(),gtm:T0r.optional(),ga4:P0r.optional()});var cwe=se.object({message:se.string()});var pDt=se.string();var GJ=se.undiscriminatedUnion([pDt,se.list(pDt)]);var jC=se.enum_(["stable","generally-available","in-development","pre-release","deprecated","beta"]);var Q0r=se.object({href:se.string().optional()});var WJ=se.object({hidden:se.boolean().optional(),environments:se.list(se.string()).optional(),button:Q0r.optional(),oauth:se.boolean().optional(),limitWebsocketMessagesPerConnection:se.property("limit-websocket-messages-per-connection",se.number().optional())});var N0r=se.object({version:se.string(),package:se.string()});var PL=se.undiscriminatedUnion([se.string(),N0r]);var k0r=se.object({python:PL.optional(),typescript:PL.optional(),go:PL.optional(),java:PL.optional(),ruby:PL.optional(),csharp:PL.optional(),php:PL.optional(),swift:PL.optional(),rust:PL.optional()});var fDt=se.object({flag:se.string(),fallbackValue:se.property("fallback-value",se.unknown().optional()),match:se.unknown().optional()});var M0r=se.undiscriminatedUnion([se.string(),fDt,se.list(fDt)]);var Fd=se.object({featureFlag:se.property("feature-flag",M0r.optional())});var Eke=se.string();var DYe=se.undiscriminatedUnion([Eke,se.list(Eke)]);var jd=se.object({viewers:DYe.optional(),orphaned:se.boolean().optional()});var L0r=se.object({api:se.string(),apiName:se.property("api-name",se.string().optional()),openrpc:se.string().optional(),audiences:GJ.optional(),displayErrors:se.property("display-errors",se.boolean().optional()),tagDescriptionPages:se.property("tag-description-pages",se.boolean().optional()),snippets:k0r.optional(),postman:se.string().optional(),summary:se.string().optional(),layout:se.list(se.lazy(()=>$J)).optional(),collapsed:se.boolean().optional(),icon:se.string().optional(),slug:se.string().optional(),hidden:se.boolean().optional(),availability:jC.optional(),skipSlug:se.property("skip-slug",se.boolean().optional()),alphabetized:se.boolean().optional(),flattened:se.boolean().optional(),paginated:se.boolean().optional(),playground:WJ.optional()}).extend(jd).extend(Fd);var U0r=se.object({endpoint:se.string(),title:se.string().optional(),slug:se.string().optional(),icon:se.string().optional(),hidden:se.boolean().optional(),availability:jC.optional(),playground:WJ.optional()}).extend(jd).extend(Fd);var z0r=se.object({operation:se.string(),title:se.string().optional(),slug:se.string().optional(),hidden:se.boolean().optional(),availability:jC.optional()}).extend(jd).extend(Fd);var TL=se.enum_(["_blank","_self","_parent","_top"]);var RYe=se.object({link:se.string(),href:se.string(),icon:se.string().optional(),target:TL.optional()});var DL=se.object({page:se.string(),path:se.string(),slug:se.string().optional(),icon:se.string().optional(),hidden:se.boolean().optional(),noindex:se.boolean().optional(),availability:jC.optional()}).extend(jd).extend(Fd);var $J=se.undiscriminatedUnion([se.string(),se.record(se.string(),se.lazy(()=>V0r)),se.lazyObject(()=>q0r),U0r,z0r,DL,RYe]);var V0r=se.undiscriminatedUnion([se.list(se.lazy(()=>$J)),se.lazyObject(()=>G0r)]);var G0r=se.object({title:se.string().optional(),summary:se.string().optional(),contents:se.list(se.lazy(()=>$J)).optional(),availability:jC.optional(),slug:se.string().optional(),icon:se.string().optional(),hidden:se.boolean().optional(),skipSlug:se.property("skip-slug",se.boolean().optional()),playground:WJ.optional()}).extend(jd).extend(Fd);var q0r=se.object({section:se.string(),referencedPackages:se.property("referenced-packages",se.list(se.string()).optional()),summary:se.string().optional(),contents:se.list(se.lazy(()=>$J)).optional(),slug:se.string().optional(),icon:se.string().optional(),hidden:se.boolean().optional(),skipSlug:se.property("skip-slug",se.boolean().optional()),collapsible:se.boolean().optional(),collapsedByDefault:se.property("collapsed-by-default",se.boolean().optional()),availability:jC.optional(),playground:WJ.optional()}).extend(jd).extend(Fd);var W0r=se.object({dark:se.string().optional(),light:se.string().optional()});var $0r=se.undiscriminatedUnion([se.string(),W0r]);var H0r=se.enum_(["default","canvas"]);var FYe=se.string();var K0r=se.object({changelog:FYe,title:se.string().optional(),slug:se.string().optional(),icon:se.string().optional(),hidden:se.boolean().optional()}).extend(jd).extend(Fd);var J0r=se.object({dark:se.string().optional(),light:se.string().optional()});var _0=se.undiscriminatedUnion([se.string(),J0r]);var Y0r=se.object({accentPrimary:se.property("accent-primary",_0.optional()),accentPrimaryDeprecated:se.property("accentPrimary",_0.optional()),background:_0.optional(),border:_0.optional(),sidebarBackground:se.property("sidebar-background",_0.optional()),headerBackground:se.property("header-background",_0.optional()),cardBackground:se.property("card-background",_0.optional()),accent1:se.property("accent-1",_0.optional()),accent2:se.property("accent-2",_0.optional()),accent3:se.property("accent-3",_0.optional()),accent4:se.property("accent-4",_0.optional()),accent5:se.property("accent-5",_0.optional()),accent6:se.property("accent-6",_0.optional()),accent7:se.property("accent-7",_0.optional()),accent8:se.property("accent-8",_0.optional()),accent9:se.property("accent-9",_0.optional()),accent10:se.property("accent-10",_0.optional()),accent11:se.property("accent-11",_0.optional()),accent12:se.property("accent-12",_0.optional())});var X0r=se.enum_(["center","left"]);var Z0r=se.undiscriminatedUnion([se.string(),se.list(se.string())]);var evr=se.undiscriminatedUnion([se.string(),se.list(se.string())]);var tvr=se.object({title:se.string(),subtitle:se.string().optional(),url:se.string(),icon:se.string().optional(),default:se.boolean().optional()});var rvr=se.enum_(["github","dashboard"]);var nvr=se.object({host:se.string().optional(),owner:se.string(),repo:se.string(),branch:se.string().optional()});var ivr=se.object({github:nvr.optional(),launch:rvr.optional()});var ovr=se.object({url:se.string(),customDomain:se.property("custom-domain",evr.optional()),private:se.boolean().optional(),editThisPage:se.property("edit-this-page",ivr.optional()),audiences:GJ.optional()});var svr=se.enum_(["curl","csharp","go","java","javascript","php","python","ruby","swift","typescript"]);var avr=se.undiscriminatedUnion([se.boolean(),se.list(svr)]);var jYe=se.enum_(["en","es","fr","de","it","pt","ja","zh","ko","el","no","pl","ru","sv","tr"]);var QYe=se.enum_(["frontmatter","filename"]);var uvr=se.object({searchText:se.property("search-text",se.string().optional()),disableSearch:se.property("disable-search",se.boolean().optional()),darkModeCode:se.property("dark-mode-code",se.boolean().optional()),defaultSearchFilters:se.property("default-search-filters",se.boolean().optional()),httpSnippets:se.property("http-snippets",avr.optional()),hide404Page:se.property("hide-404-page",se.boolean().optional()),useJavascriptAsTypescript:se.property("use-javascript-as-typescript",se.boolean().optional()),disableExplorerProxy:se.property("disable-explorer-proxy",se.boolean().optional()),disableAnalytics:se.property("disable-analytics",se.boolean().optional()),language:jYe.optional(),folderTitleSource:se.property("folder-title-source",QYe.optional()),substituteEnvVars:se.property("substitute-env-vars",se.boolean().optional())});var NYe=se.enum_(["normal","italic"]);var kYe=se.undiscriminatedUnion([se.string(),se.number()]);var cvr=se.object({path:se.string(),weight:kYe.optional(),style:NYe.optional()});var lvr=se.undiscriminatedUnion([se.string(),cvr]);var pvr=se.enum_(["auto","block","swap","fallback","optional"]);var MYe=se.object({name:se.string().optional(),path:se.string().optional(),weight:kYe.optional(),style:NYe.optional(),paths:se.list(lvr).optional(),display:pvr.optional(),fallback:se.list(se.string()).optional(),fontVariationSettings:se.property("font-variation-settings",se.string().optional())});var fvr=se.object({headingsFont:MYe.optional(),bodyFont:MYe.optional(),codeFont:MYe.optional()});var dvr=se.object({mdxComponents:se.property("mdx-components",se.list(se.string()).optional()),disableStreamToggle:se.property("disable-stream-toggle",se.boolean().optional()),openapiParserV2:se.property("openapi-parser-v2",se.boolean().optional()),openapiParserV3:se.property("openapi-parser-v3",se.boolean().optional()),dynamicSnippets:se.property("dynamic-snippets",se.boolean().optional()),aiExamples:se.property("ai-examples",se.boolean().optional()),aiExampleStyleInstructions:se.property("ai-example-style-instructions",se.string().optional()),excludeApis:se.property("exclude-apis",se.boolean().optional()),basepathAware:se.property("basepath-aware",se.boolean().optional())});var mvr=se.object({github:se.string().optional(),twitter:se.string().optional(),x:se.string().optional(),linkedin:se.string().optional(),youtube:se.string().optional(),instagram:se.string().optional(),facebook:se.string().optional(),discord:se.string().optional(),slack:se.string().optional(),hackernews:se.string().optional(),medium:se.string().optional(),website:se.string().optional()});var hvr=se.object({intercom:se.string().optional()});var LYe=se.enum_(["beforeInteractive","afterInteractive","lazyOnload"]);var gvr=se.object({path:se.string(),strategy:LYe.optional()});var Avr=se.undiscriminatedUnion([se.string(),gvr]);var yvr=se.object({url:se.string(),strategy:LYe.optional()});var dDt=se.undiscriminatedUnion([yvr,Avr]);var bvr=se.undiscriminatedUnion([dDt,se.list(dDt)]);var vvr=se.enum_(["fixed","static"]);var Evr=se.enum_(["header","header-tabs","sidebar"]);var Ivr=se.enum_(["header","sidebar"]);var wvr=se.enum_(["header","sidebar"]);var Cvr=se.object({pageWidth:se.property("page-width",se.string().optional()),contentWidth:se.property("content-width",se.string().optional()),sidebarWidth:se.property("sidebar-width",se.string().optional()),headerHeight:se.property("header-height",se.string().optional()),searchbarPlacement:se.property("searchbar-placement",Evr.optional()),tabsPlacement:se.property("tabs-placement",wvr.optional()),switcherPlacement:se.property("switcher-placement",Ivr.optional()),contentAlignment:se.property("content-alignment",X0r.optional()),headerPosition:se.property("header-position",vvr.optional()),disableHeader:se.property("disable-header",se.boolean().optional()),hideNavLinks:se.property("hide-nav-links",se.boolean().optional()),hideFeedback:se.property("hide-feedback",se.boolean().optional())});var _vr=se.object({git:se.string(),subpath:se.string().optional()});var xvr=se.object({path:se.string()});var Svr=se.undiscriminatedUnion([_vr,xvr]);var Ovr=se.enum_(["python","cpp"]);var Bvr=se.object({path:se.string()});var Pvr=se.object({input:Svr,output:Bvr,lang:Ovr});var UYe=se.string();var Tvr=se.object({dark:se.string().optional(),light:se.string().optional(),height:se.number().optional(),href:se.string().optional(),rightText:se.property("right-text",se.string().optional())});var Dvr=se.enum_(["summary","summary_large_image","app","player"]);var Rvr=se.object({ogSiteName:se.property("og:site_name",se.string().optional()),ogTitle:se.property("og:title",se.string().optional()),ogDescription:se.property("og:description",se.string().optional()),ogUrl:se.property("og:url",se.string().optional()),ogImage:se.property("og:image",se.string().optional()),ogImageWidth:se.property("og:image:width",se.number().optional()),ogImageHeight:se.property("og:image:height",se.number().optional()),ogLocale:se.property("og:locale",se.string().optional()),ogLogo:se.property("og:logo",se.string().optional()),twitterTitle:se.property("twitter:title",se.string().optional()),twitterDescription:se.property("twitter:description",se.string().optional()),twitterHandle:se.property("twitter:handle",se.string().optional()),twitterImage:se.property("twitter:image",se.string().optional()),twitterSite:se.property("twitter:site",se.string().optional()),twitterUrl:se.property("twitter:url",se.string().optional()),twitterCard:se.property("twitter:card",Dvr.optional()),canonicalHost:se.property("canonical-host",se.string().optional())});var lwe=se.object({viewers:DYe.optional()});var HJ=se.object({href:se.string().optional(),target:TL.optional(),url:se.string().optional(),text:se.string().optional(),icon:se.string().optional(),rightIcon:se.string().optional(),rounded:se.boolean().optional()}).extend(lwe);var Fvr=se.object({links:se.list(HJ),text:se.string().optional(),icon:se.string().optional(),rightIcon:se.string().optional(),rounded:se.boolean().optional()}).extend(lwe);var jvr=se.object({url:se.string(),target:TL.optional()}).extend(lwe);var Qvr=se.undiscriminatedUnion([se.string(),jvr]);var Nvr=se.union("type",{filled:HJ,outlined:HJ,minimal:HJ,github:se.object({value:Qvr}),dropdown:Fvr,primary:HJ,secondary:HJ}).transform({transform:e=>e,untransform:e=>e});var RL=se.string();var kvr=se.object({tab:RL,layout:se.list(se.lazy(()=>KJ)).optional()});var Mvr=se.object({title:se.string(),subtitle:se.string().optional(),icon:se.string().optional(),layout:se.list(se.lazy(()=>KJ)),slug:se.string().optional(),skipSlug:se.property("skip-slug",se.boolean().optional()),hidden:se.boolean().optional(),default:se.boolean().optional()}).extend(jd).extend(Fd);var Lvr=se.object({tab:RL,variants:se.list(Mvr)});var Uvr=se.undiscriminatedUnion([kvr,Lvr]);var zvr=se.list(Uvr);var Vvr=se.list(se.lazy(()=>KJ));var pwe=se.undiscriminatedUnion([Vvr,zvr]);var qvr=se.enum_(["copy-page","view-as-markdown","ask-ai","chatgpt","claude","cursor","vscode"]);var Gvr=se.object({copyPage:se.property("copy-page",se.boolean().optional()),viewAsMarkdown:se.property("view-as-markdown",se.boolean().optional()),askAi:se.property("ask-ai",se.boolean().optional()),chatgpt:se.boolean().optional(),claude:se.boolean().optional(),cursor:se.boolean().optional(),vscode:se.boolean().optional(),custom:se.list(tvr).optional()});var Wvr=se.object({default:qvr.optional(),options:Gvr.optional()});var $vr=se.enum_(["deprecated","ga","stable","beta"]);var zYe=se.object({displayName:se.property("display-name",se.string()),path:se.string(),slug:se.string().optional(),availability:$vr.optional(),audiences:GJ.optional(),hidden:se.boolean().optional(),announcement:cwe.optional()}).extend(jd).extend(Fd);var VYe=se.object({displayName:se.property("display-name",se.string()),subtitle:se.string().optional(),icon:se.string().optional(),image:se.string().optional(),versions:se.list(zYe).optional(),audiences:GJ.optional()}).extend(jd).extend(Fd);var Hvr=se.object({href:se.string(),target:TL.optional()}).extend(VYe);var Kvr=se.object({path:se.string(),slug:se.string().optional(),announcement:cwe.optional()}).extend(VYe);var Jvr=se.undiscriminatedUnion([Kvr,Hvr]);var Yvr=se.enum_(["typescript","javascript","python","java","go","ruby","csharp","php","swift","rust","nodets","nodejs","dotnet","curl","jvm","ts","js"]);var Xvr=se.object({source:se.string(),destination:se.string(),permanent:se.boolean().optional()});var fwe=se.object({displayName:se.property("display-name",se.string()),icon:se.string().optional(),slug:se.string().optional(),skipSlug:se.property("skip-slug",se.boolean().optional()),hidden:se.boolean().optional(),href:se.string().optional(),target:TL.optional(),changelog:FYe.optional()}).extend(jd).extend(Fd);var Zvr=se.enum_(["default","minimal"]);var eEr=se.enum_(["default","minimal"]);var tEr=se.enum_(["default","toolbar"]);var rEr=se.enum_(["default","toggle"]);var nEr=se.enum_(["default","minimal"]);var iEr=se.enum_(["default","bubble"]);var oEr=se.object({sidebar:nEr.optional(),body:H0r.optional(),tabs:iEr.optional(),pageActions:se.property("page-actions",tEr.optional()),footerNav:se.property("footer-nav",Zvr.optional()),languageSwitcher:se.property("language-switcher",eEr.optional()),productSwitcher:se.property("product-switcher",rEr.optional())});var nIa=se.object({instances:se.list(ovr),title:se.string().optional(),libraries:se.record(UYe,Pvr).optional(),analytics:j0r.optional(),announcement:cwe.optional(),roles:se.list(Eke).optional(),tabs:se.record(RL,fwe).optional(),versions:se.list(zYe).optional(),products:se.list(Jvr).optional(),landingPage:se.property("landing-page",DL.optional()),navigation:pwe.optional(),navbarLinks:se.property("navbar-links",se.list(Nvr).optional()),footerLinks:se.property("footer-links",mvr.optional()),pageActions:se.property("page-actions",Wvr.optional()),experimental:dvr.optional(),defaultLanguage:se.property("default-language",Yvr.optional()),languages:se.list(jYe).optional(),aiChat:se.property("ai-chat",lDt.optional()),aiSearch:se.property("ai-search",lDt.optional()),aiExamples:se.property("ai-examples",O0r.optional()),metadata:Rvr.optional(),redirects:se.list(Xvr).optional(),logo:Tvr.optional(),favicon:se.string().optional(),backgroundImage:se.property("background-image",$0r.optional()),colors:Y0r.optional(),typography:fvr.optional(),layout:Cvr.optional(),settings:uvr.optional(),theme:oEr.optional(),integrations:hvr.optional(),css:Z0r.optional(),js:bvr.optional(),header:se.string().optional(),footer:se.string().optional()});var sEr=se.object({folder:se.string(),title:se.string().optional(),titleSource:se.property("title-source",QYe.optional()),slug:se.string().optional(),icon:se.string().optional(),hidden:se.boolean().optional(),skipSlug:se.property("skip-slug",se.boolean().optional()),collapsed:se.boolean().optional(),collapsible:se.boolean().optional(),collapsedByDefault:se.property("collapsed-by-default",se.boolean().optional()),availability:jC.optional()}).extend(jd).extend(Fd);var aEr=se.object({library:UYe,title:se.string().optional(),slug:se.string().optional()}).extend(jd).extend(Fd);var KJ=se.undiscriminatedUnion([DL,se.lazyObject(()=>uEr),L0r,aEr,RYe,K0r,sEr]);var iIa=se.object({tabs:se.record(RL,fwe).optional(),landingPage:se.property("landing-page",DL.optional()),navigation:pwe});var cEr=se.object({displayName:se.property("display-name",se.string()),path:se.string(),slug:se.string().optional()}).extend(jd).extend(Fd);var oIa=se.undiscriminatedUnion([cEr,w0r]);var uEr=se.object({section:se.string(),path:se.string().optional(),contents:se.list(se.lazy(()=>KJ)),collapsed:se.boolean().optional(),collapsible:se.boolean().optional(),collapsedByDefault:se.property("collapsed-by-default",se.boolean().optional()),slug:se.string().optional(),icon:se.string().optional(),hidden:se.boolean().optional(),skipSlug:se.property("skip-slug",se.boolean().optional()),availability:jC.optional()}).extend(jd).extend(Fd);var sIa=se.object({tabs:se.record(RL,fwe).optional(),landingPage:se.property("landing-page",DL.optional()),navigation:pwe});var aIa=require("fs/promises");var _mf=/\r?\n/;async function Ike({absolutePathToFernignore:e}){let t=(await(0,aIa.readFile)(e)).toString();return uIa(t)}function uIa(e){return[UJ,...e.trim().split(_mf).map(t=>{let r=t.indexOf("#");return r!==-1?t.slice(0,r).trim():t.trim()}).filter(t=>t.length>0)]}var yn={};X(yn,{API_ORIGIN_LOCATION_KEY:()=>fEa,API_SETTINGS_KEY:()=>gEa,ASYNC_API_LOCATION_KEY:()=>dEa,DEFAULT_GROUP_GENERATORS_CONFIG_KEY:()=>vYe,DEFAULT_GROUP_NAME:()=>tDt,DefaultIntegerFormat:()=>IIa,ExampleStyle:()=>wIa,FormParameterEncoding:()=>CIa,GenerationLanguage:()=>cIa,GithubCommitAndReleaseMode:()=>PIa,GithubLicenseType:()=>DIa,GithubSelfhostedMode:()=>TIa,Language:()=>_Ia,MessageNamingSettingsSchema:()=>xIa,ModelProvider:()=>fIa,OPENAPI_LOCATION_KEY:()=>mEa,OPENAPI_OVERRIDES_LOCATION_KEY:()=>hEa,PathParameterOrder:()=>SIa,RemoveDiscriminantsFromSchemas:()=>OIa,UnionSettingsSchema:()=>BIa,ai:()=>jDi,fernDefinition:()=>NDi,generators:()=>kDi,getPackageName:()=>lIa,group:()=>MDi,isApiConfigurationV2Schema:()=>cwa,isAsyncApiSpecSchema:()=>lwa,isConjureSchema:()=>pwa,isGraphQLSpecSchema:()=>fwa,isNamespacedApiConfiguration:()=>dwa,isOpenApiSpecSchema:()=>mwa,isOpenRpcSpecSchema:()=>hwa,isProtoSpecSchema:()=>gwa,isRawProtobufAPIDefinitionSchema:()=>pIa,license:()=>LDi,replay:()=>RIa,reviewers:()=>FIa,serialization:()=>uRi});var cIa={TYPESCRIPT:"typescript",JAVA:"java",PYTHON:"python",GO:"go",RUBY:"ruby",CSHARP:"csharp",SWIFT:"swift",PHP:"php",RUST:"rust"};function lIa({generatorInvocation:e}){return e.language==="go"?xmf(e):e.outputMode._visit({downloadFiles:()=>{},github:t=>t.publishInfo?._visit({maven:r=>r.coordinate,npm:r=>r.packageName,pypi:r=>r.packageName,postman:()=>{},rubygems:r=>r.packageName,nuget:r=>r.packageName,crates:r=>r.packageName,_other:()=>{}}),githubV2:t=>t.publishInfo?._visit({maven:r=>r.coordinate,npm:r=>r.packageName,pypi:r=>r.packageName,postman:()=>{},rubygems:r=>r.packageName,nuget:r=>r.packageName,crates:r=>r.packageName,_other:()=>{}}),publish:()=>{},publishV2:()=>{},_other:()=>{}})}function xmf(e){return e.outputMode._visit({downloadFiles:()=>{},github:t=>`github.com/${t.owner}/${t.repo}`,githubV2:t=>`github.com/${t.owner}/${t.repo}`,publish:()=>{},publishV2:()=>{},_other:()=>{}})}function pIa(e){return typeof e!="string"&&"proto"in e}var jDi={};X(jDi,{ModelProvider:()=>fIa});var fIa={Openai:"openai",Anthropic:"anthropic",Bedrock:"bedrock"};var NDi={};X(NDi,{AvailabilityStatusSchema:()=>mIa,auth:()=>dIa,availability:()=>QDi,commons:()=>hIa,encoding:()=>gIa,environments:()=>AIa,file:()=>yIa,service:()=>bIa,types:()=>vIa,validation:()=>EIa});var dIa={};var QDi={};X(QDi,{AvailabilityStatusSchema:()=>mIa});var mIa={InDevelopment:"in-development",PreRelease:"pre-release",Deprecated:"deprecated",GenerallyAvailable:"generally-available"};var hIa={};var gIa={};var AIa={};var yIa={};var bIa={};var vIa={};var EIa={};var kDi={};X(kDi,{DefaultIntegerFormat:()=>IIa,ExampleStyle:()=>wIa,FormParameterEncoding:()=>CIa,Language:()=>_Ia,MessageNamingSettingsSchema:()=>xIa,PathParameterOrder:()=>SIa,RemoveDiscriminantsFromSchemas:()=>OIa,UnionSettingsSchema:()=>BIa});var IIa={Int32:"int32",Int64:"int64",Uint32:"uint32",Uint64:"uint64"};var wIa={Minimal:"minimal",Comprehensive:"comprehensive"};var CIa={Form:"form",Json:"json"};var _Ia={Java:"java",Python:"python",Go:"go",Ruby:"ruby",Csharp:"csharp",Typescript:"typescript",Php:"php",Rust:"rust",Swift:"swift"};var xIa={V1:"v1",V2:"v2"};var SIa={UrlOrder:"url-order",SpecOrder:"spec-order"};var OIa={Always:"always",Never:"never"};var BIa={V1:"v1"};var MDi={};X(MDi,{GithubCommitAndReleaseMode:()=>PIa,GithubSelfhostedMode:()=>TIa});var PIa={Commit:"commit",Release:"release"};var TIa={PullRequest:"pull-request",Push:"push"};var LDi={};X(LDi,{GithubLicenseType:()=>DIa});var DIa={Mit:"MIT",Apache:"Apache-2.0"};var RIa={};var FIa={};var uRi={};X(uRi,{AiServicesSchema:()=>gEr,ApiConfigurationSchema:()=>EIr,ApiConfigurationSchemaInternal:()=>oXe,ApiConfigurationV2Schema:()=>bIr,ApiConfigurationV2SettingsSchema:()=>uXe,ApiConfigurationV2SpecsSchema:()=>cXe,ApiDefinitionList:()=>oIr,ApiDefinitionPathSchema:()=>gwe,ApiDefinitionSchema:()=>iIr,ApiDefinitionSettingsSchema:()=>tXe,ApiDefinitionWithOverridesSchema:()=>rXe,AsyncApiSettingsSchema:()=>aXe,AsyncApiSpecSchema:()=>dIr,BaseApiSettingsSchema:()=>sXe,ConjureSchema:()=>fIr,CratesOutputLocationSchema:()=>_Ir,DefaultIntegerFormat:()=>sIr,ExampleStyle:()=>IIr,FormParameterEncoding:()=>aIr,GeneratorApiSettingsSchema:()=>CIr,GeneratorGroupSchema:()=>$Ir,GeneratorInvocationSchema:()=>WIr,GeneratorOutputSchema:()=>jIr,GeneratorPublishMetadataSchema:()=>yDt,GeneratorSnippetsSchema:()=>kIr,GeneratorsConfigurationSchema:()=>uwa,GeneratorsOpenApiObjectSchema:()=>KIr,GeneratorsOpenApiSchema:()=>JIr,GithubCommitAndReleaseMode:()=>MIr,GithubCommitAndReleaseSchema:()=>LIr,GithubConfigurationSchema:()=>GIr,GithubLicenseCustomSchema:()=>QIr,GithubLicenseSchema:()=>jL,GithubLicenseType:()=>NIr,GithubPullRequestSchema:()=>UIr,GithubPushSchema:()=>zIr,GithubSelfhostedMode:()=>VIr,GithubSelfhostedSchema:()=>qIr,GraphQlSpecSchema:()=>mIr,Language:()=>YIr,LocalFileSystemOutputLocationSchema:()=>xIr,MavenOutputLocationSchema:()=>OIr,MavenOutputSignatureSchema:()=>SIr,MessageNamingSettingsSchema:()=>XYe,ModelName:()=>mEr,ModelProvider:()=>hEr,NamespacedApiConfigurationSchema:()=>vIr,NpmOutputLocationSchema:()=>BIr,NugetOutputLocationSchema:()=>PIr,OpenApiExampleGenerationSchema:()=>uIr,OpenApiFilterSchema:()=>cIr,OpenApiSettingsSchema:()=>Awe,OpenApiSpecSchema:()=>hIr,OpenRpcSpecSchema:()=>gIr,OutputMetadataAuthor:()=>wIr,OutputMetadataSchema:()=>ywe,OverridesSchema:()=>FL,PathParameterOrder:()=>ZYe,PostmanOutputLocationSchema:()=>TIr,ProtobufApiDefinitionSchema:()=>iXe,ProtobufDefinitionSchema:()=>nXe,ProtobufSpecSchema:()=>AIr,PypiOutputLocationSchema:()=>RIr,PypiOutputMetadataSchema:()=>DIr,ReadmeCustomSectionSchema:()=>XIr,ReadmeEndpointObjectSchema:()=>ZIr,ReadmeEndpointSchema:()=>bDt,ReadmeSchema:()=>ewr,RemoveDiscriminantsFromSchemas:()=>eXe,ReplayConfigSchema:()=>HIr,RequestOrResponseExampleGenerationSchema:()=>gDt,ResolveAliases:()=>pIr,ResolveAliasesSchema:()=>lIr,ReviewerSchema:()=>ADt,ReviewersSchema:()=>bwe,RubyGemsOutputLocationSchema:()=>FIr,SpecSchema:()=>yIr,UnionSettingsSchema:()=>nIr,WhitelabelConfigurationSchema:()=>rwr,WhitelabelGithubConfigurationSchema:()=>twr,ai:()=>WDi,fernDefinition:()=>rRi,generators:()=>nRi,group:()=>iRi,license:()=>oRi,replay:()=>sRi,reviewers:()=>aRi});var WDi={};X(WDi,{AiServicesSchema:()=>gEr,ModelName:()=>mEr,ModelProvider:()=>hEr});var be={};X(be,{JsonError:()=>qYe,ParseError:()=>GYe,any:()=>HIa,bigint:()=>QIa,boolean:()=>KIa,booleanLiteral:()=>WIa,date:()=>NIa,discriminant:()=>owa,enum_:()=>pEr,getObjectLikeUtils:()=>$q,getObjectUtils:()=>wke,getSchemaUtils:()=>Qd,isProperty:()=>Phe,lazy:()=>kIa,lazyObject:()=>qIa,list:()=>dEr,never:()=>JIa,number:()=>YIa,object:()=>fEr,objectWithoutOptionalProperties:()=>VIa,optional:()=>UDi,property:()=>LIa,record:()=>twa,set:()=>rwa,string:()=>XIa,stringLiteral:()=>$Ia,transform:()=>zDi,undiscriminatedUnion:()=>iwa,union:()=>awa,unknown:()=>ZIa,withParsedProperties:()=>GDi});var dc={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",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function ed(e,t){return`Expected ${t}. Received ${Smf(e)}.`}function Smf(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 QC(e){return{...e,json:jIa(e.json),parse:jIa(e.parse)}}function jIa(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(o=>" - "+(o.path.length>0?`${o.path.join(".")}: ${o.message}`:o.message))].join(`
|
|
1675
1675
|
`)),{ok:!0,value:t}):n}}function lEr(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var qYe=class e extends Error{errors;constructor(t){super(t.map(lEr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var GYe=class e extends Error{errors;constructor(t){super(t.map(lEr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Qd(e){return{nullable:()=>Omf(e),optional:()=>UDi(e),optionalNullable:()=>Bmf(e),transform:t=>zDi(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new GYe(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new qYe(n.errors)}}}function Omf(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>dc.NULLABLE};return{...t,...Qd(t)}}function UDi(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>dc.OPTIONAL};return{...t,...Qd(t)}}function Bmf(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>dc.OPTIONAL_NULLABLE};return{...t,...Qd(t)}}function zDi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...Qd(r)}}function QIa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:ed(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:ed(t,"bigint")}]}:{ok:!0,value:t},getType:()=>dc.BIGINT};return{...QC(e),...Qd(e)}}var Pmf=/^([+-]?\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 NIa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:ed(t,"string")}]}:Pmf.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:ed(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:ed(t,"Date object")}]},getType:()=>dc.DATE};return{...QC(e),...Qd(e)}}function NC(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...QC(r),...Qd(r)}}}function pEr(e){let t=new Set(e);return NC(dc.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:ed(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:ed(n,"enum")}]}:{ok:!0,value:n})()}function kIa(e){let t=VDi(e);return{...t,...Qd(t)}}function VDi(e){return{parse:(t,r)=>WYe(e).parse(t,r),json:(t,r)=>WYe(e).json(t,r),getType:()=>WYe(e).getType()}}function WYe(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function qDi(e){return Object.entries(e)}function mDt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function Bhe(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function hDt(e){return Object.keys(e)}function MIa(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var Tmf=Object.prototype.hasOwnProperty;function $q(e){return{withParsedProperties:t=>GDi(e,t)}}function GDi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(Tmf.call(t,a)){let u=t[a];s[a]=typeof u=="function"?u(o.value):u}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!Bhe(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:ed(n,"object")}]};let o=new Set(Object.keys(t)),s=mDt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...Qd(r),...$q(r)}}function LIa(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Phe(e){return e.isProperty}var Dmf=Object.prototype.hasOwnProperty;function fEr(e){let t;function r(){if(t==null){t={};for(let[d,f]of qDi(e)){let m=Phe(f)?f.rawKey:d,h=Phe(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of qDi(e)){let m=Phe(f)?f.rawKey:d,h=Phe(f)?f.valueSchema:f;Rmf(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function u(){return i==null&&a(),i}function c(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>Phe(f)?f.rawKey:d),_getParsedProperties:()=>hDt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return UIa({value:d,requiredKeys:a(),requiredKeysSet:c(),getProperty:h=>{let A=r()[h];if(A!=null)return{transformedKey:A.parsedKey,transform:y=>{let v=[...m,h];return A.valueSchema.parse(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return UIa({value:d,requiredKeys:u(),requiredKeysSet:l(),getProperty:h=>{let A=e[h];if(A!=null)return Phe(A)?{transformedKey:A.rawKey,transform:y=>{let v=[...m,h];return A.valueSchema.json(y,{...f,breadcrumbsPrefix:v})}}:{transformedKey:h,transform:y=>{let v=[...m,h];return A.json(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>dc.OBJECT};return{...QC(p),...Qd(p),...$q(p),...wke(p)}}function UIa({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!Bhe(e))return{ok:!1,errors:[{path:s,message:ed(e,"object")}]};let a=t.length,u=[],c={};for(let l in e){if(!Dmf.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?c[d.transformedKey]=f.value:(c[l]=p,u.push(...f.errors))}else switch(i){case"fail":u.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":c[l]=p;break}}if(a>0)for(let l of t)l in e||u.push({path:s,message:`Missing required key "${l}"`});return u.length===0||o?{ok:!0,value:c}:{ok:!1,errors:u}}function wke(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>zIa({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>zIa({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>dc.OBJECT};return{...r,...Qd(r),...$q(r),...wke(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))t.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))r.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},getType:()=>dc.OBJECT};return{...n,...Qd(n),...$q(n),...wke(n)}}}}function zIa({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!Bhe(t))return{ok:!1,errors:[{path:i,message:ed(t,"object")}]};let o=new Set(e),[s,a]=MIa(hDt(t),l=>o.has(l)),u=r(mDt(t,a)),c=n(mDt(t,s));return u.ok&&c.ok?{ok:!0,value:{...u.value,...c.value}}:{ok:!1,errors:[...u.ok?[]:u.errors,...c.ok?[]:c.errors]}}function Rmf(e){return!Fmf(e)}function Fmf(e){switch(e.getType()){case dc.ANY:case dc.UNKNOWN:case dc.OPTIONAL:case dc.OPTIONAL_NULLABLE:return!0;default:return!1}}function VIa(e){return fEr(e)}function qIa(e){let t={...VDi(e),_getRawProperties:()=>WYe(e)._getRawProperties(),_getParsedProperties:()=>WYe(e)._getParsedProperties()};return{...t,...Qd(t),...$q(t),...wke(t)}}function dEr(e){let t={parse:(r,n)=>GIa(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>GIa(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>dc.LIST};return{...QC(t),...Qd(t)}}function GIa(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:ed(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function WIa(e){return NC(dc.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:ed(r,`${e.toString()}`)}]})()}function $Ia(e){return NC(dc.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:ed(r,`"${e}"`)}]})()}var HIa=NC(dc.ANY,e=>({ok:!0,value:e}));var KIa=NC(dc.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:ed(e,"boolean")}]});var JIa=NC(dc.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var YIa=NC(dc.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:ed(e,"number")}]});var XIa=NC(dc.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:ed(e,"string")}]});var ZIa=NC(dc.UNKNOWN,e=>({ok:!0,value:e}));var jmf=Object.prototype.hasOwnProperty;function twa(e,t){let r={parse:(n,i)=>ewa({value:n,isKeyNumeric:e.getType()===dc.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>ewa({value:n,isKeyNumeric:e.getType()===dc.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>dc.RECORD};return{...QC(r),...Qd(r)}}function ewa({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!Bhe(e))return{ok:!1,errors:[{path:i,message:ed(e,"object")}]};let o={},s=[];for(let a in e){if(!jmf.call(e,a))continue;let u=e[a];if(u===void 0)continue;let c=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(c=d)}let l=r(c),p=n(u,c);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function rwa(e){let t=dEr(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:ed(n,"Set")}]},getType:()=>dc.SET};return{...QC(r),...Qd(r)}}function iwa(e){let t={parse:(r,n)=>nwa((i,o)=>i.parse(r,o),e,n),json:(r,n)=>nwa((i,o)=>i.json(r,o),e,n),getType:()=>dc.UNDISCRIMINATED_UNION};return{...QC(t),...Qd(t)}}function nwa(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function owa(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var Qmf=Object.prototype.hasOwnProperty;function awa(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=pEr(hDt(t)),o={parse:(s,a)=>swa({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:u=>i.parse(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.parse(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>swa({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:u=>i.json(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.json(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>dc.UNION};return{...QC(o),...Qd(o),...$q(o)}}function swa({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!Bhe(e))return{ok:!1,errors:[{path:a,message:ed(e,"object")}]};let u=e[t],c={};for(let f in e)Qmf.call(e,f)&&f!==t&&(c[f]=e[f]);if(u==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(u);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...c}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(c,p);return d.ok?{ok:!0,value:{[r]:u,...d.value}}:d}var mEr=be.string();var hEr=be.enum_(["openai","anthropic","bedrock"]);var gEr=be.object({provider:hEr,model:mEr});var rRi={};X(rRi,{AnyAuthItem:()=>AEr,AnyAuthSchemesSchema:()=>yEr,ApiAuthSchema:()=>HYe,AuthSchemeDeclarationSchema:()=>mwe,AuthSchemeReferenceSchema:()=>$Ye,AuthScope:()=>BEr,AuthVariable:()=>Cke,AvailabilitySchema:()=>NEr,AvailabilityStatusSchema:()=>JYe,AvailabilityUnionSchema:()=>kEr,BaseTypeReferenceSchema:()=>YEr,BasicAuthSchemeSchema:()=>EEr,BearerAuthSchemeSchema:()=>SEr,EncodingSchema:()=>UEr,EndpointSecuritySchema:()=>vEr,EndpointSecuritySchemaDetails:()=>bEr,EnvironmentSchema:()=>qEr,HeaderAuthSchemeSchema:()=>OEr,HttpHeaderSchema:()=>tIr,InferredAuthenticatedRequestHeader:()=>IEr,InferredBearerAuthSchema:()=>_Er,InferredGetTokenEndpointSchema:()=>CEr,InferredGetTokenEndpointSchemaObject:()=>wEr,ListValidationSchema:()=>WEr,MapValidationSchema:()=>$Er,MultipleBaseUrlsEnvironmentSchema:()=>zEr,NumberValidationSchema:()=>HEr,OAuthAccessTokenRequestPropertiesSchema:()=>PEr,OAuthAccessTokenResponsePropertiesSchema:()=>TEr,OAuthGetTokenEndpointSchema:()=>DEr,OAuthRefreshTokenEndpointSchema:()=>jEr,OAuthRefreshTokenRequestPropertiesSchema:()=>REr,OAuthRefreshTokenResponsePropertiesSchema:()=>FEr,OAuthSchemeSchema:()=>QEr,ProtobufTypeSchema:()=>LEr,ServerVariableSchema:()=>YYe,SingleBaseUrlEnvironmentSchema:()=>VEr,StringValidationSchema:()=>KEr,TokenBearerAuthSchema:()=>xEr,TypeReferenceDeclarationWithEnvOverride:()=>eIr,TypeReferenceDeclarationWithEnvOverrideSchema:()=>ZEr,TypeReferenceDeclarationWithName:()=>XEr,ValidationSchema:()=>JEr,WithAudiences:()=>hwe,WithAvailability:()=>MEr,WithDocsSchema:()=>Vy,WithEnvironmentVariable:()=>KYe,WithEnvironmentsSchema:()=>GEr,WithHeadersSchema:()=>rIr,WithName:()=>dwe,auth:()=>$Di,availability:()=>HDi,commons:()=>KDi,encoding:()=>JDi,environments:()=>YDi,file:()=>XDi,service:()=>ZDi,types:()=>eRi,validation:()=>tRi});var $Di={};X($Di,{AnyAuthItem:()=>AEr,AnyAuthSchemesSchema:()=>yEr,ApiAuthSchema:()=>HYe,AuthSchemeDeclarationSchema:()=>mwe,AuthSchemeReferenceSchema:()=>$Ye,AuthScope:()=>BEr,AuthVariable:()=>Cke,BasicAuthSchemeSchema:()=>EEr,BearerAuthSchemeSchema:()=>SEr,EndpointSecuritySchema:()=>vEr,EndpointSecuritySchemaDetails:()=>bEr,HeaderAuthSchemeSchema:()=>OEr,InferredAuthenticatedRequestHeader:()=>IEr,InferredBearerAuthSchema:()=>_Er,InferredGetTokenEndpointSchema:()=>CEr,InferredGetTokenEndpointSchemaObject:()=>wEr,OAuthAccessTokenRequestPropertiesSchema:()=>PEr,OAuthAccessTokenResponsePropertiesSchema:()=>TEr,OAuthGetTokenEndpointSchema:()=>DEr,OAuthRefreshTokenEndpointSchema:()=>jEr,OAuthRefreshTokenRequestPropertiesSchema:()=>REr,OAuthRefreshTokenResponsePropertiesSchema:()=>FEr,OAuthSchemeSchema:()=>QEr,TokenBearerAuthSchema:()=>xEr,WithEnvironmentVariable:()=>KYe});var Vy=be.object({docs:be.string().optional()});var $Ye=be.object({scheme:be.string()}).extend(Vy);var AEr=be.undiscriminatedUnion([be.string(),$Ye]);var yEr=be.object({any:be.list(AEr)}).extend(Vy);var bEr=be.object({});var vEr=be.object({"endpoint-security":bEr}).extend(Vy);var HYe=be.undiscriminatedUnion([be.string(),$Ye,yEr,vEr]);var dwe=be.object({name:be.string().optional()});var KYe=be.object({env:be.string().optional()});var Cke=be.object({omit:be.boolean().optional()}).extend(KYe).extend(dwe);var EEr=be.object({scheme:be.stringLiteral("basic"),username:Cke.optional(),password:Cke.optional()}).extend(Vy);var IEr=be.object({"response-property":be.string(),"header-name":be.string(),"value-prefix":be.string().optional()});var wEr=be.object({endpoint:be.string(),"expiry-response-property":be.string().optional(),"authenticated-request-headers":be.list(IEr).optional()});var CEr=be.undiscriminatedUnion([be.string(),wEr]);var _Er=be.object({scheme:be.stringLiteral("bearer"),"get-token":CEr}).extend(Vy);var xEr=be.object({scheme:be.stringLiteral("bearer"),token:Cke.optional()}).extend(Vy);var SEr=be.undiscriminatedUnion([xEr,_Er]);var OEr=be.object({header:be.string(),type:be.string().optional(),prefix:be.string().optional()}).extend(KYe).extend(dwe).extend(Vy);var BEr=be.string();var PEr=be.object({"client-id":be.string().optional(),"client-secret":be.string().optional(),scopes:be.string().optional()});var TEr=be.object({"access-token":be.string().optional(),"expires-in":be.string().optional(),"refresh-token":be.string().optional()});var DEr=be.object({endpoint:be.string(),"request-properties":PEr.optional(),"response-properties":TEr.optional()});var REr=be.object({"refresh-token":be.string()});var FEr=be.object({"access-token":be.string().optional(),"expires-in":be.string().optional(),"refresh-token":be.string().optional()});var jEr=be.object({endpoint:be.string(),"request-properties":REr.optional(),"response-properties":FEr.optional()});var QEr=be.object({scheme:be.stringLiteral("oauth"),type:be.stringLiteral("client-credentials"),scopes:be.list(BEr).optional(),"client-id-env":be.string().optional(),"client-secret-env":be.string().optional(),"token-prefix":be.string().optional(),"token-header":be.string().optional(),"get-token":DEr,"refresh-token":jEr.optional()}).extend(Vy);var mwe=be.undiscriminatedUnion([QEr,OEr,EEr,SEr]);var HDi={};X(HDi,{AvailabilitySchema:()=>NEr,AvailabilityStatusSchema:()=>JYe,AvailabilityUnionSchema:()=>kEr});var JYe=be.enum_(["in-development","pre-release","deprecated","generally-available"]);var NEr=be.object({status:JYe,message:be.string().optional()});var kEr=be.undiscriminatedUnion([JYe,NEr]);var KDi={};X(KDi,{WithAudiences:()=>hwe,WithAvailability:()=>MEr,WithDocsSchema:()=>Vy,WithName:()=>dwe});var hwe=be.object({audiences:be.list(be.string()).optional()});var MEr=be.object({availability:kEr.optional()});var JDi={};X(JDi,{EncodingSchema:()=>UEr,ProtobufTypeSchema:()=>LEr});var LEr=be.object({type:be.string()});var UEr=be.object({proto:LEr.optional()});var YDi={};X(YDi,{EnvironmentSchema:()=>qEr,MultipleBaseUrlsEnvironmentSchema:()=>zEr,ServerVariableSchema:()=>YYe,SingleBaseUrlEnvironmentSchema:()=>VEr,WithEnvironmentsSchema:()=>GEr});var YYe=be.object({id:be.string(),default:be.string().optional(),values:be.list(be.string()).optional()});var zEr=be.object({urls:be.record(be.string(),be.string()),"url-templates":be.record(be.string(),be.string()).optional(),"default-urls":be.record(be.string(),be.string()).optional(),variables:be.record(be.string(),be.list(YYe)).optional()}).extend(hwe).extend(Vy);var VEr=be.object({url:be.string(),"default-url":be.string().optional(),"url-template":be.string().optional(),variables:be.list(YYe).optional()}).extend(hwe).extend(Vy);var qEr=be.undiscriminatedUnion([be.string(),VEr,zEr]);var GEr=be.object({"default-url":be.string().optional(),"default-environment":be.string().optional(),environments:be.record(be.string(),qEr).optional()});var XDi={};X(XDi,{WithHeadersSchema:()=>rIr});var WEr=be.object({minItems:be.number().optional(),maxItems:be.number().optional()});var $Er=be.object({minProperties:be.number().optional(),maxProperties:be.number().optional()});var HEr=be.object({min:be.number().optional(),max:be.number().optional(),exclusiveMin:be.boolean().optional(),exclusiveMax:be.boolean().optional(),multipleOf:be.number().optional()});var KEr=be.object({minLength:be.number().optional(),maxLength:be.number().optional(),pattern:be.string().optional(),format:be.string().optional()});var JEr=be.undiscriminatedUnion([KEr,HEr,WEr,$Er]);var YEr=be.object({default:be.unknown().optional(),encoding:UEr.optional(),validation:JEr.optional()}).extend(Vy).extend(MEr);var XEr=be.object({type:be.string()}).extend(YEr).extend(dwe).extend(hwe);var ZEr=be.object({env:be.string().optional()}).extend(XEr);var eIr=be.undiscriminatedUnion([be.string(),ZEr]);var tIr=eIr;var rIr=be.object({headers:be.record(be.string(),tIr).optional()});var ZDi={};X(ZDi,{HttpHeaderSchema:()=>tIr,TypeReferenceDeclarationWithEnvOverride:()=>eIr,TypeReferenceDeclarationWithEnvOverrideSchema:()=>ZEr});var eRi={};X(eRi,{BaseTypeReferenceSchema:()=>YEr,TypeReferenceDeclarationWithName:()=>XEr});var tRi={};X(tRi,{ListValidationSchema:()=>WEr,MapValidationSchema:()=>$Er,NumberValidationSchema:()=>HEr,StringValidationSchema:()=>KEr,ValidationSchema:()=>JEr});var nRi={};X(nRi,{ApiConfigurationSchema:()=>EIr,ApiConfigurationSchemaInternal:()=>oXe,ApiConfigurationV2Schema:()=>bIr,ApiConfigurationV2SettingsSchema:()=>uXe,ApiConfigurationV2SpecsSchema:()=>cXe,ApiDefinitionList:()=>oIr,ApiDefinitionPathSchema:()=>gwe,ApiDefinitionSchema:()=>iIr,ApiDefinitionSettingsSchema:()=>tXe,ApiDefinitionWithOverridesSchema:()=>rXe,AsyncApiSettingsSchema:()=>aXe,AsyncApiSpecSchema:()=>dIr,BaseApiSettingsSchema:()=>sXe,ConjureSchema:()=>fIr,DefaultIntegerFormat:()=>sIr,ExampleStyle:()=>IIr,FormParameterEncoding:()=>aIr,GeneratorsConfigurationSchema:()=>uwa,GeneratorsOpenApiObjectSchema:()=>KIr,GeneratorsOpenApiSchema:()=>JIr,GraphQlSpecSchema:()=>mIr,Language:()=>YIr,MessageNamingSettingsSchema:()=>XYe,NamespacedApiConfigurationSchema:()=>vIr,OpenApiExampleGenerationSchema:()=>uIr,OpenApiFilterSchema:()=>cIr,OpenApiSettingsSchema:()=>Awe,OpenApiSpecSchema:()=>hIr,OpenRpcSpecSchema:()=>gIr,OutputMetadataAuthor:()=>wIr,OutputMetadataSchema:()=>ywe,OverridesSchema:()=>FL,PathParameterOrder:()=>ZYe,ProtobufApiDefinitionSchema:()=>iXe,ProtobufDefinitionSchema:()=>nXe,ProtobufSpecSchema:()=>AIr,ReadmeCustomSectionSchema:()=>XIr,ReadmeEndpointObjectSchema:()=>ZIr,ReadmeEndpointSchema:()=>bDt,ReadmeSchema:()=>ewr,RemoveDiscriminantsFromSchemas:()=>eXe,RequestOrResponseExampleGenerationSchema:()=>gDt,ResolveAliases:()=>pIr,ResolveAliasesSchema:()=>lIr,SpecSchema:()=>yIr,UnionSettingsSchema:()=>nIr,WhitelabelConfigurationSchema:()=>rwr,WhitelabelGithubConfigurationSchema:()=>twr});var gwe=be.string();var XYe=be.enum_(["v1","v2"]);var ZYe=be.enum_(["url-order","spec-order"]);var eXe=be.enum_(["always","never"]);var nIr=be.enum_(["v1"]);var tXe=be.object({"use-title":be.boolean().optional(),unions:nIr.optional(),"message-naming":XYe.optional(),"respect-nullable-schemas":be.boolean().optional(),"only-include-referenced-schemas":be.boolean().optional(),"inline-path-parameters":be.boolean().optional(),"idiomatic-request-names":be.boolean().optional(),"wrap-references-to-nullable-in-optional":be.boolean().optional(),"coerce-optional-schemas-to-nullable":be.boolean().optional(),"group-environments-by-host":be.boolean().optional(),"remove-discriminants-from-schemas":eXe.optional(),"path-parameter-order":ZYe.optional()});var FL=be.undiscriminatedUnion([be.string(),be.list(be.string())]);var rXe=be.object({path:gwe,origin:be.string().optional(),overrides:FL.optional(),audiences:be.list(be.string()).optional(),settings:tXe.optional()});var nXe=be.object({target:be.string().optional(),root:be.string(),overrides:FL.optional(),"local-generation":be.boolean().optional(),"from-openapi":be.boolean().optional(),dependencies:be.list(be.string()).optional()});var iXe=be.object({proto:nXe});var iIr=be.undiscriminatedUnion([gwe,rXe,iXe]);var oIr=be.list(iIr);var oXe=be.undiscriminatedUnion([gwe,rXe,oIr,iXe]);var sXe=be.object({"respect-nullable-schemas":be.boolean().optional(),"title-as-schema-name":be.boolean().optional(),"optional-additional-properties":be.boolean().optional(),"coerce-enums-to-literals":be.boolean().optional(),"idiomatic-request-names":be.boolean().optional(),"wrap-references-to-nullable-in-optional":be.boolean().optional(),"coerce-optional-schemas-to-nullable":be.boolean().optional(),"group-environments-by-host":be.boolean().optional(),"remove-discriminants-from-schemas":eXe.optional(),"path-parameter-order":ZYe.optional(),"resolve-schema-collisions":be.boolean().optional()});var aXe=be.object({"message-naming":XYe.optional()}).extend(sXe);var sIr=be.enum_(["int32","int64","uint32","uint64"]);var aIr=be.enum_(["form","json"]);var gDt=be.object({"max-depth":be.number().optional()});var uIr=be.object({request:gDt.optional(),response:gDt.optional()});var cIr=be.object({endpoints:be.list(be.string()).optional()});var lIr=be.object({except:be.list(be.string()).optional()});var pIr=be.undiscriminatedUnion([be.boolean(),lIr]);var Awe=be.object({"only-include-referenced-schemas":be.boolean().optional(),"inline-path-parameters":be.boolean().optional(),"prefer-undiscriminated-unions-with-literals":be.boolean().optional(),"object-query-parameters":be.boolean().optional(),"respect-readonly-schemas":be.boolean().optional(),"respect-forward-compatible-enums":be.boolean().optional(),"use-bytes-for-binary-response":be.boolean().optional(),"default-form-parameter-encoding":aIr.optional(),filter:cIr.optional(),"example-generation":uIr.optional(),"additional-properties-defaults-to":be.boolean().optional(),"type-dates-as-strings":be.boolean().optional(),"preserve-single-schema-oneof":be.boolean().optional(),"inline-all-of-schemas":be.boolean().optional(),"resolve-aliases":pIr.optional(),"group-multi-api-environments":be.boolean().optional(),"default-integer-format":sIr.optional()}).extend(sXe);var uXe=be.object({}).extend(Awe).extend(aXe);var fIr=be.object({conjure:be.string()});var dIr=be.object({asyncapi:be.string(),origin:be.string().optional(),overrides:FL.optional(),namespace:be.string().optional(),settings:aXe.optional()});var mIr=be.object({graphql:be.string(),origin:be.string().optional(),overrides:be.string().optional(),name:be.string().optional()});var hIr=be.object({openapi:be.string(),origin:be.string().optional(),overrides:FL.optional(),overlays:be.string().optional(),namespace:be.string().optional(),settings:Awe.optional()});var gIr=be.object({openrpc:be.string(),overrides:FL.optional(),namespace:be.string().optional()});var AIr=be.object({proto:nXe});var yIr=be.undiscriminatedUnion([hIr,dIr,AIr,gIr,mIr]);var cXe=be.undiscriminatedUnion([be.list(yIr),fIr]);var bIr=be.object({auth:HYe.optional(),"auth-schemes":be.record(be.string(),mwe).optional(),specs:cXe,settings:uXe.optional()}).extend(rIr).extend(GEr);var vIr=be.object({namespaces:be.record(be.string(),oXe)});var EIr=be.undiscriminatedUnion([oXe,vIr,bIr]);var IIr=be.enum_(["minimal","comprehensive"]);var wIr=be.object({name:be.string(),email:be.string()});var ywe=be.object({description:be.string().optional(),authors:be.list(wIr).optional()});var ADt=be.object({name:be.string()});var bwe=be.object({teams:be.list(ADt).optional(),users:be.list(ADt).optional()});var CIr=be.object({auth:HYe.optional(),"auth-schemes":be.record(be.string(),mwe).optional(),settings:uXe.optional(),specs:cXe.optional()});var _Ir=be.object({url:be.string().optional(),"package-name":be.string(),token:be.string().optional()});var xIr=be.object({path:be.string()});var SIr=be.object({keyId:be.string(),password:be.string(),secretKey:be.string()});var OIr=be.object({url:be.string().optional(),coordinate:be.string(),username:be.string().optional(),password:be.string().optional(),signature:SIr.optional()});var BIr=be.object({url:be.string().optional(),"package-name":be.string(),token:be.string().optional()});var PIr=be.object({url:be.string().optional(),"package-name":be.string(),"api-key":be.string().optional()});var TIr=be.object({"api-key":be.string(),"workspace-id":be.string(),"collection-id":be.string().optional()});var DIr=be.object({keywords:be.list(be.string()).optional(),"documentation-link":be.string().optional(),"homepage-link":be.string().optional()}).extend(ywe);var RIr=be.object({url:be.string().optional(),"package-name":be.string(),token:be.string().optional(),username:be.string().optional(),password:be.string().optional(),metadata:DIr.optional()});var FIr=be.object({url:be.string().optional(),"package-name":be.string(),"api-key":be.string().optional()});var jIr=be.union("location",{npm:BIr,maven:OIr,pypi:RIr,postman:TIr,"local-file-system":xIr,nuget:PIr,rubygems:FIr,crates:_Ir}).transform({transform:e=>e,untransform:e=>e});var QIr=be.object({custom:be.string()});var NIr=be.enum_(["MIT","Apache-2.0"]);var jL=be.undiscriminatedUnion([NIr,QIr]);var yDt=be.object({"package-description":be.string().optional(),email:be.string().optional(),"reference-url":be.string().optional(),author:be.string().optional(),license:jL.optional()});var kIr=be.object({path:be.string()});var MIr=be.enum_(["commit","release"]);var LIr=be.object({repository:be.string(),license:jL.optional(),mode:MIr.optional()});var UIr=be.object({repository:be.string(),branch:be.string().optional(),license:jL.optional(),mode:be.stringLiteral("pull-request"),reviewers:bwe.optional()});var zIr=be.object({repository:be.string(),license:jL.optional(),mode:be.stringLiteral("push"),branch:be.string().optional()});var VIr=be.enum_(["pull-request","push"]);var qIr=be.object({uri:be.string(),token:be.string(),mode:VIr.optional(),branch:be.string().optional(),license:jL.optional()});var GIr=be.undiscriminatedUnion([qIr,LIr,UIr,zIr]);var WIr=be.object({name:be.string(),version:be.string(),output:jIr.optional(),github:GIr.optional(),config:be.unknown().optional(),metadata:yDt.optional(),keywords:be.list(be.string()).optional(),snippets:kIr.optional(),"ir-version":be.string().optional(),"smart-casing":be.boolean().optional(),api:CIr.optional(),"disable-examples":be.boolean().optional(),"publish-metadata":yDt.optional(),autorelease:be.boolean().optional()});var $Ir=be.object({audiences:be.list(be.string()).optional(),generators:be.list(WIr),metadata:ywe.optional(),reviewers:bwe.optional()});var HIr=be.object({enabled:be.boolean()});var KIr=be.object({path:be.string(),origin:be.string().optional(),overrides:be.string().optional(),"disable-examples":be.boolean().optional(),settings:Awe});var JIr=be.undiscriminatedUnion([KIr,be.string()]);var YIr=be.enum_(["java","python","go","ruby","csharp","typescript","php","rust","swift"]);var XIr=be.object({title:be.string(),language:YIr,content:be.string()});var ZIr=be.object({method:be.string(),path:be.string(),stream:be.boolean().optional()});var bDt=be.undiscriminatedUnion([be.string(),ZIr]);var ewr=be.object({bannerLink:be.string().optional(),introduction:be.string().optional(),apiReferenceLink:be.string().optional(),apiName:be.string().optional(),disabledSections:be.list(be.string()).optional(),defaultEndpoint:bDt.optional(),features:be.record(be.string(),be.list(bDt)).optional(),customSections:be.list(XIr).optional(),exampleStyle:IIr.optional()});var twr=be.object({username:be.string(),email:be.string(),token:be.string()});var rwr=be.object({github:twr.optional()});var uwa=be.object({"auth-schemes":be.record(be.string(),mwe).optional(),api:EIr.optional(),whitelabel:rwr.optional(),metadata:ywe.optional(),readme:ewr.optional(),"default-group":be.string().optional(),aliases:be.record(be.string(),be.list(be.string())).optional(),groups:be.record(be.string(),$Ir).optional(),reviewers:bwe.optional(),replay:HIr.optional(),ai:gEr.optional(),autorelease:be.boolean().optional(),openapi:JIr.optional(),"openapi-overrides":be.string().optional(),"spec-origin":be.string().optional(),"async-api":be.string().optional(),"api-settings":tXe.optional()});var iRi={};X(iRi,{CratesOutputLocationSchema:()=>_Ir,GeneratorApiSettingsSchema:()=>CIr,GeneratorGroupSchema:()=>$Ir,GeneratorInvocationSchema:()=>WIr,GeneratorOutputSchema:()=>jIr,GeneratorPublishMetadataSchema:()=>yDt,GeneratorSnippetsSchema:()=>kIr,GithubCommitAndReleaseMode:()=>MIr,GithubCommitAndReleaseSchema:()=>LIr,GithubConfigurationSchema:()=>GIr,GithubPullRequestSchema:()=>UIr,GithubPushSchema:()=>zIr,GithubSelfhostedMode:()=>VIr,GithubSelfhostedSchema:()=>qIr,LocalFileSystemOutputLocationSchema:()=>xIr,MavenOutputLocationSchema:()=>OIr,MavenOutputSignatureSchema:()=>SIr,NpmOutputLocationSchema:()=>BIr,NugetOutputLocationSchema:()=>PIr,PostmanOutputLocationSchema:()=>TIr,PypiOutputLocationSchema:()=>RIr,PypiOutputMetadataSchema:()=>DIr,RubyGemsOutputLocationSchema:()=>FIr});var oRi={};X(oRi,{GithubLicenseCustomSchema:()=>QIr,GithubLicenseSchema:()=>jL,GithubLicenseType:()=>NIr});var sRi={};X(sRi,{ReplayConfigSchema:()=>HIr});var aRi={};X(aRi,{ReviewerSchema:()=>ADt,ReviewersSchema:()=>bwe});function cwa(e){return e?.specs!=null}function lwa(e){return e?.asyncapi!=null}function pwa(e){return e?.conjure!=null}function fwa(e){return e?.graphql!=null}function dwa(e){return e?.namespaces!=null}function mwa(e){return e?.openapi!=null}function hwa(e){return e?.openrpc!=null}function gwa(e){return e?.proto!=null}var Nmf={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:yn.RemoveDiscriminantsFromSchemas.Always};function kmf(e){let{defaults:t,options:r,overrides:n,overrideOnly:i=new Set,undefinedIfAbsent:o=new Set}=e,s={};for(let a of Object.keys(t))i.has(a)?s[a]=n?.[a]!==void 0?n[a]:t[a]:o.has(a)?s[a]=n?.[a]!==void 0?n[a]:r?.[a]!==void 0?r[a]:void 0:s[a]=n?.[a]??r?.[a]??t[a];return s}function _ke({options:e,overrides:t}){return kmf({defaults:Nmf,options:e,overrides:t})}gg();gg();Nt();var lXe={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return lXe._visit(this,t)}}),_visit:(e,t)=>e.type==="protobuf"?t.protobuf(e):t._other(e)};var kC={basic:e=>({...e,type:"basic",_visit:function(t){return kC._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return kC._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return kC._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return kC._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return kC._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 aO={openapi:e=>({...e,type:"openapi",_visit:function(t){return aO._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return aO._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 nu={primitive:e=>({value:e,type:"primitive",_visit:function(t){return nu._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return nu._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return nu._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return nu._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return nu._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return nu._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return nu._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return nu._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return nu._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 vwe={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return vwe._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return vwe._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 Ewe={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Ewe._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Ewe._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 ms={int:e=>({value:e,type:"int",_visit:function(t){return ms._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return ms._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return ms._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return ms._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return ms._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return ms._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return ms._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return ms._visit(this,t)}}),datetimeRfc2822:e=>({value:e,type:"datetimeRfc2822",_visit:function(t){return ms._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return ms._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return ms._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return ms._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"datetimeRfc2822":return t.datetimeRfc2822(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 xg={};X(xg,{AsymmetricAlgorithm:()=>Iwe,Availability:()=>MC,CustomCodeSample:()=>JJ,DiscriminatorContext:()=>cRi,EndpointExample:()=>QL,EndpointResponseExample:()=>NL,HttpMethod:()=>LC,LiteralSchemaValue:()=>nA,MultipartRequestPropertyEncoding:()=>lRi,MultipartSchema:()=>YJ,OneOfSchema:()=>XJ,Pagination:()=>lw,PrimitiveSchemaValue:()=>Wc,Request:()=>Hq,Response:()=>_S,RetriesConfiguration:()=>vDt,Schema:()=>ya,SupportedSdkLanguage:()=>UC,WebhookHttpMethod:()=>pRi,WebhookPayloadComponent:()=>EDt,WebhookSignatureAlgorithm:()=>IDt,WebhookSignatureEncoding:()=>fRi,WebhookSignatureVerification:()=>xke,WebhookTimestampFormat:()=>nwr,WebsocketMessageOrigin:()=>dRi});var Mmf={RsaSha256:"rsa-sha256",RsaSha384:"rsa-sha384",RsaSha512:"rsa-sha512",EcdsaSha256:"ecdsa-sha256",EcdsaSha384:"ecdsa-sha384",EcdsaSha512:"ecdsa-sha512",Ed25519:"ed25519"},Iwe={...Mmf,_visit:(e,t)=>{switch(e){case Iwe.RsaSha256:return t.rsaSha256();case Iwe.RsaSha384:return t.rsaSha384();case Iwe.RsaSha512:return t.rsaSha512();case Iwe.EcdsaSha256:return t.ecdsaSha256();case Iwe.EcdsaSha384:return t.ecdsaSha384();case Iwe.EcdsaSha512:return t.ecdsaSha512();case Iwe.Ed25519:return t.ed25519();default:return t._other()}}};var Lmf={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated"},MC={...Lmf,_visit:(e,t)=>{switch(e){case MC.GenerallyAvailable:return t.generallyAvailable();case MC.Beta:return t.beta();case MC.Deprecated:return t.deprecated();default:return t._other()}}};var JJ={language:e=>({...e,type:"language",_visit:function(t){return JJ._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return JJ._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 Umf={Data:"data",Protocol:"protocol"},cRi={...Umf,_visit:(e,t)=>{switch(e){case cRi.Data:return t.data();case cRi.Protocol:return t.protocol();default:return t._other()}}};var QL={unknown:e=>({value:e,type:"unknown",_visit:function(t){return QL._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return QL._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 NL={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return NL._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return NL._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 zmf={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE"},LC={...zmf,_visit:(e,t)=>{switch(e){case LC.Get:return t.get();case LC.Post:return t.post();case LC.Put:return t.put();case LC.Patch:return t.patch();case LC.Delete:return t.delete();case LC.Head:return t.head();case LC.Options:return t.options();case LC.Trace:return t.trace();default:return t._other()}}};var nA={boolean:e=>({value:e,type:"boolean",_visit:function(t){return nA._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return nA._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 Vmf={Json:"json",Form:"form"},lRi={...Vmf,_visit:(e,t)=>{switch(e){case lRi.Json:return t.json();case lRi.Form:return t.form();default:return t._other()}}};var YJ={file:e=>({...e,type:"file",_visit:function(t){return YJ._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return YJ._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 XJ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return XJ._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return XJ._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 lw={cursor:e=>({...e,type:"cursor",_visit:function(t){return lw._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return lw._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return lw._visit(this,t)}}),uri:e=>({...e,type:"uri",_visit:function(t){return lw._visit(this,t)}}),path:e=>({...e,type:"path",_visit:function(t){return lw._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);case"uri":return t.uri(e);case"path":return t.path(e);default:return t._other(e)}}};var Wc={int:e=>({...e,type:"int",_visit:function(t){return Wc._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Wc._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Wc._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Wc._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Wc._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Wc._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Wc._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Wc._visit(this,e)}}),datetimeRfc2822:()=>({type:"datetimeRfc2822",_visit:function(e){return Wc._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Wc._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Wc._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Wc._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"datetimeRfc2822":return t.datetimeRfc2822();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var Hq={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Hq._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Hq._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Hq._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return Hq._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 _S={file:e=>({...e,type:"file",_visit:function(t){return _S._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return _S._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return _S._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return _S._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return _S._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return _S._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return _S._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 vDt={disabled:e=>({value:e,type:"disabled",_visit:function(t){return vDt._visit(this,t)}}),_visit:(e,t)=>e.type==="disabled"?t.disabled(e.value):t._other(e)};var ya={primitive:e=>({...e,type:"primitive",_visit:function(t){return ya._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ya._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ya._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ya._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ya._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ya._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ya._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ya._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ya._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ya._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ya._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 qmf={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"},UC={...qmf,_visit:(e,t)=>{switch(e){case UC.Curl:return t.curl();case UC.Python:return t.python();case UC.Javascript:return t.javascript();case UC.Typescript:return t.typescript();case UC.Go:return t.go();case UC.Ruby:return t.ruby();case UC.Csharp:return t.csharp();case UC.Java:return t.java();case UC.Js:return t.js();case UC.Node:return t.node();case UC.Ts:return t.ts();case UC.Nodets:return t.nodets();case UC.Golang:return t.golang();case UC.Dotnet:return t.dotnet();case UC.Jvm:return t.jvm();default:return t._other()}}};var Gmf={Get:"GET",Post:"POST"},pRi={...Gmf,_visit:(e,t)=>{switch(e){case pRi.Get:return t.get();case pRi.Post:return t.post();default:return t._other()}}};var Wmf={Body:"body",Timestamp:"timestamp",NotificationUrl:"notification-url",MessageId:"message-id"},EDt={...Wmf,_visit:(e,t)=>{switch(e){case EDt.Body:return t.body();case EDt.Timestamp:return t.timestamp();case EDt.NotificationUrl:return t.notificationUrl();case EDt.MessageId:return t.messageId();default:return t._other()}}};var $mf={Sha256:"sha256",Sha1:"sha1",Sha384:"sha384",Sha512:"sha512"},IDt={...$mf,_visit:(e,t)=>{switch(e){case IDt.Sha256:return t.sha256();case IDt.Sha1:return t.sha1();case IDt.Sha384:return t.sha384();case IDt.Sha512:return t.sha512();default:return t._other()}}};var Hmf={Base64:"base64",Hex:"hex"},fRi={...Hmf,_visit:(e,t)=>{switch(e){case fRi.Base64:return t.base64();case fRi.Hex:return t.hex();default:return t._other()}}};var xke={hmac:e=>({...e,type:"hmac",_visit:function(t){return xke._visit(this,t)}}),asymmetric:e=>({...e,type:"asymmetric",_visit:function(t){return xke._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"hmac":return t.hmac(e);case"asymmetric":return t.asymmetric(e);default:return t._other(e)}}};var Kmf={UnixSeconds:"unix-seconds",UnixMillis:"unix-millis",Iso8601:"iso8601"},nwr={...Kmf,_visit:(e,t)=>{switch(e){case nwr.UnixSeconds:return t.unixSeconds();case nwr.UnixMillis:return t.unixMillis();case nwr.Iso8601:return t.iso8601();default:return t._other()}}};var Jmf={Client:"client",Server:"server"},dRi={...Jmf,_visit:(e,t)=>{switch(e){case dRi.Client:return t.client();case dRi.Server:return t.server();default:return t._other()}}};var p2={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return p2._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return p2._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 Si={int:e=>({...e,type:"int",_visit:function(t){return Si._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Si._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Si._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Si._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Si._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Si._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Si._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Si._visit(this,t)}}),datetimeRfc2822:e=>({...e,type:"datetimeRfc2822",_visit:function(t){return Si._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Si._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Si._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Si._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"datetimeRfc2822":return t.datetimeRfc2822(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 WP={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return WP._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return WP._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return WP._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return WP._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 Yh={file:e=>({...e,type:"file",_visit:function(t){return Yh._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Yh._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Yh._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return Yh._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Yh._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Yh._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Yh._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 jr={primitive:e=>({...e,type:"primitive",_visit:function(t){return jr._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return jr._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return jr._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return jr._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return jr._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return jr._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return jr._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return jr._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return jr._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return jr._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return jr._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 ba={};X(ba,{AllOfPropertyConflict:()=>AXe,ArraySchema:()=>Twr,ArraySchemaWithExample:()=>MCr,AsymmetricAlgorithm:()=>Dwr,AsymmetricWebhookSignatureVerification:()=>Fwr,Availability:()=>hwr,Base64WithExample:()=>LCr,BasicSecurityScheme:()=>uwr,BearerSecurityScheme:()=>cwr,BooleanSchema:()=>jwr,BooleanWithExample:()=>UCr,BytesResponse:()=>vXe,CasingOverrides:()=>vwr,CommonProperty:()=>Qwr,CommonPropertyWithExample:()=>zCr,CursorPagination:()=>Nwr,CustomCodeSample:()=>Uwr,CustomCodeSampleLanguage:()=>kwr,CustomCodeSampleSdk:()=>Lwr,CustomPagination:()=>zwr,DateWithExample:()=>VCr,DatetimeWithExample:()=>xDt,DiscriminatedOneOfSchema:()=>Vwr,DiscriminatedOneOfSchemaWithExample:()=>qCr,DiscriminatorContext:()=>EXe,DoubleSchema:()=>qwr,DoubleWithExample:()=>GCr,Encoding:()=>pwr,Endpoint:()=>aCr,EndpointExample:()=>CXe,EndpointResponseExample:()=>$wr,EndpointSdkName:()=>tY,EndpointSecurity:()=>_Xe,EndpointWithExample:()=>Gwa,EnumSchema:()=>mXe,EnumSchemaWithExample:()=>ZCr,EnumValue:()=>Cwe,ErrorExample:()=>Jwr,FernExample:()=>Gwr,FileResponse:()=>RXe,FileSchema:()=>iCr,FloatWithExample:()=>e_r,FormUrlEncodedRequest:()=>tCr,FullEndpointExample:()=>Kwr,FullExample:()=>Fm,FullObjectExample:()=>Owr,FullOneOfExample:()=>Bwr,GlobalHeader:()=>uCr,GlobalSecurity:()=>cCr,Header:()=>xwe,HeaderExample:()=>IXe,HeaderSecurityScheme:()=>fwr,HeaderWithExample:()=>Pwe,HmacWebhookSignatureVerification:()=>dCr,HttpEndpointServer:()=>xXe,HttpError:()=>Ywr,HttpErrorWithExample:()=>WCr,HttpMethod:()=>SXe,IdempotencyHeader:()=>mCr,Int64WithExample:()=>t_r,IntSchema:()=>hCr,IntWithExample:()=>r_r,JsonRequest:()=>rCr,JsonRequestWithExample:()=>HCr,JsonResponse:()=>FXe,JsonResponseWithExample:()=>VXe,KeyValuePair:()=>Pwr,LiteralExample:()=>xwr,LiteralSchema:()=>NXe,LiteralSchemaValue:()=>gCr,LongSchema:()=>ACr,MapSchema:()=>vCr,MapSchemaWithExample:()=>a_r,MultipartFormDataWebhookPayload:()=>ECr,MultipartFormDataWebhookPayloadWithExample:()=>u_r,MultipartRequest:()=>TXe,MultipartRequestProperty:()=>Swe,MultipartRequestPropertyEncoding:()=>nCr,MultipartSchema:()=>oCr,NamedFullExample:()=>FF,Namespace:()=>dwr,NamespaceId:()=>mwr,NullExample:()=>Swr,NullableSchema:()=>ICr,NullableSchemaWithExample:()=>c_r,OauthSecurityScheme:()=>Ewr,ObjectProperty:()=>wCr,ObjectPropertyConflictInfo:()=>kXe,ObjectPropertyWithExample:()=>l_r,ObjectSchema:()=>CCr,ObjectSchemaWithExample:()=>p_r,OctetStreamRequest:()=>DXe,OffsetPagination:()=>Xwr,OneOfSchema:()=>_Cr,OneOfSchemaWithExample:()=>f_r,OpenApiIntermediateRepresentation:()=>qwa,OpenApiSource:()=>Awr,OptionalSchema:()=>kCr,OptionalSchemaWithExample:()=>m_r,Pagination:()=>OXe,ParseFormUrlEncodedRequest:()=>KCr,ParseMultipartRequest:()=>JCr,ParseOctetStreamRequest:()=>YCr,PathPagination:()=>Zwr,PathParameter:()=>BXe,PathParameterExample:()=>Hwr,PathParameterWithExample:()=>$Cr,PrimitiveExample:()=>hXe,PrimitiveSchema:()=>Bwe,PrimitiveSchemaValue:()=>bCr,PrimitiveSchemaValueWithExample:()=>s_r,PrimitiveSchemaWithExample:()=>GXe,PropertyKey:()=>gXe,ProtobufEncoding:()=>lwr,ProtobufSource:()=>ywr,QueryParameter:()=>PXe,QueryParameterExample:()=>wXe,QueryParameterWithExample:()=>zXe,QuerySecurityScheme:()=>Iwr,ReferencedSchema:()=>rY,Request:()=>sCr,RequestWithExample:()=>XCr,Response:()=>jXe,ResponseWithExample:()=>qXe,RetriesConfiguration:()=>QXe,Schema:()=>Nc,SchemaId:()=>$P,SchemaWithExample:()=>Df,Schemas:()=>SCr,SdkGroup:()=>gwr,SdkGroupInfo:()=>OCr,SdkGroupName:()=>wwe,SecurityScheme:()=>wwr,SecuritySchemeId:()=>_we,Server:()=>_Dt,ServerVariable:()=>Cwr,Source:()=>bwr,StatusCode:()=>ZJ,StreamingResponseExample:()=>Wwr,StringSchema:()=>yCr,StringSchemaWithExample:()=>n_r,SupportedSdkLanguage:()=>Mwr,Tag:()=>_wr,TagId:()=>HP,Tags:()=>BCr,TextResponse:()=>Owe,Uint64WithExample:()=>i_r,UintWithExample:()=>o_r,UnDiscriminatedOneOfSchema:()=>xCr,UnDiscriminatedOneOfSchemaWithExample:()=>d_r,UnknownSchemaWithExample:()=>h_r,UriPagination:()=>eCr,Webhook:()=>PCr,WebhookExampleCall:()=>MXe,WebhookHttpMethod:()=>LXe,WebhookPayloadComponent:()=>lCr,WebhookPayloadFormat:()=>pCr,WebhookSignatureAlgorithm:()=>fCr,WebhookSignatureEncoding:()=>yXe,WebhookSignatureVerification:()=>UXe,WebhookTimestamp:()=>bXe,WebhookTimestampFormat:()=>Rwr,WebhookWithExample:()=>Wwa,WebsocketChannel:()=>NCr,WebsocketHandshake:()=>TCr,WebsocketHandshakeWithExample:()=>$wa,WebsocketMessageExample:()=>jCr,WebsocketMessageOrigin:()=>DCr,WebsocketMessageSchema:()=>RCr,WebsocketServer:()=>FCr,WebsocketSessionExample:()=>QCr,WithAvailability:()=>hs,WithDescription:()=>gn,WithEncoding:()=>RF,WithInline:()=>Tf,WithName:()=>Bu,WithNamespace:()=>su,WithSdkGroupName:()=>$c,WithSdkMethodName:()=>eY,WithSource:()=>Wo,WithStatusCode:()=>kL,WithTitle:()=>Hc,commons:()=>bRi,example:()=>vRi,finalIr:()=>ERi,parseIr:()=>IRi});var bRi={};X(bRi,{BasicSecurityScheme:()=>uwr,BearerSecurityScheme:()=>cwr,Encoding:()=>pwr,HeaderSecurityScheme:()=>fwr,Namespace:()=>dwr,NamespaceId:()=>mwr,OauthSecurityScheme:()=>Ewr,OpenApiSource:()=>Awr,ProtobufEncoding:()=>lwr,ProtobufSource:()=>ywr,QuerySecurityScheme:()=>Iwr,SchemaId:()=>$P,SdkGroup:()=>gwr,SdkGroupName:()=>wwe,SecurityScheme:()=>wwr,SecuritySchemeId:()=>_we,Server:()=>_Dt,ServerVariable:()=>Cwr,Source:()=>bwr,StatusCode:()=>ZJ,Tag:()=>_wr,TagId:()=>HP,WithAvailability:()=>hs,WithDescription:()=>gn,WithEncoding:()=>RF,WithInline:()=>Tf,WithName:()=>Bu,WithNamespace:()=>su,WithSdkGroupName:()=>$c,WithSdkMethodName:()=>eY,WithSource:()=>Wo,WithStatusCode:()=>kL,WithTitle:()=>Hc});var G={};X(G,{JsonError:()=>pXe,ParseError:()=>fXe,any:()=>Pwa,bigint:()=>ywa,boolean:()=>Twa,booleanLiteral:()=>Owa,date:()=>bwa,discriminant:()=>Uwa,enum_:()=>owr,getObjectLikeUtils:()=>Kq,getObjectUtils:()=>Ske,getSchemaUtils:()=>Nd,isProperty:()=>Dhe,lazy:()=>vwa,lazyObject:()=>xwa,list:()=>awr,never:()=>Dwa,number:()=>Rwa,object:()=>swr,objectWithoutOptionalProperties:()=>_wa,optional:()=>mRi,property:()=>Iwa,record:()=>Nwa,set:()=>kwa,string:()=>Fwa,stringLiteral:()=>Bwa,transform:()=>hRi,undiscriminatedUnion:()=>Lwa,union:()=>Vwa,unknown:()=>jwa,withParsedProperties:()=>yRi});var mc={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",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function td(e,t){return`Expected ${t}. Received ${Ymf(e)}.`}function Ymf(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 zC(e){return{...e,json:Awa(e.json),parse:Awa(e.parse)}}function Awa(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(o=>" - "+(o.path.length>0?`${o.path.join(".")}: ${o.message}`:o.message))].join(`
|
|
1676
|
-
`)),{ok:!0,value:t}):n}}function iwr(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var pXe=class e extends Error{errors;constructor(t){super(t.map(iwr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var fXe=class e extends Error{errors;constructor(t){super(t.map(iwr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Nd(e){return{nullable:()=>Xmf(e),optional:()=>mRi(e),optionalNullable:()=>Zmf(e),transform:t=>hRi(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new fXe(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new pXe(n.errors)}}}function Xmf(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>mc.NULLABLE};return{...t,...Nd(t)}}function mRi(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>mc.OPTIONAL};return{...t,...Nd(t)}}function Zmf(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>mc.OPTIONAL_NULLABLE};return{...t,...Nd(t)}}function hRi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...Nd(r)}}function ywa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:td(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:td(t,"bigint")}]}:{ok:!0,value:t},getType:()=>mc.BIGINT};return{...zC(e),...Nd(e)}}var ehf=/^([+-]?\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 bwa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:td(t,"string")}]}:ehf.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:td(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:td(t,"Date object")}]},getType:()=>mc.DATE};return{...zC(e),...Nd(e)}}function VC(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...zC(r),...Nd(r)}}}function owr(e){let t=new Set(e);return VC(mc.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:td(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:td(n,"enum")}]}:{ok:!0,value:n})()}function vwa(e){let t=gRi(e);return{...t,...Nd(t)}}function gRi(e){return{parse:(t,r)=>dXe(e).parse(t,r),json:(t,r)=>dXe(e).json(t,r),getType:()=>dXe(e).getType()}}function dXe(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function ARi(e){return Object.entries(e)}function wDt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function The(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function CDt(e){return Object.keys(e)}function Ewa(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var thf=Object.prototype.hasOwnProperty;function Kq(e){return{withParsedProperties:t=>yRi(e,t)}}function yRi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(thf.call(t,a)){let u=t[a];s[a]=typeof u=="function"?u(o.value):u}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!The(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:td(n,"object")}]};let o=new Set(Object.keys(t)),s=wDt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...Nd(r),...Kq(r)}}function Iwa(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Dhe(e){return e.isProperty}var rhf=Object.prototype.hasOwnProperty;function swr(e){let t;function r(){if(t==null){t={};for(let[d,f]of ARi(e)){let m=Dhe(f)?f.rawKey:d,h=Dhe(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of ARi(e)){let m=Dhe(f)?f.rawKey:d,h=Dhe(f)?f.valueSchema:f;nhf(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function u(){return i==null&&a(),i}function c(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>Dhe(f)?f.rawKey:d),_getParsedProperties:()=>CDt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return wwa({value:d,requiredKeys:a(),requiredKeysSet:c(),getProperty:h=>{let A=r()[h];if(A!=null)return{transformedKey:A.parsedKey,transform:y=>{let v=[...m,h];return A.valueSchema.parse(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return wwa({value:d,requiredKeys:u(),requiredKeysSet:l(),getProperty:h=>{let A=e[h];if(A!=null)return Dhe(A)?{transformedKey:A.rawKey,transform:y=>{let v=[...m,h];return A.valueSchema.json(y,{...f,breadcrumbsPrefix:v})}}:{transformedKey:h,transform:y=>{let v=[...m,h];return A.json(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>mc.OBJECT};return{...zC(p),...Nd(p),...Kq(p),...Ske(p)}}function wwa({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!The(e))return{ok:!1,errors:[{path:s,message:td(e,"object")}]};let a=t.length,u=[],c={};for(let l in e){if(!rhf.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?c[d.transformedKey]=f.value:(c[l]=p,u.push(...f.errors))}else switch(i){case"fail":u.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":c[l]=p;break}}if(a>0)for(let l of t)l in e||u.push({path:s,message:`Missing required key "${l}"`});return u.length===0||o?{ok:!0,value:c}:{ok:!1,errors:u}}function Ske(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>Cwa({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>Cwa({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>mc.OBJECT};return{...r,...Nd(r),...Kq(r),...Ske(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))t.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))r.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},getType:()=>mc.OBJECT};return{...n,...Nd(n),...Kq(n),...Ske(n)}}}}function Cwa({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!The(t))return{ok:!1,errors:[{path:i,message:td(t,"object")}]};let o=new Set(e),[s,a]=Ewa(CDt(t),l=>o.has(l)),u=r(wDt(t,a)),c=n(wDt(t,s));return u.ok&&c.ok?{ok:!0,value:{...u.value,...c.value}}:{ok:!1,errors:[...u.ok?[]:u.errors,...c.ok?[]:c.errors]}}function nhf(e){return!ihf(e)}function ihf(e){switch(e.getType()){case mc.ANY:case mc.UNKNOWN:case mc.OPTIONAL:case mc.OPTIONAL_NULLABLE:return!0;default:return!1}}function _wa(e){return swr(e)}function xwa(e){let t={...gRi(e),_getRawProperties:()=>dXe(e)._getRawProperties(),_getParsedProperties:()=>dXe(e)._getParsedProperties()};return{...t,...Nd(t),...Kq(t),...Ske(t)}}function awr(e){let t={parse:(r,n)=>Swa(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>Swa(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>mc.LIST};return{...zC(t),...Nd(t)}}function Swa(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:td(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function Owa(e){return VC(mc.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:td(r,`${e.toString()}`)}]})()}function Bwa(e){return VC(mc.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:td(r,`"${e}"`)}]})()}var Pwa=VC(mc.ANY,e=>({ok:!0,value:e}));var Twa=VC(mc.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:td(e,"boolean")}]});var Dwa=VC(mc.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var Rwa=VC(mc.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:td(e,"number")}]});var Fwa=VC(mc.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:td(e,"string")}]});var jwa=VC(mc.UNKNOWN,e=>({ok:!0,value:e}));var ohf=Object.prototype.hasOwnProperty;function Nwa(e,t){let r={parse:(n,i)=>Qwa({value:n,isKeyNumeric:e.getType()===mc.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>Qwa({value:n,isKeyNumeric:e.getType()===mc.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>mc.RECORD};return{...zC(r),...Nd(r)}}function Qwa({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!The(e))return{ok:!1,errors:[{path:i,message:td(e,"object")}]};let o={},s=[];for(let a in e){if(!ohf.call(e,a))continue;let u=e[a];if(u===void 0)continue;let c=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(c=d)}let l=r(c),p=n(u,c);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function kwa(e){let t=awr(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:td(n,"Set")}]},getType:()=>mc.SET};return{...zC(r),...Nd(r)}}function Lwa(e){let t={parse:(r,n)=>Mwa((i,o)=>i.parse(r,o),e,n),json:(r,n)=>Mwa((i,o)=>i.json(r,o),e,n),getType:()=>mc.UNDISCRIMINATED_UNION};return{...zC(t),...Nd(t)}}function Mwa(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function Uwa(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var shf=Object.prototype.hasOwnProperty;function Vwa(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=owr(CDt(t)),o={parse:(s,a)=>zwa({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:u=>i.parse(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.parse(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>zwa({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:u=>i.json(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.json(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>mc.UNION};return{...zC(o),...Nd(o),...Kq(o)}}function zwa({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!The(e))return{ok:!1,errors:[{path:a,message:td(e,"object")}]};let u=e[t],c={};for(let f in e)shf.call(e,f)&&f!==t&&(c[f]=e[f]);if(u==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(u);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...c}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(c,p);return d.ok?{ok:!0,value:{[r]:u,...d.value}}:d}var uwr=G.objectWithoutOptionalProperties({usernameVariableName:G.string().optional(),usernameEnvVar:G.string().optional(),passwordVariableName:G.string().optional(),passwordEnvVar:G.string().optional()});var cwr=G.objectWithoutOptionalProperties({tokenVariableName:G.string().optional(),tokenEnvVar:G.string().optional()});var lwr=G.objectWithoutOptionalProperties({typeName:G.string()});var pwr=G.union("type",{protobuf:lwr}).transform({transform:e=>e.type==="protobuf"?lXe.protobuf(e):e,untransform:({_visit:e,...t})=>t});var fwr=G.objectWithoutOptionalProperties({headerName:G.string(),prefix:G.string().optional(),headerVariableName:G.string().optional(),headerEnvVar:G.string().optional()});var dwr=G.objectWithoutOptionalProperties({type:G.stringLiteral("namespace"),name:G.string()});var mwr=G.string();var hwr=G.enum_(["GenerallyAvailable","Beta","Deprecated"]);var hs=G.objectWithoutOptionalProperties({availability:hwr.optional()});var gn=G.objectWithoutOptionalProperties({description:G.string().optional()});var Tf=G.objectWithoutOptionalProperties({inline:G.boolean().optional()});var Bu=G.objectWithoutOptionalProperties({nameOverride:G.string().optional(),generatedName:G.string()});var su=G.objectWithoutOptionalProperties({namespace:G.string().optional()});var gwr=G.undiscriminatedUnion([G.string(),dwr]);var wwe=G.list(gwr);var $c=G.objectWithoutOptionalProperties({groupName:wwe.optional()});var Awr=G.objectWithoutOptionalProperties({file:G.string()});var ywr=G.objectWithoutOptionalProperties({file:G.string()});var bwr=G.union("type",{openapi:Awr,protobuf:ywr}).transform({transform:e=>{switch(e.type){case"openapi":return aO.openapi(e);case"protobuf":return aO.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wo=G.objectWithoutOptionalProperties({source:bwr.optional()});var Hc=G.objectWithoutOptionalProperties({title:G.string().optional()});var vwr=G.objectWithoutOptionalProperties({snake:G.string().optional(),camel:G.string().optional(),screamingSnake:G.string().optional(),pascal:G.string().optional()});var Cwe=G.objectWithoutOptionalProperties({nameOverride:G.string().optional(),generatedName:G.string(),value:G.string(),casing:vwr.optional()}).extend(gn).extend(hs);var mXe=G.objectWithoutOptionalProperties({default:Cwe.optional(),values:G.list(Cwe)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var Ewr=G.objectWithoutOptionalProperties({scopesEnum:mXe.optional()});var Iwr=G.objectWithoutOptionalProperties({queryParameterName:G.string()});var $P=G.string();var wwr=G.union("type",{basic:uwr,bearer:cwr,header:fwr,query:Iwr,oauth:Ewr}).transform({transform:e=>{switch(e.type){case"basic":return kC.basic(e);case"bearer":return kC.bearer(e);case"header":return kC.header(e);case"query":return kC.query(e);case"oauth":return kC.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var _we=G.string();var Cwr=G.objectWithoutOptionalProperties({id:G.string(),default:G.string().optional(),values:G.list(G.string()).optional()});var _Dt=G.objectWithoutOptionalProperties({name:G.string().optional(),url:G.string(),audiences:G.list(G.string()).optional(),defaultUrl:G.string().optional(),urlTemplate:G.string().optional(),variables:G.list(Cwr).optional()}).extend(gn);var ZJ=G.number();var HP=G.string();var _wr=G.objectWithoutOptionalProperties({id:HP}).extend(gn);var RF=G.objectWithoutOptionalProperties({encoding:pwr.optional()});var eY=G.objectWithoutOptionalProperties({sdkMethodName:G.string().optional()});var kL=G.objectWithoutOptionalProperties({statusCode:ZJ.optional()});var vRi={};X(vRi,{FullExample:()=>Fm,FullObjectExample:()=>Owr,FullOneOfExample:()=>Bwr,KeyValuePair:()=>Pwr,LiteralExample:()=>xwr,NullExample:()=>Swr,PrimitiveExample:()=>hXe,PropertyKey:()=>gXe});var xwr=G.union("type",{boolean:G.object({value:G.boolean()}),string:G.object({value:G.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ewe.boolean(e.value);case"string":return Ewe.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Swr=G.objectWithoutOptionalProperties({});var hXe=G.union("type",{int:G.object({value:G.number()}),int64:G.object({value:G.number()}),uint:G.object({value:G.number()}),uint64:G.object({value:G.number()}),float:G.object({value:G.number()}),double:G.object({value:G.number()}),string:G.object({value:G.string()}),datetime:G.object({value:G.string()}),datetimeRfc2822:G.object({value:G.string()}),date:G.object({value:G.string()}),base64:G.object({value:G.string()}),boolean:G.object({value:G.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return ms.int(e.value);case"int64":return ms.int64(e.value);case"uint":return ms.uint(e.value);case"uint64":return ms.uint64(e.value);case"float":return ms.float(e.value);case"double":return ms.double(e.value);case"string":return ms.string(e.value);case"datetime":return ms.datetime(e.value);case"datetimeRfc2822":return ms.datetimeRfc2822(e.value);case"date":return ms.date(e.value);case"base64":return ms.base64(e.value);case"boolean":return ms.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Fm=G.union("type",{primitive:G.object({value:hXe}),object:G.lazyObject(()=>Owr),array:G.object({value:G.list(G.lazy(()=>Fm))}),map:G.object({value:G.list(G.lazyObject(()=>Pwr))}),enum:G.object({value:G.string()}),literal:G.object({value:xwr}),oneOf:G.object({value:G.lazy(()=>Bwr)}),null:Swr,unknown:G.object({value:G.lazy(()=>Fm)})}).transform({transform:e=>{switch(e.type){case"primitive":return nu.primitive(e.value);case"object":return nu.object(e);case"array":return nu.array(e.value);case"map":return nu.map(e.value);case"enum":return nu.enum(e.value);case"literal":return nu.literal(e.value);case"oneOf":return nu.oneOf(e.value);case"null":return nu.null(e);case"unknown":return nu.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var gXe=G.string();var Owr=G.objectWithoutOptionalProperties({properties:G.record(gXe,G.lazy(()=>Fm))});var Bwr=G.union("type",{discriminated:G.object({value:G.record(gXe,G.lazy(()=>Fm))}),undiscriminated:G.object({value:G.lazy(()=>Fm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return vwe.discriminated(e.value);case"undiscriminated":return vwe.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Pwr=G.objectWithoutOptionalProperties({key:hXe,value:G.lazy(()=>Fm)});var ERi={};X(ERi,{AllOfPropertyConflict:()=>AXe,ArraySchema:()=>Twr,AsymmetricAlgorithm:()=>Dwr,AsymmetricWebhookSignatureVerification:()=>Fwr,Availability:()=>hwr,BooleanSchema:()=>jwr,BytesResponse:()=>vXe,CasingOverrides:()=>vwr,CommonProperty:()=>Qwr,CursorPagination:()=>Nwr,CustomCodeSample:()=>Uwr,CustomCodeSampleLanguage:()=>kwr,CustomCodeSampleSdk:()=>Lwr,CustomPagination:()=>zwr,DiscriminatedOneOfSchema:()=>Vwr,DiscriminatorContext:()=>EXe,DoubleSchema:()=>qwr,Endpoint:()=>aCr,EndpointExample:()=>CXe,EndpointResponseExample:()=>$wr,EndpointSdkName:()=>tY,EndpointSecurity:()=>_Xe,EnumSchema:()=>mXe,EnumValue:()=>Cwe,ErrorExample:()=>Jwr,FernExample:()=>Gwr,FileResponse:()=>RXe,FileSchema:()=>iCr,FormUrlEncodedRequest:()=>tCr,FullEndpointExample:()=>Kwr,GlobalHeader:()=>uCr,GlobalSecurity:()=>cCr,Header:()=>xwe,HeaderExample:()=>IXe,HmacWebhookSignatureVerification:()=>dCr,HttpEndpointServer:()=>xXe,HttpError:()=>Ywr,HttpMethod:()=>SXe,IdempotencyHeader:()=>mCr,IntSchema:()=>hCr,JsonRequest:()=>rCr,JsonResponse:()=>FXe,LiteralSchema:()=>NXe,LiteralSchemaValue:()=>gCr,LongSchema:()=>ACr,MapSchema:()=>vCr,MultipartFormDataWebhookPayload:()=>ECr,MultipartRequest:()=>TXe,MultipartRequestProperty:()=>Swe,MultipartRequestPropertyEncoding:()=>nCr,MultipartSchema:()=>oCr,NullableSchema:()=>ICr,ObjectProperty:()=>wCr,ObjectPropertyConflictInfo:()=>kXe,ObjectSchema:()=>CCr,OctetStreamRequest:()=>DXe,OffsetPagination:()=>Xwr,OneOfSchema:()=>_Cr,OpenApiIntermediateRepresentation:()=>qwa,OptionalSchema:()=>kCr,Pagination:()=>OXe,PathPagination:()=>Zwr,PathParameter:()=>BXe,PathParameterExample:()=>Hwr,PrimitiveSchema:()=>Bwe,PrimitiveSchemaValue:()=>bCr,QueryParameter:()=>PXe,QueryParameterExample:()=>wXe,ReferencedSchema:()=>rY,Request:()=>sCr,Response:()=>jXe,RetriesConfiguration:()=>QXe,Schema:()=>Nc,Schemas:()=>SCr,SdkGroupInfo:()=>OCr,StreamingResponseExample:()=>Wwr,StringSchema:()=>yCr,SupportedSdkLanguage:()=>Mwr,Tags:()=>BCr,TextResponse:()=>Owe,UnDiscriminatedOneOfSchema:()=>xCr,UriPagination:()=>eCr,Webhook:()=>PCr,WebhookExampleCall:()=>MXe,WebhookHttpMethod:()=>LXe,WebhookPayloadComponent:()=>lCr,WebhookPayloadFormat:()=>pCr,WebhookSignatureAlgorithm:()=>fCr,WebhookSignatureEncoding:()=>yXe,WebhookSignatureVerification:()=>UXe,WebhookTimestamp:()=>bXe,WebhookTimestampFormat:()=>Rwr,WebsocketChannel:()=>NCr,WebsocketHandshake:()=>TCr,WebsocketMessageExample:()=>jCr,WebsocketMessageOrigin:()=>DCr,WebsocketMessageSchema:()=>RCr,WebsocketServer:()=>FCr,WebsocketSessionExample:()=>QCr});var AXe=G.objectWithoutOptionalProperties({propertyKey:G.string(),allOfSchemaIds:G.list($P),conflictingTypeSignatures:G.boolean()});var Twr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Nc),minItems:G.number().optional(),maxItems:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var Dwr=G.enum_(["rsa-sha256","rsa-sha384","rsa-sha512","ecdsa-sha256","ecdsa-sha384","ecdsa-sha512","ed25519"]);var yXe=G.enum_(["base64","hex"]);var Rwr=G.enum_(["unix-seconds","unix-millis","iso8601"]);var bXe=G.objectWithoutOptionalProperties({header:G.string(),format:Rwr.optional(),tolerance:G.number().optional()});var Fwr=G.objectWithoutOptionalProperties({header:G.string(),asymmetricAlgorithm:Dwr,encoding:yXe.optional(),signaturePrefix:G.string().optional(),jwksUrl:G.string().optional(),keyIdHeader:G.string().optional(),timestamp:bXe.optional()});var jwr=G.objectWithoutOptionalProperties({default:G.boolean().optional()});var vXe=G.objectWithoutOptionalProperties({}).extend(gn).extend(Wo).extend(kL);var Qwr=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Nc)});var Nwr=G.objectWithoutOptionalProperties({cursor:G.string(),nextCursor:G.property("next_cursor",G.string()),results:G.string()});var kwr=G.objectWithoutOptionalProperties({name:G.string().optional(),language:G.string(),code:G.string(),install:G.string().optional()}).extend(gn);var Mwr=G.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var Lwr=G.objectWithoutOptionalProperties({name:G.string().optional(),sdk:Mwr,code:G.string()}).extend(gn);var Uwr=G.union("type",{language:kwr,sdk:Lwr}).transform({transform:e=>{switch(e.type){case"language":return JJ.language(e);case"sdk":return JJ.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var zwr=G.objectWithoutOptionalProperties({results:G.string()});var EXe=G.enum_(["data","protocol"]);var Vwr=G.objectWithoutOptionalProperties({discriminantProperty:G.string(),discriminantPropertyNameOverride:G.string().optional(),discriminatorContext:EXe.optional(),commonProperties:G.list(G.lazyObject(()=>Qwr)),schemas:G.record(G.string(),G.lazy(()=>Nc))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var qwr=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional()});var Gwr=G.unknown();var Wwr=G.objectWithoutOptionalProperties({sse:G.boolean(),events:G.list(G.lazy(()=>Fm))});var $wr=G.union("type",{withStreaming:Wwr,withoutStreaming:G.object({value:G.lazy(()=>Fm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return NL.withStreaming(e);case"withoutStreaming":return NL.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var IXe=G.objectWithoutOptionalProperties({name:G.string(),value:G.lazy(()=>Fm)});var Hwr=G.objectWithoutOptionalProperties({name:G.string(),parameterNameOverride:G.string().optional(),value:G.lazy(()=>Fm)});var wXe=G.objectWithoutOptionalProperties({name:G.string(),value:G.lazy(()=>Fm)});var Kwr=G.objectWithoutOptionalProperties({name:G.string().optional(),pathParameters:G.list(Hwr).optional(),queryParameters:G.list(wXe).optional(),headers:G.list(IXe).optional(),request:G.lazy(()=>Fm).optional(),response:$wr.optional(),codeSamples:G.list(Uwr)}).extend(gn);var CXe=G.union("type",{unknown:G.object({value:Gwr}),full:Kwr}).transform({transform:e=>{switch(e.type){case"unknown":return QL.unknown(e.value);case"full":return QL.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var tY=G.objectWithoutOptionalProperties({groupName:wwe,methodName:G.string()});var _Xe=G.list(G.record(_we,G.list(G.string())));var xwe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Nc),env:G.string().optional(),parameterNameOverride:G.string().optional()}).extend(gn).extend(hs).extend(Wo);var xXe=G.objectWithoutOptionalProperties({name:G.string().optional(),url:G.string().optional(),audiences:G.list(G.string()).optional()});var Jwr=G.objectWithoutOptionalProperties({name:G.string().optional(),description:G.string().optional(),example:G.lazy(()=>Fm)});var Ywr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc).optional(),examples:G.list(Jwr).optional()}).extend(gn).extend(Bu).extend(Wo);var SXe=G.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Xwr=G.objectWithoutOptionalProperties({offset:G.string(),results:G.string(),step:G.string().optional(),hasNextPage:G.string().optional()});var Zwr=G.objectWithoutOptionalProperties({nextPath:G.string(),results:G.string()});var eCr=G.objectWithoutOptionalProperties({nextUri:G.string(),results:G.string()});var OXe=G.union("type",{cursor:Nwr,offset:Xwr,custom:zwr,uri:eCr,path:Zwr}).transform({transform:e=>{switch(e.type){case"cursor":return lw.cursor(e);case"offset":return lw.offset(e);case"custom":return lw.custom(e);case"uri":return lw.uri(e);case"path":return lw.path(e);default:return e}},untransform:({_visit:e,...t})=>t});var BXe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Nc),variableReference:G.string().optional(),parameterNameOverride:G.string().optional()}).extend(gn).extend(hs).extend(Wo);var PXe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Nc),parameterNameOverride:G.string().optional(),explode:G.boolean().optional()}).extend(gn).extend(hs).extend(Wo);var tCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc),contentType:G.string().optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo);var rCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc),contentType:G.string().optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo);var nCr=G.enum_(["json","form"]);var iCr=G.objectWithoutOptionalProperties({isOptional:G.boolean(),isArray:G.boolean()}).extend(gn);var oCr=G.union("type",{file:iCr,json:G.object({value:G.lazy(()=>Nc)})}).transform({transform:e=>{switch(e.type){case"file":return YJ.file(e);case"json":return YJ.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Swe=G.objectWithoutOptionalProperties({key:G.string(),schema:oCr,contentType:G.string().optional(),exploded:G.boolean().optional(),encoding:nCr.optional()}).extend(gn);var TXe=G.objectWithoutOptionalProperties({name:G.string().optional(),properties:G.list(Swe)}).extend(gn).extend(Wo);var DXe=G.objectWithoutOptionalProperties({contentType:G.string().optional()}).extend(gn).extend(Wo);var sCr=G.union("type",{octetStream:DXe,multipart:TXe,json:rCr,formUrlEncoded:tCr}).transform({transform:e=>{switch(e.type){case"octetStream":return Hq.octetStream(e);case"multipart":return Hq.multipart(e);case"json":return Hq.json(e);case"formUrlEncoded":return Hq.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var RXe=G.objectWithoutOptionalProperties({}).extend(gn).extend(Wo).extend(kL);var FXe=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc),responseProperty:G.string().optional(),terminator:G.string().optional()}).extend(gn).extend(Wo).extend(kL);var Owe=G.objectWithoutOptionalProperties({}).extend(gn).extend(Wo).extend(kL);var jXe=G.union("type",{file:RXe,json:FXe,text:Owe,bytes:vXe,streamingSse:FXe,streamingText:Owe,streamingJson:FXe}).transform({transform:e=>{switch(e.type){case"file":return _S.file(e);case"json":return _S.json(e);case"text":return _S.text(e);case"bytes":return _S.bytes(e);case"streamingSse":return _S.streamingSse(e);case"streamingText":return _S.streamingText(e);case"streamingJson":return _S.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var QXe=G.union("type",{disabled:G.object({value:G.boolean().optional()})}).transform({transform:e=>e.type==="disabled"?vDt.disabled(e.value):e,untransform:({_visit:e,...t})=>t});var aCr=G.objectWithoutOptionalProperties({authed:G.boolean(),security:_Xe.optional(),internal:G.boolean().optional(),idempotent:G.boolean().optional(),method:SXe,audiences:G.list(G.string()),path:G.string(),summary:G.string().optional(),operationId:G.string().optional(),tags:G.list(HP),pathParameters:G.list(BXe),queryParameters:G.list(PXe),headers:G.list(xwe),sdkName:tY.optional(),generatedRequestName:G.string(),requestNameOverride:G.string().optional(),request:sCr.optional(),response:jXe.optional(),errors:G.record(ZJ,Ywr),servers:G.list(xXe),examples:G.list(CXe),pagination:OXe.optional(),retries:QXe.optional()}).extend(gn).extend(hs).extend(Wo).extend(su);var uCr=G.objectWithoutOptionalProperties({header:G.string(),name:G.string().optional(),optional:G.boolean().optional(),env:G.string().optional(),schema:G.lazy(()=>Nc).optional()});var cCr=G.list(G.record(_we,G.list(G.string())));var lCr=G.enum_(["body","timestamp","notification-url","message-id"]);var pCr=G.objectWithoutOptionalProperties({components:G.list(lCr),delimiter:G.string().optional()});var fCr=G.enum_(["sha256","sha1","sha384","sha512"]);var dCr=G.objectWithoutOptionalProperties({header:G.string(),algorithm:fCr.optional(),encoding:yXe.optional(),signaturePrefix:G.string().optional(),payloadFormat:pCr.optional(),timestamp:bXe.optional()});var mCr=G.objectWithoutOptionalProperties({header:G.string(),name:G.string().optional(),env:G.string().optional(),schema:G.lazy(()=>Nc).optional()});var hCr=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional()});var gCr=G.union("type",{boolean:G.object({value:G.boolean()}),string:G.object({value:G.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return nA.boolean(e.value);case"string":return nA.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var NXe=G.objectWithoutOptionalProperties({value:gCr}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var ACr=G.objectWithoutOptionalProperties({default:G.number().optional()});var yCr=G.objectWithoutOptionalProperties({default:G.string().optional(),pattern:G.string().optional(),format:G.string().optional(),minLength:G.number().optional(),maxLength:G.number().optional()});var bCr=G.union("type",{int:hCr,int64:ACr,uint:G.object({}),uint64:G.object({}),float:G.object({}),double:qwr,string:yCr,datetime:G.object({}),datetimeRfc2822:G.object({}),date:G.object({}),base64:G.object({}),boolean:jwr}).transform({transform:e=>{switch(e.type){case"int":return Wc.int(e);case"int64":return Wc.int64(e);case"uint":return Wc.uint();case"uint64":return Wc.uint64();case"float":return Wc.float();case"double":return Wc.double(e);case"string":return Wc.string(e);case"datetime":return Wc.datetime();case"datetimeRfc2822":return Wc.datetimeRfc2822();case"date":return Wc.date();case"base64":return Wc.base64();case"boolean":return Wc.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bwe=G.objectWithoutOptionalProperties({schema:bCr}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var vCr=G.objectWithoutOptionalProperties({key:Bwe,value:G.lazy(()=>Nc),minProperties:G.number().optional(),maxProperties:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Hc).extend(Tf);var ECr=G.objectWithoutOptionalProperties({name:G.string().optional(),properties:G.list(Swe)}).extend(gn).extend(Wo);var ICr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Nc)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var kXe=G.objectWithoutOptionalProperties({differentSchema:G.boolean()});var wCr=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Nc),readonly:G.boolean().optional(),writeonly:G.boolean().optional(),conflict:G.record($P,kXe),generatedName:G.string(),nameOverride:G.string().optional(),audiences:G.list(G.string())}).extend(hs);var rY=G.objectWithoutOptionalProperties({schema:$P}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc);var CCr=G.objectWithoutOptionalProperties({allOf:G.list(rY),properties:G.list(G.lazyObject(()=>wCr)),allOfPropertyConflicts:G.list(AXe),additionalProperties:G.boolean(),minProperties:G.number().optional(),maxProperties:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var _Cr=G.union("type",{discriminated:G.lazyObject(()=>Vwr),undiscriminated:G.lazyObject(()=>xCr)}).transform({transform:e=>{switch(e.type){case"discriminated":return XJ.discriminated(e);case"undiscriminated":return XJ.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var SCr=G.objectWithoutOptionalProperties({rootSchemas:G.record($P,G.lazy(()=>Nc)),namespacedSchemas:G.record(mwr,G.record($P,G.lazy(()=>Nc)))});var OCr=G.objectWithoutOptionalProperties({summary:G.string().optional(),description:G.string().optional()});var BCr=G.objectWithoutOptionalProperties({tagsById:G.record(HP,_wr),orderedTagIds:G.list(HP).optional()});var MXe=G.objectWithoutOptionalProperties({name:G.string().optional(),payload:G.lazy(()=>Fm)}).extend(gn);var LXe=G.enum_(["GET","POST"]);var UXe=G.union("type",{hmac:dCr,asymmetric:Fwr}).transform({transform:e=>{switch(e.type){case"hmac":return xke.hmac(e);case"asymmetric":return xke.asymmetric(e);default:return e}},untransform:({_visit:e,...t})=>t});var PCr=G.objectWithoutOptionalProperties({audiences:G.list(G.string()),sdkName:tY.optional(),method:LXe,summary:G.string().optional(),operationId:G.string(),tags:G.list(HP),headers:G.list(xwe),generatedPayloadName:G.string(),payload:G.lazy(()=>Nc),multipartFormData:ECr.optional(),response:jXe.optional(),signatureVerification:UXe.optional(),examples:G.list(MXe)}).extend(gn).extend(Wo).extend(su);var TCr=G.objectWithoutOptionalProperties({queryParameters:G.list(PXe),headers:G.list(xwe),pathParameters:G.list(BXe)});var DCr=G.enum_(["client","server"]);var RCr=G.objectWithoutOptionalProperties({name:G.string(),origin:DCr,body:G.lazy(()=>Nc),methodName:G.string().optional()});var FCr=G.objectWithoutOptionalProperties({name:G.string(),url:G.string()});var jCr=G.objectWithoutOptionalProperties({messageType:G.string(),payload:G.lazy(()=>Fm)}).extend(gn);var QCr=G.objectWithoutOptionalProperties({name:G.string().optional(),queryParameters:G.list(wXe).optional(),headers:G.list(IXe).optional(),messages:G.list(jCr)}).extend(gn);var NCr=G.objectWithoutOptionalProperties({audiences:G.list(G.string()),path:G.string(),groupName:wwe,summary:G.string().optional(),connectMethodName:G.string().optional(),handshake:TCr,messages:G.list(RCr),servers:G.list(FCr),examples:G.list(QCr)}).extend(gn).extend(Wo);var qwa=G.objectWithoutOptionalProperties({apiVersion:G.unknown().optional(),title:G.string().optional(),description:G.string().optional(),basePath:G.string().optional(),servers:G.list(_Dt),websocketServers:G.list(_Dt),groups:G.record(G.string(),OCr),tags:BCr,hasEndpointsMarkedInternal:G.boolean(),endpoints:G.list(aCr),webhooks:G.list(PCr),channels:G.record(G.string(),NCr),groupedSchemas:SCr,variables:G.record(G.string(),Bwe),nonRequestReferencedSchemas:G.set($P),securitySchemes:G.record(_we,wwr),security:cCr.optional(),globalHeaders:G.list(uCr).optional(),idempotencyHeaders:G.list(mCr).optional()});var kCr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Nc)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var Nc=G.union("type",{primitive:Bwe,object:G.lazyObject(()=>CCr),array:G.lazyObject(()=>Twr),map:G.lazyObject(()=>vCr),optional:G.lazyObject(()=>kCr),enum:mXe,reference:rY,literal:NXe,oneOf:G.object({value:G.lazy(()=>_Cr)}),nullable:G.lazyObject(()=>ICr),unknown:Bu}).transform({transform:e=>{switch(e.type){case"primitive":return ya.primitive(e);case"object":return ya.object(e);case"array":return ya.array(e);case"map":return ya.map(e);case"optional":return ya.optional(e);case"enum":return ya.enum(e);case"reference":return ya.reference(e);case"literal":return ya.literal(e);case"oneOf":return ya.oneOf(e.value);case"nullable":return ya.nullable(e);case"unknown":return ya.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var xCr=G.objectWithoutOptionalProperties({schemas:G.list(G.lazy(()=>Nc))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var IRi={};X(IRi,{ArraySchemaWithExample:()=>MCr,Base64WithExample:()=>LCr,BooleanWithExample:()=>UCr,CommonPropertyWithExample:()=>zCr,DateWithExample:()=>VCr,DatetimeWithExample:()=>xDt,DiscriminatedOneOfSchemaWithExample:()=>qCr,DoubleWithExample:()=>GCr,EndpointWithExample:()=>Gwa,EnumSchemaWithExample:()=>ZCr,FloatWithExample:()=>e_r,HeaderWithExample:()=>Pwe,HttpErrorWithExample:()=>WCr,Int64WithExample:()=>t_r,IntWithExample:()=>r_r,JsonRequestWithExample:()=>HCr,JsonResponseWithExample:()=>VXe,MapSchemaWithExample:()=>a_r,MultipartFormDataWebhookPayloadWithExample:()=>u_r,NamedFullExample:()=>FF,NullableSchemaWithExample:()=>c_r,ObjectPropertyWithExample:()=>l_r,ObjectSchemaWithExample:()=>p_r,OneOfSchemaWithExample:()=>f_r,OptionalSchemaWithExample:()=>m_r,ParseFormUrlEncodedRequest:()=>KCr,ParseMultipartRequest:()=>JCr,ParseOctetStreamRequest:()=>YCr,PathParameterWithExample:()=>$Cr,PrimitiveSchemaValueWithExample:()=>s_r,PrimitiveSchemaWithExample:()=>GXe,QueryParameterWithExample:()=>zXe,RequestWithExample:()=>XCr,ResponseWithExample:()=>qXe,SchemaWithExample:()=>Df,StringSchemaWithExample:()=>n_r,Uint64WithExample:()=>i_r,UintWithExample:()=>o_r,UnDiscriminatedOneOfSchemaWithExample:()=>d_r,UnknownSchemaWithExample:()=>h_r,WebhookWithExample:()=>Wwa,WebsocketHandshakeWithExample:()=>$wa});var MCr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Df),minItems:G.number().optional(),maxItems:G.number().optional(),example:G.list(G.unknown()).optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var LCr=G.objectWithoutOptionalProperties({example:G.string().optional()});var UCr=G.objectWithoutOptionalProperties({default:G.boolean().optional(),example:G.boolean().optional()});var zCr=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Df)});var xDt=G.objectWithoutOptionalProperties({example:G.string().optional()});var VCr=G.objectWithoutOptionalProperties({example:G.string().optional()});var qCr=G.objectWithoutOptionalProperties({discriminantProperty:G.string(),discriminantPropertyNameOverride:G.string().optional(),discriminatorContext:EXe.optional(),commonProperties:G.list(G.lazyObject(()=>zCr)),schemas:G.record(G.string(),G.lazy(()=>Df))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var GCr=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional(),example:G.number().optional()});var Pwe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Df),env:G.string().optional(),parameterNameOverride:G.string().optional()}).extend(gn).extend(hs).extend(Wo);var FF=G.objectWithoutOptionalProperties({name:G.string().optional(),value:G.unknown()}).extend(gn);var WCr=G.objectWithoutOptionalProperties({statusCode:ZJ,schema:G.lazy(()=>Df),fullExamples:G.list(FF).optional()}).extend(gn).extend(Bu).extend(Wo);var $Cr=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Df),variableReference:G.string().optional(),parameterNameOverride:G.string().optional(),explode:G.boolean().optional()}).extend(gn).extend(hs).extend(Wo);var zXe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Df),parameterNameOverride:G.string().optional(),explode:G.boolean().optional()}).extend(gn).extend(hs).extend(Wo);var HCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Df),contentType:G.string().optional(),fullExamples:G.list(FF).optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo).extend(eY);var KCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Df),contentType:G.string().optional(),fullExamples:G.list(FF).optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo).extend(eY);var JCr=G.objectWithoutOptionalProperties({fullExamples:G.list(FF).optional()}).extend(TXe).extend(eY);var YCr=G.objectWithoutOptionalProperties({}).extend(DXe).extend(eY);var XCr=G.union("type",{octetStream:YCr,multipart:JCr,json:HCr,formUrlEncoded:KCr}).transform({transform:e=>{switch(e.type){case"octetStream":return WP.octetStream(e);case"multipart":return WP.multipart(e);case"json":return WP.json(e);case"formUrlEncoded":return WP.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var VXe=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Df),responseProperty:G.string().optional(),terminator:G.string().optional(),fullExamples:G.list(FF).optional()}).extend(gn).extend(Wo).extend(kL);var qXe=G.union("type",{file:RXe,json:VXe,text:Owe,bytes:vXe,streamingSse:VXe,streamingText:Owe,streamingJson:VXe}).transform({transform:e=>{switch(e.type){case"file":return Yh.file(e);case"json":return Yh.json(e);case"text":return Yh.text(e);case"bytes":return Yh.bytes(e);case"streamingSse":return Yh.streamingSse(e);case"streamingText":return Yh.streamingText(e);case"streamingJson":return Yh.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gwa=G.objectWithoutOptionalProperties({authed:G.boolean(),security:_Xe.optional(),internal:G.boolean().optional(),idempotent:G.boolean().optional(),method:SXe,audiences:G.list(G.string()),path:G.string(),summary:G.string().optional(),operationId:G.string().optional(),tags:G.list(HP),pathParameters:G.list($Cr),queryParameters:G.list(zXe),headers:G.list(Pwe),sdkName:tY.optional(),generatedRequestName:G.string(),requestNameOverride:G.string().optional(),request:XCr.optional(),response:qXe.optional(),errors:G.record(ZJ,WCr),servers:G.list(xXe),examples:G.list(CXe),pagination:OXe.optional(),retries:QXe.optional()}).extend(gn).extend(hs).extend(Wo).extend(su);var ZCr=G.objectWithoutOptionalProperties({default:Cwe.optional(),values:G.list(Cwe),example:G.string().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var e_r=G.objectWithoutOptionalProperties({example:G.number().optional()});var t_r=G.objectWithoutOptionalProperties({default:G.number().optional(),example:G.number().optional()});var r_r=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional(),example:G.number().optional()});var n_r=G.objectWithoutOptionalProperties({default:G.string().optional(),pattern:G.string().optional(),format:G.string().optional(),minLength:G.number().optional(),maxLength:G.number().optional(),example:G.string().optional()});var i_r=G.objectWithoutOptionalProperties({default:G.number().optional(),example:G.number().optional()});var o_r=G.objectWithoutOptionalProperties({default:G.number().optional(),example:G.number().optional()});var s_r=G.union("type",{int:r_r,int64:t_r,uint:o_r,uint64:i_r,float:e_r,double:GCr,string:n_r,datetime:xDt,datetimeRfc2822:xDt,date:VCr,base64:LCr,boolean:UCr}).transform({transform:e=>{switch(e.type){case"int":return Si.int(e);case"int64":return Si.int64(e);case"uint":return Si.uint(e);case"uint64":return Si.uint64(e);case"float":return Si.float(e);case"double":return Si.double(e);case"string":return Si.string(e);case"datetime":return Si.datetime(e);case"datetimeRfc2822":return Si.datetimeRfc2822(e);case"date":return Si.date(e);case"base64":return Si.base64(e);case"boolean":return Si.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var GXe=G.objectWithoutOptionalProperties({schema:s_r}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var a_r=G.objectWithoutOptionalProperties({key:GXe,value:G.lazy(()=>Df),minProperties:G.number().optional(),maxProperties:G.number().optional(),example:G.unknown().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Hc).extend(Tf);var u_r=G.objectWithoutOptionalProperties({name:G.string().optional(),properties:G.list(Swe)}).extend(gn).extend(Wo);var c_r=G.objectWithoutOptionalProperties({value:G.lazy(()=>Df)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var l_r=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Df),readonly:G.boolean().optional(),writeonly:G.boolean().optional(),audiences:G.list(G.string()),conflict:G.record($P,kXe),nameOverride:G.string().optional(),generatedName:G.string()}).extend(hs);var p_r=G.objectWithoutOptionalProperties({allOf:G.list(rY),properties:G.list(G.lazyObject(()=>l_r)),allOfPropertyConflicts:G.list(AXe),fullExamples:G.list(FF).optional(),additionalProperties:G.boolean(),minProperties:G.number().optional(),maxProperties:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var f_r=G.union("type",{discriminated:G.lazyObject(()=>qCr),undiscriminated:G.lazyObject(()=>d_r)}).transform({transform:e=>{switch(e.type){case"discriminated":return p2.discriminated(e);case"undiscriminated":return p2.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var m_r=G.objectWithoutOptionalProperties({value:G.lazy(()=>Df)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var h_r=G.objectWithoutOptionalProperties({example:G.unknown()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var Df=G.union("type",{primitive:GXe,object:G.lazyObject(()=>p_r),array:G.lazyObject(()=>MCr),map:G.lazyObject(()=>a_r),optional:G.lazyObject(()=>m_r),enum:ZCr,reference:rY,literal:NXe,oneOf:G.object({value:G.lazy(()=>f_r)}),nullable:G.lazyObject(()=>c_r),unknown:h_r}).transform({transform:e=>{switch(e.type){case"primitive":return jr.primitive(e);case"object":return jr.object(e);case"array":return jr.array(e);case"map":return jr.map(e);case"optional":return jr.optional(e);case"enum":return jr.enum(e);case"reference":return jr.reference(e);case"literal":return jr.literal(e);case"oneOf":return jr.oneOf(e.value);case"nullable":return jr.nullable(e);case"unknown":return jr.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var d_r=G.objectWithoutOptionalProperties({schemas:G.list(G.lazy(()=>Df))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var Wwa=G.objectWithoutOptionalProperties({audiences:G.list(G.string()),sdkName:tY.optional(),method:LXe,summary:G.string().optional(),operationId:G.string(),tags:G.list(HP),headers:G.list(Pwe),generatedPayloadName:G.string(),payload:G.lazy(()=>Df),multipartFormData:u_r.optional(),response:qXe.optional(),signatureVerification:UXe.optional(),examples:G.list(MXe)}).extend(gn).extend(Wo).extend(su);var $wa=G.objectWithoutOptionalProperties({queryParameters:G.list(zXe),headers:G.list(Pwe)});var Hwa=/^(\d+)/,WXe=/^[a-zA-Z][a-zA-Z0-9_]*$/,Kwa={"<":"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 Oke(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let s=Math.floor(e/10),a=e%10;return a===0?n[s]:`${n[s]}_${t[a]}`}if(e<1e3){let s=Math.floor(e/100),a=e%100;return a===0?`${t[s]}_hundred`:`${t[s]}_hundred_${Oke(a)}`}let i=Math.floor(e/1e3),o=e%1e3;return o===0?`${t[i]}_thousand`:`${t[i]}_thousand_${Oke(o)}`}xi();function SDt(e){let t=e.match(Hwa);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let o=Oke(i);return n.length>0?`${o}_${n}`:o}}}function $Xe(e){let t=SDt(e),r=Kwa[e];return t!=null?dl($n(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":dl($n(e)))}xi();function jF(e,t){return e.type==="primitive"&&t.type==="primitive"?Jwa(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?ahf(e.values,t.values):e.type==="array"&&t.type==="array"?jF(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"?jF(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?uhf(e.value,t.value):e.type==="object"&&t.type==="object"?chf(e,t):e.type==="map"&&t.type==="map"?Jwa(e.key.schema,t.key.schema)&&jF(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Jwa(e,t){return e.type===t.type}function ahf(e,t){let r=new Set(e.map(i=>i.value)),n=new Set(t.map(i=>i.value));return m0(r,n)}function uhf(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:jF(n,i)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:jF(r,i)}):!1}function chf(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let o=r[n];return o==null?!1:jF(o,i.schema)})}Nt();function qy(e){switch(e){case MC.Deprecated:return"deprecated";case MC.Beta:return"pre-release";case MC.GenerallyAvailable:return"generally-available";default:return}}Nt();function g_r(e){if(e.type==="protobuf")return{proto:{type:e.typeName}};xe(e.type)}Nt();gg();Nt();gg();xi();function Ywa(e){let t=e.match(/^(_+)/),r=e.match(/(_+)$/),n=t?.[1]??"",i=r?.[1]??"";if(n===""&&i==="")return $n(e);if(n.length+i.length>=e.length)return e;let o=e.slice(n.length,e.length-i.length||void 0);return`${n}${$n(o)}${i}`}function lhf(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function Xwa(e){let t=e?lhf(e):void 0;if(t==null||t.length===0)return nke;let r=[];for(let[n,i]of t.entries())typeof i=="string"?r.push(Ywa(i)):typeof i=="object"?i.type==="namespace"?n<t.length-1?r.push(Ywa(i.name)):r.push(i.name,nke):xe(i.type):xe(i);return r.join("/")}function Rhe(e){return ds.of(`${Xwa(e)}.yml`)}function wRi({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?nke:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,Xwa(r))}function Zwa({sdkName:e,namespaceOverride:t}){return ds.of(`${wRi({sdkName:e,namespaceOverride:t})}.yml`)}function eCa({location:e,namespaceOverride:t}){return t!=null?f0(ds.of(t),e):e}var phf=ds.of(vp);function tCa(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return A_r({namespace:e.namespace,groupName:e.groupName});case"oneOf":return A_r({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return phf;default:xe(e)}}function A_r({namespace:e,groupName:t}){return e!=null&&t!=null?Rhe([{type:"namespace",name:e},...t]):e!=null?Rhe([{type:"namespace",name:e}]):Rhe(t)}Nt();function Fhe(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:xe(e)}}function cp(e){return typeof e=="string"?e:e.type}function HXe(e){if(typeof e!="string")return e.docs}function ODt(e){if(typeof e!="string")return e.default}function CRi(e){if(typeof e!="string")return e.validation}function KXe(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 nCa(e){let t=cp(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?rCa(e):{...e,type:rCa(e.type)}}function rCa(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function Bke(e){return cp(e).startsWith("optional<")?e:typeof e=="string"?iCa(e):{...e,type:iCa(e.type)}}function iCa(e){return e.startsWith("optional<")?e:`optional<${e}>`}var fhf=-2147483648,dhf=2147483647,mhf=-17976931348623157e292,hhf=17976931348623157e292;function iu({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:o}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return y_r(e);case"array":return SRi({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"map":return ORi({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"reference":return xRi({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return PRi();case"optional":return b_r({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"nullable":return BRi({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"enum":return Chf({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:o});case"literal":return e.value,TRi(e);case"object":return _hf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"oneOf":return xhf({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});default:xe(e)}}function y_r(e){switch(e.schema.type){case"string":return yhf({description:e.description,schema:e.schema});case"int":return bhf({description:e.description,schema:e.schema});case"float":return vhf({description:e.description,schema:e.schema});case"double":return Ehf({description:e.description,schema:e.schema});case"boolean":return ghf({description:e.description,schema:e.schema});case"int64":return Ahf({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",datetimeRfc2822:()=>"datetime-rfc-2822",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:qy(e.availability)}:{}}}function ghf({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function Ahf({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function yhf({description:e,schema:t}){let r="string",n=Ihf(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function bhf({description:e,schema:t}){let r="integer",n=oCa(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function vhf({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function Ehf({description:e,schema:t}){let r="double",n=oCa(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function Ihf(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,o=whf(t);if(!(o==null&&r==null&&n==null&&i==null))return{format:o,pattern:r,minLength:n,maxLength:i}}function whf(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 oCa(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:o,exclusiveMaximum:s}=e;if(r=_Ri(r,t),n=_Ri(n,t),i=_Ri(i,t),!(r==null&&n==null&&o==null&&s==null&&i==null))return{min:r,max:n,exclusiveMin:o,exclusiveMax:s,multipleOf:i}}function _Ri(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[fhf,dhf]:[mhf,hhf];return e<r||e>n?void 0:e}function xRi({schema:e,fileContainingReference:t,context:r}){let n=r.getSchema(e.schema,e.namespace);if(n==null)return"unknown";let i=Shf(n)??e.schema,o=r.options.respectReadonlySchemas?r.getSchemaFinalName(i):i,s=Fhe(n),a=Ohf(n),c=v_r({context:r,fileContainingReference:t,declarationFile:A_r({namespace:e.namespace,groupName:s}),type:o});return n.type==="nullable"&&(c=r.options.wrapReferencesToNullableInOptional?`optional<${c}>`:`nullable<${c}>`),n.type==="optional"&&!c.startsWith("optional<")&&(c=`optional<${c}>`),e.description==null&&a==null?c:{type:c,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function SRi({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=`list<${cp(s)}>`;return e.description==null&&e.title==null?a:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{},type:a}}function ORi({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=y_r(e.key),a=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),u=e.encoding!=null?g_r(e.encoding):void 0,c=`map<${cp(s)}, ${cp(a)}>`;if(e.description==null&&u==null&&e.title==null)return c;let l={type:c};return e.description!=null&&(l.docs=e.description),e.encoding!=null&&(l.encoding=u),e.availability!=null&&(l.availability=qy(e.availability)),l}function BRi({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){if(!n.options.respectNullableSchemas)return b_r({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});let s=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=cp(s),u=HXe(s),c=ODt(s),l=CRi(s),p=nCa(a);if(n.options.wrapReferencesToNullableInOptional&&(p=Bke(p)),e.availability==null&&e.description==null&&u==null&&c==null&&l==null&&e.title==null)return p;let d=typeof p=="string"?{type:p}:p;return(e.description!=null||u!=null)&&(d.docs=e.description??u),c!=null&&(d.default=c),l!=null&&(d.validation=l),e.availability!=null&&(d.availability=qy(e.availability)),d}function b_r({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=cp(s),u=HXe(s),c=ODt(s),l=CRi(s),p=Bke(a);if(e.availability==null&&e.description==null&&u==null&&c==null&&l==null&&e.title==null)return p;let d=typeof p=="string"?{type:p}:p;return(e.description!=null||u!=null)&&(d.docs=e.description??u),c!=null&&(d.default=c),l!=null&&(d.validation=l),e.availability!=null&&(d.availability=qy(e.availability)),d}function PRi(){return"unknown"}function TRi(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:xe(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function Chf({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let o=BDt(e,i),s=e.nameOverride??e.generatedName;n.builder.addType(r,{name:s,schema:o.schema});let a=v_r({type:s,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return a;let u={type:a};return e.description!=null&&(u.docs=e.description),e.default!=null&&(u.default=e.default.value),e.availability!=null&&(u.availability=qy(e.availability)),u}function _hf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=DRi({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:s.schema});let u=v_r({type:a,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function xhf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=RRi({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:s.schema});let u=v_r({type:a,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{...e.title!=null?{"display-name":e.title}:{},type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function v_r({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function Shf(e){return ya._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 Ohf(e){return ya._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 pw;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(pw||(pw={}));Nt();function jhe(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:xe(e)}}function aCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let o;switch(e.type){case"primitive":o=Thf(e);break;case"array":o=Bhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":o=Phf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":o=Dhf({schema:e,context:t,declarationFile:r,namespace:n});break;case"unknown":o=Fhf(e.nameOverride,e.generatedName);break;case"optional":o=cCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":o=Rhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":o=BDt(e,i);break;case"literal":o=jhf(e,e.nameOverride,e.generatedName);break;case"object":o=DRi({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"oneOf":o=RRi({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;default:xe(e)}return o}function DRi({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let o=t.isInState(pw.Request),s=t.options.respectReadonlySchemas,a=t.getEndpointMethod(),c=o&&s&&(a==="POST"||a==="PUT"||a==="PATCH"),l=!1,p={},d=new Set;for(let v of e.properties){if(v.readonly&&(l=!0),c&&v.readonly)continue;if(Object.keys(v.conflict).length>0){if(Object.entries(v.conflict).every(([x,R])=>!R.differentSchema))continue;Object.entries(v.conflict).forEach(([x])=>{FRi({property:v.key,schemaId:x,context:t,namespace:n}).forEach(z=>{d.add(z)})})}let E=iu({schema:v.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}),b=v.audiences,I=v.nameOverride,w=qy(v.availability),_=Mhf(v);p[v.key]=khf({typeReference:E,audiences:b,name:I,availability:w,propertyAccess:_})}let f=new Set;for(let v of e.allOfPropertyConflicts)v.allOfSchemaIds.forEach(E=>d.add(E)),v.conflictingTypeSignatures&&f.add(v.propertyKey);let m=[];for(let v of e.allOf){let E=E_r({schema:v.schema,context:t,namespace:n});if(E==null||d.has(v.schema)||d.has(E))continue;let b=iu({schema:ya.reference(v),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});m.push(KXe(cp(b)))}for(let v of d){let E=JXe(t,v,n);for(let b of E.properties)p[b.key]==null&&(f.has(b.key)&&(p[b.key]="unknown"),p[b.key]=iu({schema:b.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}));for(let b of E.allOf){if(d.has(b.schema))continue;let I=iu({schema:ya.reference(b),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});m.push(KXe(cp(I)))}}let h={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(p).map(([v,E])=>Nhf(v)?[v,typeof E=="string"?{type:E,name:`_${v}`}:{...E,name:`_${v}`}]:[v,E]))};m.length>0&&(h.extends=m),e.additionalProperties&&(h["extra-properties"]=!0),e.availability!=null&&(h.availability=qy(e.availability)),e.source!=null&&(h.source=jhe(e.source)),h.inline=jRi(e,i);let A=e.nameOverride??e.generatedName,y=l&&t.options.respectReadonlySchemas&&!c?`${A}Read`:A;return y!==A&&t.setSchemaFinalName(A,y),{name:y,schema:h}}function FRi({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return FRi({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:o,allOf:s}=JXe(r,t,n),a=o.some(c=>c.key===e),u=[...s.flatMap(c=>FRi({property:e,context:r,schemaId:c.schema,namespace:n}))];if(a||u.length>0)return[t,...u]}return[]}function uCa(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?JXe(e,t.schema,r):t.type==="nullable"?uCa(e,t.value,r):{properties:[],allOf:[]}}function JXe(e,t,r){let n=e.getSchema(t,r);return n==null?{properties:[],allOf:[]}:uCa(e,n,r)}function Bhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:SRi({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function Phf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:ORi({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function Thf(e){let t=y_r(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function sCa(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function BDt(e,t){let r={enum:e.values.map(o=>{let s=o.nameOverride??o.generatedName,a=o.value;if(s===a&&o.description==null&&(o.casing==null||sCa(o.casing)))return s;let u={value:o.value};if(s!==a&&(u.name=s),o.description!=null&&(u.docs=o.description),o.casing!=null&&!sCa(o.casing)){let c={},l=!1;o.casing.camel!=null&&(c.camel=o.casing.camel,l=!0),o.casing.screamingSnake!=null&&(c["screaming-snake"]=o.casing.screamingSnake,l=!0),o.casing.snake!=null&&(c.snake=o.casing.snake,l=!0),o.casing.pascal!=null&&(c.pascal=o.casing.pascal,l=!0),l&&(u.casing=c)}return u})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=jRi(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?jhe(e.source):void 0};for(let o of r.enum){let s=typeof o=="string"?o:o.name??o.value;n.has(s.toLowerCase())||(i.enum.push(o),n.add(s.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function Dhf({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:xRi({schema:e,context:t,fileContainingReference:r,namespace:n})}}function Rhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:BRi({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:cCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function cCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:b_r({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function Fhf(e,t){return{name:e??t,schema:PRi()}}function jhf(e,t,r){return{name:t??r,schema:TRi(e)}}function RRi({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let o=e.encoding!=null?g_r(e.encoding):void 0;if(e.type==="discriminated"){let a={};for(let c of e.commonProperties)a[c.key]=iu({schema:c.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1});let u={};for(let[c,l]of Object.entries(e.schemas))u[c]=iu({schema:l,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantPropertyNameOverride!=null?{name:e.discriminantPropertyNameOverride,value:e.discriminantProperty}:e.discriminantProperty,"base-properties":a,docs:e.description??void 0,availability:e.availability!=null?qy(e.availability):void 0,union:u,encoding:o,source:e.source!=null?jhe(e.source):void 0,...e.discriminatorContext&&{context:e.discriminatorContext}}}}let s=[];for(let a of e.schemas)s.push(iu({schema:a,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:s,encoding:o,source:e.source!=null?jhe(e.source):void 0,inline:jRi(e,i)}}}var Qhf=/^[0-9]/;function Nhf(e){return Qhf.test(e)}function E_r({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?E_r({context:t,schema:n.schema,namespace:r}):e}function khf({typeReference:e,audiences:t,name:r,availability:n,propertyAccess:i}){return t.length===0&&r==null&&n==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{},...i!=null?{access:i}:{}}}function jRi(e,t){return e.inline===!0||t>0?!0:void 0}function Mhf(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return mm.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return mm.ObjectPropertyAccess.WriteOnly}}xi();function lCa(e){let t=e.replace(/^x-|^X-/,"");return $n(t)}function pCa(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??lCa(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(ds.of("__package__.yml"),{name:"OauthScope",schema:BDt(n.scopesEnum,0).schema})}}xi();function nY({header:e,context:t,fileContainingReference:r,namespace:n}){let i=iu({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),o=cp(i),s=e.name.replace(/^x-|^X-/,""),a=e.parameterNameOverride!=null?e.parameterNameOverride:$n(s);if(e.description==null&&e.name===a&&e.env==null&&e.availability==null)return o;let u={type:o};return a!==e.name&&(u.name=a),e.description!=null&&(u.docs=e.description),e.env!=null&&(u.env=e.env),e.availability!=null&&(u.availability=qy(e.availability)),u}function I_r({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=iu({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return cp(i);let o=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:cp(i)};return e.description!=null&&(o.docs=e.description),e.availability!=null&&(o.availability=qy(e.availability)),o}gg();function C_r({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=QRi({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let o=cp(i.value),s=ODt(i.value);o==="unknown"?o="string":o==="optional<unknown>"&&(o="optional<string>");let a={type:o};return s!=null&&(a.default=s),i.allowMultiple&&(a["allow-multiple"]=!0),e.explode!=null&&(a.explode=e.explode),e.description!=null&&(a.docs=e.description),e.parameterNameOverride!=null&&(a.name=e.parameterNameOverride),e.availability!=null&&(a.availability=qy(e.availability)),Lhf(i.value)&&i.value.validation!==void 0&&(a.validation=i.value.validation),a.default==null&&a["allow-multiple"]==null&&a.docs==null&&a.name==null&&a.availability==null&&a.validation==null&&a.explode==null?o:a}function QRi({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:iu({schema:ya.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:ds.of(vp),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,u]of Object.entries(i.value.schemas))u.type==="primitive"&&u.schema.type==="string"&&(s=!0),u.type==="literal"&&u.value.type==="string"&&(WXe.test(u.value.value)?o.push(u.value.value):o.push({value:u.value.value,name:$Xe(u.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&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(i.value.schemas.length===2){let[a,u]=i.value.schemas;if(a!=null&&u!=null&&w_r({array:a,primitive:u}))return{value:iu({schema:ya.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&w_r({array:u,primitive:a}))return{value:iu({schema:ya.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[a,u]of Object.entries(i.value.schemas))return QRi({schema:u,context:t,fileContainingReference:r,namespace:n})}else if(t.options.objectQueryParameters)return{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let i=e.type==="optional"?ya.optional:ya.nullable;if(e.value.type==="reference"){let o=t.getSchema(e.value.schema,n);if(o==null)return;if(o.type==="array")return{value:iu({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:o.value,description:e.description??o.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:iu({schema:i({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:n,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="primitive"&&u.schema.type==="string"&&(s=!0),u.type==="literal"&&u.value.type==="string"&&(WXe.test(u.value.value)?o.push(u.value.value):o.push({value:u.value.value,name:$Xe(u.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&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[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&w_r({array:a,primitive:u}))return{value:iu({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&w_r({array:u,primitive:a}))return{value:iu({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[a,u]of Object.entries(e.value.value.schemas))return QRi({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:iu({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:iu({schema:ya.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:n,declarationDepth:0}),allowMultiple:!0}:{value:iu({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function w_r({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function Lhf(e){return typeof e=="object"&&e!==null&&"type"in e}Nt();function fCa({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"]=Uhf(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=zhf({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Twe(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function Uhf(e){let t={};return e.forEach(r=>{let n=Twe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function zhf({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let o=Twe(i.value);r.has(i.name)||o!=null&&(n[i.name]=o)}),n}function Twe(e){switch(e.type){case"primitive":return dCa(e.value);case"object":return mCa(e.properties);case"array":return Vhf(e.value);case"map":return qhf(e.value);case"oneOf":return Ghf(e.value);case"enum":return e.value;case"literal":return Whf(e.value);case"unknown":return Twe(e.value);case"null":return null;default:xe(e)}}function dCa(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"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:xe(e)}}function mCa(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Twe(r)]))}function Vhf(e){return e.map(t=>Twe(t))}function qhf(e){return Object.fromEntries(e.map(t=>[dCa(t.key),Twe(t.value)]))}function Ghf(e){return e.type==="discriminated"?mCa(e.value):Twe(e.value)}function Whf(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:xe(e)}}function PDt(e){try{let r=new URL(e).pathname.split("/").filter(n=>n.length>0);if(r.length>0)return r[r.length-1]}catch{}}function __r(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function x_r(e,t,r=!1){let n=PDt(t);return r&&n!=null?n:e!=null&&n!=null?`${e}_${n}`:n??e??"websocket"}function Qhe(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function S_r(e,t){return t??(e?.groupName!=null?Qhe(e.groupName):void 0)}function hCa({channel:e,context:t,declarationFile:r}){let n=e.servers[0],i=n!=null?t.options.groupEnvironmentsByHost?t.getUrlId(n.url)??x_r(n.name,n.url,!0):n.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${n?.name}", server url="${n?.url}", resolved urlId="${i}" (from collision map: ${t.getUrlId(n?.url??"")!=null})`);let o=e.path;for(let p of e.handshake.pathParameters)p.parameterNameOverride!=null&&(o=o.replace(`{${p.name}}`,`{${p.parameterNameOverride}}`));let s={path:o,url:i,auth:!1};e.audiences!=null&&e.audiences.length>0&&(s.audiences=e.audiences),e.summary!=null&&(s["display-name"]=e.summary),e.connectMethodName!=null&&(s["connect-method-name"]=e.connectMethodName),e.description!=null&&(s.docs=e.description);let a=Qhe(e.groupName),u={};if(e.handshake.pathParameters.length>0)for(let p of e.handshake.pathParameters){let d=p.parameterNameOverride??p.name;u[d]=I_r({pathParameter:p,context:t,fileContainingReference:r,namespace:a})}Object.keys(u).length>0&&(s["path-parameters"]=u);let c={};if(e.handshake.queryParameters.length>0)for(let p of e.handshake.queryParameters){let d=C_r({queryParameter:p,context:t,fileContainingReference:r,namespace:a});d!=null&&(c[p.name]=d)}Object.keys(c).length>0&&(s["query-parameters"]=c);let l={};if(e.handshake.headers.length>0)for(let p of e.handshake.headers){let d=nY({header:p,context:t,fileContainingReference:r,namespace:a});l[p.name]=d}Object.keys(l).length>0&&(s.headers=l),t.builder.addChannel(r,{channel:s});for(let p of e.messages){let d={origin:p.origin,body:iu({schema:p.body,context:t,fileContainingReference:r,namespace:a,declarationDepth:0})};p.methodName!=null&&(d["method-name"]=p.methodName),t.builder.addChannelMessage(r,{messageId:p.name,message:d})}for(let p of e.examples){let d=fCa({context:t,websocketExample:p});t.builder.addChannelExample(r,{example:d})}}function NRi(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var KP="Base",yCa="Default";function gCa(e){try{return new URL(e).hostname}catch{return}}function ACa(e){return e??yCa}function $hf(e,t){let r=new Map;for(let n of e){if(NRi(n)||!("url"in n)||!n.url)continue;let i=gCa(n.url)??n.url;r.has(i)||r.set(i,{environmentName:ACa(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.httpServers.push({name:n.name,url:n.url,audiences:n.audiences})}for(let n of t){let i=gCa(n.url)??n.url;r.has(i)||r.set(i,{environmentName:ACa(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.websocketServers.push(n)}return r}function Pke(e){return Object.entries(e).reduce((t,[r,n])=>(wF(n)?Object.entries(n.urls).forEach(([i,o])=>{t[i]=o}):t[r]=typeof n=="string"?n:n.url,t),{})}function bCa(e){if(e.environmentOverrides!=null){for(let[b,I]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:b,schema:I});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=[],n=e.ir.servers.some(b=>NRi(b)),i=e.ir.servers;for(let b of i)if(NRi(b)){let I={urls:{}},w={},_={},C={};for(let[R,z]of Object.entries(b.urls))I.urls[R]=z.defaultUrl??z.url,z.urlTemplate&&(w[R]=z.urlTemplate),z.defaultUrl&&(_[R]=z.defaultUrl),z.variables&&z.variables.length>0&&(C[R]=z.variables);(Object.keys(w).length>0||Object.keys(C).length>0)&&(I["url-templates"]=w,I["default-urls"]=_,I.variables=C),b.name&&(t[b.name]=I)}else if("url"in b&&b.url){let w=b.urlTemplate!=null&&b.variables!=null&&b.variables.length>0?{url:b.url,audiences:b.audiences,"default-url":b.defaultUrl,"url-template":b.urlTemplate,variables:b.variables?.map(_=>({id:_.id,default:_.default,values:_.values}))}:b.audiences?{url:b.url,audiences:b.audiences}:b.url;if(b.name==null){r.push(w);continue}t[b.name]=w}let o={},s={},a=[],u={},c={},l={};for(let b of e.ir.endpoints)for(let I of b.servers){if(I.url==null&&I.name!=null){o[I.name]||(o[I.name]=[]);continue}if(I.url==null)continue;let w=I,_="defaultUrl"in I&&typeof w.defaultUrl=="string"?w.defaultUrl:void 0,C="urlTemplate"in I&&typeof w.urlTemplate=="string"?w.urlTemplate:void 0,x="variables"in I&&Array.isArray(w.variables)?w.variables:void 0,R=_??I.url,z=I.audiences?{url:R,audiences:I.audiences}:R;if(I.name==null){a.push(z);continue}o[I.name]||(o[I.name]=[]),o[I.name]?.push({url:R,audiences:I.audiences}),s[I.name]=z,C&&I.name&&(u[I.name]=C),_&&I.name&&(c[I.name]=_),x&&x.length>0&&I.name&&(l[I.name]=x)}let p={},d=[];for(let b of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${b.name}", url="${b.url}"`);let I=b.audiences?{url:b.url,audiences:b.audiences}:b.url;if(b.name==null){d.push(I);continue}p[b.name]=I}let f=Object.keys(t).length,m=f>0,h=Object.keys(s).length>0,A=Object.keys(o).some(b=>o[b]?.length===0),y=Object.keys(p).length>0;if(e.options.groupEnvironmentsByHost&&y&&(m||e.ir.servers.length>0)){let b=Object.entries(p).map(([w,_])=>({name:w,url:typeof _=="string"?_:_.url,audiences:typeof _=="string"?void 0:_.audiences})),I=$hf(i,b);if(I.size>0){let w=!0;for(let[_,C]of I.entries()){let x={},R=[...C.httpServers.map(U=>({...U,isHttp:!0})),...C.websocketServers.map(U=>({...U,isHttp:!1}))],z=new Map;for(let U of R){let q=PDt(U.url),te=__r(U.url);q&&te&&(z.has(q)||z.set(q,new Set),z.get(q)?.add(te))}if(C.httpServers.length>0){let U=C.httpServers[0];U!=null&&(x[KP]=U.url,e.setUrlId(U.url,KP));for(let q=1;q<C.httpServers.length;q++){let te=C.httpServers[q];if(te!=null){let ie=PDt(te.url),V=__r(te.url),K=ie?z.get(ie):void 0,Ee=K&&K.size>1,H=Ee&&V!=="https"?`${ie}_${V}`:ie||`Http${q+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${te.url}", pathSegment="${ie}", protocol="${V}", hasCollision=${Ee}, urlId="${H}"`),x[H]=te.url,e.setUrlId(te.url,H)}}}for(let U of C.websocketServers){let q=PDt(U.url),te=__r(U.url),ie=q?z.get(q):void 0,V=ie&&ie.size>1,K=V?`${q}_${te}`:x_r(U.name,U.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${U.name}", url="${U.url}", pathSegment="${q}", protocol="${te}", hasCollision=${V}, urlId="${K}"`),x[K]=U.url,e.setUrlId(U.url,K)}if(Object.keys(x).length>1)e.builder.addEnvironment({name:C.environmentName,schema:{urls:x}});else if(Object.keys(x).length===1){let U=Object.values(x)[0];U!=null&&e.builder.addEnvironment({name:C.environmentName,schema:U})}w&&(e.builder.setDefaultEnvironment(C.environmentName),Object.keys(x).length>1&&e.builder.setDefaultUrl(KP),w=!1)}return}}if(!m&&!h&&y&&e.ir.servers.length===0){for(let[b,I]of Object.entries(p))e.builder.addEnvironment({name:b,schema:I});e.builder.setDefaultEnvironment(Object.keys(p)[0]),e.builder.setDefaultUrl(KP);return}if(a.length>0&&e.logger.debug(`Skipping endpoint level servers ${a.map(b=>typeof b=="string"?b:b.url).join(", ")} because x-fern-server-name was not provided.`),!m){let b=e.ir.servers[0],I=b?.url,w=b?.audiences,_=b?.defaultUrl,C=b?.urlTemplate,x=b?.variables;if(I!=null){let z=C!=null&&x!=null&&x.length>0?{url:I,audiences:w,"default-url":_,"url-template":C,variables:x?.map(U=>({id:U.id,default:U.default,values:U.values}))}:w?{url:I,audiences:w}:I;t[yCa]=z}}let v=Object.values(t).map(b=>typeof b=="string"?b:wF(b)?Object.values(b.urls)[0]:b.url),E=r.filter(b=>{let I=typeof b=="string"?b:b.url;return!v.includes(I)});if(E.length>0&&e.logger.debug(`Skipping top level servers ${E.map(b=>typeof b=="string"?b:b.url).join(", ")} because x-fern-server-name was not provided.`),n){let b=!0;for(let[I,w]of Object.entries(t))if(e.builder.addEnvironment({name:I,schema:w}),b){if(e.builder.setDefaultEnvironment(I),wF(w)){let _=Object.keys(w.urls)[0];_&&e.builder.setDefaultUrl(_)}b=!1}return}if(!h&&!A){let b=!0;for(let[I,w]of Object.entries(t))if(b){if(y){let _=typeof w=="string"?w:wF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;e.builder.addEnvironment({name:I,schema:{urls:{[KP]:_??"",...Pke(p)}}})}else e.builder.addEnvironment({name:I,schema:w});e.builder.setDefaultEnvironment(I),b=!1}else if(y){let _=typeof w=="string"?w:wF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;e.builder.addEnvironment({name:I,schema:{urls:{[KP]:_??"",...Pke(p)}}})}else e.builder.addEnvironment({name:I,schema:w});y&&e.builder.setDefaultUrl(KP)}else if(f===1){let b=Object.keys(t)[0],I=Object.values(t)[0],w=typeof I=="string"?I:wF(I)?Object.values(I.urls)[0]:I["default-url"]??I.url,_={},C={},x={};typeof I!="string"&&!wF(I)&&(I["url-template"]&&(_[KP]=I["url-template"]),I["default-url"]&&(C[KP]=I["default-url"]),I.variables&&I.variables.length>0&&(x[KP]=I.variables)),Object.assign(_,u),Object.assign(C,c),Object.assign(x,l);let R=Object.keys(_).length>0||Object.keys(x).length>0,z={urls:{[KP]:w??"",...Pke(s),...Pke(p)},...R?{"url-templates":_,"default-urls":C,variables:x}:{}};e.builder.addEnvironment({name:b,schema:z}),e.builder.setDefaultEnvironment(b),e.builder.setDefaultUrl(KP)}else{let b=new Map;for(let I of e.ir.endpoints)for(let w of I.servers)if(w.url!=null&&w.name!=null){b.has(w.name)||b.set(w.name,new Map);let _=w.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",C=b.get(w.name);C&&C.set(_,w.url)}if(b.size>0){let I=!0;for(let[w,_]of Object.entries(t)){let C=typeof _=="string"?_:wF(_)?Object.values(_.urls)[0]:_["default-url"]??_.url;if(!C)continue;let x=C.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",R={[KP]:C};for(let[z,U]of b.entries()){let q=U.get(x)||U.get("production")||U.values().next().value;q&&(R[z]=q)}y&&Object.assign(R,Pke(p)),Object.keys(R).length>1?e.builder.addEnvironment({name:w,schema:{urls:R}}):e.builder.addEnvironment({name:w,schema:C}),I&&(e.builder.setDefaultEnvironment(w),I=!1)}b.size>0&&e.builder.setDefaultUrl(KP)}else{let I=!0;for(let[w,_]of Object.entries(t)){if(y||Object.keys(s).length>0){let C=typeof _=="string"?_:wF(_)?Object.values(_.urls)[0]:_["default-url"]??_.url;e.builder.addEnvironment({name:w,schema:{urls:{[KP]:C??"",...Pke(s),...Pke(p)}}})}else e.builder.addEnvironment({name:w,schema:_});I&&(e.builder.setDefaultEnvironment(w),I=!1)}}}}gg();xi();var kRi=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},Hhf=.75,Khf=new Set(["authorization"]);function vCa(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let o=n.schema?Fhe(n.schema):void 0,s=o!=null?Qhe(o):void 0,a=ds.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?cp(iu({schema:n.schema,context:e,fileContainingReference:s?f0(ds.of($n(s)),a):a,namespace:s,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.options.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let o of i.headers){if(Khf.has(o.name.toLowerCase()))continue;let s=r[o.name];if(s==null){let a=t[o.name],u=nY({header:{...o,schema:a?.schema??o.schema,name:a?.name??o.name},fileContainingReference:ds.of(w0),context:e,namespace:void 0});s=new kRi(u),r[o.name]=s}s.increment()}let n=e.ir.endpoints.length*Hhf;for(let[i,o]of Object.entries(r)){let s=t[i],a=o.count===e.ir.endpoints.length,u=o.count>=n;s==null&&(a?e.builder.addGlobalHeader({name:i,schema:o.schema}):u&&e.builder.addGlobalHeader({name:i,schema:Bke(o.schema)}))}}}gg();function ECa(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?Fhe(t.schema):void 0,n=r!=null?Qhe(r):void 0,i=nY({header:{...t,schema:t.schema??ya.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Wc.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:ds.of(w0),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Bke(i)})}}Nt();gg();Nt();Nt();function uO(e){switch(e.type){case"primitive":return wCa(e.value);case"object":return CCa(e.properties);case"array":return _Ca(e.value);case"map":return Yhf(e.value);case"oneOf":return Xhf(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return Zhf(e.value);case"unknown":return uO(e.value);case"null":return null;default:xe(e)}}function ICa(e){switch(e.type){case"withStreaming":return e.sse?{stream:Jhf(e.events)}:{stream:_Ca(e.events)};case"withoutStreaming":return{body:uO(e.value)};default:xe(e)}}function wCa(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"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:xe(e)}}function CCa(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,uO(r)]))}function Jhf(e){return e.map(t=>({event:"",data:uO(t)}))}function _Ca(e){return e.map(t=>uO(t))}function Yhf(e){return Object.fromEntries(e.map(t=>[wCa(t.key),uO(t.value)]))}function Xhf(e){return e.type==="discriminated"?CCa(e.value):uO(e.value)}function Zhf(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:xe(e)}}function xCa({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"]=egf(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=tgf(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),o=Object.keys(i).length>0,s=new Set(e.headers?.map(a=>a.name)??[]);if(n||o){let a=[];if(e.headers!=null)for(let u of e.headers)u.name!==t.builder.getAuthHeaderName()&&a.push(u);for(let[u,c]of Object.entries(i)){if(c!=null&&typeof c=="object"&&c.type!=null){let l=_v({type:c.type,_default:void 0,validation:void 0,visitor:{primitive:pt,map:pt,list:pt,optional:p=>p,nullable:p=>p,set:pt,named:pt,literal:p=>{if(p.type==="string")return p.string;if(p.type==="boolean")return p.boolean.toString()},unknown:pt}});if(l!=null){let p=a.findIndex(f=>f.name===u),d={name:u,value:nu.literal(Ewe.string(l))};p>=0?a[p]=d:a.push(d);continue}}s.has(u)||a.push({name:u,value:nu.primitive(ms.string(u))})}r.headers=rgf({context:t,namedFullExamples:a})}return e.request!=null&&(r.request=uO(e.request)),e.response!=null&&(r.response=ICa(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(a=>a.type==="language"?{name:a.name??void 0,docs:a.description??void 0,language:a.language,code:a.code,install:a.install??void 0}:{name:a.name??void 0,docs:a.description??void 0,sdk:a.sdk,code:a.code}).filter(Ca)),r}function egf(e){let t={};return e.forEach(r=>{let n=uO(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function tgf(e){let t={};return e.forEach(r=>{let n=uO(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function rgf({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=uO(n.value);i!=null&&(r[n.name]=i)}),r}function SCa(e){return LC._visit(e,{get:()=>mm.HttpMethodSchema.Get,post:()=>mm.HttpMethodSchema.Post,put:()=>mm.HttpMethodSchema.Put,patch:()=>mm.HttpMethodSchema.Patch,delete:()=>mm.HttpMethodSchema.Delete,head:()=>mm.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 OCa(e){return e==="POST"||e==="PUT"||e==="PATCH"}function BCa({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],o=new Set,s=e.path,a=S_r(e.sdkName,e.namespace),u={};for(let A of e.pathParameters)A.parameterNameOverride&&(s=s.replace(A.name,A.parameterNameOverride)),u[A.parameterNameOverride??A.name]=I_r({pathParameter:A,context:r,fileContainingReference:t,namespace:a}),o.add(A.name);let c={};for(let A of e.queryParameters){let y=C_r({queryParameter:A,context:r,fileContainingReference:t,namespace:a});y!=null&&(c[A.name]=y,o.add(A.name))}let l;if(e.pagination!=null)switch(e.pagination.type){case"cursor":l={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":l={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":l={type:"custom",results:e.pagination.results};break;case"uri":l={next_uri:e.pagination.nextUri,results:e.pagination.results};break;case"path":l={next_path:e.pagination.nextPath,results:e.pagination.results};break;default:xe(e.pagination)}let p={path:s,method:SCa(e.method),auth:ngf({endpoint:e,context:r}),docs:e.description??void 0,pagination:l,source:e.source!=null?jhe(e.source):void 0};!agf({context:r,request:e.request})&&Object.keys(u).length>0&&(p["path-parameters"]=u),e.summary!=null&&(p["display-name"]=e.summary);let d={},f=r.builder.getGlobalHeaderNames(),m=r.builder.getAuthHeaderName();m!=null&&f.add(m);let h=e.headers.filter(A=>!f.has(A.name));for(let A of h){let y=nY({header:A,context:r,fileContainingReference:t,namespace:a});d[A.name]=y,o.add(typeof y=="string"?A.name:y.name??A.name)}if(e.request!=null){r.setInState(pw.Request);let A=sgf({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(u).length>0?u:void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(d).length>0?d:void 0,usedNames:o,namespace:a});p.request=A.value,i=[...i,...A.schemaIdsToExclude??[]],r.unsetInState(pw.Request)}else{let A=r.options.inlinePathParameters&&Object.keys(u).length>0,y=Object.keys(c).length>0,v=Object.keys(d).length>0,E={};(A||y||v)&&(E.name=e.requestNameOverride??e.generatedRequestName),A&&(E["path-parameters"]=u),y&&(E["query-parameters"]=c),v&&(E.headers=d),Object.keys(E).length>0&&(p.request=E)}if(e.response!=null&&e.response._visit({json:A=>{let y=iu({schema:A.schema,context:r,fileContainingReference:t,namespace:a,declarationDepth:0});p.response={docs:A.description??void 0,type:cp(y)},A.statusCode!=null&&(p.response["status-code"]=A.statusCode),A.responseProperty!=null&&(p.response.property=A.responseProperty)},streamingJson:A=>{let y=iu({schema:A.schema,context:r,fileContainingReference:t,namespace:a,declarationDepth:0});p["response-stream"]={docs:A.description??void 0,type:cp(y),format:"json",terminator:A.terminator??void 0}},streamingSse:A=>{let y=iu({schema:A.schema,context:r,fileContainingReference:t,namespace:a,declarationDepth:0});p["response-stream"]={docs:A.description??void 0,type:cp(y),format:"sse",terminator:A.terminator??void 0}},file:A=>{p.response={docs:A.description??void 0,type:"file","status-code":A.statusCode}},bytes:A=>{p.response={docs:A.description??void 0,type:"bytes","status-code":A.statusCode}},streamingText:A=>{p["response-stream"]={docs:A.description??void 0,type:"text"}},text:A=>{p.response={docs:A.description??void 0,type:"text","status-code":A.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let A=r.getDefaultServerName(),y=e.servers[0];y==null?A!=null&&(p.url=A):p.url=y.name??void 0}return e.idempotent&&(p.idempotent=!0),e.availability!=null&&(p.availability=qy(e.availability)),Object.entries(e.errors).forEach(([A,y])=>{let v=y.generatedName,E=ds.of(vp);r.builder.enableUniqueErrorsPerEndpoint&&(v=`${e.generatedRequestName}${y.generatedName}`,y.schema!=null&&(y.schema.type!=="reference"&&y.schema.type!=="oneOf"?y.schema.generatedName=`${e.generatedRequestName}${y.schema.generatedName}`:y.schema.type==="oneOf"&&(y.schema.value.generatedName=`${e.generatedRequestName}${y.schema.value.generatedName}`)));let b={"status-code":parseInt(A)},I=eCa({location:PCa,namespaceOverride:a});if(y.schema!=null){let C=iu({schema:y.schema,context:r,fileContainingReference:I,declarationFile:I,namespace:a,declarationDepth:0});b.type=cp(C),b.docs=y.description}r.builder.addError(I,{name:v,schema:r.isErrorUnknownSchema(parseInt(A))?{...b,type:"unknown"}:b}),p.errors==null&&(p.errors=[]);let w=r.builder.addImport({file:t,fileToImport:I});p.errors.push(w!=null?`${w}.${v}`:v),b.type!=null&&y.examples?.forEach(C=>{let x={value:uO(C.example),name:C.name,docs:C.description};r.builder.addErrorExample(I,{name:v,example:x})})}),e.examples.length>0&&(p.examples=igf({endpointExamples:e.examples,context:r})),e.retries!=null&&(p.retries=ogf({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?p.audiences=[MRi,...e.audiences]:e.audiences.length>0&&(p.audiences=e.audiences),{value:p,schemaIdsToExclude:i}}function ngf({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 igf({endpointExamples:e,context:t}){return e.map(r=>{try{return xCa({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function ogf({retries:e}){if(e!=null){if(e.type==="disabled")return{disabled:e.value??void 0};xe(e)}}function sgf({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:o,pathParameters:s,queryParameters:a,nonRequestReferencedSchemas:u,headers:c,usedNames:l,namespace:p}){if(n.type==="json"||n.type==="formUrlEncoded"){let d=n.schema.type==="reference"?n.schema.schema:void 0,f=n.schema.type==="reference"?r.getSchema(n.schema.schema,p):n.schema;if(f?.type!=="object"||d!=null&&u.includes(d)){let I=iu({schema:n.schema,fileContainingReference:t,context:r,namespace:p,declarationDepth:0}),w={schemaIdsToExclude:[],value:{body:I}},_=Object.keys(s??{}).length>0,C=Object.keys(a??{}).length>0,x=Object.keys(c??{}).length>0;return _&&(w.value["path-parameters"]=s),C&&(w.value["query-parameters"]=a),x&&(w.value.headers=c),(_||C||x)&&(w.value.name=i??o),n.contentType!=null&&(w.value["content-type"]=n.contentType),n.description!=null&&(w.value.docs=n.description),w}let m=new Map;for(let I of f.allOf){let w=r.getSchema(I.schema,p);if(w==null)continue;let _=Fhe(w),C=Rhe(_),{properties:x}=JXe(r,I.schema,p);for(let R of x)m.set(R.key,C)}let h=Object.fromEntries(f.properties.filter(I=>I.readonly==null?!0:!(OCa(e.method)&&I.readonly)).map(I=>{let w=m.get(I.key)??t,_=iu({schema:I.schema,fileContainingReference:t,declarationFile:w,context:r,namespace:p,declarationDepth:1}),C=I.nameOverride??I.key,x=qy(I.availability);if(!l.has(C)&&I.audiences.length<=0)return l.add(C),I.nameOverride!=null?[I.key,{type:cp(_),docs:HXe(_),name:I.nameOverride,availability:x}]:[I.key,x?{...typeof _=="string"?{type:_}:_,availability:x}:_];let R={type:cp(_),docs:HXe(_)};return l.has(C)&&(R.name=I.generatedName),I.audiences.length>0&&(R.audiences=I.audiences),x!=null&&(R.availability=x),l.add(C),[I.key,R]})),A=new Set,y=new Set;for(let I of f.allOfPropertyConflicts)I.allOfSchemaIds.forEach(w=>A.add(w)),I.conflictingTypeSignatures&&y.add(I.propertyKey);let v=[];for(let I of f.allOf){let w=E_r({schema:I.schema,context:r,namespace:p});if(w==null||A.has(I.schema)||A.has(w))continue;let _=iu({schema:ya.reference(I),fileContainingReference:t,context:r,namespace:p,declarationDepth:0}),C=KXe(cp(_));C!=="unknown"&&v.push(C)}for(let I of A){let w=JXe(r,I,p),_=r.getSchema(I,p),C=_!=null?Rhe(Fhe(_)):t;for(let x of w.properties)h[x.key]==null&&(y.has(x.key)?h[x.key]="unknown":h[x.key]=iu({schema:x.schema,fileContainingReference:t,declarationFile:C,context:r,namespace:p,declarationDepth:1}));for(let x of w.allOf){if(A.has(x.schema))continue;let R=iu({schema:ya.reference(x),fileContainingReference:t,context:r,namespace:p,declarationDepth:0}),z=KXe(cp(R));z!=="unknown"&&!v.includes(z)&&v.push(z)}}let E={properties:h};v.length>0&&(E.extends=v),n.additionalProperties&&(E["extra-properties"]=!0);let b={name:i??f.nameOverride??f.generatedName,"path-parameters":s,"query-parameters":a,headers:c,body:E};return n.contentType!=null&&(b["content-type"]=n.contentType),n.description!=null&&(b.docs=n.description),{schemaIdsToExclude:d!=null?[d]:[],value:b}}else if(n.type==="octetStream"){let d={body:"bytes","content-type":n.contentType??wf.APPLICATION_OCTET_STREAM,"query-parameters":a};return a!=null&&(d.name=i??o),n.description!=null&&(d.docs=n.description),{schemaIdsToExclude:[],value:d}}else if(n.type==="multipart"){let d=Object.fromEntries(n.properties.map(f=>{if(f.schema.type==="file"){let m=f.schema.isArray?"list<file>":"file";if(m=f.schema.isOptional?`optional<${m}>`:m,f.description!=null||f.contentType!=null){let h={type:m};if(f.description!=null&&(h.docs=f.description),f.contentType!=null){let A=f.contentType.split(",")[0];h["content-type"]=A}return[f.key,h]}return[f.key,m]}else{let m=iu({schema:f.schema.value,fileContainingReference:t,context:r,namespace:p,declarationDepth:1});if(f.contentType||f.exploded||f.encoding){let h=typeof m=="string"?{type:m}:m;f.contentType!=null&&(h["content-type"]=f.contentType),f.encoding==="form"?h.style="form":f.encoding==="json"?h.style="json":f.exploded&&(h.style="exploded"),m=h}return[f.key,m]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??o,"path-parameters":s,"query-parameters":a,headers:c,body:{properties:d},"content-type":wf.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else xe(n)}function agf({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:xe(t)}}gg();xi();function ugf({location:e,namespaceOverride:t}){return t!=null?{...e,file:f0(ds.of(t),e.file)}:e}function cgf(e){let t=e.namespace,r=e.tags.filter(u=>u!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:ds.of(`${$n(r)}.yml`),endpointId:e.summary!=null?$n(e.summary):$n(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:ds.of(vp),endpointId:$n(e.summary)}:{file:ds.of(vp),endpointId:$n(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:ds.of(vp),endpointId:n};let i=TDt(r),o=TDt(n);if(m0(i,o))return{file:ds.of("__package__.yml"),endpointId:r};let s=fgf({operationId:n,tag:r,path:e.path,method:e.method});if(s!=null)return s;let a=[];for(let u=0;u<i.length;++u){let c=i[u];if(c!=null&&c===o[u])a.push(c);else{let l=$n(r);return{file:ds.of(`${l}.yml`),endpointId:n,tag:r}}}if(a.length>=o.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:ds.of($n(a.join("_"))+".yml"),endpointId:$n(o.slice(a.length).join("_")),tag:r}}function DDt(e){let t=e.tags[0];if(e.sdkName!=null){let r=wRi({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:ds.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return ugf({namespaceOverride:e.namespace,location:cgf(e)})}function TDt(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=x4(t),t}var lgf=new RegExp("[^a-zA-Z0-9{}]+"),pgf=new RegExp("[{}]","g");function fgf({operationId:e,tag:t,path:r,method:n}){let o=`${r.split(lgf).join("_").replaceAll(pgf,"_")}_${n.toLowerCase()}`;if(e.endsWith(o))return{file:ds.of($n(t)+".yml"),endpointId:$n(e.slice(0,-1*o.length)),tag:t}}function TCa(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let o of r){let{endpointId:s,file:a,tag:u}=DDt(o),c=a.split(".")[0];c!=null&&t.add(c);let l;if(o.sdkName!=null){let f=e.ir.groups;for(let m of o.sdkName.groupName){let h=typeof m=="string"?m:m.name,A=f[h];if(A==null)break;if(A.summary!=null||A.description!=null){l=f[h];break}}}let p=u==null?void 0:n.tagsById[u];e.setInState(pw.Endpoint),e.setEndpointMethod(o.method);let d=BCa({context:e,endpoint:o,declarationFile:a});e.unsetEndpointMethod(),e.unsetInState(pw.Endpoint),i=[...i,...d.schemaIdsToExclude],e.builder.addEndpoint(a,{name:s,schema:d.value,source:o.source!=null?jhe(o.source):void 0}),(p?.id!=null||p?.description!=null)&&e.builder.setServiceInfo(a,{"display-name":l?.summary??p?.id,docs:l?.description??p?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}gg();function DCa(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?Qhe(r.groupName):void 0,i=iu({schema:ya.primitive(r),context:e,fileContainingReference:ds.of(vp),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:cp(i),docs:r.description??void 0}})}}gg();xi();function jCa(e){for(let t of e.ir.webhooks){let r=hgf({webhook:t,context:e});if(r==null)continue;let n=S_r(t.sdkName,t.namespace),i={};for(let s of t.headers)i[s.name]=nY({header:s,context:e,fileContainingReference:r.file,namespace:n});let o={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:iu({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),signature:ggf(t.signatureVerification),examples:t.examples!=null?t.examples.map(s=>({docs:s.description,name:s.name,payload:uO(s.payload)})):void 0};t.response!=null&&t.response._visit({json:s=>{let a=iu({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o.response={docs:s.description??void 0,type:cp(a)},s.statusCode!=null&&(o.response["status-code"]=s.statusCode)},file:s=>{o.response={docs:s.description??void 0,type:"file","status-code":s.statusCode}},bytes:s=>{o.response={docs:s.description??void 0,type:"bytes","status-code":s.statusCode}},text:s=>{o.response={docs:s.description??void 0,type:"text","status-code":s.statusCode}},streamingJson:s=>{let a=iu({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:cp(a),format:"json"}},streamingSse:s=>{let a=iu({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:cp(a),format:"sse"}},streamingText:s=>{o["response-stream"]={docs:s.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:o}),t.description!=null&&(o.docs=t.description)}}function dgf({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:f0(ds.of(t),e.file)}:e}function mgf({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:ds.of(vp),endpointId:n};let i=TDt(r),o=TDt(n);if(m0(i,o))return{file:ds.of("__package__.yml"),endpointId:r};let s=[];for(let a=0;a<i.length;++a){let u=i[a];if(u!=null&&u===o[a])s.push(u);else{let c=$n(r);return{file:ds.of(`${c}.yml`),endpointId:n,tag:r}}}if(s.length>=o.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:ds.of($n(s.join("_"))+".yml"),endpointId:$n(o.slice(s.length).join("_")),tag:r}}function hgf({webhook:e,context:t}){return e.sdkName!=null?{file:Zwa({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:dgf({namespaceOverride:e.namespace,location:mgf({webhook:e,context:t})})}function ggf(e){if(e!=null)switch(e.type){case"hmac":return{type:"hmac",header:e.header,algorithm:Agf(e.algorithm),encoding:RCa(e.encoding),"signature-prefix":e.signaturePrefix,"payload-format":bgf(e.payloadFormat),timestamp:FCa(e.timestamp)};case"asymmetric":return{type:"asymmetric",header:e.header,"asymmetric-algorithm":ygf(e.asymmetricAlgorithm),encoding:RCa(e.encoding),"signature-prefix":e.signaturePrefix,"jwks-url":e.jwksUrl,"key-id-header":e.keyIdHeader,timestamp:FCa(e.timestamp)};default:return}}function Agf(e){if(e!=null)switch(e){case"sha256":return"sha256";case"sha1":return"sha1";case"sha384":return"sha384";case"sha512":return"sha512";default:return}}function RCa(e){if(e!=null)switch(e){case"base64":return"base64";case"hex":return"hex";default:return}}function ygf(e){switch(e){case"rsa-sha256":return"rsa-sha256";case"rsa-sha384":return"rsa-sha384";case"rsa-sha512":return"rsa-sha512";case"ecdsa-sha256":return"ecdsa-sha256";case"ecdsa-sha384":return"ecdsa-sha384";case"ecdsa-sha512":return"ecdsa-sha512";case"ed25519":return"ed25519";default:return"rsa-sha256"}}function bgf(e){if(e!=null)return{components:e.components.map(vgf),delimiter:e.delimiter}}function vgf(e){switch(e){case"body":return"body";case"timestamp":return"timestamp";case"notification-url":return"notification-url";case"message-id":return"message-id";default:return"body"}}function Egf(e){switch(e){case"unix-seconds":return"unix-seconds";case"unix-millis":return"unix-millis";case"iso8601":return"iso8601";default:return}}function FCa(e){if(e!=null)return{header:e.header,format:e.format!=null?Egf(e.format):void 0,tolerance:e.tolerance}}var MRi="external",PCa=ds.of(vp);function QCa({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){if(n.options.respectReadonlySchemas)for(let[i,o]of Object.entries(e)){if(t.includes(i)||o.type!=="object")continue;let s=o.nameOverride??o.generatedName;if(o.properties.some(u=>u.readonly)){let u=`${s}Read`;n.setSchemaFinalName(s,u)}}for(let[i,o]of Object.entries(e)){if(t.includes(i))continue;let s=tCa(o),a=aCa({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0});if(ZIe(a.schema)){let u=cp(a.schema);if(u===(a.name??i)||u===`optional<${a.name??i}>`||u===`nullable<${a.name??i}>`||u===`optional<nullable<${a.name??i}>>`)continue}n.builder.addType(s,{name:a.name??i,schema:a.schema})}}function NCa(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),bCa(e),vCa(e),ECa(e),pCa(e),DCa(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(MRi);let t=TCa(e),r=t.sdkGroups;e.setInState(pw.Webhook),jCa(e),e.unsetInState(pw.Webhook),e.setInState(pw.Channel);for(let i of Object.values(e.ir.channels)){let o=Rhe(i.groupName);hCa({channel:i,context:e,declarationFile:o})}e.unsetInState(pw.Channel);let n=Igf({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});QCa({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,o]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))QCa({schemas:o,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(o=>r.has(o))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function Igf({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(o=>Object.keys(o))]),i=new Set(t);for(let o of n)r.includes(o)||i.add(o);return Array.from(i)}Nt();var RDt=class{context;constructor(t){this.context=t}};gg();xi();gg();var O_r=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[s,a]of Object.entries(n.files)){let u=i!=null?ds.of(`${i}${"/"}${s}`):ds.of(s);t[u]=a}let o=Object.keys(n.directories).sort();for(let s of o){let a=i!=null?`${i}${"/"}${s}`:s,u=n.directories[s];r(u,a)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ds.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var Tke=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new O_r,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":n,"display-name":i,docs:o}){let s=this.getOrCreateFile(t);s.service==null&&(s.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(s.service.auth=r),n!=null&&(s.service["base-path"]=n),i!=null&&(s.service["display-name"]=i),o!=null&&(s.docs=o)}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 kJ(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 n of Object.values(this.rootApiFile["auth-schemes"]))kCa(n)&&t.push(n.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(kCa(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}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:n}){if(t===r)return;let i=n??$n((v4(r)+"/"+F1(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===ds.of(w0))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=e7e(v4(ZGe.of(`/${t}`)),ZGe.of(`/${r}`)),i;let o=this.getOrCreateFile(t);return o.imports==null&&(o.imports={}),o.imports[i]=e7e(v4(ZGe.of(`/${t}`)),ZGe.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===ds.of(w0))return;let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let o=i.types[r];o!=null&&(typeof o=="string"?i.types[r]={type:o,examples:[n]}:(o.examples==null&&(o.examples=[]),o.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let o=i.errors[r];if(o==null)return;o.examples==null&&(o.examples=[]),(o.examples.some(a=>m0(a,n))??!1)||o.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(o.service.source=i),o.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=f0(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let n=Object.values(r.service.endpoints);if(n.length===0)continue;if(n.every(o=>o.auth===!0)){r.service.auth=!0;for(let o of Object.values(r.service.endpoints))delete o.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(([i,o])=>[i,{...o,path:f0(r,o.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([o,s])=>[o,{...s,path:f0(r,s.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===vp?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 kCa(e){return e?.header!=null}var B_r=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;schemaNameMapping=new Map;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:o,authOverrides:s}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=s,this.globalHeaderOverrides=o,this.options=_ke({options:n}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new Tke(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let a={};if(!this.enableUniqueErrorsPerEndpoint)for(let u of r.endpoints)for(let[c,l]of Object.entries(u.errors)){let p=parseInt(c),d=a[p];d==null&&l.schema!=null?a[p]=l.schema:d!=null&&l.schema!=null&&jF(d,l.schema)||this.unknownSchema.add(p)}}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(pw.Channel,pw.Endpoint,pw.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:xe(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undiscriminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:xe(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}setSchemaFinalName(t,r){this.schemaNameMapping.set(t,r)}getSchemaFinalName(t){return this.options.respectReadonlySchemas?this.schemaNameMapping.get(t)??t:t}};function LRi(e){let t=new B_r(e);return NCa(t)}gg();xi();function wgf(e,t){return j2e(e,{single:r=>[typeof r=="string"?r:r.scheme],any:r=>r.any.map(n=>typeof n=="string"?n:n.scheme),endpointSecurity:()=>t!=null?Object.keys(t):[]})}function Cgf(e,t){if(e==null)return;let r=wgf(t,e),n={};for(let i of r)e[i]!=null&&(n[i]=e[i]);return Object.keys(n).length>0?n:void 0}var P_r=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let n=this.args.generatorsConfiguration?.api?.["auth-schemes"],i=this.args.generatorsConfiguration?.api?.auth,o=t??i;if(o==null)return;let s=r!=null||n!=null?{...n,...r}:void 0,a=Cgf(s,o);return{auth:o,"auth-schemes":a}}convert({context:t,ir:r,settings:n,absoluteFilePath:i}){let o=LRi({taskContext:t,ir:r,options:_ke({options:n,overrides:this.args}),authOverrides:this.buildAuthOverrides(n?.auth,n?.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:i??this.args.absoluteFilePath,rootApiFile:{defaultUrl:o.rootApiFile["default-url"],contents:o.rootApiFile,rawContents:Tr.dump(o.rootApiFile)},namedDefinitionFiles:{...Ql(o.definitionFiles,s=>({absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Tr.dump(s),contents:s})),[ds.of(vp)]:{absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Tr.dump(o.packageMarkerFile),contents:o.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var FDt=class extends Lq{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;coerceEnumsToLiterals;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;defaultIntegerFormat;pathParameterOrder;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.pathParameterOrder=t.pathParameterOrder,this.converter=new P_r(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:n},i){let o=await this.getOpenAPIIr({context:t,relativePathToDependency:n},i);return this.converter.convert({context:t,ir:o,settings:i,absoluteFilePath:r})}async toFernWorkspace({context:t},r,n){let i=await this.getDefinition({context:t},r);return new OF({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};var xS={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 YXe={of(e){return e}};var MCa={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},URi={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:MCa,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},bn={SOURCE:YXe.of("source"),SDK_NAMESPACE:YXe.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:YXe.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:YXe.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:YXe.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",WEBHOOK_SIGNATURE:"x-fern-webhook-signature",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",DISCRIMINATOR_CONTEXT:"x-fern-discriminator-context"};var _gf={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:yn.RemoveDiscriminantsFromSchemas.Always,defaultIntegerFormat:yn.DefaultIntegerFormat.Int32,pathParameterOrder:yn.PathParameterOrder.UrlOrder,resolveSchemaCollisions:!1};function xgf(e){let{defaults:t,options:r,overrides:n,overrideOnly:i=new Set,undefinedIfAbsent:o=new Set}=e,s={};for(let a of Object.keys(t))i.has(a)?s[a]=n?.[a]!==void 0?n[a]:t[a]:o.has(a)?s[a]=n?.[a]!==void 0?n[a]:r?.[a]!==void 0?r[a]:void 0:s[a]=n?.[a]??r?.[a]??t[a];return s}function ML({options:e,overrides:t}){return xgf({defaults:_gf,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}Nt();var LCa={naming:"v1"};xi();xi();function qr(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function jDt(e,t,r,n,i=[]){try{let o=qr(e,t);if(o!=null)return r.parse(o)}catch{let s=x4(i).join(" -> ");n.error(`${s.length>0?`${s}: `:""}Failed to parse ${t}`)}}function Dke(e){let t=qr(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 UCa({schema:e,logger:t}){return qr(e,bn.ENCODING)??void 0}function zCa(e){return qr(e,bn.FERN_ENUM)}Nt();function VCa({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:o}){let s=qr(n,bn.SDK_NAMESPACE),a=qr(n,bn.SDK_GROUP_NAME),u=qr(n,bn.TYPE_DEFINITION);if(u!=null)return QDt({fernType:u,nameOverride:e,generatedName:t,title:r,description:i,availability:o,namespace:s,groupName:typeof a=="string"?[a]:a})}function QDt({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a}){return _v({type:e,_default:void 0,validation:void 0,visitor:{primitive:u=>{switch(u.v1){case"BASE_64":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.base64({example:void 0})});case"BOOLEAN":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.boolean({default:void 0,example:void 0})});case"DATE":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.date({example:void 0})});case"DATE_TIME":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.datetime({example:void 0})});case"FLOAT":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.float({example:void 0})});case"DOUBLE":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.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 jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.uint({default:void 0,example:void 0})});case"INTEGER":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.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 jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.uint64({default:void 0,example:void 0})});case"LONG":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});case"DATE_TIME_RFC_2822":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.datetimeRfc2822({example:void 0})});default:xe(u.v1)}},unknown:()=>jr.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:o,namespace:s,groupName:a}),map:({keyType:u,valueType:c})=>u?.type==="primitive"&&c!=null?jr.map({nameOverride:t,generatedName:r,title:n,key:u,value:c,description:i,availability:o,namespace:s,groupName:a,encoding:void 0,example:void 0,inline:void 0,minProperties:void 0,maxProperties:void 0}):void 0,list:u=>u!=null?jr.array({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,example:void 0,inline:void 0,minItems:void 0,maxItems:void 0}):void 0,optional:u=>u!=null?jr.optional({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,inline:void 0}):void 0,nullable:u=>u!=null?jr.nullable({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,inline:void 0}):void 0,set:u=>u!=null?jr.array({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,example:void 0,inline:void 0,minItems:void 0,maxItems:void 0}):void 0,literal:u=>jr.literal({nameOverride:t,generatedName:r,title:n,value:u._visit({string:c=>nA.string(c),boolean:c=>nA.boolean(c),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:o,namespace:s,groupName:a}),named:u=>jr.reference({schema:u,nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,source:aO.openapi({file:"<memory>"})})}})}function qCa(e){let t=qr(e,bn.SOURCE);if(t!=null)return t.endsWith(".proto")?aO.protobuf({file:t}):aO.openapi({file:t})}function Rke(e){if(e!=null&&typeof e=="boolean")return e}function iY(){let e=new Map,t=new Map;return{getUniqueSchemaId(r,n,i=!1){let o=e.get(r)||0;if(e.set(r,o+1),o>0&&i){let s=`${r}${o+1}`;return n?.warn?.(`Schema name collision detected: '${r}' already exists. Renaming to '${s}' to avoid conflicts.`),s}return r},getUniqueTitleName(r,n,i,o=!1){let s=t.get(r)||0;if(t.set(r,s+1),s>0&&o){let a=`${r}${s+1}`;return i?.warn(`Schema title collision detected: Multiple schemas use title '${r}'. Schema '${n}' retitled to '${a}' to avoid conflicts.`),a}return r},reset(){e.clear(),t.clear()}}}Nt();function Hn(e){return e?.$ref!=null}function GCa({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:o,availability:s,wrapAsOptional:a,wrapAsNullable:u,context:c,namespace:l,groupName:p,example:d,encoding:f,source:m,minProperties:h,maxProperties:A}){return i===void 0&&(i=c.options.additionalPropertiesDefaultsTo),zRi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:u,description:o,availability:s,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Si.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 i=="boolean"||NDt(i,c.options)?jr.unknown({...Sgf(i),generatedName:`${t}Value`}):WCa(Za(i,!1,c.options.optionalAdditionalProperties?u:!1,c,[...n,"Value"],m,l,void 0,void 0,void 0)),namespace:l,groupName:p,example:d,encoding:f,minProperties:h,maxProperties:A})}function WCa(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=WCa(e.value);break;case"oneOf":e.value.inline=!0;break;default:xe(e)}return e}function zRi({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsOptional:o,wrapAsNullable:s,description:a,availability:u,namespace:c,groupName:l,example:p,encoding:d,minProperties:f,maxProperties:m}){let h=jr.map({nameOverride:e,generatedName:t,title:r,description:a,availability:u,key:n,value:i,namespace:c,groupName:l,encoding:d,example:p,inline:void 0,minProperties:f,maxProperties:m});return s&&(h=jr.nullable({nameOverride:e,generatedName:t,title:r,value:h,description:a,availability:u,namespace:c,groupName:l,inline:void 0})),o&&(h=jr.optional({nameOverride:e,generatedName:t,title:r,value:h,description:a,availability:u,namespace:c,groupName:l,inline:void 0})),h}function NDt(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:Hn(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(n=>Hn(n)?!0:n.type!=null||n.properties!=null||n.allOf!=null||n.oneOf!=null||n.anyOf!=null||n.enum!=null||"items"in n||n.additionalProperties!=null):!("enum"in e&&e.enum!=null)}function Sgf(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"||Hn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function $Ca({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:o,availability:s,wrapAsOptional:a,wrapAsNullable:u,context:c,namespace:l,groupName:p,example:d,source:f,minItems:m,maxItems:h}){let A=i==null?jr.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:l,groupName:p}):Za(i,!1,!1,c,[...n,"Item"],f,l);return Ogf({nameOverride:e,generatedName:t,title:r,namespace:l,groupName:p,itemSchema:A,wrapAsOptional:a,wrapAsNullable:u,description:o,availability:s,example:d,minItems:m,maxItems:h})}function Ogf({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,namespace:u,groupName:c,example:l,minItems:p,maxItems:d}){let f=jr.array({nameOverride:e,generatedName:t,title:r,value:n,description:s,availability:a,namespace:u,groupName:c,example:l,inline:void 0,minItems:p,maxItems:d});return o&&(f=jr.nullable({nameOverride:e,generatedName:t,title:r,value:f,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),i&&(f=jr.optional({nameOverride:e,generatedName:t,title:r,value:f,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),f}function cO(e){switch(qr(e,bn.AVAILABILITY)){case"deprecated":return MC.Deprecated;case"beta":return MC.Beta;case"generally-available":return MC.GenerallyAvailable;default:break}if(!Hn(e)&&e.deprecated)return MC.Deprecated}function T_r({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:o,availability:s,required:a,wrapAsOptional:u,wrapAsNullable:c,discriminator:l,context:p,namespace:d,groupName:f,encoding:m,source:h}){let A=l.propertyName,y=qr(l,bn.FERN_PROPERTY_NAME),v=qr(l,bn.DISCRIMINATOR_CONTEXT)??"data",E=Object.fromEntries(Object.entries(l.mapping??{}).map(([I,w])=>{let _=Jq({$ref:w},!1,!1,p,[w],m,h,d);return p.markReferencedByDiscriminatedUnion({$ref:w},A,1),[I,_]})),b=Object.entries(i).filter(([I])=>I!==A).map(([I,w])=>{let _=a!=null&&a.includes(I),[C,x]=p.options.coerceOptionalSchemasToNullable?[!1,!_]:[!_,!1],R=Za(w,C,x,p,[...n,I],h,d);return{key:I,schema:R}});return HCa({nameOverride:e,generatedName:t,title:r,wrapAsOptional:u,wrapAsNullable:c,properties:b,description:o,availability:s,discriminant:A,discriminantNameOverride:y,discriminatorContext:v,subtypes:E,namespace:d,groupName:f,source:h})}function VRi({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:o,availability:s,required:a,wrapAsOptional:u,wrapAsNullable:c,discriminant:l,variants:p,context:d,namespace:f,groupName:m,encoding:h,source:A}){let y=Object.fromEntries(Object.entries(p).map(([E,b])=>{if(Hn(b)){let I=Jq(b,!1,!1,d,[b.$ref],h,A,f);return d.markReferencedByDiscriminatedUnion(b,l,1),[E,I]}else{let I=XXe(b,!1,!1,d,[...n,E],h,A,f,new Set([l]));return[E,I]}})),v=Object.entries(i).filter(([E])=>E!==l).map(([E,b])=>{let I=a!=null&&a.includes(E),[w,_]=d.options.coerceOptionalSchemasToNullable?[!1,!I]:[!I,!1],C=Za(b,w,_,d,[...n,E],A,f);return{key:E,schema:C}});return HCa({nameOverride:e,generatedName:t,title:r,wrapAsOptional:u,wrapAsNullable:c,properties:v,description:o,availability:s,discriminant:l,discriminantNameOverride:void 0,discriminatorContext:"data",subtypes:y,namespace:f,groupName:m,source:A})}function HCa({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:o,description:s,availability:a,discriminant:u,discriminantNameOverride:c,discriminatorContext:l,subtypes:p,namespace:d,groupName:f,source:m}){let h=jr.oneOf(p2.discriminated({description:s,availability:a,discriminantProperty:u,discriminantPropertyNameOverride:c,discriminatorContext:l,nameOverride:e,generatedName:t,title:r,schemas:p,commonProperties:o,namespace:d,groupName:f,encoding:void 0,source:m,inline:void 0}));return i&&(h=jr.nullable({nameOverride:e,generatedName:t,title:r,value:h,namespace:d,groupName:f,description:s,availability:a,inline:void 0})),n&&(h=jr.optional({nameOverride:e,generatedName:t,title:r,value:h,namespace:d,groupName:f,description:s,availability:a,inline:void 0})),h}function KCa(e){if(e.proto!=null)return lXe.protobuf({typeName:e.proto.type})}function Dwe({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:o,_default:s,description:a,availability:u,wrapAsOptional:c,wrapAsNullable:l,namespace:p,groupName:d,context:f,source:m,inline:h}){let A=Pgf(i??[]),y=new Set(o),v=Array.from(y).map((b,I)=>{let w=n?.[b],_=A[I],C=WXe.test(b),x=w?.name??_,R=C?b:$Xe(b);return x!=null&&!WXe.test(x)&&(f?.logger.warn(`Enum name override ${x} is not a valid name. Falling back on ${R}.`),x=void 0),{nameOverride:x,generatedName:R,value:b,description:w?.description,availability:u,casing:{snake:w?.casing?.snake??void 0,pascal:w?.casing?.pascal??void 0,screamingSnake:w?.casing?.screamingSnake??void 0,camel:w?.casing?.camel??void 0}}}),E=s!=null?v.find(b=>b.value===s):void 0;return Bgf({wrapAsOptional:c,wrapAsNullable:l,nameOverride:e,generatedName:t,title:r,values:v,_default:E,description:a,availability:u,namespace:p,groupName:d,source:m,inline:h})}function Bgf({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:n,title:i,values:o,_default:s,description:a,availability:u,namespace:c,groupName:l,source:p,inline:d}){let f=jr.enum({nameOverride:r,generatedName:n,title:i,values:o,description:a,availability:u,default:s,example:void 0,namespace:c,groupName:l,source:p,inline:d});return t&&(f=jr.nullable({nameOverride:r,generatedName:n,title:i,value:f,description:a,availability:u,namespace:c,groupName:l,inline:d})),e&&(f=jr.optional({nameOverride:r,generatedName:n,title:i,value:f,description:a,availability:u,namespace:c,groupName:l,inline:d})),f}function Pgf(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function JCa({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,description:l,availability:p,wrapAsOptional:d,wrapAsNullable:f,example:m,namespace:h,groupName:A,defaultIntegerFormat:y=yn.DefaultIntegerFormat.Int32}){let v=n??y,E=(()=>{switch(v){case yn.DefaultIntegerFormat.Int64:return Si.int64({default:i,example:m});case yn.DefaultIntegerFormat.Uint32:return Si.uint({default:i,example:m});case yn.DefaultIntegerFormat.Uint64:return Si.uint64({default:i,example:m});default:return Si.int({default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,example:m})}})();return SS({nameOverride:e,generatedName:t,title:r,primitive:E,wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A})}function Tgf(e){return typeof e=="string"?nA.string(e):typeof e=="boolean"?nA.boolean(e):nA.string(`${e}`)}function qRi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,value:o,description:s,availability:a,namespace:u,groupName:c}){let l=jr.literal({nameOverride:e,generatedName:t,title:r,value:Tgf(o),description:s,availability:a,namespace:u,groupName:c});return i&&(l=jr.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),n&&(l=jr.optional({nameOverride:e,generatedName:t,title:r,value:l,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),l}function GRi({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,description:l,availability:p,wrapAsOptional:d,wrapAsNullable:f,example:m,namespace:h,groupName:A}){return n==null||n==="double"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.double({default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="float"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.float({example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="int32"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.int({default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="int64"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.int64({default:i,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="uint32"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.uint({default:i,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="uint64"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.uint64({default:i,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="time-delta"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.float({example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):SS({nameOverride:e,generatedName:t,title:r,primitive:Si.float({example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A})}var Dgf={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},Rgf={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}}},Fgf={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}}},jgf={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},Qgf={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Ngf={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},kgf={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Mgf={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function kDt(e){let t=e.split("/").map(o=>o.replace(/~1/g,"/")),r=[],n=[Dgf,Rgf,Fgf,jgf,Qgf,Ngf,kgf,Mgf],i;do{i=t;for(let o of n)if(o.isApplicable(t)){let{refUnderProcessing:s,newBreadcrumbs:a}=o.applyStrategy(t);t=s,r=[...r,...a]}}while(t.join("")!==i.join(""));return r}xi();function Gy(e,t){let n=e.map(i=>/^[^a-zA-Z0-9]+$/.test(i)?i:dl($n(i))).join("");return/^\d/.test(n)?SDt(n)??n:n}function YCa(e){let t=e.join("_");return $n(t)}Nt();function Rf(e){switch(e.type){case"object":return ya.object({allOf:e.allOf,properties:e.properties.map(t=>Ugf(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,minProperties:e.minProperties,maxProperties:e.maxProperties});case"array":return ya.array({description:e.description,availability:e.availability,value:Rf(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline,minItems:e.minItems,maxItems:e.maxItems});case"enum":return ya.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 ya.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 ya.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Rf(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return ya.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Rf(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return ya.primitive({description:e.description,availability:e.availability,schema:XCa(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ya.map({description:e.description,availability:e.availability,key:ya.primitive({description:e.key.description,availability:e.key.availability,schema:XCa(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:Rf(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline,minProperties:e.minProperties,maxProperties:e.maxProperties});case"reference":return ya.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 ya.oneOf(Lgf(e.value));case"unknown":return ya.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:xe(e)}}function Lgf(e){switch(e.type){case"discriminated":return XJ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:Rf(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,discriminantPropertyNameOverride:e.discriminantPropertyNameOverride,discriminatorContext:e.discriminatorContext,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,Rf(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return XJ.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>Rf(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:xe(e)}}function XCa(e){switch(e.type){case"string":return Wc.string(e);case"base64":return Wc.base64();case"boolean":return Wc.boolean(e);case"date":return Wc.date();case"datetime":return Wc.datetime();case"datetimeRfc2822":return Wc.datetimeRfc2822();case"double":return Wc.double(e);case"float":return Wc.float();case"int":return Wc.int(e);case"int64":return Wc.int64(e);case"uint":return Wc.uint();case"uint64":return Wc.uint64();default:xe(e)}}function Ugf(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:Rf(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function D_r(e,t){return jF(Rf(e),Rf(t))}function ZCa({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:o,required:s,wrapAsOptional:a,wrapAsNullable:u,allOf:c,context:l,propertiesToExclude:p,namespace:d,groupName:f,fullExamples:m,additionalProperties:h,availability:A,source:y,minProperties:v,maxProperties:E}){let b=[...s??[]],I={...e_a({properties:i,breadcrumbs:n,context:l})},w=[],_=[];for(let U of c)if(!l.options.inlineAllOfSchemas&&Hn(U)){let q=l.resolveSchemaReference(U);if(q.discriminator!=null&&q.discriminator.mapping!=null)continue;if(q.oneOf!=null||q.anyOf!=null){let ie=q.oneOf??q.anyOf;if(ie!=null){for(let V of ie){let K=Hn(V)?l.resolveSchemaReference(V):V,Ee=Za(K,!1,!1,l.DUMMY,n,y,d);Ee.type==="object"&&w.push(...Ee.properties.map(Ie=>Ie.schema.type!=="optional"&&Ie.schema.type!=="nullable"?{...Ie,schema:jr.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Ie.schema,description:void 0,availability:Ie.availability,namespace:void 0,groupName:void 0,inline:void 0})}:Ie))}continue}}let te=Rwe(U);if(te==null)continue;_.push({schemaId:te,convertedSchema:WRi(U,[te],y,l.options.preserveSchemaIds,l),properties:t_a({schema:U,context:l,breadcrumbs:n,source:y,namespace:d})}),l.markSchemaAsReferencedByNonRequest(te)}else if(Hn(U)){let q=l.resolveSchemaReference(U),te=Za(q,!1,!1,l,n,y,d);te.type==="object"&&w.push(...te.properties)}else{let q=U.required??[];w=w.map(ie=>(ie.schema.type==="optional"||ie.schema.type==="nullable")&&q.includes(ie.key)?{...ie,schema:ie.schema.value}:ie);let te=U.oneOf??U.anyOf;if(te!=null&&U.type==null&&U.properties==null){let ie=new Set(w.map(V=>V.key));for(let V of te){let K=Hn(V)?l.resolveSchemaReference(V):V,Ee=Vgf(K),Ie=Za(Ee,!1,!1,l,n,y,d);if(Ie.type==="object")for(let H of Ie.properties)ie.has(H.key)||(ie.add(H.key),H.schema.type!=="optional"&&H.schema.type!=="nullable"?w.push({...H,schema:jr.optional({nameOverride:void 0,generatedName:"",title:void 0,value:H.schema,description:void 0,availability:H.availability,namespace:void 0,groupName:void 0,inline:void 0})}):w.push(H))}}else{let ie=Za(U,!1,!1,l,n,y,d);ie.type==="object"&&w.push(...ie.properties)}}let C={};for(let U of _)for(let[q,te]of Object.entries(U.properties)){let ie=C[q];ie!=null?(ie.schemaIds.push(U.schemaId),ie.schemas.some(K=>D_r(K,te))||ie.schemas.push(te)):C[q]={schemaIds:[U.schemaId],schemas:[te]}}let x=[];for(let[U,q]of Object.entries(C))q.schemaIds.length>1&&x.push({propertyKey:U,allOfSchemaIds:q.schemaIds,conflictingTypeSignatures:q.schemas.length>1});let R=Object.fromEntries(Object.entries(I).filter(([U,q])=>!(!Hn(q)&&q.type==="null"))),z=Object.entries(R).map(([U,q])=>{let te=qr(q,bn.AUDIENCES)??[],ie=cO(q),V=Hn(q)?!1:q.readOnly,K=Hn(q)?!1:q.writeOnly,Ie=!(b.includes(U)&&!V),H=qr(q,bn.FERN_PROPERTY_NAME),J=[...n,U],Ae=YCa(J),ge=Za(q,Ie,!1,l,J,y,d),we={};for(let _e of _){let pe=_e.properties[U];pe!=null&&!D_r(ge,pe)?we[_e.schemaId]={differentSchema:!0}:pe!=null&&(we[_e.schemaId]={differentSchema:!1})}return{key:U,schema:ge,nameOverride:H,audiences:te,conflict:we,generatedName:Ae,availability:ie,readonly:V,writeonly:K}});return z.push(...w.map(U=>{let q=U.conflict;for(let te of _){let ie=te.properties[U.key];ie!=null&&!D_r(U.schema,ie)?q[te.schemaId]={differentSchema:!0}:ie!=null&&(q[te.schemaId]={differentSchema:!1})}return{...U,conflict:q}})),zgf({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:u,properties:z.filter(U=>!p.has(U.key)),description:o,allOf:_.map(U=>U.convertedSchema),allOfPropertyConflicts:x,namespace:d,groupName:f,fullExamples:m,additionalProperties:h,availability:A,source:y,context:l,minProperties:v,maxProperties:E})}function zgf({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:o,description:s,allOf:a,allOfPropertyConflicts:u,namespace:c,groupName:l,fullExamples:p,additionalProperties:d,availability:f,source:m,context:h,minProperties:A,maxProperties:y}){let v=jr.object({description:s,properties:o,nameOverride:e,generatedName:t,title:r,allOf:a,allOfPropertyConflicts:u,namespace:c,groupName:l,fullExamples:p,additionalProperties:NDt(d,h.options),availability:f,source:m,inline:void 0,minProperties:A,maxProperties:y});return i&&(v=jr.nullable({nameOverride:e,generatedName:t,title:r,value:v,description:s,availability:f,namespace:c,groupName:l,inline:void 0})),n&&(v=jr.optional({nameOverride:e,generatedName:t,title:r,value:v,description:s,availability:f,namespace:c,groupName:l,inline:void 0})),v}function e_a({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([n,i])=>{let o=qr(i,bn.IGNORE);return o&&r.logger.debug(`Property ${t.join(".")}.${n} is marked with x-fern-ignore. Skipping.`),!o}))}function Vgf(e){if(e.properties==null)return e;let t={};for(let[r,n]of Object.entries(e.properties))!Hn(n)&&"not"in n||(t[r]=n);return{...e,properties:t}}function t_a({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let o={},[s,a]=Hn(e)?[t.resolveSchemaReference(e),kDt(e.$ref)]:[e,r];for(let u of s.allOf??[])o={...o,...t_a({schema:u,context:t,breadcrumbs:a,source:n,namespace:i})};for(let[u,c]of Object.entries(e_a({properties:s.properties??{},breadcrumbs:r,context:t}))){let l=Za(c,!1,!1,t,[...a,u],n,i);o[u]=l}return o}xi();function Fwe({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:o,wrapAsOptional:s,wrapAsNullable:a,context:u,subtypes:c,namespace:l,groupName:p,encoding:d,source:f,subtypeSuffixOverrides:m}){let h=Wgf({schemas:c}),A=c.flatMap((v,E)=>{if(!Hn(v)&&v.enum!=null&&u.options.coerceEnumsToLiterals&&v.type==="string")return v.enum.map(I=>jr.literal({nameOverride:void 0,generatedName:Gy([t,I],u.options.preserveSchemaIds),title:void 0,value:nA.string(String(I)),namespace:l,groupName:void 0,description:void 0,availability:I.availability}));let b=h[E];if(m!=null){let I=m[E];I!=null&&"name"in I&&(b=I.name)}return[Za(v,!1,!1,u,[...n,b??`${E}`],f,l)]}),y=qgf(A);return Ggf({uniqueSubtypes:y,nameOverride:e,generatedName:t,title:r,wrapAsOptional:s,wrapAsNullable:a,description:i,availability:o,namespace:l,groupName:p,context:u,encoding:d,source:f})}function qgf(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r],i=!1;for(let o=r+1;o<e.length;++o){let s=e[o];if(n!=null&&s!=null&&jF(n,s)){i=!0;break}}n!=null&&!i&&t.push(n)}return t}function Ggf({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,namespace:u,groupName:c,context:l,encoding:p,source:d}){if(Object.entries(e).every(([m,h])=>h.type==="literal")){let m={},h=[];return Object.entries(e).forEach(([A,y])=>{y.type==="literal"&&y.value.type==="string"&&(h.push(y.value.value),y.description!=null&&(m[y.value.value]={description:y.description}))}),Dwe({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,fernEnum:m,enumVarNames:void 0,enumValues:h,_default:void 0,namespace:u,groupName:c,context:l,source:d,inline:void 0})}if(e.length===1&&e[0]!=null&&!l.options.preserveSingleSchemaOneOf){let m=e[0];return o&&(m=jr.nullable({nameOverride:t,generatedName:r,title:n,value:m,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),i&&(m=jr.optional({nameOverride:t,generatedName:r,title:n,value:m,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),m}return r_a({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,subtypes:e,namespace:u,groupName:c,encoding:p,source:d})}function $Ri({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsOptional:o,wrapAsNullable:s,context:a,namespace:u,groupName:c,discriminator:l,encoding:p,source:d}){let f=Object.entries(l.mapping??{}).map(([A,y],v)=>{let E={$ref:y},b=Jq(E,!1,!1,a,[y],p,d,u);return a.markSchemaWithDiscriminantValue(E,l.propertyName,A),b.type==="object"&&(b.properties={[l.propertyName]:jr.literal({nameOverride:void 0,generatedName:Gy([t,A],a.options.preserveSchemaIds),title:void 0,value:nA.string(A),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...b.properties.filter(I=>I.key!==l.propertyName)}),b}),m=[];for(let A=0;A<f.length;++A){let y=f[A],v=!1;for(let E=A+1;E<f.length;++E){let b=f[E];if(y!=null&&b!=null&&jF(y,b)){v=!0;break}}y!=null&&!v&&m.push(y)}if(Object.entries(m).every(([A,y])=>y.type==="literal")){let A={},y=[];return Object.entries(m).forEach(([v,E])=>{E.type==="literal"&&E.value.type==="string"&&(y.push(E.value.value),E.description!=null&&(A[E.value.value]={description:E.description}))}),Dwe({nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:s,description:n,availability:i,fernEnum:A,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:u,groupName:c,context:a,source:d,inline:void 0})}return m.length===1&&m[0]!=null&&!a.options.preserveSingleSchemaOneOf?m[0]:r_a({nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:s,description:n,availability:i,subtypes:m,namespace:u,groupName:c,encoding:p,source:d})}function Wgf({schemas:e}){let t={},r=0;for(let i of e){if(!Hn(i)){if(i.properties!=null&&Object.entries(i.properties).length>0){let o=Object.keys(i.properties),s={},a=o;for(let[u,c]of Object.entries(t)){let l=uYt(c,o);a=uYt(a,c),s[u]=l}s[r]=a,t=s}}r++}return e.map((i,o)=>{let s=t[o];if(s!=null&&s.length>0){let a=s.sort();if(a[0]!=null)return a[0]}return Oke(o)??`${o}`})}function r_a({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,description:o,availability:s,subtypes:a,namespace:u,groupName:c,encoding:l,source:p}){let d=jr.oneOf(p2.undiscriminated({description:o,availability:s,nameOverride:e,generatedName:t,title:r,schemas:a,namespace:u,groupName:c,encoding:l,source:p,inline:void 0}));return i&&(d=jr.nullable({nameOverride:e,generatedName:t,title:r,value:d,description:o,availability:s,namespace:u,groupName:c,inline:void 0})),n&&(d=jr.optional({nameOverride:e,generatedName:t,title:r,value:d,description:o,availability:s,namespace:u,groupName:c,inline:void 0})),d}function ZXe(e){if(e.default!=null&&typeof e.default=="string")return e.default}function R_r({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=Dke(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function n_a({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=Dke(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function Yq({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=Dke(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function i_a({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=Dke(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var Fke="#/components/schemas/";var u_a=iY();function N_r(){u_a.reset()}function $gf(e,t,r){let n=qr(e,bn.TYPE_NAME),i=t.options.useTitlesAsName?Jgf(e.title):void 0,o=n??i;if(!o)return;let s=r.split(".");return n!=null||s.length===1?u_a.getUniqueTitleName(o,r,t.logger,t.options.resolveSchemaCollisions):o}function c_a(e,t){let r=Hn(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 c_a(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 Hgf(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:c_a(t,r):!1}function Za(e,t,r,n,i,o,s,a=!1,u=new Set,c){let l=qCa(e)??o,p=rAf({schema:e,logger:n.logger}),d=c;if(Hn(e)){let f=Kgf(e);f!==void 0&&(d=f)}if(Hn(e)){let f=Rwe(e);return f!=null?Hgf(f,e,n)?XXe(n.resolveSchemaReference(e),t,r,n,kDt(e.$ref),p,l,s,u,a,d):(a?n.markSchemaAsReferencedByRequest(f):n.markSchemaAsReferencedByNonRequest(f),Jq(e,t,r,n,i,p,l,s)):XXe(n.resolveSchemaReference(e),t,r,n,kDt(e.$ref),p,l,s,u,a,d)}return XXe(e,t,r,n,i,p,l,s,u,a,c)}function Kgf(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 Jq(e,t,r,n,i,o,s,a){let u=e.$ref.includes("properties")?XXe(n.resolveSchemaReference(e),t,r,n,i,o,s,a,new Set):jr.reference(WRi(e,i,s,n.options.preserveSchemaIds,n));if(r===!1){let c=n.resolveSchemaReference(e);(c.nullable===!0||Array.isArray(c.type)&&c.type.length>=2&&c.type.includes("null"))&&(r=!0)}return r&&(u=jr.nullable({title:void 0,nameOverride:void 0,generatedName:Gy(i,n.options.preserveSchemaIds),value:u,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(u=jr.optional({title:void 0,nameOverride:void 0,generatedName:Gy(i,n.options.preserveSchemaIds),value:u,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),u}function Jgf(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function XXe(e,t,r,n,i,o,s,a,u=new Set,c=!1,l){typeof e=="string"&&(e={type:e});let p=$gf(e,n,i.join(".")),d=qr(e,bn.SDK_GROUP_NAME)??qr(e,xS.TAGS)?.[0],f=(typeof d=="string"?[d]:d)??[];f=n.resolveGroupName(f);let m=Gy(i,n.options.preserveSchemaIds),h=e.title,A=e.description,y=cO(e),v=[];e.example!=null&&v.push({name:void 0,value:e.example,description:void 0});let E=qr(e,xS.EXAMPLES);E!=null&&Object.keys(E).length>0&&v.push(...Object.entries(E).map(([w,_])=>({name:_?.summary??w,value:_.value,description:_.description})));let b=Dke(e);b!=null&&Object.keys(b).length>0&&v.push(...b.map(w=>({name:void 0,value:w,description:void 0})));let I=VCa({schema:e,description:A,title:h,nameOverride:p,generatedName:m,availability:y});if(I!=null){let w=I;return r&&(w=jr.nullable({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:w})),t&&(w=jr.optional({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:w})),w}try{if(Array.isArray(e.type)){let C=e.type.indexOf("null"),x=C!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&x)e.type.splice(C,1),e.type=e.type[0],e.nullable=!0;else if(x&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let R=new Set([...e.oneOf,...e.type]);e.oneOf=[...R]}}if(r=r||e.nullable===!0,"const"in e){let C=e.const;if(typeof C=="string"||typeof C=="boolean")return qRi({nameOverride:p,generatedName:m,title:h,wrapAsOptional:t,wrapAsNullable:r,value:C,description:A,availability:y,namespace:a,groupName:f});e.enum=[C]}if(e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(x=>x!==null),!Q_r(e.enum))return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.string({default:ZXe(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:Yq({schema:e,logger:n.logger,fallback:l})}),namespace:a,groupName:f,wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y});let C=zCa(e);return n.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&C==null?qRi({nameOverride:p,generatedName:m,title:h,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:A,availability:y,namespace:a,groupName:f}):Dwe({nameOverride:p,generatedName:m,title:h,fernEnum:C,enumVarNames:qr(e,[xS.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,namespace:a,groupName:f,context:n,source:s,inline:void 0})}if(Q_r(e.type)&&e.type.length>1){let C=e.type.includes("null"),x=e.type.filter(R=>R!=="null").map(R=>({type:R,nullable:C}));return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:x,namespace:a,groupName:f,encoding:o,source:s})}if(e.type==="boolean"){let C=qr(e,bn.BOOLEAN_LITERAL);return C!=null?s_a({nameOverride:p,generatedName:m,title:h,literal:nA.boolean(C),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f}):SS({nameOverride:p,generatedName:m,title:h,primitive:Si.boolean({default:Ygf(e.default),example:n_a({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f})}if(e.type==="number")return GRi({nameOverride:p,generatedName:m,title:h,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Rke(e.exclusiveMinimum),exclusiveMaximum:Rke(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,example:R_r({schema:e,logger:n.logger,fallback:l}),namespace:a,groupName:f});if(e.type==="integer")return JCa({nameOverride:p,generatedName:m,title:h,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Rke(e.exclusiveMinimum),exclusiveMaximum:Rke(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,example:R_r({schema:e,logger:n.logger,fallback:l}),namespace:a,groupName:f,defaultIntegerFormat:n.options.defaultIntegerFormat});if(e.type==="float")return GRi({nameOverride:p,generatedName:m,title:h,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Rke(e.exclusiveMinimum),exclusiveMaximum:Rke(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,example:R_r({schema:e,logger:n.logger,fallback:l}),namespace:a,groupName:f});if(e.type==="string"){if(e.format==null&&e.contentMediaType==="application/octet-stream"&&(e={...e,format:"binary"}),e.format==="date-time")return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.datetime({example:Yq({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f});if(e.format==="date-time-rfc-2822")return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.datetimeRfc2822({example:Yq({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f});if(e.format==="date"&&n.options.typeDatesAsStrings===!1)return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.date({example:Yq({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f});if(e.format==="json-string"){let x=jr.unknown({nameOverride:p,generatedName:m,title:h,description:A,availability:y,namespace:a,groupName:f,example:void 0});return r&&(x=jr.nullable({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:x})),t&&(x=jr.optional({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:x})),x}let C=p_a(e,"const");return C!=null?s_a({nameOverride:p,generatedName:m,title:h,literal:nA.string(C),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f}):SS({nameOverride:p,generatedName:m,title:h,primitive:Si.string({default:ZXe(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Yq({schema:e,logger:n.logger,fallback:l})}),namespace:a,groupName:f,wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y})}if(e.type==="array")return $Ca({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,item:e.items,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,example:i_a({schema:e,logger:n.logger,fallback:l}),source:s,minItems:e.minItems,maxItems:e.maxItems});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&F_r(e)&&o_a(e))return GCa({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,additionalProperties:e.additionalProperties,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,example:e.example,source:s,minProperties:e.minProperties,maxProperties:e.maxProperties});if(e.oneOf!=null&&e.oneOf.length>0&&qr(e,bn.IS_DISCRIMINATED)===!1)return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf,namespace:a,groupName:f,encoding:o,source:s});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return n.options.discriminatedUnionV2?$Ri({nameOverride:p,generatedName:m,title:h,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,discriminator:e.discriminator,encoding:o,source:s}):T_r({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,source:s});if(e.oneOf!=null&&e.oneOf.length>0){let C=qr(e,bn.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return n.options.discriminatedUnionV2||C?$Ri({nameOverride:p,generatedName:m,title:h,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,discriminator:e.discriminator,encoding:o,source:s}):T_r({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,source:s});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(n.options.preserveSingleSchemaOneOf)return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf.filter(R=>Hn(R)||R.type!=="null"),encoding:o,namespace:a,groupName:f,source:s});let x=Za(e.oneOf[0],t,r,n,i,s,a,c);return oY(x,A,a,f)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let U=e.oneOf[0],q=e.oneOf[1];if(!Hn(U)&&U.type==="null"){let te=Za(q,t,!0,n,i,s,a);return oY(te,A,a,f)}else if(!Hn(q)&&q.type==="null"){let te=Za(U,t,!0,n,i,s,a);return oY(te,A,a,f)}}let x=Zgf({schemas:e.oneOf});if(x!=null)return Dwe({nameOverride:p,generatedName:m,title:h,fernEnum:void 0,enumVarNames:void 0,enumValues:x,_default:e.default,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,namespace:a,groupName:f,context:n,source:s,inline:void 0});let R=a_a({schemas:e.oneOf,context:n});if(R!=null&&!n.options.discriminatedUnionV2&&!C)return VRi({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,properties:e.properties??{},required:e.required,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,discriminant:R.discriminant,variants:R.schemas,context:n,namespace:a,groupName:f,encoding:o,source:s});let z=e.oneOf.filter(U=>!Hn(U)&&U.type==="null").length>0;return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r||z,context:n,subtypes:e.oneOf.filter(U=>Hn(U)||U.type!=="null"),encoding:o,namespace:a,groupName:f,source:s})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let R=Za(e.anyOf[0],t,r,n,i,s,a,c);return oY(R,A,a,f)}if(e.anyOf.length===2){let[R,z]=e.anyOf;if(R!=null&&z!=null){if(!Hn(R)&&R.type==="null"){let U=Za(z,t,!0,n,i,s,a);return oY(U,A,a,f)}else if(!Hn(z)&&z.type==="null"){let U=Za(R,t,!0,n,i,s,a);return oY(U,A,a,f)}}}let C=a_a({schemas:e.anyOf,context:n});if(C!=null&&!n.options.discriminatedUnionV2)return VRi({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,properties:e.properties??{},required:e.required,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,discriminant:C.discriminant,variants:C.schemas,context:n,namespace:a,groupName:f,encoding:o,source:s});let x=e.anyOf.filter(R=>!Hn(R)&&R.type==="null").length>0;return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r||x,context:n,subtypes:e.anyOf.filter(R=>Hn(R)||R.type!=="null"),encoding:o,namespace:a,groupName:f,source:s})}if(e.discriminator?.mapping!=null&&Object.keys(e.discriminator.mapping).length>0&&e.oneOf==null&&e.anyOf==null)return T_r({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,source:s});if(e.allOf!=null||e.properties!=null){let C=[];for(let R of e.allOf??[])(Hn(R)||Object.keys(R).length>0)&&C.push(R);if((e.properties==null||F_r(e))&&C.length===1&&C[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let R=Za(C[0],t,r,n,i,s,a,c);return oY(R,A,a,f)}let x=C.filter(R=>{let z=j_r(R);return z||n.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(R)}`),z});if((e.properties==null||F_r(e))&&x.length===1&&x[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let R=Za(x[0],t,r,n,i,s,a,c);return oY(R,A,a,f)}return ZCa({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,properties:e.properties??{},description:A,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:x,context:n,propertiesToExclude:u,namespace:a,groupName:f,fullExamples:v,additionalProperties:e.additionalProperties,availability:y,encoding:o,source:s,minProperties:e.minProperties,maxProperties:e.maxProperties})}if(e.type==="object"&&Xgf(e)&&o_a(e)&&F_r(e))return zRi({nameOverride:p,generatedName:m,title:h,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${m}Key`,title:void 0,description:void 0,availability:void 0,schema:Si.string({default:ZXe(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Yq({schema:e,logger:n.logger,fallback:l})}),namespace:a,groupName:f},valueSchema:jr.unknown({nameOverride:void 0,generatedName:`${m}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:a,groupName:f}),namespace:a,groupName:f,encoding:o,example:e.example,minProperties:e.minProperties,maxProperties:e.maxProperties});e.type!=null&&n.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${i.join("->")}. Coercing to unknown.`);let w=e.example??e.default,_=jr.unknown({nameOverride:p,generatedName:m,title:h,description:A,availability:y,namespace:a,groupName:f,example:w});return r&&(_=jr.nullable({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:_})),t&&(_=jr.optional({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:_})),_}catch(w){return n.logger.debug(`Error converting schema: ${w.message}
|
|
1676
|
+
`)),{ok:!0,value:t}):n}}function iwr(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var pXe=class e extends Error{errors;constructor(t){super(t.map(iwr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var fXe=class e extends Error{errors;constructor(t){super(t.map(iwr).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Nd(e){return{nullable:()=>Xmf(e),optional:()=>mRi(e),optionalNullable:()=>Zmf(e),transform:t=>hRi(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new fXe(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new pXe(n.errors)}}}function Xmf(e){let t={parse:(r,n)=>r==null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>mc.NULLABLE};return{...t,...Nd(t)}}function mRi(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>mc.OPTIONAL};return{...t,...Nd(t)}}function Zmf(e){let t={parse:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,n),json:(r,n)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,n),getType:()=>mc.OPTIONAL_NULLABLE};return{...t,...Nd(t)}}function hRi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);return o.ok?{ok:!0,value:t.transform(o.value)}:o},json:(n,i)=>{let o=t.untransform(n);return e.json(o,i)},getType:()=>e.getType()};return{...r,...Nd(r)}}function ywa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:td(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:td(t,"bigint")}]}:{ok:!0,value:t},getType:()=>mc.BIGINT};return{...zC(e),...Nd(e)}}var ehf=/^([+-]?\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 bwa(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:td(t,"string")}]}:ehf.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:td(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:td(t,"Date object")}]},getType:()=>mc.DATE};return{...zC(e),...Nd(e)}}function VC(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...zC(r),...Nd(r)}}}function owr(e){let t=new Set(e);return VC(mc.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:o=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:o,message:td(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:o,message:td(n,"enum")}]}:{ok:!0,value:n})()}function vwa(e){let t=gRi(e);return{...t,...Nd(t)}}function gRi(e){return{parse:(t,r)=>dXe(e).parse(t,r),json:(t,r)=>dXe(e).json(t,r),getType:()=>dXe(e).getType()}}function dXe(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function ARi(e){return Object.entries(e)}function wDt(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,o])=>(r.has(i)&&(n[i]=o),n),{})}function The(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null?!0:Object.getPrototypeOf(t)===null}function CDt(e){return Object.keys(e)}function Ewa(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}var thf=Object.prototype.hasOwnProperty;function Kq(e){return{withParsedProperties:t=>yRi(e,t)}}function yRi(e,t){let r={parse:(n,i)=>{let o=e.parse(n,i);if(!o.ok)return o;let s={};for(let a in t)if(thf.call(t,a)){let u=t[a];s[a]=typeof u=="function"?u(o.value):u}return{ok:!0,value:{...o.value,...s}}},json:(n,i)=>{if(!The(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:td(n,"object")}]};let o=new Set(Object.keys(t)),s=wDt(n,Object.keys(n).filter(a=>!o.has(a)));return e.json(s,i)},getType:()=>e.getType()};return{...r,...Nd(r),...Kq(r)}}function Iwa(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function Dhe(e){return e.isProperty}var rhf=Object.prototype.hasOwnProperty;function swr(e){let t;function r(){if(t==null){t={};for(let[d,f]of ARi(e)){let m=Dhe(f)?f.rawKey:d,h=Dhe(f)?f.valueSchema:f;t[m]={rawKey:m,parsedKey:d,valueSchema:h}}}return t}let n,i,o,s;function a(){if(n==null){n=[],i=[];for(let[d,f]of ARi(e)){let m=Dhe(f)?f.rawKey:d,h=Dhe(f)?f.valueSchema:f;nhf(h)&&(n.push(m),i.push(d))}o=new Set(n),s=new Set(i)}return n}function u(){return i==null&&a(),i}function c(){return o==null&&a(),o}function l(){return s==null&&a(),s}let p={_getRawProperties:()=>Object.entries(e).map(([d,f])=>Dhe(f)?f.rawKey:d),_getParsedProperties:()=>CDt(e),parse:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return wwa({value:d,requiredKeys:a(),requiredKeysSet:c(),getProperty:h=>{let A=r()[h];if(A!=null)return{transformedKey:A.parsedKey,transform:y=>{let v=[...m,h];return A.valueSchema.parse(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},json:(d,f)=>{let m=f?.breadcrumbsPrefix??[];return wwa({value:d,requiredKeys:u(),requiredKeysSet:l(),getProperty:h=>{let A=e[h];if(A!=null)return Dhe(A)?{transformedKey:A.rawKey,transform:y=>{let v=[...m,h];return A.valueSchema.json(y,{...f,breadcrumbsPrefix:v})}}:{transformedKey:h,transform:y=>{let v=[...m,h];return A.json(y,{...f,breadcrumbsPrefix:v})}}},unrecognizedObjectKeys:f?.unrecognizedObjectKeys,skipValidation:f?.skipValidation,breadcrumbsPrefix:m,omitUndefined:f?.omitUndefined})},getType:()=>mc.OBJECT};return{...zC(p),...Nd(p),...Kq(p),...Ske(p)}}function wwa({value:e,requiredKeys:t,requiredKeysSet:r,getProperty:n,unrecognizedObjectKeys:i="fail",skipValidation:o=!1,breadcrumbsPrefix:s=[]}){if(!The(e))return{ok:!1,errors:[{path:s,message:td(e,"object")}]};let a=t.length,u=[],c={};for(let l in e){if(!rhf.call(e,l))continue;let p=e[l],d=n(l);if(d!=null){a>0&&r.has(l)&&a--;let f=d.transform(p);f.ok?c[d.transformedKey]=f.value:(c[l]=p,u.push(...f.errors))}else switch(i){case"fail":u.push({path:[...s,l],message:`Unexpected key "${l}"`});break;case"strip":break;case"passthrough":c[l]=p;break}}if(a>0)for(let l of t)l in e||u.push({path:s,message:`Missing required key "${l}"`});return u.length===0||o?{ok:!0,value:c}:{ok:!1,errors:u}}function Ske(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>Cwa({extensionKeys:t._getRawProperties(),value:n,transformBase:o=>e.parse(o,i),transformExtension:o=>t.parse(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>Cwa({extensionKeys:t._getParsedProperties(),value:n,transformBase:o=>e.json(o,i),transformExtension:o=>t.json(o,i),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>mc.OBJECT};return{...r,...Nd(r),...Kq(r),...Ske(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),n={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(i,o)=>{let s=e.parse(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))t.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},json:(i,o)=>{let s=e.json(i,{...o,unrecognizedObjectKeys:"passthrough"});if(!s.ok)return s;let a={};if(typeof i=="object"&&i!=null)for(let[u,c]of Object.entries(i))r.has(u)||(a[u]=c);return{ok:!0,value:{...a,...s.value}}},getType:()=>mc.OBJECT};return{...n,...Nd(n),...Kq(n),...Ske(n)}}}}function Cwa({extensionKeys:e,value:t,transformBase:r,transformExtension:n,breadcrumbsPrefix:i=[]}){if(!The(t))return{ok:!1,errors:[{path:i,message:td(t,"object")}]};let o=new Set(e),[s,a]=Ewa(CDt(t),l=>o.has(l)),u=r(wDt(t,a)),c=n(wDt(t,s));return u.ok&&c.ok?{ok:!0,value:{...u.value,...c.value}}:{ok:!1,errors:[...u.ok?[]:u.errors,...c.ok?[]:c.errors]}}function nhf(e){return!ihf(e)}function ihf(e){switch(e.getType()){case mc.ANY:case mc.UNKNOWN:case mc.OPTIONAL:case mc.OPTIONAL_NULLABLE:return!0;default:return!1}}function _wa(e){return swr(e)}function xwa(e){let t={...gRi(e),_getRawProperties:()=>dXe(e)._getRawProperties(),_getParsedProperties:()=>dXe(e)._getParsedProperties()};return{...t,...Nd(t),...Kq(t),...Ske(t)}}function awr(e){let t={parse:(r,n)=>Swa(r,(i,o)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),json:(r,n)=>Swa(r,(i,o)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${o}]`]})),getType:()=>mc.LIST};return{...zC(t),...Nd(t)}}function Swa(e,t){if(!Array.isArray(e))return{ok:!1,errors:[{message:td(e,"list"),path:[]}]};let r=[],n=[];for(let i=0;i<e.length;i++){let o=t(e[i],i);o.ok?r.push(o.value):n.push(...o.errors)}return n.length===0?{ok:!0,value:r}:{ok:!1,errors:n}}function Owa(e){return VC(mc.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:td(r,`${e.toString()}`)}]})()}function Bwa(e){return VC(mc.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:td(r,`"${e}"`)}]})()}var Pwa=VC(mc.ANY,e=>({ok:!0,value:e}));var Twa=VC(mc.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:td(e,"boolean")}]});var Dwa=VC(mc.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var Rwa=VC(mc.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:td(e,"number")}]});var Fwa=VC(mc.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:td(e,"string")}]});var jwa=VC(mc.UNKNOWN,e=>({ok:!0,value:e}));var ohf=Object.prototype.hasOwnProperty;function Nwa(e,t){let r={parse:(n,i)=>Qwa({value:n,isKeyNumeric:e.getType()===mc.NUMBER,transformKey:o=>e.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.parse(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>Qwa({value:n,isKeyNumeric:e.getType()===mc.NUMBER,transformKey:o=>e.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o} (key)`]}),transformValue:(o,s)=>t.json(o,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${s}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>mc.RECORD};return{...zC(r),...Nd(r)}}function Qwa({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){if(!The(e))return{ok:!1,errors:[{path:i,message:td(e,"object")}]};let o={},s=[];for(let a in e){if(!ohf.call(e,a))continue;let u=e[a];if(u===void 0)continue;let c=a;if(t){let d=a.length>0?Number(a):NaN;Number.isNaN(d)||(c=d)}let l=r(c),p=n(u,c);l.ok&&p.ok?o[l.value]=p.value:(l.ok||s.push(...l.errors),p.ok||s.push(...p.errors))}return s.length===0?{ok:!0,value:o}:{ok:!1,errors:s}}function kwa(e){let t=awr(e),r={parse:(n,i)=>{let o=t.parse(n,i);return o.ok?{ok:!0,value:new Set(o.value)}:o},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:td(n,"Set")}]},getType:()=>mc.SET};return{...zC(r),...Nd(r)}}function Lwa(e){let t={parse:(r,n)=>Mwa((i,o)=>i.parse(r,o),e,n),json:(r,n)=>Mwa((i,o)=>i.json(r,o),e,n),getType:()=>mc.UNDISCRIMINATED_UNION};return{...zC(t),...Nd(t)}}function Mwa(e,t,r){let n=[];for(let[i,o]of t.entries()){let s=e(o,{...r,skipValidation:!1});if(s.ok)return s;for(let a of s.errors)n.push({path:a.path,message:`[Variant ${i}] ${a.message}`})}return{ok:!1,errors:n}}function Uwa(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}var shf=Object.prototype.hasOwnProperty;function Vwa(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=owr(CDt(t)),o={parse:(s,a)=>zwa({value:s,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:u=>i.parse(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.parse(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),json:(s,a)=>zwa({value:s,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:u=>i.json(u,{allowUnrecognizedEnumValues:a?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...a?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:u=>t[u],allowUnrecognizedUnionMembers:a?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(u,c)=>c.json(u,a),breadcrumbsPrefix:a?.breadcrumbsPrefix}),getType:()=>mc.UNION};return{...zC(o),...Nd(o),...Kq(o)}}function zwa({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:o=!1,transformAdditionalProperties:s,breadcrumbsPrefix:a=[]}){if(!The(e))return{ok:!1,errors:[{path:a,message:td(e,"object")}]};let u=e[t],c={};for(let f in e)shf.call(e,f)&&f!==t&&(c[f]=e[f]);if(u==null)return{ok:!1,errors:[{path:a,message:`Missing discriminant ("${t}")`}]};let l=n(u);if(!l.ok)return{ok:!1,errors:l.errors};let p=i(l.value);if(p==null)return o?{ok:!0,value:{[r]:l.value,...c}}:{ok:!1,errors:[{path:[...a,t],message:"Unexpected discriminant value"}]};let d=s(c,p);return d.ok?{ok:!0,value:{[r]:u,...d.value}}:d}var uwr=G.objectWithoutOptionalProperties({usernameVariableName:G.string().optional(),usernameEnvVar:G.string().optional(),passwordVariableName:G.string().optional(),passwordEnvVar:G.string().optional()});var cwr=G.objectWithoutOptionalProperties({tokenVariableName:G.string().optional(),tokenEnvVar:G.string().optional()});var lwr=G.objectWithoutOptionalProperties({typeName:G.string()});var pwr=G.union("type",{protobuf:lwr}).transform({transform:e=>e.type==="protobuf"?lXe.protobuf(e):e,untransform:({_visit:e,...t})=>t});var fwr=G.objectWithoutOptionalProperties({headerName:G.string(),prefix:G.string().optional(),headerVariableName:G.string().optional(),headerEnvVar:G.string().optional()});var dwr=G.objectWithoutOptionalProperties({type:G.stringLiteral("namespace"),name:G.string()});var mwr=G.string();var hwr=G.enum_(["GenerallyAvailable","Beta","Deprecated"]);var hs=G.objectWithoutOptionalProperties({availability:hwr.optional()});var gn=G.objectWithoutOptionalProperties({description:G.string().optional()});var Tf=G.objectWithoutOptionalProperties({inline:G.boolean().optional()});var Bu=G.objectWithoutOptionalProperties({nameOverride:G.string().optional(),generatedName:G.string()});var su=G.objectWithoutOptionalProperties({namespace:G.string().optional()});var gwr=G.undiscriminatedUnion([G.string(),dwr]);var wwe=G.list(gwr);var $c=G.objectWithoutOptionalProperties({groupName:wwe.optional()});var Awr=G.objectWithoutOptionalProperties({file:G.string()});var ywr=G.objectWithoutOptionalProperties({file:G.string()});var bwr=G.union("type",{openapi:Awr,protobuf:ywr}).transform({transform:e=>{switch(e.type){case"openapi":return aO.openapi(e);case"protobuf":return aO.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wo=G.objectWithoutOptionalProperties({source:bwr.optional()});var Hc=G.objectWithoutOptionalProperties({title:G.string().optional()});var vwr=G.objectWithoutOptionalProperties({snake:G.string().optional(),camel:G.string().optional(),screamingSnake:G.string().optional(),pascal:G.string().optional()});var Cwe=G.objectWithoutOptionalProperties({nameOverride:G.string().optional(),generatedName:G.string(),value:G.string(),casing:vwr.optional()}).extend(gn).extend(hs);var mXe=G.objectWithoutOptionalProperties({default:Cwe.optional(),values:G.list(Cwe)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var Ewr=G.objectWithoutOptionalProperties({scopesEnum:mXe.optional()});var Iwr=G.objectWithoutOptionalProperties({queryParameterName:G.string()});var $P=G.string();var wwr=G.union("type",{basic:uwr,bearer:cwr,header:fwr,query:Iwr,oauth:Ewr}).transform({transform:e=>{switch(e.type){case"basic":return kC.basic(e);case"bearer":return kC.bearer(e);case"header":return kC.header(e);case"query":return kC.query(e);case"oauth":return kC.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var _we=G.string();var Cwr=G.objectWithoutOptionalProperties({id:G.string(),default:G.string().optional(),values:G.list(G.string()).optional()});var _Dt=G.objectWithoutOptionalProperties({name:G.string().optional(),url:G.string(),audiences:G.list(G.string()).optional(),defaultUrl:G.string().optional(),urlTemplate:G.string().optional(),variables:G.list(Cwr).optional()}).extend(gn);var ZJ=G.number();var HP=G.string();var _wr=G.objectWithoutOptionalProperties({id:HP}).extend(gn);var RF=G.objectWithoutOptionalProperties({encoding:pwr.optional()});var eY=G.objectWithoutOptionalProperties({sdkMethodName:G.string().optional()});var kL=G.objectWithoutOptionalProperties({statusCode:ZJ.optional()});var vRi={};X(vRi,{FullExample:()=>Fm,FullObjectExample:()=>Owr,FullOneOfExample:()=>Bwr,KeyValuePair:()=>Pwr,LiteralExample:()=>xwr,NullExample:()=>Swr,PrimitiveExample:()=>hXe,PropertyKey:()=>gXe});var xwr=G.union("type",{boolean:G.object({value:G.boolean()}),string:G.object({value:G.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Ewe.boolean(e.value);case"string":return Ewe.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Swr=G.objectWithoutOptionalProperties({});var hXe=G.union("type",{int:G.object({value:G.number()}),int64:G.object({value:G.number()}),uint:G.object({value:G.number()}),uint64:G.object({value:G.number()}),float:G.object({value:G.number()}),double:G.object({value:G.number()}),string:G.object({value:G.string()}),datetime:G.object({value:G.string()}),datetimeRfc2822:G.object({value:G.string()}),date:G.object({value:G.string()}),base64:G.object({value:G.string()}),boolean:G.object({value:G.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return ms.int(e.value);case"int64":return ms.int64(e.value);case"uint":return ms.uint(e.value);case"uint64":return ms.uint64(e.value);case"float":return ms.float(e.value);case"double":return ms.double(e.value);case"string":return ms.string(e.value);case"datetime":return ms.datetime(e.value);case"datetimeRfc2822":return ms.datetimeRfc2822(e.value);case"date":return ms.date(e.value);case"base64":return ms.base64(e.value);case"boolean":return ms.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Fm=G.union("type",{primitive:G.object({value:hXe}),object:G.lazyObject(()=>Owr),array:G.object({value:G.list(G.lazy(()=>Fm))}),map:G.object({value:G.list(G.lazyObject(()=>Pwr))}),enum:G.object({value:G.string()}),literal:G.object({value:xwr}),oneOf:G.object({value:G.lazy(()=>Bwr)}),null:Swr,unknown:G.object({value:G.lazy(()=>Fm)})}).transform({transform:e=>{switch(e.type){case"primitive":return nu.primitive(e.value);case"object":return nu.object(e);case"array":return nu.array(e.value);case"map":return nu.map(e.value);case"enum":return nu.enum(e.value);case"literal":return nu.literal(e.value);case"oneOf":return nu.oneOf(e.value);case"null":return nu.null(e);case"unknown":return nu.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var gXe=G.string();var Owr=G.objectWithoutOptionalProperties({properties:G.record(gXe,G.lazy(()=>Fm))});var Bwr=G.union("type",{discriminated:G.object({value:G.record(gXe,G.lazy(()=>Fm))}),undiscriminated:G.object({value:G.lazy(()=>Fm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return vwe.discriminated(e.value);case"undiscriminated":return vwe.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Pwr=G.objectWithoutOptionalProperties({key:hXe,value:G.lazy(()=>Fm)});var ERi={};X(ERi,{AllOfPropertyConflict:()=>AXe,ArraySchema:()=>Twr,AsymmetricAlgorithm:()=>Dwr,AsymmetricWebhookSignatureVerification:()=>Fwr,Availability:()=>hwr,BooleanSchema:()=>jwr,BytesResponse:()=>vXe,CasingOverrides:()=>vwr,CommonProperty:()=>Qwr,CursorPagination:()=>Nwr,CustomCodeSample:()=>Uwr,CustomCodeSampleLanguage:()=>kwr,CustomCodeSampleSdk:()=>Lwr,CustomPagination:()=>zwr,DiscriminatedOneOfSchema:()=>Vwr,DiscriminatorContext:()=>EXe,DoubleSchema:()=>qwr,Endpoint:()=>aCr,EndpointExample:()=>CXe,EndpointResponseExample:()=>$wr,EndpointSdkName:()=>tY,EndpointSecurity:()=>_Xe,EnumSchema:()=>mXe,EnumValue:()=>Cwe,ErrorExample:()=>Jwr,FernExample:()=>Gwr,FileResponse:()=>RXe,FileSchema:()=>iCr,FormUrlEncodedRequest:()=>tCr,FullEndpointExample:()=>Kwr,GlobalHeader:()=>uCr,GlobalSecurity:()=>cCr,Header:()=>xwe,HeaderExample:()=>IXe,HmacWebhookSignatureVerification:()=>dCr,HttpEndpointServer:()=>xXe,HttpError:()=>Ywr,HttpMethod:()=>SXe,IdempotencyHeader:()=>mCr,IntSchema:()=>hCr,JsonRequest:()=>rCr,JsonResponse:()=>FXe,LiteralSchema:()=>NXe,LiteralSchemaValue:()=>gCr,LongSchema:()=>ACr,MapSchema:()=>vCr,MultipartFormDataWebhookPayload:()=>ECr,MultipartRequest:()=>TXe,MultipartRequestProperty:()=>Swe,MultipartRequestPropertyEncoding:()=>nCr,MultipartSchema:()=>oCr,NullableSchema:()=>ICr,ObjectProperty:()=>wCr,ObjectPropertyConflictInfo:()=>kXe,ObjectSchema:()=>CCr,OctetStreamRequest:()=>DXe,OffsetPagination:()=>Xwr,OneOfSchema:()=>_Cr,OpenApiIntermediateRepresentation:()=>qwa,OptionalSchema:()=>kCr,Pagination:()=>OXe,PathPagination:()=>Zwr,PathParameter:()=>BXe,PathParameterExample:()=>Hwr,PrimitiveSchema:()=>Bwe,PrimitiveSchemaValue:()=>bCr,QueryParameter:()=>PXe,QueryParameterExample:()=>wXe,ReferencedSchema:()=>rY,Request:()=>sCr,Response:()=>jXe,RetriesConfiguration:()=>QXe,Schema:()=>Nc,Schemas:()=>SCr,SdkGroupInfo:()=>OCr,StreamingResponseExample:()=>Wwr,StringSchema:()=>yCr,SupportedSdkLanguage:()=>Mwr,Tags:()=>BCr,TextResponse:()=>Owe,UnDiscriminatedOneOfSchema:()=>xCr,UriPagination:()=>eCr,Webhook:()=>PCr,WebhookExampleCall:()=>MXe,WebhookHttpMethod:()=>LXe,WebhookPayloadComponent:()=>lCr,WebhookPayloadFormat:()=>pCr,WebhookSignatureAlgorithm:()=>fCr,WebhookSignatureEncoding:()=>yXe,WebhookSignatureVerification:()=>UXe,WebhookTimestamp:()=>bXe,WebhookTimestampFormat:()=>Rwr,WebsocketChannel:()=>NCr,WebsocketHandshake:()=>TCr,WebsocketMessageExample:()=>jCr,WebsocketMessageOrigin:()=>DCr,WebsocketMessageSchema:()=>RCr,WebsocketServer:()=>FCr,WebsocketSessionExample:()=>QCr});var AXe=G.objectWithoutOptionalProperties({propertyKey:G.string(),allOfSchemaIds:G.list($P),conflictingTypeSignatures:G.boolean()});var Twr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Nc),minItems:G.number().optional(),maxItems:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var Dwr=G.enum_(["rsa-sha256","rsa-sha384","rsa-sha512","ecdsa-sha256","ecdsa-sha384","ecdsa-sha512","ed25519"]);var yXe=G.enum_(["base64","hex"]);var Rwr=G.enum_(["unix-seconds","unix-millis","iso8601"]);var bXe=G.objectWithoutOptionalProperties({header:G.string(),format:Rwr.optional(),tolerance:G.number().optional()});var Fwr=G.objectWithoutOptionalProperties({header:G.string(),asymmetricAlgorithm:Dwr,encoding:yXe.optional(),signaturePrefix:G.string().optional(),jwksUrl:G.string().optional(),keyIdHeader:G.string().optional(),timestamp:bXe.optional()});var jwr=G.objectWithoutOptionalProperties({default:G.boolean().optional()});var vXe=G.objectWithoutOptionalProperties({}).extend(gn).extend(Wo).extend(kL);var Qwr=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Nc)});var Nwr=G.objectWithoutOptionalProperties({cursor:G.string(),nextCursor:G.property("next_cursor",G.string()),results:G.string()});var kwr=G.objectWithoutOptionalProperties({name:G.string().optional(),language:G.string(),code:G.string(),install:G.string().optional()}).extend(gn);var Mwr=G.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var Lwr=G.objectWithoutOptionalProperties({name:G.string().optional(),sdk:Mwr,code:G.string()}).extend(gn);var Uwr=G.union("type",{language:kwr,sdk:Lwr}).transform({transform:e=>{switch(e.type){case"language":return JJ.language(e);case"sdk":return JJ.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var zwr=G.objectWithoutOptionalProperties({results:G.string()});var EXe=G.enum_(["data","protocol"]);var Vwr=G.objectWithoutOptionalProperties({discriminantProperty:G.string(),discriminantPropertyNameOverride:G.string().optional(),discriminatorContext:EXe.optional(),commonProperties:G.list(G.lazyObject(()=>Qwr)),schemas:G.record(G.string(),G.lazy(()=>Nc))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var qwr=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional()});var Gwr=G.unknown();var Wwr=G.objectWithoutOptionalProperties({sse:G.boolean(),events:G.list(G.lazy(()=>Fm))});var $wr=G.union("type",{withStreaming:Wwr,withoutStreaming:G.object({value:G.lazy(()=>Fm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return NL.withStreaming(e);case"withoutStreaming":return NL.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var IXe=G.objectWithoutOptionalProperties({name:G.string(),value:G.lazy(()=>Fm)});var Hwr=G.objectWithoutOptionalProperties({name:G.string(),parameterNameOverride:G.string().optional(),value:G.lazy(()=>Fm)});var wXe=G.objectWithoutOptionalProperties({name:G.string(),value:G.lazy(()=>Fm)});var Kwr=G.objectWithoutOptionalProperties({name:G.string().optional(),pathParameters:G.list(Hwr).optional(),queryParameters:G.list(wXe).optional(),headers:G.list(IXe).optional(),request:G.lazy(()=>Fm).optional(),response:$wr.optional(),codeSamples:G.list(Uwr)}).extend(gn);var CXe=G.union("type",{unknown:G.object({value:Gwr}),full:Kwr}).transform({transform:e=>{switch(e.type){case"unknown":return QL.unknown(e.value);case"full":return QL.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var tY=G.objectWithoutOptionalProperties({groupName:wwe,methodName:G.string()});var _Xe=G.list(G.record(_we,G.list(G.string())));var xwe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Nc),env:G.string().optional(),parameterNameOverride:G.string().optional()}).extend(gn).extend(hs).extend(Wo);var xXe=G.objectWithoutOptionalProperties({name:G.string().optional(),url:G.string().optional(),audiences:G.list(G.string()).optional()});var Jwr=G.objectWithoutOptionalProperties({name:G.string().optional(),description:G.string().optional(),example:G.lazy(()=>Fm)});var Ywr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc).optional(),examples:G.list(Jwr).optional()}).extend(gn).extend(Bu).extend(Wo);var SXe=G.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Xwr=G.objectWithoutOptionalProperties({offset:G.string(),results:G.string(),step:G.string().optional(),hasNextPage:G.string().optional()});var Zwr=G.objectWithoutOptionalProperties({nextPath:G.string(),results:G.string()});var eCr=G.objectWithoutOptionalProperties({nextUri:G.string(),results:G.string()});var OXe=G.union("type",{cursor:Nwr,offset:Xwr,custom:zwr,uri:eCr,path:Zwr}).transform({transform:e=>{switch(e.type){case"cursor":return lw.cursor(e);case"offset":return lw.offset(e);case"custom":return lw.custom(e);case"uri":return lw.uri(e);case"path":return lw.path(e);default:return e}},untransform:({_visit:e,...t})=>t});var BXe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Nc),variableReference:G.string().optional(),parameterNameOverride:G.string().optional()}).extend(gn).extend(hs).extend(Wo);var PXe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Nc),parameterNameOverride:G.string().optional(),explode:G.boolean().optional()}).extend(gn).extend(hs).extend(Wo);var tCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc),contentType:G.string().optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo);var rCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc),contentType:G.string().optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo);var nCr=G.enum_(["json","form"]);var iCr=G.objectWithoutOptionalProperties({isOptional:G.boolean(),isArray:G.boolean()}).extend(gn);var oCr=G.union("type",{file:iCr,json:G.object({value:G.lazy(()=>Nc)})}).transform({transform:e=>{switch(e.type){case"file":return YJ.file(e);case"json":return YJ.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Swe=G.objectWithoutOptionalProperties({key:G.string(),schema:oCr,contentType:G.string().optional(),exploded:G.boolean().optional(),encoding:nCr.optional()}).extend(gn);var TXe=G.objectWithoutOptionalProperties({name:G.string().optional(),properties:G.list(Swe)}).extend(gn).extend(Wo);var DXe=G.objectWithoutOptionalProperties({contentType:G.string().optional()}).extend(gn).extend(Wo);var sCr=G.union("type",{octetStream:DXe,multipart:TXe,json:rCr,formUrlEncoded:tCr}).transform({transform:e=>{switch(e.type){case"octetStream":return Hq.octetStream(e);case"multipart":return Hq.multipart(e);case"json":return Hq.json(e);case"formUrlEncoded":return Hq.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var RXe=G.objectWithoutOptionalProperties({}).extend(gn).extend(Wo).extend(kL);var FXe=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Nc),responseProperty:G.string().optional(),terminator:G.string().optional()}).extend(gn).extend(Wo).extend(kL);var Owe=G.objectWithoutOptionalProperties({}).extend(gn).extend(Wo).extend(kL);var jXe=G.union("type",{file:RXe,json:FXe,text:Owe,bytes:vXe,streamingSse:FXe,streamingText:Owe,streamingJson:FXe}).transform({transform:e=>{switch(e.type){case"file":return _S.file(e);case"json":return _S.json(e);case"text":return _S.text(e);case"bytes":return _S.bytes(e);case"streamingSse":return _S.streamingSse(e);case"streamingText":return _S.streamingText(e);case"streamingJson":return _S.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var QXe=G.union("type",{disabled:G.object({value:G.boolean().optional()})}).transform({transform:e=>e.type==="disabled"?vDt.disabled(e.value):e,untransform:({_visit:e,...t})=>t});var aCr=G.objectWithoutOptionalProperties({authed:G.boolean(),security:_Xe.optional(),internal:G.boolean().optional(),idempotent:G.boolean().optional(),method:SXe,audiences:G.list(G.string()),path:G.string(),summary:G.string().optional(),operationId:G.string().optional(),tags:G.list(HP),pathParameters:G.list(BXe),queryParameters:G.list(PXe),headers:G.list(xwe),sdkName:tY.optional(),generatedRequestName:G.string(),requestNameOverride:G.string().optional(),request:sCr.optional(),response:jXe.optional(),errors:G.record(ZJ,Ywr),servers:G.list(xXe),examples:G.list(CXe),pagination:OXe.optional(),retries:QXe.optional()}).extend(gn).extend(hs).extend(Wo).extend(su);var uCr=G.objectWithoutOptionalProperties({header:G.string(),name:G.string().optional(),optional:G.boolean().optional(),env:G.string().optional(),schema:G.lazy(()=>Nc).optional()});var cCr=G.list(G.record(_we,G.list(G.string())));var lCr=G.enum_(["body","timestamp","notification-url","message-id"]);var pCr=G.objectWithoutOptionalProperties({components:G.list(lCr),delimiter:G.string().optional()});var fCr=G.enum_(["sha256","sha1","sha384","sha512"]);var dCr=G.objectWithoutOptionalProperties({header:G.string(),algorithm:fCr.optional(),encoding:yXe.optional(),signaturePrefix:G.string().optional(),payloadFormat:pCr.optional(),timestamp:bXe.optional()});var mCr=G.objectWithoutOptionalProperties({header:G.string(),name:G.string().optional(),env:G.string().optional(),schema:G.lazy(()=>Nc).optional()});var hCr=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional()});var gCr=G.union("type",{boolean:G.object({value:G.boolean()}),string:G.object({value:G.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return nA.boolean(e.value);case"string":return nA.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var NXe=G.objectWithoutOptionalProperties({value:gCr}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var ACr=G.objectWithoutOptionalProperties({default:G.number().optional()});var yCr=G.objectWithoutOptionalProperties({default:G.string().optional(),pattern:G.string().optional(),format:G.string().optional(),minLength:G.number().optional(),maxLength:G.number().optional()});var bCr=G.union("type",{int:hCr,int64:ACr,uint:G.object({}),uint64:G.object({}),float:G.object({}),double:qwr,string:yCr,datetime:G.object({}),datetimeRfc2822:G.object({}),date:G.object({}),base64:G.object({}),boolean:jwr}).transform({transform:e=>{switch(e.type){case"int":return Wc.int(e);case"int64":return Wc.int64(e);case"uint":return Wc.uint();case"uint64":return Wc.uint64();case"float":return Wc.float();case"double":return Wc.double(e);case"string":return Wc.string(e);case"datetime":return Wc.datetime();case"datetimeRfc2822":return Wc.datetimeRfc2822();case"date":return Wc.date();case"base64":return Wc.base64();case"boolean":return Wc.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bwe=G.objectWithoutOptionalProperties({schema:bCr}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var vCr=G.objectWithoutOptionalProperties({key:Bwe,value:G.lazy(()=>Nc),minProperties:G.number().optional(),maxProperties:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Hc).extend(Tf);var ECr=G.objectWithoutOptionalProperties({name:G.string().optional(),properties:G.list(Swe)}).extend(gn).extend(Wo);var ICr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Nc)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var kXe=G.objectWithoutOptionalProperties({differentSchema:G.boolean()});var wCr=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Nc),readonly:G.boolean().optional(),writeonly:G.boolean().optional(),conflict:G.record($P,kXe),generatedName:G.string(),nameOverride:G.string().optional(),audiences:G.list(G.string())}).extend(hs);var rY=G.objectWithoutOptionalProperties({schema:$P}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc);var CCr=G.objectWithoutOptionalProperties({allOf:G.list(rY),properties:G.list(G.lazyObject(()=>wCr)),allOfPropertyConflicts:G.list(AXe),additionalProperties:G.boolean(),minProperties:G.number().optional(),maxProperties:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var _Cr=G.union("type",{discriminated:G.lazyObject(()=>Vwr),undiscriminated:G.lazyObject(()=>xCr)}).transform({transform:e=>{switch(e.type){case"discriminated":return XJ.discriminated(e);case"undiscriminated":return XJ.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var SCr=G.objectWithoutOptionalProperties({rootSchemas:G.record($P,G.lazy(()=>Nc)),namespacedSchemas:G.record(mwr,G.record($P,G.lazy(()=>Nc)))});var OCr=G.objectWithoutOptionalProperties({summary:G.string().optional(),description:G.string().optional()});var BCr=G.objectWithoutOptionalProperties({tagsById:G.record(HP,_wr),orderedTagIds:G.list(HP).optional()});var MXe=G.objectWithoutOptionalProperties({name:G.string().optional(),payload:G.lazy(()=>Fm)}).extend(gn);var LXe=G.enum_(["GET","POST"]);var UXe=G.union("type",{hmac:dCr,asymmetric:Fwr}).transform({transform:e=>{switch(e.type){case"hmac":return xke.hmac(e);case"asymmetric":return xke.asymmetric(e);default:return e}},untransform:({_visit:e,...t})=>t});var PCr=G.objectWithoutOptionalProperties({audiences:G.list(G.string()),sdkName:tY.optional(),method:LXe,summary:G.string().optional(),operationId:G.string(),tags:G.list(HP),headers:G.list(xwe),generatedPayloadName:G.string(),payload:G.lazy(()=>Nc),multipartFormData:ECr.optional(),response:jXe.optional(),signatureVerification:UXe.optional(),examples:G.list(MXe)}).extend(gn).extend(Wo).extend(su);var TCr=G.objectWithoutOptionalProperties({queryParameters:G.list(PXe),headers:G.list(xwe),pathParameters:G.list(BXe)});var DCr=G.enum_(["client","server"]);var RCr=G.objectWithoutOptionalProperties({name:G.string(),origin:DCr,body:G.lazy(()=>Nc),methodName:G.string().optional()});var FCr=G.objectWithoutOptionalProperties({name:G.string(),url:G.string()});var jCr=G.objectWithoutOptionalProperties({messageType:G.string(),payload:G.lazy(()=>Fm)}).extend(gn);var QCr=G.objectWithoutOptionalProperties({name:G.string().optional(),queryParameters:G.list(wXe).optional(),headers:G.list(IXe).optional(),messages:G.list(jCr)}).extend(gn);var NCr=G.objectWithoutOptionalProperties({audiences:G.list(G.string()),path:G.string(),groupName:wwe,summary:G.string().optional(),connectMethodName:G.string().optional(),handshake:TCr,messages:G.list(RCr),servers:G.list(FCr),examples:G.list(QCr)}).extend(gn).extend(Wo);var qwa=G.objectWithoutOptionalProperties({apiVersion:G.unknown().optional(),title:G.string().optional(),description:G.string().optional(),basePath:G.string().optional(),servers:G.list(_Dt),websocketServers:G.list(_Dt),groups:G.record(G.string(),OCr),tags:BCr,hasEndpointsMarkedInternal:G.boolean(),endpoints:G.list(aCr),webhooks:G.list(PCr),channels:G.record(G.string(),NCr),groupedSchemas:SCr,variables:G.record(G.string(),Bwe),nonRequestReferencedSchemas:G.set($P),securitySchemes:G.record(_we,wwr),security:cCr.optional(),globalHeaders:G.list(uCr).optional(),idempotencyHeaders:G.list(mCr).optional()});var kCr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Nc)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var Nc=G.union("type",{primitive:Bwe,object:G.lazyObject(()=>CCr),array:G.lazyObject(()=>Twr),map:G.lazyObject(()=>vCr),optional:G.lazyObject(()=>kCr),enum:mXe,reference:rY,literal:NXe,oneOf:G.object({value:G.lazy(()=>_Cr)}),nullable:G.lazyObject(()=>ICr),unknown:Bu}).transform({transform:e=>{switch(e.type){case"primitive":return ya.primitive(e);case"object":return ya.object(e);case"array":return ya.array(e);case"map":return ya.map(e);case"optional":return ya.optional(e);case"enum":return ya.enum(e);case"reference":return ya.reference(e);case"literal":return ya.literal(e);case"oneOf":return ya.oneOf(e.value);case"nullable":return ya.nullable(e);case"unknown":return ya.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var xCr=G.objectWithoutOptionalProperties({schemas:G.list(G.lazy(()=>Nc))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var IRi={};X(IRi,{ArraySchemaWithExample:()=>MCr,Base64WithExample:()=>LCr,BooleanWithExample:()=>UCr,CommonPropertyWithExample:()=>zCr,DateWithExample:()=>VCr,DatetimeWithExample:()=>xDt,DiscriminatedOneOfSchemaWithExample:()=>qCr,DoubleWithExample:()=>GCr,EndpointWithExample:()=>Gwa,EnumSchemaWithExample:()=>ZCr,FloatWithExample:()=>e_r,HeaderWithExample:()=>Pwe,HttpErrorWithExample:()=>WCr,Int64WithExample:()=>t_r,IntWithExample:()=>r_r,JsonRequestWithExample:()=>HCr,JsonResponseWithExample:()=>VXe,MapSchemaWithExample:()=>a_r,MultipartFormDataWebhookPayloadWithExample:()=>u_r,NamedFullExample:()=>FF,NullableSchemaWithExample:()=>c_r,ObjectPropertyWithExample:()=>l_r,ObjectSchemaWithExample:()=>p_r,OneOfSchemaWithExample:()=>f_r,OptionalSchemaWithExample:()=>m_r,ParseFormUrlEncodedRequest:()=>KCr,ParseMultipartRequest:()=>JCr,ParseOctetStreamRequest:()=>YCr,PathParameterWithExample:()=>$Cr,PrimitiveSchemaValueWithExample:()=>s_r,PrimitiveSchemaWithExample:()=>GXe,QueryParameterWithExample:()=>zXe,RequestWithExample:()=>XCr,ResponseWithExample:()=>qXe,SchemaWithExample:()=>Df,StringSchemaWithExample:()=>n_r,Uint64WithExample:()=>i_r,UintWithExample:()=>o_r,UnDiscriminatedOneOfSchemaWithExample:()=>d_r,UnknownSchemaWithExample:()=>h_r,WebhookWithExample:()=>Wwa,WebsocketHandshakeWithExample:()=>$wa});var MCr=G.objectWithoutOptionalProperties({value:G.lazy(()=>Df),minItems:G.number().optional(),maxItems:G.number().optional(),example:G.list(G.unknown()).optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var LCr=G.objectWithoutOptionalProperties({example:G.string().optional()});var UCr=G.objectWithoutOptionalProperties({default:G.boolean().optional(),example:G.boolean().optional()});var zCr=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Df)});var xDt=G.objectWithoutOptionalProperties({example:G.string().optional()});var VCr=G.objectWithoutOptionalProperties({example:G.string().optional()});var qCr=G.objectWithoutOptionalProperties({discriminantProperty:G.string(),discriminantPropertyNameOverride:G.string().optional(),discriminatorContext:EXe.optional(),commonProperties:G.list(G.lazyObject(()=>zCr)),schemas:G.record(G.string(),G.lazy(()=>Df))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var GCr=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional(),example:G.number().optional()});var Pwe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Df),env:G.string().optional(),parameterNameOverride:G.string().optional()}).extend(gn).extend(hs).extend(Wo);var FF=G.objectWithoutOptionalProperties({name:G.string().optional(),value:G.unknown()}).extend(gn);var WCr=G.objectWithoutOptionalProperties({statusCode:ZJ,schema:G.lazy(()=>Df),fullExamples:G.list(FF).optional()}).extend(gn).extend(Bu).extend(Wo);var $Cr=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Df),variableReference:G.string().optional(),parameterNameOverride:G.string().optional(),explode:G.boolean().optional()}).extend(gn).extend(hs).extend(Wo);var zXe=G.objectWithoutOptionalProperties({name:G.string(),schema:G.lazy(()=>Df),parameterNameOverride:G.string().optional(),explode:G.boolean().optional()}).extend(gn).extend(hs).extend(Wo);var HCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Df),contentType:G.string().optional(),fullExamples:G.list(FF).optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo).extend(eY);var KCr=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Df),contentType:G.string().optional(),fullExamples:G.list(FF).optional(),additionalProperties:G.boolean()}).extend(gn).extend(Wo).extend(eY);var JCr=G.objectWithoutOptionalProperties({fullExamples:G.list(FF).optional()}).extend(TXe).extend(eY);var YCr=G.objectWithoutOptionalProperties({}).extend(DXe).extend(eY);var XCr=G.union("type",{octetStream:YCr,multipart:JCr,json:HCr,formUrlEncoded:KCr}).transform({transform:e=>{switch(e.type){case"octetStream":return WP.octetStream(e);case"multipart":return WP.multipart(e);case"json":return WP.json(e);case"formUrlEncoded":return WP.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var VXe=G.objectWithoutOptionalProperties({schema:G.lazy(()=>Df),responseProperty:G.string().optional(),terminator:G.string().optional(),fullExamples:G.list(FF).optional()}).extend(gn).extend(Wo).extend(kL);var qXe=G.union("type",{file:RXe,json:VXe,text:Owe,bytes:vXe,streamingSse:VXe,streamingText:Owe,streamingJson:VXe}).transform({transform:e=>{switch(e.type){case"file":return Yh.file(e);case"json":return Yh.json(e);case"text":return Yh.text(e);case"bytes":return Yh.bytes(e);case"streamingSse":return Yh.streamingSse(e);case"streamingText":return Yh.streamingText(e);case"streamingJson":return Yh.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gwa=G.objectWithoutOptionalProperties({authed:G.boolean(),security:_Xe.optional(),internal:G.boolean().optional(),idempotent:G.boolean().optional(),method:SXe,audiences:G.list(G.string()),path:G.string(),summary:G.string().optional(),operationId:G.string().optional(),tags:G.list(HP),pathParameters:G.list($Cr),queryParameters:G.list(zXe),headers:G.list(Pwe),sdkName:tY.optional(),generatedRequestName:G.string(),requestNameOverride:G.string().optional(),request:XCr.optional(),response:qXe.optional(),errors:G.record(ZJ,WCr),servers:G.list(xXe),examples:G.list(CXe),pagination:OXe.optional(),retries:QXe.optional()}).extend(gn).extend(hs).extend(Wo).extend(su);var ZCr=G.objectWithoutOptionalProperties({default:Cwe.optional(),values:G.list(Cwe),example:G.string().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var e_r=G.objectWithoutOptionalProperties({example:G.number().optional()});var t_r=G.objectWithoutOptionalProperties({default:G.number().optional(),example:G.number().optional()});var r_r=G.objectWithoutOptionalProperties({default:G.number().optional(),minimum:G.number().optional(),maximum:G.number().optional(),exclusiveMinimum:G.boolean().optional(),exclusiveMaximum:G.boolean().optional(),multipleOf:G.number().optional(),example:G.number().optional()});var n_r=G.objectWithoutOptionalProperties({default:G.string().optional(),pattern:G.string().optional(),format:G.string().optional(),minLength:G.number().optional(),maxLength:G.number().optional(),example:G.string().optional()});var i_r=G.objectWithoutOptionalProperties({default:G.number().optional(),example:G.number().optional()});var o_r=G.objectWithoutOptionalProperties({default:G.number().optional(),example:G.number().optional()});var s_r=G.union("type",{int:r_r,int64:t_r,uint:o_r,uint64:i_r,float:e_r,double:GCr,string:n_r,datetime:xDt,datetimeRfc2822:xDt,date:VCr,base64:LCr,boolean:UCr}).transform({transform:e=>{switch(e.type){case"int":return Si.int(e);case"int64":return Si.int64(e);case"uint":return Si.uint(e);case"uint64":return Si.uint64(e);case"float":return Si.float(e);case"double":return Si.double(e);case"string":return Si.string(e);case"datetime":return Si.datetime(e);case"datetimeRfc2822":return Si.datetimeRfc2822(e);case"date":return Si.date(e);case"base64":return Si.base64(e);case"boolean":return Si.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var GXe=G.objectWithoutOptionalProperties({schema:s_r}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var a_r=G.objectWithoutOptionalProperties({key:GXe,value:G.lazy(()=>Df),minProperties:G.number().optional(),maxProperties:G.number().optional(),example:G.unknown().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Hc).extend(Tf);var u_r=G.objectWithoutOptionalProperties({name:G.string().optional(),properties:G.list(Swe)}).extend(gn).extend(Wo);var c_r=G.objectWithoutOptionalProperties({value:G.lazy(()=>Df)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var l_r=G.objectWithoutOptionalProperties({key:G.string(),schema:G.lazy(()=>Df),readonly:G.boolean().optional(),writeonly:G.boolean().optional(),audiences:G.list(G.string()),conflict:G.record($P,kXe),nameOverride:G.string().optional(),generatedName:G.string()}).extend(hs);var p_r=G.objectWithoutOptionalProperties({allOf:G.list(rY),properties:G.list(G.lazyObject(()=>l_r)),allOfPropertyConflicts:G.list(AXe),fullExamples:G.list(FF).optional(),additionalProperties:G.boolean(),minProperties:G.number().optional(),maxProperties:G.number().optional()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Wo).extend(Hc).extend(Tf);var f_r=G.union("type",{discriminated:G.lazyObject(()=>qCr),undiscriminated:G.lazyObject(()=>d_r)}).transform({transform:e=>{switch(e.type){case"discriminated":return p2.discriminated(e);case"undiscriminated":return p2.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var m_r=G.objectWithoutOptionalProperties({value:G.lazy(()=>Df)}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc).extend(Tf);var h_r=G.objectWithoutOptionalProperties({example:G.unknown()}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(Hc);var Df=G.union("type",{primitive:GXe,object:G.lazyObject(()=>p_r),array:G.lazyObject(()=>MCr),map:G.lazyObject(()=>a_r),optional:G.lazyObject(()=>m_r),enum:ZCr,reference:rY,literal:NXe,oneOf:G.object({value:G.lazy(()=>f_r)}),nullable:G.lazyObject(()=>c_r),unknown:h_r}).transform({transform:e=>{switch(e.type){case"primitive":return jr.primitive(e);case"object":return jr.object(e);case"array":return jr.array(e);case"map":return jr.map(e);case"optional":return jr.optional(e);case"enum":return jr.enum(e);case"reference":return jr.reference(e);case"literal":return jr.literal(e);case"oneOf":return jr.oneOf(e.value);case"nullable":return jr.nullable(e);case"unknown":return jr.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var d_r=G.objectWithoutOptionalProperties({schemas:G.list(G.lazy(()=>Df))}).extend($c).extend(su).extend(Bu).extend(gn).extend(hs).extend(RF).extend(Wo).extend(Hc).extend(Tf);var Wwa=G.objectWithoutOptionalProperties({audiences:G.list(G.string()),sdkName:tY.optional(),method:LXe,summary:G.string().optional(),operationId:G.string(),tags:G.list(HP),headers:G.list(Pwe),generatedPayloadName:G.string(),payload:G.lazy(()=>Df),multipartFormData:u_r.optional(),response:qXe.optional(),signatureVerification:UXe.optional(),examples:G.list(MXe)}).extend(gn).extend(Wo).extend(su);var $wa=G.objectWithoutOptionalProperties({queryParameters:G.list(zXe),headers:G.list(Pwe)});var Hwa=/^(\d+)/,WXe=/^[a-zA-Z][a-zA-Z0-9_]*$/,Kwa={"<":"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 Oke(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let s=Math.floor(e/10),a=e%10;return a===0?n[s]:`${n[s]}_${t[a]}`}if(e<1e3){let s=Math.floor(e/100),a=e%100;return a===0?`${t[s]}_hundred`:`${t[s]}_hundred_${Oke(a)}`}let i=Math.floor(e/1e3),o=e%1e3;return o===0?`${t[i]}_thousand`:`${t[i]}_thousand_${Oke(o)}`}xi();function SDt(e){let t=e.match(Hwa);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let o=Oke(i);return n.length>0?`${o}_${n}`:o}}}function $Xe(e){let t=SDt(e),r=Kwa[e];return t!=null?dl($n(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":dl($n(e)))}xi();function jF(e,t){return e.type==="primitive"&&t.type==="primitive"?Jwa(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?ahf(e.values,t.values):e.type==="array"&&t.type==="array"?jF(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"?jF(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?uhf(e.value,t.value):e.type==="object"&&t.type==="object"?chf(e,t):e.type==="map"&&t.type==="map"?Jwa(e.key.schema,t.key.schema)&&jF(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function Jwa(e,t){return e.type===t.type}function ahf(e,t){let r=new Set(e.map(i=>i.value)),n=new Set(t.map(i=>i.value));return m0(r,n)}function uhf(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:jF(n,i)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:jF(r,i)}):!1}function chf(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let o=r[n];return o==null?!1:jF(o,i.schema)})}Nt();function qy(e){switch(e){case MC.Deprecated:return"deprecated";case MC.Beta:return"pre-release";case MC.GenerallyAvailable:return"generally-available";default:return}}Nt();function g_r(e){if(e.type==="protobuf")return{proto:{type:e.typeName}};xe(e.type)}Nt();gg();Nt();gg();xi();function Ywa(e){let t=e.match(/^(_+)/),r=e.match(/(_+)$/),n=t?.[1]??"",i=r?.[1]??"";if(n===""&&i==="")return $n(e);if(n.length+i.length>=e.length)return e;let o=e.slice(n.length,e.length-i.length||void 0);return`${n}${$n(o)}${i}`}function lhf(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function Xwa(e){let t=e?lhf(e):void 0;if(t==null||t.length===0)return nke;let r=[];for(let[n,i]of t.entries())typeof i=="string"?r.push(Ywa(i)):typeof i=="object"?i.type==="namespace"?n<t.length-1?r.push(Ywa(i.name)):r.push(i.name,nke):xe(i.type):xe(i);return r.join("/")}function Rhe(e){return ds.of(`${Xwa(e)}.yml`)}function wRi({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?nke:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,Xwa(r))}function Zwa({sdkName:e,namespaceOverride:t}){return ds.of(`${wRi({sdkName:e,namespaceOverride:t})}.yml`)}function eCa({location:e,namespaceOverride:t}){return t!=null?f0(ds.of(t),e):e}var phf=ds.of(vp);function tCa(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return A_r({namespace:e.namespace,groupName:e.groupName});case"oneOf":return A_r({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return phf;default:xe(e)}}function A_r({namespace:e,groupName:t}){return e!=null&&t!=null?Rhe([{type:"namespace",name:e},...t]):e!=null?Rhe([{type:"namespace",name:e}]):Rhe(t)}Nt();function Fhe(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:xe(e)}}function cp(e){return typeof e=="string"?e:e.type}function HXe(e){if(typeof e!="string")return e.docs}function ODt(e){if(typeof e!="string")return e.default}function CRi(e){if(typeof e!="string")return e.validation}function KXe(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 nCa(e){let t=cp(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?rCa(e):{...e,type:rCa(e.type)}}function rCa(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function Bke(e){return cp(e).startsWith("optional<")?e:typeof e=="string"?iCa(e):{...e,type:iCa(e.type)}}function iCa(e){return e.startsWith("optional<")?e:`optional<${e}>`}var fhf=-2147483648,dhf=2147483647,mhf=-17976931348623157e292,hhf=17976931348623157e292;function iu({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:o}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return y_r(e);case"array":return SRi({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"map":return ORi({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"reference":return xRi({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return PRi();case"optional":return b_r({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"nullable":return BRi({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"enum":return Chf({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:o});case"literal":return e.value,TRi(e);case"object":return _hf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});case"oneOf":return xhf({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});default:xe(e)}}function y_r(e){switch(e.schema.type){case"string":return yhf({description:e.description,schema:e.schema});case"int":return bhf({description:e.description,schema:e.schema});case"float":return vhf({description:e.description,schema:e.schema});case"double":return Ehf({description:e.description,schema:e.schema});case"boolean":return ghf({description:e.description,schema:e.schema});case"int64":return Ahf({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",datetimeRfc2822:()=>"datetime-rfc-2822",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:qy(e.availability)}:{}}}function ghf({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function Ahf({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function yhf({description:e,schema:t}){let r="string",n=Ihf(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function bhf({description:e,schema:t}){let r="integer",n=oCa(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function vhf({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function Ehf({description:e,schema:t}){let r="double",n=oCa(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function Ihf(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,o=whf(t);if(!(o==null&&r==null&&n==null&&i==null))return{format:o,pattern:r,minLength:n,maxLength:i}}function whf(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 oCa(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:o,exclusiveMaximum:s}=e;if(r=_Ri(r,t),n=_Ri(n,t),i=_Ri(i,t),!(r==null&&n==null&&o==null&&s==null&&i==null))return{min:r,max:n,exclusiveMin:o,exclusiveMax:s,multipleOf:i}}function _Ri(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[fhf,dhf]:[mhf,hhf];return e<r||e>n?void 0:e}function xRi({schema:e,fileContainingReference:t,context:r}){let n=r.getSchema(e.schema,e.namespace);if(n==null)return"unknown";let i=Shf(n)??e.schema,o=r.options.respectReadonlySchemas?r.getSchemaFinalName(i):i,s=Fhe(n),a=Ohf(n),c=v_r({context:r,fileContainingReference:t,declarationFile:A_r({namespace:e.namespace,groupName:s}),type:o});return n.type==="nullable"&&(c=r.options.wrapReferencesToNullableInOptional?`optional<${c}>`:`nullable<${c}>`),n.type==="optional"&&!c.startsWith("optional<")&&(c=`optional<${c}>`),e.description==null&&a==null?c:{type:c,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function SRi({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=`list<${cp(s)}>`;return e.description==null&&e.title==null?a:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{},type:a}}function ORi({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=y_r(e.key),a=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),u=e.encoding!=null?g_r(e.encoding):void 0,c=`map<${cp(s)}, ${cp(a)}>`;if(e.description==null&&u==null&&e.title==null)return c;let l={type:c};return e.description!=null&&(l.docs=e.description),e.encoding!=null&&(l.encoding=u),e.availability!=null&&(l.availability=qy(e.availability)),l}function BRi({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){if(!n.options.respectNullableSchemas)return b_r({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:o});let s=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=cp(s),u=HXe(s),c=ODt(s),l=CRi(s),p=nCa(a);if(n.options.wrapReferencesToNullableInOptional&&(p=Bke(p)),e.availability==null&&e.description==null&&u==null&&c==null&&l==null&&e.title==null)return p;let d=typeof p=="string"?{type:p}:p;return(e.description!=null||u!=null)&&(d.docs=e.description??u),c!=null&&(d.default=c),l!=null&&(d.validation=l),e.availability!=null&&(d.availability=qy(e.availability)),d}function b_r({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=iu({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=cp(s),u=HXe(s),c=ODt(s),l=CRi(s),p=Bke(a);if(e.availability==null&&e.description==null&&u==null&&c==null&&l==null&&e.title==null)return p;let d=typeof p=="string"?{type:p}:p;return(e.description!=null||u!=null)&&(d.docs=e.description??u),c!=null&&(d.default=c),l!=null&&(d.validation=l),e.availability!=null&&(d.availability=qy(e.availability)),d}function PRi(){return"unknown"}function TRi(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:xe(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function Chf({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let o=BDt(e,i),s=e.nameOverride??e.generatedName;n.builder.addType(r,{name:s,schema:o.schema});let a=v_r({type:s,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return a;let u={type:a};return e.description!=null&&(u.docs=e.description),e.default!=null&&(u.default=e.default.value),e.availability!=null&&(u.availability=qy(e.availability)),u}function _hf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=DRi({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:s.schema});let u=v_r({type:a,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function xhf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:o}){let s=RRi({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:o}),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:s.schema});let u=v_r({type:a,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?u:{...e.title!=null?{"display-name":e.title}:{},type:u,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:qy(e.availability)}:{}}}function v_r({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function Shf(e){return ya._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 Ohf(e){return ya._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 pw;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(pw||(pw={}));Nt();function jhe(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:xe(e)}}function aCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let o;switch(e.type){case"primitive":o=Thf(e);break;case"array":o=Bhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":o=Phf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":o=Dhf({schema:e,context:t,declarationFile:r,namespace:n});break;case"unknown":o=Fhf(e.nameOverride,e.generatedName);break;case"optional":o=cCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":o=Rhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":o=BDt(e,i);break;case"literal":o=jhf(e,e.nameOverride,e.generatedName);break;case"object":o=DRi({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"oneOf":o=RRi({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;default:xe(e)}return o}function DRi({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let o=t.isInState(pw.Request),s=t.options.respectReadonlySchemas,a=t.getEndpointMethod(),c=o&&s&&(a==="POST"||a==="PUT"||a==="PATCH"),l=!1,p={},d=new Set;for(let v of e.properties){if(v.readonly&&(l=!0),c&&v.readonly)continue;if(Object.keys(v.conflict).length>0){if(Object.entries(v.conflict).every(([x,R])=>!R.differentSchema))continue;Object.entries(v.conflict).forEach(([x])=>{FRi({property:v.key,schemaId:x,context:t,namespace:n}).forEach(z=>{d.add(z)})})}let E=iu({schema:v.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}),b=v.audiences,I=v.nameOverride,w=qy(v.availability),_=Mhf(v);p[v.key]=khf({typeReference:E,audiences:b,name:I,availability:w,propertyAccess:_})}let f=new Set;for(let v of e.allOfPropertyConflicts)v.allOfSchemaIds.forEach(E=>d.add(E)),v.conflictingTypeSignatures&&f.add(v.propertyKey);let m=[];for(let v of e.allOf){let E=E_r({schema:v.schema,context:t,namespace:n});if(E==null||d.has(v.schema)||d.has(E))continue;let b=iu({schema:ya.reference(v),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});m.push(KXe(cp(b)))}for(let v of d){let E=JXe(t,v,n);for(let b of E.properties)p[b.key]==null&&(f.has(b.key)&&(p[b.key]="unknown"),p[b.key]=iu({schema:b.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}));for(let b of E.allOf){if(d.has(b.schema))continue;let I=iu({schema:ya.reference(b),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});m.push(KXe(cp(I)))}}let h={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(p).map(([v,E])=>Nhf(v)?[v,typeof E=="string"?{type:E,name:`_${v}`}:{...E,name:`_${v}`}]:[v,E]))};m.length>0&&(h.extends=m),e.additionalProperties&&(h["extra-properties"]=!0),e.availability!=null&&(h.availability=qy(e.availability)),e.source!=null&&(h.source=jhe(e.source)),h.inline=jRi(e,i);let A=e.nameOverride??e.generatedName,y=l&&t.options.respectReadonlySchemas&&!c?`${A}Read`:A;return y!==A&&t.setSchemaFinalName(A,y),{name:y,schema:h}}function FRi({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return FRi({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:o,allOf:s}=JXe(r,t,n),a=o.some(c=>c.key===e),u=[...s.flatMap(c=>FRi({property:e,context:r,schemaId:c.schema,namespace:n}))];if(a||u.length>0)return[t,...u]}return[]}function uCa(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?JXe(e,t.schema,r):t.type==="nullable"?uCa(e,t.value,r):{properties:[],allOf:[]}}function JXe(e,t,r){let n=e.getSchema(t,r);return n==null?{properties:[],allOf:[]}:uCa(e,n,r)}function Bhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:SRi({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function Phf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:ORi({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function Thf(e){let t=y_r(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function sCa(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function BDt(e,t){let r={enum:e.values.map(o=>{let s=o.nameOverride??o.generatedName,a=o.value;if(s===a&&o.description==null&&(o.casing==null||sCa(o.casing)))return s;let u={value:o.value};if(s!==a&&(u.name=s),o.description!=null&&(u.docs=o.description),o.casing!=null&&!sCa(o.casing)){let c={},l=!1;o.casing.camel!=null&&(c.camel=o.casing.camel,l=!0),o.casing.screamingSnake!=null&&(c["screaming-snake"]=o.casing.screamingSnake,l=!0),o.casing.snake!=null&&(c.snake=o.casing.snake,l=!0),o.casing.pascal!=null&&(c.pascal=o.casing.pascal,l=!0),l&&(u.casing=c)}return u})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=jRi(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?jhe(e.source):void 0};for(let o of r.enum){let s=typeof o=="string"?o:o.name??o.value;n.has(s.toLowerCase())||(i.enum.push(o),n.add(s.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function Dhf({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:xRi({schema:e,context:t,fileContainingReference:r,namespace:n})}}function Rhf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:BRi({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:cCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function cCa({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:b_r({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function Fhf(e,t){return{name:e??t,schema:PRi()}}function jhf(e,t,r){return{name:t??r,schema:TRi(e)}}function RRi({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let o=e.encoding!=null?g_r(e.encoding):void 0;if(e.type==="discriminated"){let a={};for(let c of e.commonProperties)a[c.key]=iu({schema:c.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1});let u={};for(let[c,l]of Object.entries(e.schemas))u[c]=iu({schema:l,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantPropertyNameOverride!=null?{name:e.discriminantPropertyNameOverride,value:e.discriminantProperty}:e.discriminantProperty,"base-properties":a,docs:e.description??void 0,availability:e.availability!=null?qy(e.availability):void 0,union:u,encoding:o,source:e.source!=null?jhe(e.source):void 0,...e.discriminatorContext&&{context:e.discriminatorContext}}}}let s=[];for(let a of e.schemas)s.push(iu({schema:a,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:s,encoding:o,source:e.source!=null?jhe(e.source):void 0,inline:jRi(e,i)}}}var Qhf=/^[0-9]/;function Nhf(e){return Qhf.test(e)}function E_r({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?E_r({context:t,schema:n.schema,namespace:r}):e}function khf({typeReference:e,audiences:t,name:r,availability:n,propertyAccess:i}){return t.length===0&&r==null&&n==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{},...i!=null?{access:i}:{}}}function jRi(e,t){return e.inline===!0||t>0?!0:void 0}function Mhf(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return mm.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return mm.ObjectPropertyAccess.WriteOnly}}xi();function lCa(e){let t=e.replace(/^x-|^X-/,"");return $n(t)}function pCa(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??lCa(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:i}),t||(e.builder.setAuth(r),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(ds.of("__package__.yml"),{name:"OauthScope",schema:BDt(n.scopesEnum,0).schema})}}xi();function nY({header:e,context:t,fileContainingReference:r,namespace:n}){let i=iu({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),o=cp(i),s=e.name.replace(/^x-|^X-/,""),a=e.parameterNameOverride!=null?e.parameterNameOverride:$n(s);if(e.description==null&&e.name===a&&e.env==null&&e.availability==null)return o;let u={type:o};return a!==e.name&&(u.name=a),e.description!=null&&(u.docs=e.description),e.env!=null&&(u.env=e.env),e.availability!=null&&(u.availability=qy(e.availability)),u}function I_r({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=iu({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return cp(i);let o=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:cp(i)};return e.description!=null&&(o.docs=e.description),e.availability!=null&&(o.availability=qy(e.availability)),o}gg();function C_r({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=QRi({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let o=cp(i.value),s=ODt(i.value);o==="unknown"?o="string":o==="optional<unknown>"&&(o="optional<string>");let a={type:o};return s!=null&&(a.default=s),i.allowMultiple&&(a["allow-multiple"]=!0),e.explode!=null&&(a.explode=e.explode),e.description!=null&&(a.docs=e.description),e.parameterNameOverride!=null&&(a.name=e.parameterNameOverride),e.availability!=null&&(a.availability=qy(e.availability)),Lhf(i.value)&&i.value.validation!==void 0&&(a.validation=i.value.validation),a.default==null&&a["allow-multiple"]==null&&a.docs==null&&a.name==null&&a.availability==null&&a.validation==null&&a.explode==null?o:a}function QRi({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:iu({schema:ya.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:ds.of(vp),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,u]of Object.entries(i.value.schemas))u.type==="primitive"&&u.schema.type==="string"&&(s=!0),u.type==="literal"&&u.value.type==="string"&&(WXe.test(u.value.value)?o.push(u.value.value):o.push({value:u.value.value,name:$Xe(u.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&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(i.value.schemas.length===2){let[a,u]=i.value.schemas;if(a!=null&&u!=null&&w_r({array:a,primitive:u}))return{value:iu({schema:ya.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&w_r({array:u,primitive:a}))return{value:iu({schema:ya.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[a,u]of Object.entries(i.value.schemas))return QRi({schema:u,context:t,fileContainingReference:r,namespace:n})}else if(t.options.objectQueryParameters)return{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let i=e.type==="optional"?ya.optional:ya.nullable;if(e.value.type==="reference"){let o=t.getSchema(e.value.schema,n);if(o==null)return;if(o.type==="array")return{value:iu({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:o.value,description:e.description??o.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:iu({schema:i({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:n,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let o=[],s=!1;for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="primitive"&&u.schema.type==="string"&&(s=!0),u.type==="literal"&&u.value.type==="string"&&(WXe.test(u.value.value)?o.push(u.value.value):o.push({value:u.value.value,name:$Xe(u.value.value)}));if(o.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:o}}),s&&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[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&w_r({array:a,primitive:u}))return{value:iu({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(a!=null&&u!=null&&w_r({array:u,primitive:a}))return{value:iu({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[a,u]of Object.entries(e.value.value.schemas))return QRi({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:iu({schema:e,context:t,fileContainingReference:r,declarationFile:ds.of(vp),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:iu({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:iu({schema:ya.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:n,declarationDepth:0}),allowMultiple:!0}:{value:iu({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function w_r({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function Lhf(e){return typeof e=="object"&&e!==null&&"type"in e}Nt();function fCa({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"]=Uhf(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=zhf({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=Twe(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function Uhf(e){let t={};return e.forEach(r=>{let n=Twe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function zhf({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let o=Twe(i.value);r.has(i.name)||o!=null&&(n[i.name]=o)}),n}function Twe(e){switch(e.type){case"primitive":return dCa(e.value);case"object":return mCa(e.properties);case"array":return Vhf(e.value);case"map":return qhf(e.value);case"oneOf":return Ghf(e.value);case"enum":return e.value;case"literal":return Whf(e.value);case"unknown":return Twe(e.value);case"null":return null;default:xe(e)}}function dCa(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"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:xe(e)}}function mCa(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,Twe(r)]))}function Vhf(e){return e.map(t=>Twe(t))}function qhf(e){return Object.fromEntries(e.map(t=>[dCa(t.key),Twe(t.value)]))}function Ghf(e){return e.type==="discriminated"?mCa(e.value):Twe(e.value)}function Whf(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:xe(e)}}function PDt(e){try{let r=new URL(e).pathname.split("/").filter(n=>n.length>0);if(r.length>0)return r[r.length-1]}catch{}}function __r(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function x_r(e,t,r=!1){let n=PDt(t);return r&&n!=null?n:e!=null&&n!=null?`${e}_${n}`:n??e??"websocket"}function Qhe(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function S_r(e,t){return t??(e?.groupName!=null?Qhe(e.groupName):void 0)}function hCa({channel:e,context:t,declarationFile:r}){let n=e.servers[0],i=n!=null?t.options.groupEnvironmentsByHost?t.getUrlId(n.url)??x_r(n.name,n.url,!0):n.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${n?.name}", server url="${n?.url}", resolved urlId="${i}" (from collision map: ${t.getUrlId(n?.url??"")!=null})`);let o=e.path;for(let p of e.handshake.pathParameters)p.parameterNameOverride!=null&&(o=o.replace(`{${p.name}}`,`{${p.parameterNameOverride}}`));let s={path:o,url:i,auth:!1};e.audiences!=null&&e.audiences.length>0&&(s.audiences=e.audiences),e.summary!=null&&(s["display-name"]=e.summary),e.connectMethodName!=null&&(s["connect-method-name"]=e.connectMethodName),e.description!=null&&(s.docs=e.description);let a=Qhe(e.groupName),u={};if(e.handshake.pathParameters.length>0)for(let p of e.handshake.pathParameters){let d=p.parameterNameOverride??p.name;u[d]=I_r({pathParameter:p,context:t,fileContainingReference:r,namespace:a})}Object.keys(u).length>0&&(s["path-parameters"]=u);let c={};if(e.handshake.queryParameters.length>0)for(let p of e.handshake.queryParameters){let d=C_r({queryParameter:p,context:t,fileContainingReference:r,namespace:a});d!=null&&(c[p.name]=d)}Object.keys(c).length>0&&(s["query-parameters"]=c);let l={};if(e.handshake.headers.length>0)for(let p of e.handshake.headers){let d=nY({header:p,context:t,fileContainingReference:r,namespace:a});l[p.name]=d}Object.keys(l).length>0&&(s.headers=l),t.builder.addChannel(r,{channel:s});for(let p of e.messages){let d={origin:p.origin,body:iu({schema:p.body,context:t,fileContainingReference:r,namespace:a,declarationDepth:0})};p.methodName!=null&&(d["method-name"]=p.methodName),t.builder.addChannelMessage(r,{messageId:p.name,message:d})}for(let p of e.examples){let d=fCa({context:t,websocketExample:p});t.builder.addChannelExample(r,{example:d})}}function NRi(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var KP="Base",yCa="Default";function gCa(e){try{return new URL(e).hostname}catch{return}}function ACa(e){return e??yCa}function $hf(e,t){let r=new Map;for(let n of e){if(NRi(n)||!("url"in n)||!n.url)continue;let i=gCa(n.url)??n.url;r.has(i)||r.set(i,{environmentName:ACa(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.httpServers.push({name:n.name,url:n.url,audiences:n.audiences})}for(let n of t){let i=gCa(n.url)??n.url;r.has(i)||r.set(i,{environmentName:ACa(n.name),httpServers:[],websocketServers:[]}),r.get(i)?.websocketServers.push(n)}return r}function Pke(e){return Object.entries(e).reduce((t,[r,n])=>(wF(n)?Object.entries(n.urls).forEach(([i,o])=>{t[i]=o}):t[r]=typeof n=="string"?n:n.url,t),{})}function bCa(e){if(e.environmentOverrides!=null){for(let[b,I]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:b,schema:I});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=[],n=e.ir.servers.some(b=>NRi(b)),i=e.ir.servers;for(let b of i)if(NRi(b)){let I={urls:{}},w={},_={},C={};for(let[R,z]of Object.entries(b.urls))I.urls[R]=z.defaultUrl??z.url,z.urlTemplate&&(w[R]=z.urlTemplate),z.defaultUrl&&(_[R]=z.defaultUrl),z.variables&&z.variables.length>0&&(C[R]=z.variables);(Object.keys(w).length>0||Object.keys(C).length>0)&&(I["url-templates"]=w,I["default-urls"]=_,I.variables=C),b.name&&(t[b.name]=I)}else if("url"in b&&b.url){let w=b.urlTemplate!=null&&b.variables!=null&&b.variables.length>0?{url:b.url,audiences:b.audiences,"default-url":b.defaultUrl,"url-template":b.urlTemplate,variables:b.variables?.map(_=>({id:_.id,default:_.default,values:_.values}))}:b.audiences?{url:b.url,audiences:b.audiences}:b.url;if(b.name==null){r.push(w);continue}t[b.name]=w}let o={},s={},a=[],u={},c={},l={};for(let b of e.ir.endpoints)for(let I of b.servers){if(I.url==null&&I.name!=null){o[I.name]||(o[I.name]=[]);continue}if(I.url==null)continue;let w=I,_="defaultUrl"in I&&typeof w.defaultUrl=="string"?w.defaultUrl:void 0,C="urlTemplate"in I&&typeof w.urlTemplate=="string"?w.urlTemplate:void 0,x="variables"in I&&Array.isArray(w.variables)?w.variables:void 0,R=_??I.url,z=I.audiences?{url:R,audiences:I.audiences}:R;if(I.name==null){a.push(z);continue}o[I.name]||(o[I.name]=[]),o[I.name]?.push({url:R,audiences:I.audiences}),s[I.name]=z,C&&I.name&&(u[I.name]=C),_&&I.name&&(c[I.name]=_),x&&x.length>0&&I.name&&(l[I.name]=x)}let p={},d=[];for(let b of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${b.name}", url="${b.url}"`);let I=b.audiences?{url:b.url,audiences:b.audiences}:b.url;if(b.name==null){d.push(I);continue}p[b.name]=I}let f=Object.keys(t).length,m=f>0,h=Object.keys(s).length>0,A=Object.keys(o).some(b=>o[b]?.length===0),y=Object.keys(p).length>0;if(e.options.groupEnvironmentsByHost&&y&&(m||e.ir.servers.length>0)){let b=Object.entries(p).map(([w,_])=>({name:w,url:typeof _=="string"?_:_.url,audiences:typeof _=="string"?void 0:_.audiences})),I=$hf(i,b);if(I.size>0){let w=!0;for(let[_,C]of I.entries()){let x={},R=[...C.httpServers.map(U=>({...U,isHttp:!0})),...C.websocketServers.map(U=>({...U,isHttp:!1}))],z=new Map;for(let U of R){let q=PDt(U.url),te=__r(U.url);q&&te&&(z.has(q)||z.set(q,new Set),z.get(q)?.add(te))}if(C.httpServers.length>0){let U=C.httpServers[0];U!=null&&(x[KP]=U.url,e.setUrlId(U.url,KP));for(let q=1;q<C.httpServers.length;q++){let te=C.httpServers[q];if(te!=null){let ie=PDt(te.url),V=__r(te.url),K=ie?z.get(ie):void 0,Ee=K&&K.size>1,H=Ee&&V!=="https"?`${ie}_${V}`:ie||`Http${q+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${te.url}", pathSegment="${ie}", protocol="${V}", hasCollision=${Ee}, urlId="${H}"`),x[H]=te.url,e.setUrlId(te.url,H)}}}for(let U of C.websocketServers){let q=PDt(U.url),te=__r(U.url),ie=q?z.get(q):void 0,V=ie&&ie.size>1,K=V?`${q}_${te}`:x_r(U.name,U.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${U.name}", url="${U.url}", pathSegment="${q}", protocol="${te}", hasCollision=${V}, urlId="${K}"`),x[K]=U.url,e.setUrlId(U.url,K)}if(Object.keys(x).length>1)e.builder.addEnvironment({name:C.environmentName,schema:{urls:x}});else if(Object.keys(x).length===1){let U=Object.values(x)[0];U!=null&&e.builder.addEnvironment({name:C.environmentName,schema:U})}w&&(e.builder.setDefaultEnvironment(C.environmentName),Object.keys(x).length>1&&e.builder.setDefaultUrl(KP),w=!1)}return}}if(!m&&!h&&y&&e.ir.servers.length===0){for(let[b,I]of Object.entries(p))e.builder.addEnvironment({name:b,schema:I});e.builder.setDefaultEnvironment(Object.keys(p)[0]),e.builder.setDefaultUrl(KP);return}if(a.length>0&&e.logger.debug(`Skipping endpoint level servers ${a.map(b=>typeof b=="string"?b:b.url).join(", ")} because x-fern-server-name was not provided.`),!m){let b=e.ir.servers[0],I=b?.url,w=b?.audiences,_=b?.defaultUrl,C=b?.urlTemplate,x=b?.variables;if(I!=null){let z=C!=null&&x!=null&&x.length>0?{url:I,audiences:w,"default-url":_,"url-template":C,variables:x?.map(U=>({id:U.id,default:U.default,values:U.values}))}:w?{url:I,audiences:w}:I;t[yCa]=z}}let v=Object.values(t).map(b=>typeof b=="string"?b:wF(b)?Object.values(b.urls)[0]:b.url),E=r.filter(b=>{let I=typeof b=="string"?b:b.url;return!v.includes(I)});if(E.length>0&&e.logger.debug(`Skipping top level servers ${E.map(b=>typeof b=="string"?b:b.url).join(", ")} because x-fern-server-name was not provided.`),n){let b=!0;for(let[I,w]of Object.entries(t))if(e.builder.addEnvironment({name:I,schema:w}),b){if(e.builder.setDefaultEnvironment(I),wF(w)){let _=Object.keys(w.urls)[0];_&&e.builder.setDefaultUrl(_)}b=!1}return}if(!h&&!A){let b=!0;for(let[I,w]of Object.entries(t))if(b){if(y){let _=typeof w=="string"?w:wF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;e.builder.addEnvironment({name:I,schema:{urls:{[KP]:_??"",...Pke(p)}}})}else e.builder.addEnvironment({name:I,schema:w});e.builder.setDefaultEnvironment(I),b=!1}else if(y){let _=typeof w=="string"?w:wF(w)?Object.values(w.urls)[0]:w["default-url"]??w.url;e.builder.addEnvironment({name:I,schema:{urls:{[KP]:_??"",...Pke(p)}}})}else e.builder.addEnvironment({name:I,schema:w});y&&e.builder.setDefaultUrl(KP)}else if(f===1){let b=Object.keys(t)[0],I=Object.values(t)[0],w=typeof I=="string"?I:wF(I)?Object.values(I.urls)[0]:I["default-url"]??I.url,_={},C={},x={};typeof I!="string"&&!wF(I)&&(I["url-template"]&&(_[KP]=I["url-template"]),I["default-url"]&&(C[KP]=I["default-url"]),I.variables&&I.variables.length>0&&(x[KP]=I.variables)),Object.assign(_,u),Object.assign(C,c),Object.assign(x,l);let R=Object.keys(_).length>0||Object.keys(x).length>0,z={urls:{[KP]:w??"",...Pke(s),...Pke(p)},...R?{"url-templates":_,"default-urls":C,variables:x}:{}};e.builder.addEnvironment({name:b,schema:z}),e.builder.setDefaultEnvironment(b),e.builder.setDefaultUrl(KP)}else{let b=new Map;for(let I of e.ir.endpoints)for(let w of I.servers)if(w.url!=null&&w.name!=null){b.has(w.name)||b.set(w.name,new Map);let _=w.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",C=b.get(w.name);C&&C.set(_,w.url)}if(b.size>0){let I=!0;for(let[w,_]of Object.entries(t)){let C=typeof _=="string"?_:wF(_)?Object.values(_.urls)[0]:_["default-url"]??_.url;if(!C)continue;let x=C.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",R={[KP]:C};for(let[z,U]of b.entries()){let q=U.get(x)||U.get("production")||U.values().next().value;q&&(R[z]=q)}y&&Object.assign(R,Pke(p)),Object.keys(R).length>1?e.builder.addEnvironment({name:w,schema:{urls:R}}):e.builder.addEnvironment({name:w,schema:C}),I&&(e.builder.setDefaultEnvironment(w),I=!1)}b.size>0&&e.builder.setDefaultUrl(KP)}else{let I=!0;for(let[w,_]of Object.entries(t)){if(y||Object.keys(s).length>0){let C=typeof _=="string"?_:wF(_)?Object.values(_.urls)[0]:_["default-url"]??_.url;e.builder.addEnvironment({name:w,schema:{urls:{[KP]:C??"",...Pke(s),...Pke(p)}}})}else e.builder.addEnvironment({name:w,schema:_});I&&(e.builder.setDefaultEnvironment(w),I=!1)}}}}gg();xi();var kRi=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},Hhf=.75,Khf=new Set(["authorization"]);function vCa(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let o=n.optional===!0?"optional<string>":"string",s=o;if(n.name==null&&n.env==null&&typeof n.schema=="string")s=n.schema;else if(n!=null){let a=n.schema?Fhe(n.schema):void 0,u=a!=null?Qhe(a):void 0,c=ds.of("api.yml");s={name:n.name,env:n.env,type:n.schema!=null?cp(iu({schema:n.schema,context:e,fileContainingReference:u?f0(ds.of($n(u)),c):c,namespace:u,declarationDepth:0}))??o:o}}e.builder.addGlobalHeader({name:r,schema:s})}if(e.options.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let o of i.headers){if(Khf.has(o.name.toLowerCase()))continue;let s=r[o.name];if(s==null){let a=t[o.name],u=nY({header:{...o,schema:a?.schema??o.schema,name:a?.name??o.name},fileContainingReference:ds.of(w0),context:e,namespace:void 0});s=new kRi(u),r[o.name]=s}s.increment()}let n=e.ir.endpoints.length*Hhf;for(let[i,o]of Object.entries(r)){let s=t[i],a=o.count===e.ir.endpoints.length,u=o.count>=n;s==null&&(a?e.builder.addGlobalHeader({name:i,schema:o.schema}):u&&e.builder.addGlobalHeader({name:i,schema:Bke(o.schema)}))}}}gg();function ECa(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?Fhe(t.schema):void 0,n=r!=null?Qhe(r):void 0,i=nY({header:{...t,schema:t.schema??ya.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Wc.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:ds.of(w0),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Bke(i)})}}Nt();gg();Nt();Nt();function uO(e){switch(e.type){case"primitive":return wCa(e.value);case"object":return CCa(e.properties);case"array":return _Ca(e.value);case"map":return Yhf(e.value);case"oneOf":return Xhf(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return Zhf(e.value);case"unknown":return uO(e.value);case"null":return null;default:xe(e)}}function ICa(e){switch(e.type){case"withStreaming":return e.sse?{stream:Jhf(e.events)}:{stream:_Ca(e.events)};case"withoutStreaming":return{body:uO(e.value)};default:xe(e)}}function wCa(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"datetimeRfc2822":return e.value;case"date":return e.value;case"base64":case"boolean":return e.value;default:xe(e)}}function CCa(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,uO(r)]))}function Jhf(e){return e.map(t=>({event:"",data:uO(t)}))}function _Ca(e){return e.map(t=>uO(t))}function Yhf(e){return Object.fromEntries(e.map(t=>[wCa(t.key),uO(t.value)]))}function Xhf(e){return e.type==="discriminated"?CCa(e.value):uO(e.value)}function Zhf(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:xe(e)}}function xCa({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"]=egf(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=tgf(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),o=Object.keys(i).length>0,s=new Set(e.headers?.map(a=>a.name)??[]);if(n||o){let a=[];if(e.headers!=null)for(let u of e.headers)u.name!==t.builder.getAuthHeaderName()&&a.push(u);for(let[u,c]of Object.entries(i)){if(c!=null&&typeof c=="object"&&c.type!=null){let l=_v({type:c.type,_default:void 0,validation:void 0,visitor:{primitive:pt,map:pt,list:pt,optional:p=>p,nullable:p=>p,set:pt,named:pt,literal:p=>{if(p.type==="string")return p.string;if(p.type==="boolean")return p.boolean.toString()},unknown:pt}});if(l!=null){let p=a.findIndex(f=>f.name===u),d={name:u,value:nu.literal(Ewe.string(l))};p>=0?a[p]=d:a.push(d);continue}}s.has(u)||a.push({name:u,value:nu.primitive(ms.string(u))})}r.headers=rgf({context:t,namedFullExamples:a})}return e.request!=null&&(r.request=uO(e.request)),e.response!=null&&(r.response=ICa(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(a=>a.type==="language"?{name:a.name??void 0,docs:a.description??void 0,language:a.language,code:a.code,install:a.install??void 0}:{name:a.name??void 0,docs:a.description??void 0,sdk:a.sdk,code:a.code}).filter(Ca)),r}function egf(e){let t={};return e.forEach(r=>{let n=uO(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function tgf(e){let t={};return e.forEach(r=>{let n=uO(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function rgf({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=uO(n.value);i!=null&&(r[n.name]=i)}),r}function SCa(e){return LC._visit(e,{get:()=>mm.HttpMethodSchema.Get,post:()=>mm.HttpMethodSchema.Post,put:()=>mm.HttpMethodSchema.Put,patch:()=>mm.HttpMethodSchema.Patch,delete:()=>mm.HttpMethodSchema.Delete,head:()=>mm.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 OCa(e){return e==="POST"||e==="PUT"||e==="PATCH"}function BCa({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],o=new Set,s=e.path,a=S_r(e.sdkName,e.namespace),u={};for(let A of e.pathParameters)A.parameterNameOverride&&(s=s.replace(A.name,A.parameterNameOverride)),u[A.parameterNameOverride??A.name]=I_r({pathParameter:A,context:r,fileContainingReference:t,namespace:a}),o.add(A.name);let c={};for(let A of e.queryParameters){let y=C_r({queryParameter:A,context:r,fileContainingReference:t,namespace:a});y!=null&&(c[A.name]=y,o.add(A.name))}let l;if(e.pagination!=null)switch(e.pagination.type){case"cursor":l={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":l={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":l={type:"custom",results:e.pagination.results};break;case"uri":l={next_uri:e.pagination.nextUri,results:e.pagination.results};break;case"path":l={next_path:e.pagination.nextPath,results:e.pagination.results};break;default:xe(e.pagination)}let p={path:s,method:SCa(e.method),auth:ngf({endpoint:e,context:r}),docs:e.description??void 0,pagination:l,source:e.source!=null?jhe(e.source):void 0};!agf({context:r,request:e.request})&&Object.keys(u).length>0&&(p["path-parameters"]=u),e.summary!=null&&(p["display-name"]=e.summary);let d={},f=r.builder.getGlobalHeaderNames(),m=r.builder.getAuthHeaderName();m!=null&&f.add(m);let h=e.headers.filter(A=>!f.has(A.name));for(let A of h){let y=nY({header:A,context:r,fileContainingReference:t,namespace:a});d[A.name]=y,o.add(typeof y=="string"?A.name:y.name??A.name)}if(e.request!=null){r.setInState(pw.Request);let A=sgf({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(u).length>0?u:void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(d).length>0?d:void 0,usedNames:o,namespace:a});p.request=A.value,i=[...i,...A.schemaIdsToExclude??[]],r.unsetInState(pw.Request)}else{let A=r.options.inlinePathParameters&&Object.keys(u).length>0,y=Object.keys(c).length>0,v=Object.keys(d).length>0,E={};(A||y||v)&&(E.name=e.requestNameOverride??e.generatedRequestName),A&&(E["path-parameters"]=u),y&&(E["query-parameters"]=c),v&&(E.headers=d),Object.keys(E).length>0&&(p.request=E)}if(e.response!=null&&e.response._visit({json:A=>{let y=iu({schema:A.schema,context:r,fileContainingReference:t,namespace:a,declarationDepth:0});p.response={docs:A.description??void 0,type:cp(y)},A.statusCode!=null&&(p.response["status-code"]=A.statusCode),A.responseProperty!=null&&(p.response.property=A.responseProperty)},streamingJson:A=>{let y=iu({schema:A.schema,context:r,fileContainingReference:t,namespace:a,declarationDepth:0});p["response-stream"]={docs:A.description??void 0,type:cp(y),format:"json",terminator:A.terminator??void 0}},streamingSse:A=>{let y=iu({schema:A.schema,context:r,fileContainingReference:t,namespace:a,declarationDepth:0});p["response-stream"]={docs:A.description??void 0,type:cp(y),format:"sse",terminator:A.terminator??void 0}},file:A=>{p.response={docs:A.description??void 0,type:"file","status-code":A.statusCode}},bytes:A=>{p.response={docs:A.description??void 0,type:"bytes","status-code":A.statusCode}},streamingText:A=>{p["response-stream"]={docs:A.description??void 0,type:"text"}},text:A=>{p.response={docs:A.description??void 0,type:"text","status-code":A.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let A=r.getDefaultServerName(),y=e.servers[0];y==null?A!=null&&(p.url=A):p.url=y.name??void 0}return e.idempotent&&(p.idempotent=!0),e.availability!=null&&(p.availability=qy(e.availability)),Object.entries(e.errors).forEach(([A,y])=>{let v=y.generatedName,E=ds.of(vp);r.builder.enableUniqueErrorsPerEndpoint&&(v=`${e.generatedRequestName}${y.generatedName}`,y.schema!=null&&(y.schema.type!=="reference"&&y.schema.type!=="oneOf"?y.schema.generatedName=`${e.generatedRequestName}${y.schema.generatedName}`:y.schema.type==="oneOf"&&(y.schema.value.generatedName=`${e.generatedRequestName}${y.schema.value.generatedName}`)));let b={"status-code":parseInt(A)},I=eCa({location:PCa,namespaceOverride:a});if(y.schema!=null){let C=iu({schema:y.schema,context:r,fileContainingReference:I,declarationFile:I,namespace:a,declarationDepth:0});b.type=cp(C),b.docs=y.description}r.builder.addError(I,{name:v,schema:r.isErrorUnknownSchema(parseInt(A))?{...b,type:"unknown"}:b}),p.errors==null&&(p.errors=[]);let w=r.builder.addImport({file:t,fileToImport:I});p.errors.push(w!=null?`${w}.${v}`:v),b.type!=null&&y.examples?.forEach(C=>{let x={value:uO(C.example),name:C.name,docs:C.description};r.builder.addErrorExample(I,{name:v,example:x})})}),e.examples.length>0&&(p.examples=igf({endpointExamples:e.examples,context:r})),e.retries!=null&&(p.retries=ogf({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?p.audiences=[MRi,...e.audiences]:e.audiences.length>0&&(p.audiences=e.audiences),{value:p,schemaIdsToExclude:i}}function ngf({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 igf({endpointExamples:e,context:t}){return e.map(r=>{try{return xCa({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function ogf({retries:e}){if(e!=null){if(e.type==="disabled")return{disabled:e.value??void 0};xe(e)}}function sgf({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:o,pathParameters:s,queryParameters:a,nonRequestReferencedSchemas:u,headers:c,usedNames:l,namespace:p}){if(n.type==="json"||n.type==="formUrlEncoded"){let d=n.schema.type==="reference"?n.schema.schema:void 0,f=n.schema.type==="reference"?r.getSchema(n.schema.schema,p):n.schema;if(f?.type!=="object"||d!=null&&u.includes(d)){let I=iu({schema:n.schema,fileContainingReference:t,context:r,namespace:p,declarationDepth:0}),w={schemaIdsToExclude:[],value:{body:I}},_=Object.keys(s??{}).length>0,C=Object.keys(a??{}).length>0,x=Object.keys(c??{}).length>0;return _&&(w.value["path-parameters"]=s),C&&(w.value["query-parameters"]=a),x&&(w.value.headers=c),(_||C||x)&&(w.value.name=i??o),n.contentType!=null&&(w.value["content-type"]=n.contentType),n.description!=null&&(w.value.docs=n.description),w}let m=new Map;for(let I of f.allOf){let w=r.getSchema(I.schema,p);if(w==null)continue;let _=Fhe(w),C=Rhe(_),{properties:x}=JXe(r,I.schema,p);for(let R of x)m.set(R.key,C)}let h=Object.fromEntries(f.properties.filter(I=>I.readonly==null?!0:!(OCa(e.method)&&I.readonly)).map(I=>{let w=m.get(I.key)??t,_=iu({schema:I.schema,fileContainingReference:t,declarationFile:w,context:r,namespace:p,declarationDepth:1}),C=I.nameOverride??I.key,x=qy(I.availability);if(!l.has(C)&&I.audiences.length<=0)return l.add(C),I.nameOverride!=null?[I.key,{type:cp(_),docs:HXe(_),name:I.nameOverride,availability:x}]:[I.key,x?{...typeof _=="string"?{type:_}:_,availability:x}:_];let R={type:cp(_),docs:HXe(_)};return l.has(C)&&(R.name=I.generatedName),I.audiences.length>0&&(R.audiences=I.audiences),x!=null&&(R.availability=x),l.add(C),[I.key,R]})),A=new Set,y=new Set;for(let I of f.allOfPropertyConflicts)I.allOfSchemaIds.forEach(w=>A.add(w)),I.conflictingTypeSignatures&&y.add(I.propertyKey);let v=[];for(let I of f.allOf){let w=E_r({schema:I.schema,context:r,namespace:p});if(w==null||A.has(I.schema)||A.has(w))continue;let _=iu({schema:ya.reference(I),fileContainingReference:t,context:r,namespace:p,declarationDepth:0}),C=KXe(cp(_));C!=="unknown"&&v.push(C)}for(let I of A){let w=JXe(r,I,p),_=r.getSchema(I,p),C=_!=null?Rhe(Fhe(_)):t;for(let x of w.properties)h[x.key]==null&&(y.has(x.key)?h[x.key]="unknown":h[x.key]=iu({schema:x.schema,fileContainingReference:t,declarationFile:C,context:r,namespace:p,declarationDepth:1}));for(let x of w.allOf){if(A.has(x.schema))continue;let R=iu({schema:ya.reference(x),fileContainingReference:t,context:r,namespace:p,declarationDepth:0}),z=KXe(cp(R));z!=="unknown"&&!v.includes(z)&&v.push(z)}}let E={properties:h};v.length>0&&(E.extends=v),n.additionalProperties&&(E["extra-properties"]=!0);let b={name:i??f.nameOverride??f.generatedName,"path-parameters":s,"query-parameters":a,headers:c,body:E};return n.contentType!=null&&(b["content-type"]=n.contentType),n.description!=null&&(b.docs=n.description),{schemaIdsToExclude:d!=null?[d]:[],value:b}}else if(n.type==="octetStream"){let d={body:"bytes","content-type":n.contentType??wf.APPLICATION_OCTET_STREAM,"query-parameters":a};return a!=null&&(d.name=i??o),n.description!=null&&(d.docs=n.description),{schemaIdsToExclude:[],value:d}}else if(n.type==="multipart"){let d=Object.fromEntries(n.properties.map(f=>{if(f.schema.type==="file"){let m=f.schema.isArray?"list<file>":"file";if(m=f.schema.isOptional?`optional<${m}>`:m,f.description!=null||f.contentType!=null){let h={type:m};if(f.description!=null&&(h.docs=f.description),f.contentType!=null){let A=f.contentType.split(",")[0];h["content-type"]=A}return[f.key,h]}return[f.key,m]}else{let m=iu({schema:f.schema.value,fileContainingReference:t,context:r,namespace:p,declarationDepth:1});if(f.contentType||f.exploded||f.encoding){let h=typeof m=="string"?{type:m}:m;f.contentType!=null&&(h["content-type"]=f.contentType),f.encoding==="form"?h.style="form":f.encoding==="json"?h.style="json":f.exploded&&(h.style="exploded"),m=h}return[f.key,m]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??o,"path-parameters":s,"query-parameters":a,headers:c,body:{properties:d},"content-type":wf.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else xe(n)}function agf({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:xe(t)}}gg();xi();function ugf({location:e,namespaceOverride:t}){return t!=null?{...e,file:f0(ds.of(t),e.file)}:e}function cgf(e){let t=e.namespace,r=e.tags.filter(u=>u!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:ds.of(`${$n(r)}.yml`),endpointId:e.summary!=null?$n(e.summary):$n(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:ds.of(vp),endpointId:$n(e.summary)}:{file:ds.of(vp),endpointId:$n(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:ds.of(vp),endpointId:n};let i=TDt(r),o=TDt(n);if(m0(i,o))return{file:ds.of("__package__.yml"),endpointId:r};let s=fgf({operationId:n,tag:r,path:e.path,method:e.method});if(s!=null)return s;let a=[];for(let u=0;u<i.length;++u){let c=i[u];if(c!=null&&c===o[u])a.push(c);else{let l=$n(r);return{file:ds.of(`${l}.yml`),endpointId:n,tag:r}}}if(a.length>=o.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:ds.of($n(a.join("_"))+".yml"),endpointId:$n(o.slice(a.length).join("_")),tag:r}}function DDt(e){let t=e.tags[0];if(e.sdkName!=null){let r=wRi({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:ds.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return ugf({namespaceOverride:e.namespace,location:cgf(e)})}function TDt(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=x4(t),t}var lgf=new RegExp("[^a-zA-Z0-9{}]+"),pgf=new RegExp("[{}]","g");function fgf({operationId:e,tag:t,path:r,method:n}){let o=`${r.split(lgf).join("_").replaceAll(pgf,"_")}_${n.toLowerCase()}`;if(e.endsWith(o))return{file:ds.of($n(t)+".yml"),endpointId:$n(e.slice(0,-1*o.length)),tag:t}}function TCa(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let o of r){let{endpointId:s,file:a,tag:u}=DDt(o),c=a.split(".")[0];c!=null&&t.add(c);let l;if(o.sdkName!=null){let f=e.ir.groups;for(let m of o.sdkName.groupName){let h=typeof m=="string"?m:m.name,A=f[h];if(A==null)break;if(A.summary!=null||A.description!=null){l=f[h];break}}}let p=u==null?void 0:n.tagsById[u];e.setInState(pw.Endpoint),e.setEndpointMethod(o.method);let d=BCa({context:e,endpoint:o,declarationFile:a});e.unsetEndpointMethod(),e.unsetInState(pw.Endpoint),i=[...i,...d.schemaIdsToExclude],e.builder.addEndpoint(a,{name:s,schema:d.value,source:o.source!=null?jhe(o.source):void 0}),(p?.id!=null||p?.description!=null)&&e.builder.setServiceInfo(a,{"display-name":l?.summary??p?.id,docs:l?.description??p?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}gg();function DCa(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?Qhe(r.groupName):void 0,i=iu({schema:ya.primitive(r),context:e,fileContainingReference:ds.of(vp),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:cp(i),docs:r.description??void 0}})}}gg();xi();function jCa(e){for(let t of e.ir.webhooks){let r=hgf({webhook:t,context:e});if(r==null)continue;let n=S_r(t.sdkName,t.namespace),i={};for(let s of t.headers)i[s.name]=nY({header:s,context:e,fileContainingReference:r.file,namespace:n});let o={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:iu({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),signature:ggf(t.signatureVerification),examples:t.examples!=null?t.examples.map(s=>({docs:s.description,name:s.name,payload:uO(s.payload)})):void 0};t.response!=null&&t.response._visit({json:s=>{let a=iu({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o.response={docs:s.description??void 0,type:cp(a)},s.statusCode!=null&&(o.response["status-code"]=s.statusCode)},file:s=>{o.response={docs:s.description??void 0,type:"file","status-code":s.statusCode}},bytes:s=>{o.response={docs:s.description??void 0,type:"bytes","status-code":s.statusCode}},text:s=>{o.response={docs:s.description??void 0,type:"text","status-code":s.statusCode}},streamingJson:s=>{let a=iu({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:cp(a),format:"json"}},streamingSse:s=>{let a=iu({schema:s.schema,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0});o["response-stream"]={docs:s.description??void 0,type:cp(a),format:"sse"}},streamingText:s=>{o["response-stream"]={docs:s.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+t.response?.type)}}),e.builder.addWebhook(r.file,{name:r.endpointId,schema:o}),t.description!=null&&(o.docs=t.description)}}function dgf({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:f0(ds.of(t),e.file)}:e}function mgf({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:ds.of(vp),endpointId:n};let i=TDt(r),o=TDt(n);if(m0(i,o))return{file:ds.of("__package__.yml"),endpointId:r};let s=[];for(let a=0;a<i.length;++a){let u=i[a];if(u!=null&&u===o[a])s.push(u);else{let c=$n(r);return{file:ds.of(`${c}.yml`),endpointId:n,tag:r}}}if(s.length>=o.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:ds.of($n(s.join("_"))+".yml"),endpointId:$n(o.slice(s.length).join("_")),tag:r}}function hgf({webhook:e,context:t}){return e.sdkName!=null?{file:Zwa({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:dgf({namespaceOverride:e.namespace,location:mgf({webhook:e,context:t})})}function ggf(e){if(e!=null)switch(e.type){case"hmac":return{type:"hmac",header:e.header,algorithm:Agf(e.algorithm),encoding:RCa(e.encoding),"signature-prefix":e.signaturePrefix,"payload-format":bgf(e.payloadFormat),timestamp:FCa(e.timestamp)};case"asymmetric":return{type:"asymmetric",header:e.header,"asymmetric-algorithm":ygf(e.asymmetricAlgorithm),encoding:RCa(e.encoding),"signature-prefix":e.signaturePrefix,"jwks-url":e.jwksUrl,"key-id-header":e.keyIdHeader,timestamp:FCa(e.timestamp)};default:return}}function Agf(e){if(e!=null)switch(e){case"sha256":return"sha256";case"sha1":return"sha1";case"sha384":return"sha384";case"sha512":return"sha512";default:return}}function RCa(e){if(e!=null)switch(e){case"base64":return"base64";case"hex":return"hex";default:return}}function ygf(e){switch(e){case"rsa-sha256":return"rsa-sha256";case"rsa-sha384":return"rsa-sha384";case"rsa-sha512":return"rsa-sha512";case"ecdsa-sha256":return"ecdsa-sha256";case"ecdsa-sha384":return"ecdsa-sha384";case"ecdsa-sha512":return"ecdsa-sha512";case"ed25519":return"ed25519";default:return"rsa-sha256"}}function bgf(e){if(e!=null)return{components:e.components.map(vgf),delimiter:e.delimiter}}function vgf(e){switch(e){case"body":return"body";case"timestamp":return"timestamp";case"notification-url":return"notification-url";case"message-id":return"message-id";default:return"body"}}function Egf(e){switch(e){case"unix-seconds":return"unix-seconds";case"unix-millis":return"unix-millis";case"iso8601":return"iso8601";default:return}}function FCa(e){if(e!=null)return{header:e.header,format:e.format!=null?Egf(e.format):void 0,tolerance:e.tolerance}}var MRi="external",PCa=ds.of(vp);function QCa({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){if(n.options.respectReadonlySchemas)for(let[i,o]of Object.entries(e)){if(t.includes(i)||o.type!=="object")continue;let s=o.nameOverride??o.generatedName;if(o.properties.some(u=>u.readonly)){let u=`${s}Read`;n.setSchemaFinalName(s,u)}}for(let[i,o]of Object.entries(e)){if(t.includes(i))continue;let s=tCa(o),a=aCa({schema:o,context:n,declarationFile:s,namespace:r,declarationDepth:0});if(ZIe(a.schema)){let u=cp(a.schema);if(u===(a.name??i)||u===`optional<${a.name??i}>`||u===`nullable<${a.name??i}>`||u===`optional<nullable<${a.name??i}>>`)continue}n.builder.addType(s,{name:a.name??i,schema:a.schema})}}function NCa(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),bCa(e),vCa(e),ECa(e),pCa(e),DCa(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(MRi);let t=TCa(e),r=t.sdkGroups;e.setInState(pw.Webhook),jCa(e),e.unsetInState(pw.Webhook),e.setInState(pw.Channel);for(let i of Object.values(e.ir.channels)){let o=Rhe(i.groupName);hCa({channel:i,context:e,declarationFile:o})}e.unsetInState(pw.Channel);let n=Igf({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});QCa({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,o]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))QCa({schemas:o,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(o=>r.has(o))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function Igf({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(o=>Object.keys(o))]),i=new Set(t);for(let o of n)r.includes(o)||i.add(o);return Array.from(i)}Nt();var RDt=class{context;constructor(t){this.context=t}};gg();xi();gg();var O_r=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[s,a]of Object.entries(n.files)){let u=i!=null?ds.of(`${i}${"/"}${s}`):ds.of(s);t[u]=a}let o=Object.keys(n.directories).sort();for(let s of o){let a=i!=null?`${i}${"/"}${s}`:s,u=n.directories[s];r(u,a)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ds.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var Tke=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new O_r,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":n,"display-name":i,docs:o}){let s=this.getOrCreateFile(t);s.service==null&&(s.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(s.service.auth=r),n!=null&&(s.service["base-path"]=n),i!=null&&(s.service["display-name"]=i),o!=null&&(s.docs=o)}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 kJ(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 n of Object.values(this.rootApiFile["auth-schemes"]))kCa(n)&&t.push(n.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(kCa(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}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:n}){if(t===r)return;let i=n??$n((v4(r)+"/"+F1(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===ds.of(w0))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=e7e(v4(ZGe.of(`/${t}`)),ZGe.of(`/${r}`)),i;let o=this.getOrCreateFile(t);return o.imports==null&&(o.imports={}),o.imports[i]=e7e(v4(ZGe.of(`/${t}`)),ZGe.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===ds.of(w0))return;let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let o=i.types[r];o!=null&&(typeof o=="string"?i.types[r]={type:o,examples:[n]}:(o.examples==null&&(o.examples=[]),o.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let o=i.errors[r];if(o==null)return;o.examples==null&&(o.examples=[]),(o.examples.some(a=>m0(a,n))??!1)||o.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(o.service.source=i),o.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=f0(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let n=Object.values(r.service.endpoints);if(n.length===0)continue;if(n.every(o=>o.auth===!0)){r.service.auth=!0;for(let o of Object.values(r.service.endpoints))delete o.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(([i,o])=>[i,{...o,path:f0(r,o.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([o,s])=>[o,{...s,path:f0(r,s.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===vp?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 kCa(e){return e?.header!=null}var B_r=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;schemaNameMapping=new Map;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:o,authOverrides:s}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=s,this.globalHeaderOverrides=o,this.options=_ke({options:n}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new Tke(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let a={};if(!this.enableUniqueErrorsPerEndpoint)for(let u of r.endpoints)for(let[c,l]of Object.entries(u.errors)){let p=parseInt(c),d=a[p];d==null&&l.schema!=null?a[p]=l.schema:d!=null&&l.schema!=null&&jF(d,l.schema)||this.unknownSchema.add(p)}}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(pw.Channel,pw.Endpoint,pw.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:xe(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undiscriminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:xe(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}setSchemaFinalName(t,r){this.schemaNameMapping.set(t,r)}getSchemaFinalName(t){return this.options.respectReadonlySchemas?this.schemaNameMapping.get(t)??t:t}};function LRi(e){let t=new B_r(e);return NCa(t)}gg();xi();function wgf(e,t){return j2e(e,{single:r=>[typeof r=="string"?r:r.scheme],any:r=>r.any.map(n=>typeof n=="string"?n:n.scheme),endpointSecurity:()=>t!=null?Object.keys(t):[]})}function Cgf(e,t){if(e==null)return;let r=wgf(t,e),n={};for(let i of r)e[i]!=null&&(n[i]=e[i]);return Object.keys(n).length>0?n:void 0}var P_r=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let n=this.args.generatorsConfiguration?.api?.["auth-schemes"],i=this.args.generatorsConfiguration?.api?.auth,o=t??i;if(o==null)return;let s=r!=null||n!=null?{...n,...r}:void 0,a=Cgf(s,o);return{auth:o,"auth-schemes":a}}convert({context:t,ir:r,settings:n,absoluteFilePath:i}){let o=LRi({taskContext:t,ir:r,options:_ke({options:n,overrides:this.args}),authOverrides:this.buildAuthOverrides(n?.auth,n?.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:i??this.args.absoluteFilePath,rootApiFile:{defaultUrl:o.rootApiFile["default-url"],contents:o.rootApiFile,rawContents:Tr.dump(o.rootApiFile)},namedDefinitionFiles:{...Ql(o.definitionFiles,s=>({absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Tr.dump(s),contents:s})),[ds.of(vp)]:{absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Tr.dump(o.packageMarkerFile),contents:o.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var FDt=class extends Lq{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;coerceEnumsToLiterals;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;defaultIntegerFormat;pathParameterOrder;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.pathParameterOrder=t.pathParameterOrder,this.converter=new P_r(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:n},i){let o=await this.getOpenAPIIr({context:t,relativePathToDependency:n},i);return this.converter.convert({context:t,ir:o,settings:i,absoluteFilePath:r})}async toFernWorkspace({context:t},r,n){let i=await this.getDefinition({context:t},r);return new OF({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};var xS={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 YXe={of(e){return e}};var MCa={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},URi={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:MCa,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},bn={SOURCE:YXe.of("source"),SDK_NAMESPACE:YXe.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:YXe.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:YXe.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:YXe.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",WEBHOOK_SIGNATURE:"x-fern-webhook-signature",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",DISCRIMINATOR_CONTEXT:"x-fern-discriminator-context"};var _gf={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:yn.RemoveDiscriminantsFromSchemas.Always,defaultIntegerFormat:yn.DefaultIntegerFormat.Int32,pathParameterOrder:yn.PathParameterOrder.UrlOrder,resolveSchemaCollisions:!1};function xgf(e){let{defaults:t,options:r,overrides:n,overrideOnly:i=new Set,undefinedIfAbsent:o=new Set}=e,s={};for(let a of Object.keys(t))i.has(a)?s[a]=n?.[a]!==void 0?n[a]:t[a]:o.has(a)?s[a]=n?.[a]!==void 0?n[a]:r?.[a]!==void 0?r[a]:void 0:s[a]=n?.[a]??r?.[a]??t[a];return s}function ML({options:e,overrides:t}){return xgf({defaults:_gf,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}Nt();var LCa={naming:"v1"};xi();xi();function qr(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function jDt(e,t,r,n,i=[]){try{let o=qr(e,t);if(o!=null)return r.parse(o)}catch{let s=x4(i).join(" -> ");n.error(`${s.length>0?`${s}: `:""}Failed to parse ${t}`)}}function Dke(e){let t=qr(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 UCa({schema:e,logger:t}){return qr(e,bn.ENCODING)??void 0}function zCa(e){return qr(e,bn.FERN_ENUM)}Nt();function VCa({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:o}){let s=qr(n,bn.SDK_NAMESPACE),a=qr(n,bn.SDK_GROUP_NAME),u=qr(n,bn.TYPE_DEFINITION);if(u!=null)return QDt({fernType:u,nameOverride:e,generatedName:t,title:r,description:i,availability:o,namespace:s,groupName:typeof a=="string"?[a]:a})}function QDt({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a}){return _v({type:e,_default:void 0,validation:void 0,visitor:{primitive:u=>{switch(u.v1){case"BASE_64":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.base64({example:void 0})});case"BOOLEAN":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.boolean({default:void 0,example:void 0})});case"DATE":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.date({example:void 0})});case"DATE_TIME":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.datetime({example:void 0})});case"FLOAT":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.float({example:void 0})});case"DOUBLE":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.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 jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.uint({default:void 0,example:void 0})});case"INTEGER":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.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 jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.uint64({default:void 0,example:void 0})});case"LONG":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});case"DATE_TIME_RFC_2822":return jr.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,schema:Si.datetimeRfc2822({example:void 0})});default:xe(u.v1)}},unknown:()=>jr.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:o,namespace:s,groupName:a}),map:({keyType:u,valueType:c})=>u?.type==="primitive"&&c!=null?jr.map({nameOverride:t,generatedName:r,title:n,key:u,value:c,description:i,availability:o,namespace:s,groupName:a,encoding:void 0,example:void 0,inline:void 0,minProperties:void 0,maxProperties:void 0}):void 0,list:u=>u!=null?jr.array({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,example:void 0,inline:void 0,minItems:void 0,maxItems:void 0}):void 0,optional:u=>u!=null?jr.optional({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,inline:void 0}):void 0,nullable:u=>u!=null?jr.nullable({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,inline:void 0}):void 0,set:u=>u!=null?jr.array({nameOverride:t,generatedName:r,title:n,value:u,description:i,availability:o,namespace:s,groupName:a,example:void 0,inline:void 0,minItems:void 0,maxItems:void 0}):void 0,literal:u=>jr.literal({nameOverride:t,generatedName:r,title:n,value:u._visit({string:c=>nA.string(c),boolean:c=>nA.boolean(c),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:o,namespace:s,groupName:a}),named:u=>jr.reference({schema:u,nameOverride:t,generatedName:r,title:n,description:i,availability:o,namespace:s,groupName:a,source:aO.openapi({file:"<memory>"})})}})}function qCa(e){let t=qr(e,bn.SOURCE);if(t!=null)return t.endsWith(".proto")?aO.protobuf({file:t}):aO.openapi({file:t})}function Rke(e){if(e!=null&&typeof e=="boolean")return e}function iY(){let e=new Map,t=new Map;return{getUniqueSchemaId(r,n,i=!1){let o=e.get(r)||0;if(e.set(r,o+1),o>0&&i){let s=`${r}${o+1}`;return n?.warn?.(`Schema name collision detected: '${r}' already exists. Renaming to '${s}' to avoid conflicts.`),s}return r},getUniqueTitleName(r,n,i,o=!1){let s=t.get(r)||0;if(t.set(r,s+1),s>0&&o){let a=`${r}${s+1}`;return i?.warn(`Schema title collision detected: Multiple schemas use title '${r}'. Schema '${n}' retitled to '${a}' to avoid conflicts.`),a}return r},reset(){e.clear(),t.clear()}}}Nt();function Hn(e){return e?.$ref!=null}function GCa({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:o,availability:s,wrapAsOptional:a,wrapAsNullable:u,context:c,namespace:l,groupName:p,example:d,encoding:f,source:m,minProperties:h,maxProperties:A}){return i===void 0&&(i=c.options.additionalPropertiesDefaultsTo),zRi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:u,description:o,availability:s,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Si.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 i=="boolean"||NDt(i,c.options)?jr.unknown({...Sgf(i),generatedName:`${t}Value`}):WCa(Za(i,!1,c.options.optionalAdditionalProperties?u:!1,c,[...n,"Value"],m,l,void 0,void 0,void 0)),namespace:l,groupName:p,example:d,encoding:f,minProperties:h,maxProperties:A})}function WCa(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=WCa(e.value);break;case"oneOf":e.value.inline=!0;break;default:xe(e)}return e}function zRi({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsOptional:o,wrapAsNullable:s,description:a,availability:u,namespace:c,groupName:l,example:p,encoding:d,minProperties:f,maxProperties:m}){let h=jr.map({nameOverride:e,generatedName:t,title:r,description:a,availability:u,key:n,value:i,namespace:c,groupName:l,encoding:d,example:p,inline:void 0,minProperties:f,maxProperties:m});return s&&(h=jr.nullable({nameOverride:e,generatedName:t,title:r,value:h,description:a,availability:u,namespace:c,groupName:l,inline:void 0})),o&&(h=jr.optional({nameOverride:e,generatedName:t,title:r,value:h,description:a,availability:u,namespace:c,groupName:l,inline:void 0})),h}function NDt(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:Hn(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(n=>Hn(n)?!0:n.type!=null||n.properties!=null||n.allOf!=null||n.oneOf!=null||n.anyOf!=null||n.enum!=null||"items"in n||n.additionalProperties!=null):!("enum"in e&&e.enum!=null)}function Sgf(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"||Hn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function $Ca({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:o,availability:s,wrapAsOptional:a,wrapAsNullable:u,context:c,namespace:l,groupName:p,example:d,source:f,minItems:m,maxItems:h}){let A=i==null?jr.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:l,groupName:p}):Za(i,!1,!1,c,[...n,"Item"],f,l);return Ogf({nameOverride:e,generatedName:t,title:r,namespace:l,groupName:p,itemSchema:A,wrapAsOptional:a,wrapAsNullable:u,description:o,availability:s,example:d,minItems:m,maxItems:h})}function Ogf({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,namespace:u,groupName:c,example:l,minItems:p,maxItems:d}){let f=jr.array({nameOverride:e,generatedName:t,title:r,value:n,description:s,availability:a,namespace:u,groupName:c,example:l,inline:void 0,minItems:p,maxItems:d});return o&&(f=jr.nullable({nameOverride:e,generatedName:t,title:r,value:f,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),i&&(f=jr.optional({nameOverride:e,generatedName:t,title:r,value:f,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),f}function cO(e){switch(qr(e,bn.AVAILABILITY)){case"deprecated":return MC.Deprecated;case"beta":return MC.Beta;case"generally-available":return MC.GenerallyAvailable;default:break}if(!Hn(e)&&e.deprecated)return MC.Deprecated}function T_r({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:o,availability:s,required:a,wrapAsOptional:u,wrapAsNullable:c,discriminator:l,context:p,namespace:d,groupName:f,encoding:m,source:h}){let A=l.propertyName,y=qr(l,bn.FERN_PROPERTY_NAME),v=qr(l,bn.DISCRIMINATOR_CONTEXT)??"data",E=Object.fromEntries(Object.entries(l.mapping??{}).map(([I,w])=>{let _=Jq({$ref:w},!1,!1,p,[w],m,h,d);return p.markReferencedByDiscriminatedUnion({$ref:w},A,1),[I,_]})),b=Object.entries(i).filter(([I])=>I!==A).map(([I,w])=>{let _=a!=null&&a.includes(I),[C,x]=p.options.coerceOptionalSchemasToNullable?[!1,!_]:[!_,!1],R=Za(w,C,x,p,[...n,I],h,d);return{key:I,schema:R}});return HCa({nameOverride:e,generatedName:t,title:r,wrapAsOptional:u,wrapAsNullable:c,properties:b,description:o,availability:s,discriminant:A,discriminantNameOverride:y,discriminatorContext:v,subtypes:E,namespace:d,groupName:f,source:h})}function VRi({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:o,availability:s,required:a,wrapAsOptional:u,wrapAsNullable:c,discriminant:l,variants:p,context:d,namespace:f,groupName:m,encoding:h,source:A}){let y=Object.fromEntries(Object.entries(p).map(([E,b])=>{if(Hn(b)){let I=Jq(b,!1,!1,d,[b.$ref],h,A,f);return d.markReferencedByDiscriminatedUnion(b,l,1),[E,I]}else{let I=XXe(b,!1,!1,d,[...n,E],h,A,f,new Set([l]));return[E,I]}})),v=Object.entries(i).filter(([E])=>E!==l).map(([E,b])=>{let I=a!=null&&a.includes(E),[w,_]=d.options.coerceOptionalSchemasToNullable?[!1,!I]:[!I,!1],C=Za(b,w,_,d,[...n,E],A,f);return{key:E,schema:C}});return HCa({nameOverride:e,generatedName:t,title:r,wrapAsOptional:u,wrapAsNullable:c,properties:v,description:o,availability:s,discriminant:l,discriminantNameOverride:void 0,discriminatorContext:"data",subtypes:y,namespace:f,groupName:m,source:A})}function HCa({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:o,description:s,availability:a,discriminant:u,discriminantNameOverride:c,discriminatorContext:l,subtypes:p,namespace:d,groupName:f,source:m}){let h=jr.oneOf(p2.discriminated({description:s,availability:a,discriminantProperty:u,discriminantPropertyNameOverride:c,discriminatorContext:l,nameOverride:e,generatedName:t,title:r,schemas:p,commonProperties:o,namespace:d,groupName:f,encoding:void 0,source:m,inline:void 0}));return i&&(h=jr.nullable({nameOverride:e,generatedName:t,title:r,value:h,namespace:d,groupName:f,description:s,availability:a,inline:void 0})),n&&(h=jr.optional({nameOverride:e,generatedName:t,title:r,value:h,namespace:d,groupName:f,description:s,availability:a,inline:void 0})),h}function KCa(e){if(e.proto!=null)return lXe.protobuf({typeName:e.proto.type})}function Dwe({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:o,_default:s,description:a,availability:u,wrapAsOptional:c,wrapAsNullable:l,namespace:p,groupName:d,context:f,source:m,inline:h}){let A=Pgf(i??[]),y=new Set(o),v=Array.from(y).map((b,I)=>{let w=n?.[b],_=A[I],C=WXe.test(b),x=w?.name??_,R=C?b:$Xe(b);return x!=null&&!WXe.test(x)&&(f?.logger.warn(`Enum name override ${x} is not a valid name. Falling back on ${R}.`),x=void 0),{nameOverride:x,generatedName:R,value:b,description:w?.description,availability:u,casing:{snake:w?.casing?.snake??void 0,pascal:w?.casing?.pascal??void 0,screamingSnake:w?.casing?.screamingSnake??void 0,camel:w?.casing?.camel??void 0}}}),E=s!=null?v.find(b=>b.value===s):void 0;return Bgf({wrapAsOptional:c,wrapAsNullable:l,nameOverride:e,generatedName:t,title:r,values:v,_default:E,description:a,availability:u,namespace:p,groupName:d,source:m,inline:h})}function Bgf({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:n,title:i,values:o,_default:s,description:a,availability:u,namespace:c,groupName:l,source:p,inline:d}){let f=jr.enum({nameOverride:r,generatedName:n,title:i,values:o,description:a,availability:u,default:s,example:void 0,namespace:c,groupName:l,source:p,inline:d});return t&&(f=jr.nullable({nameOverride:r,generatedName:n,title:i,value:f,description:a,availability:u,namespace:c,groupName:l,inline:d})),e&&(f=jr.optional({nameOverride:r,generatedName:n,title:i,value:f,description:a,availability:u,namespace:c,groupName:l,inline:d})),f}function Pgf(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function JCa({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,description:l,availability:p,wrapAsOptional:d,wrapAsNullable:f,example:m,namespace:h,groupName:A,defaultIntegerFormat:y=yn.DefaultIntegerFormat.Int32}){let v=n??y,E=(()=>{switch(v){case yn.DefaultIntegerFormat.Int64:return Si.int64({default:i,example:m});case yn.DefaultIntegerFormat.Uint32:return Si.uint({default:i,example:m});case yn.DefaultIntegerFormat.Uint64:return Si.uint64({default:i,example:m});default:return Si.int({default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,example:m})}})();return SS({nameOverride:e,generatedName:t,title:r,primitive:E,wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A})}function Tgf(e){return typeof e=="string"?nA.string(e):typeof e=="boolean"?nA.boolean(e):nA.string(`${e}`)}function qRi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,value:o,description:s,availability:a,namespace:u,groupName:c}){let l=jr.literal({nameOverride:e,generatedName:t,title:r,value:Tgf(o),description:s,availability:a,namespace:u,groupName:c});return i&&(l=jr.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),n&&(l=jr.optional({nameOverride:e,generatedName:t,title:r,value:l,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),l}function GRi({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,description:l,availability:p,wrapAsOptional:d,wrapAsNullable:f,example:m,namespace:h,groupName:A}){return n==null||n==="double"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.double({default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="float"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.float({example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="int32"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.int({default:i,minimum:o,maximum:s,exclusiveMinimum:a,exclusiveMaximum:u,multipleOf:c,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="int64"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.int64({default:i,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="uint32"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.uint({default:i,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="uint64"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.uint64({default:i,example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):n==="time-delta"?SS({nameOverride:e,generatedName:t,title:r,primitive:Si.float({example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A}):SS({nameOverride:e,generatedName:t,title:r,primitive:Si.float({example:m}),wrapAsOptional:d,wrapAsNullable:f,description:l,availability:p,namespace:h,groupName:A})}var Dgf={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},Rgf={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}}},Fgf={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}}},jgf={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},Qgf={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Ngf={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},kgf={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},Mgf={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function kDt(e){let t=e.split("/").map(o=>o.replace(/~1/g,"/")),r=[],n=[Dgf,Rgf,Fgf,jgf,Qgf,Ngf,kgf,Mgf],i;do{i=t;for(let o of n)if(o.isApplicable(t)){let{refUnderProcessing:s,newBreadcrumbs:a}=o.applyStrategy(t);t=s,r=[...r,...a]}}while(t.join("")!==i.join(""));return r}xi();function Gy(e,t){let n=e.map(i=>/^[^a-zA-Z0-9]+$/.test(i)?i:dl($n(i))).join("");return/^\d/.test(n)?SDt(n)??n:n}function YCa(e){let t=e.join("_");return $n(t)}Nt();function Rf(e){switch(e.type){case"object":return ya.object({allOf:e.allOf,properties:e.properties.map(t=>Ugf(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,minProperties:e.minProperties,maxProperties:e.maxProperties});case"array":return ya.array({description:e.description,availability:e.availability,value:Rf(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline,minItems:e.minItems,maxItems:e.maxItems});case"enum":return ya.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 ya.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 ya.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Rf(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return ya.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Rf(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return ya.primitive({description:e.description,availability:e.availability,schema:XCa(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ya.map({description:e.description,availability:e.availability,key:ya.primitive({description:e.key.description,availability:e.key.availability,schema:XCa(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:Rf(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline,minProperties:e.minProperties,maxProperties:e.maxProperties});case"reference":return ya.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 ya.oneOf(Lgf(e.value));case"unknown":return ya.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:xe(e)}}function Lgf(e){switch(e.type){case"discriminated":return XJ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:Rf(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,discriminantPropertyNameOverride:e.discriminantPropertyNameOverride,discriminatorContext:e.discriminatorContext,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,Rf(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return XJ.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>Rf(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:xe(e)}}function XCa(e){switch(e.type){case"string":return Wc.string(e);case"base64":return Wc.base64();case"boolean":return Wc.boolean(e);case"date":return Wc.date();case"datetime":return Wc.datetime();case"datetimeRfc2822":return Wc.datetimeRfc2822();case"double":return Wc.double(e);case"float":return Wc.float();case"int":return Wc.int(e);case"int64":return Wc.int64(e);case"uint":return Wc.uint();case"uint64":return Wc.uint64();default:xe(e)}}function Ugf(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:Rf(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function D_r(e,t){return jF(Rf(e),Rf(t))}function ZCa({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:o,required:s,wrapAsOptional:a,wrapAsNullable:u,allOf:c,context:l,propertiesToExclude:p,namespace:d,groupName:f,fullExamples:m,additionalProperties:h,availability:A,source:y,minProperties:v,maxProperties:E}){let b=[...s??[]],I={...e_a({properties:i,breadcrumbs:n,context:l})},w=[],_=[];for(let U of c)if(!l.options.inlineAllOfSchemas&&Hn(U)){let q=l.resolveSchemaReference(U);if(q.discriminator!=null&&q.discriminator.mapping!=null)continue;if(q.oneOf!=null||q.anyOf!=null){let ie=q.oneOf??q.anyOf;if(ie!=null){for(let V of ie){let K=Hn(V)?l.resolveSchemaReference(V):V,Ee=Za(K,!1,!1,l.DUMMY,n,y,d);Ee.type==="object"&&w.push(...Ee.properties.map(Ie=>Ie.schema.type!=="optional"&&Ie.schema.type!=="nullable"?{...Ie,schema:jr.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Ie.schema,description:void 0,availability:Ie.availability,namespace:void 0,groupName:void 0,inline:void 0})}:Ie))}continue}}let te=Rwe(U);if(te==null)continue;_.push({schemaId:te,convertedSchema:WRi(U,[te],y,l.options.preserveSchemaIds,l),properties:t_a({schema:U,context:l,breadcrumbs:n,source:y,namespace:d})}),l.markSchemaAsReferencedByNonRequest(te)}else if(Hn(U)){let q=l.resolveSchemaReference(U),te=Za(q,!1,!1,l,n,y,d);te.type==="object"&&w.push(...te.properties)}else{let q=U.required??[];w=w.map(ie=>(ie.schema.type==="optional"||ie.schema.type==="nullable")&&q.includes(ie.key)?{...ie,schema:ie.schema.value}:ie);let te=U.oneOf??U.anyOf;if(te!=null&&U.type==null&&U.properties==null){let ie=new Set(w.map(V=>V.key));for(let V of te){let K=Hn(V)?l.resolveSchemaReference(V):V,Ee=Vgf(K),Ie=Za(Ee,!1,!1,l,n,y,d);if(Ie.type==="object")for(let H of Ie.properties)ie.has(H.key)||(ie.add(H.key),H.schema.type!=="optional"&&H.schema.type!=="nullable"?w.push({...H,schema:jr.optional({nameOverride:void 0,generatedName:"",title:void 0,value:H.schema,description:void 0,availability:H.availability,namespace:void 0,groupName:void 0,inline:void 0})}):w.push(H))}}else{let ie=Za(U,!1,!1,l,n,y,d);ie.type==="object"&&w.push(...ie.properties)}}let C={};for(let U of _)for(let[q,te]of Object.entries(U.properties)){let ie=C[q];ie!=null?(ie.schemaIds.push(U.schemaId),ie.schemas.some(K=>D_r(K,te))||ie.schemas.push(te)):C[q]={schemaIds:[U.schemaId],schemas:[te]}}let x=[];for(let[U,q]of Object.entries(C))q.schemaIds.length>1&&x.push({propertyKey:U,allOfSchemaIds:q.schemaIds,conflictingTypeSignatures:q.schemas.length>1});let R=Object.fromEntries(Object.entries(I).filter(([U,q])=>!(!Hn(q)&&q.type==="null"))),z=Object.entries(R).map(([U,q])=>{let te=qr(q,bn.AUDIENCES)??[],ie=cO(q),V=Hn(q)?!1:q.readOnly,K=Hn(q)?!1:q.writeOnly,Ie=!(b.includes(U)&&!V),H=qr(q,bn.FERN_PROPERTY_NAME),J=[...n,U],Ae=YCa(J),ge=Za(q,Ie,!1,l,J,y,d),we={};for(let _e of _){let pe=_e.properties[U];pe!=null&&!D_r(ge,pe)?we[_e.schemaId]={differentSchema:!0}:pe!=null&&(we[_e.schemaId]={differentSchema:!1})}return{key:U,schema:ge,nameOverride:H,audiences:te,conflict:we,generatedName:Ae,availability:ie,readonly:V,writeonly:K}});return z.push(...w.map(U=>{let q=U.conflict;for(let te of _){let ie=te.properties[U.key];ie!=null&&!D_r(U.schema,ie)?q[te.schemaId]={differentSchema:!0}:ie!=null&&(q[te.schemaId]={differentSchema:!1})}return{...U,conflict:q}})),zgf({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:u,properties:z.filter(U=>!p.has(U.key)),description:o,allOf:_.map(U=>U.convertedSchema),allOfPropertyConflicts:x,namespace:d,groupName:f,fullExamples:m,additionalProperties:h,availability:A,source:y,context:l,minProperties:v,maxProperties:E})}function zgf({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:o,description:s,allOf:a,allOfPropertyConflicts:u,namespace:c,groupName:l,fullExamples:p,additionalProperties:d,availability:f,source:m,context:h,minProperties:A,maxProperties:y}){let v=jr.object({description:s,properties:o,nameOverride:e,generatedName:t,title:r,allOf:a,allOfPropertyConflicts:u,namespace:c,groupName:l,fullExamples:p,additionalProperties:NDt(d,h.options),availability:f,source:m,inline:void 0,minProperties:A,maxProperties:y});return i&&(v=jr.nullable({nameOverride:e,generatedName:t,title:r,value:v,description:s,availability:f,namespace:c,groupName:l,inline:void 0})),n&&(v=jr.optional({nameOverride:e,generatedName:t,title:r,value:v,description:s,availability:f,namespace:c,groupName:l,inline:void 0})),v}function e_a({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([n,i])=>{let o=qr(i,bn.IGNORE);return o&&r.logger.debug(`Property ${t.join(".")}.${n} is marked with x-fern-ignore. Skipping.`),!o}))}function Vgf(e){if(e.properties==null)return e;let t={};for(let[r,n]of Object.entries(e.properties))!Hn(n)&&"not"in n||(t[r]=n);return{...e,properties:t}}function t_a({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let o={},[s,a]=Hn(e)?[t.resolveSchemaReference(e),kDt(e.$ref)]:[e,r];for(let u of s.allOf??[])o={...o,...t_a({schema:u,context:t,breadcrumbs:a,source:n,namespace:i})};for(let[u,c]of Object.entries(e_a({properties:s.properties??{},breadcrumbs:r,context:t}))){let l=Za(c,!1,!1,t,[...a,u],n,i);o[u]=l}return o}xi();function Fwe({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:o,wrapAsOptional:s,wrapAsNullable:a,context:u,subtypes:c,namespace:l,groupName:p,encoding:d,source:f,subtypeSuffixOverrides:m}){let h=Wgf({schemas:c}),A=c.flatMap((v,E)=>{if(!Hn(v)&&v.enum!=null&&u.options.coerceEnumsToLiterals&&v.type==="string")return v.enum.map(I=>jr.literal({nameOverride:void 0,generatedName:Gy([t,I],u.options.preserveSchemaIds),title:void 0,value:nA.string(String(I)),namespace:l,groupName:void 0,description:void 0,availability:I.availability}));let b=h[E];if(m!=null){let I=m[E];I!=null&&"name"in I&&(b=I.name)}return[Za(v,!1,!1,u,[...n,b??`${E}`],f,l)]}),y=qgf(A);return Ggf({uniqueSubtypes:y,nameOverride:e,generatedName:t,title:r,wrapAsOptional:s,wrapAsNullable:a,description:i,availability:o,namespace:l,groupName:p,context:u,encoding:d,source:f})}function qgf(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r],i=!1;for(let o=r+1;o<e.length;++o){let s=e[o];if(n!=null&&s!=null&&jF(n,s)){i=!0;break}}n!=null&&!i&&t.push(n)}return t}function Ggf({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,namespace:u,groupName:c,context:l,encoding:p,source:d}){if(Object.entries(e).every(([m,h])=>h.type==="literal")){let m={},h=[];return Object.entries(e).forEach(([A,y])=>{y.type==="literal"&&y.value.type==="string"&&(h.push(y.value.value),y.description!=null&&(m[y.value.value]={description:y.description}))}),Dwe({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,fernEnum:m,enumVarNames:void 0,enumValues:h,_default:void 0,namespace:u,groupName:c,context:l,source:d,inline:void 0})}if(e.length===1&&e[0]!=null&&!l.options.preserveSingleSchemaOneOf){let m=e[0];return o&&(m=jr.nullable({nameOverride:t,generatedName:r,title:n,value:m,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),i&&(m=jr.optional({nameOverride:t,generatedName:r,title:n,value:m,description:s,availability:a,namespace:u,groupName:c,inline:void 0})),m}return r_a({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:o,description:s,availability:a,subtypes:e,namespace:u,groupName:c,encoding:p,source:d})}function $Ri({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsOptional:o,wrapAsNullable:s,context:a,namespace:u,groupName:c,discriminator:l,encoding:p,source:d}){let f=Object.entries(l.mapping??{}).map(([A,y],v)=>{let E={$ref:y},b=Jq(E,!1,!1,a,[y],p,d,u);return a.markSchemaWithDiscriminantValue(E,l.propertyName,A),b.type==="object"&&(b.properties={[l.propertyName]:jr.literal({nameOverride:void 0,generatedName:Gy([t,A],a.options.preserveSchemaIds),title:void 0,value:nA.string(A),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...b.properties.filter(I=>I.key!==l.propertyName)}),b}),m=[];for(let A=0;A<f.length;++A){let y=f[A],v=!1;for(let E=A+1;E<f.length;++E){let b=f[E];if(y!=null&&b!=null&&jF(y,b)){v=!0;break}}y!=null&&!v&&m.push(y)}if(Object.entries(m).every(([A,y])=>y.type==="literal")){let A={},y=[];return Object.entries(m).forEach(([v,E])=>{E.type==="literal"&&E.value.type==="string"&&(y.push(E.value.value),E.description!=null&&(A[E.value.value]={description:E.description}))}),Dwe({nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:s,description:n,availability:i,fernEnum:A,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:u,groupName:c,context:a,source:d,inline:void 0})}return m.length===1&&m[0]!=null&&!a.options.preserveSingleSchemaOneOf?m[0]:r_a({nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:s,description:n,availability:i,subtypes:m,namespace:u,groupName:c,encoding:p,source:d})}function Wgf({schemas:e}){let t={},r=0;for(let i of e){if(!Hn(i)){if(i.properties!=null&&Object.entries(i.properties).length>0){let o=Object.keys(i.properties),s={},a=o;for(let[u,c]of Object.entries(t)){let l=uYt(c,o);a=uYt(a,c),s[u]=l}s[r]=a,t=s}}r++}return e.map((i,o)=>{let s=t[o];if(s!=null&&s.length>0){let a=s.sort();if(a[0]!=null)return a[0]}return Oke(o)??`${o}`})}function r_a({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,description:o,availability:s,subtypes:a,namespace:u,groupName:c,encoding:l,source:p}){let d=jr.oneOf(p2.undiscriminated({description:o,availability:s,nameOverride:e,generatedName:t,title:r,schemas:a,namespace:u,groupName:c,encoding:l,source:p,inline:void 0}));return i&&(d=jr.nullable({nameOverride:e,generatedName:t,title:r,value:d,description:o,availability:s,namespace:u,groupName:c,inline:void 0})),n&&(d=jr.optional({nameOverride:e,generatedName:t,title:r,value:d,description:o,availability:s,namespace:u,groupName:c,inline:void 0})),d}function ZXe(e){if(e.default!=null&&typeof e.default=="string")return e.default}function R_r({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=Dke(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function n_a({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=Dke(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function Yq({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=Dke(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function i_a({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=Dke(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var Fke="#/components/schemas/";var u_a=iY();function N_r(){u_a.reset()}function $gf(e,t,r){let n=qr(e,bn.TYPE_NAME),i=t.options.useTitlesAsName?Jgf(e.title):void 0,o=n??i;if(!o)return;let s=r.split(".");return n!=null||s.length===1?u_a.getUniqueTitleName(o,r,t.logger,t.options.resolveSchemaCollisions):o}function c_a(e,t){let r=Hn(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 c_a(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 Hgf(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:c_a(t,r):!1}function Za(e,t,r,n,i,o,s,a=!1,u=new Set,c){let l=qCa(e)??o,p=rAf({schema:e,logger:n.logger}),d=c;if(Hn(e)){let f=Kgf(e);f!==void 0&&(d=f)}if(Hn(e)){let f=Rwe(e);return f!=null?Hgf(f,e,n)?XXe(n.resolveSchemaReference(e),t,r,n,kDt(e.$ref),p,l,s,u,a,d):(a?n.markSchemaAsReferencedByRequest(f):n.markSchemaAsReferencedByNonRequest(f),Jq(e,t,r,n,i,p,l,s)):XXe(n.resolveSchemaReference(e),t,r,n,kDt(e.$ref),p,l,s,u,a,d)}return XXe(e,t,r,n,i,p,l,s,u,a,c)}function Kgf(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 Jq(e,t,r,n,i,o,s,a){let u=e.$ref.includes("properties")?XXe(n.resolveSchemaReference(e),t,r,n,i,o,s,a,new Set):jr.reference(WRi(e,i,s,n.options.preserveSchemaIds,n));if(r===!1){let c=n.resolveSchemaReference(e);(c.nullable===!0||Array.isArray(c.type)&&c.type.length>=2&&c.type.includes("null"))&&(r=!0)}return r&&(u=jr.nullable({title:void 0,nameOverride:void 0,generatedName:Gy(i,n.options.preserveSchemaIds),value:u,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(u=jr.optional({title:void 0,nameOverride:void 0,generatedName:Gy(i,n.options.preserveSchemaIds),value:u,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),u}function Jgf(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function XXe(e,t,r,n,i,o,s,a,u=new Set,c=!1,l){typeof e=="string"&&(e={type:e});let p=$gf(e,n,i.join(".")),d=qr(e,bn.SDK_GROUP_NAME)??qr(e,xS.TAGS)?.[0],f=(typeof d=="string"?[d]:d)??[];f=n.resolveGroupName(f);let m=Gy(i,n.options.preserveSchemaIds),h=e.title,A=e.description,y=cO(e),v=[];e.example!=null&&v.push({name:void 0,value:e.example,description:void 0});let E=qr(e,xS.EXAMPLES);E!=null&&Object.keys(E).length>0&&v.push(...Object.entries(E).map(([w,_])=>({name:_?.summary??w,value:_.value,description:_.description})));let b=Dke(e);b!=null&&Object.keys(b).length>0&&v.push(...b.map(w=>({name:void 0,value:w,description:void 0})));let I=VCa({schema:e,description:A,title:h,nameOverride:p,generatedName:m,availability:y});if(I!=null){let w=I;return r&&(w=jr.nullable({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:w})),t&&(w=jr.optional({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:w})),w}try{if(Array.isArray(e.type)){let C=e.type.indexOf("null"),x=C!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&x)e.type.splice(C,1),e.type=e.type[0],e.nullable=!0;else if(x&&(e.type.splice(C,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let R=new Set([...e.oneOf,...e.type]);e.oneOf=[...R]}}if(r=r||e.nullable===!0,"const"in e){let C=e.const;if(typeof C=="string"||typeof C=="boolean")return qRi({nameOverride:p,generatedName:m,title:h,wrapAsOptional:t,wrapAsNullable:r,value:C,description:A,availability:y,namespace:a,groupName:f});e.enum=[C]}if(e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(x=>x!==null),!Q_r(e.enum))return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.string({default:ZXe(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:Yq({schema:e,logger:n.logger,fallback:l})}),namespace:a,groupName:f,wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y});let C=zCa(e);return n.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&C==null?qRi({nameOverride:p,generatedName:m,title:h,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:A,availability:y,namespace:a,groupName:f}):Dwe({nameOverride:p,generatedName:m,title:h,fernEnum:C,enumVarNames:qr(e,[xS.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,namespace:a,groupName:f,context:n,source:s,inline:void 0})}if(Q_r(e.type)&&e.type.length>1){let C=e.type.includes("null"),x=e.type.filter(R=>R!=="null").map(R=>({type:R,nullable:C}));return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:x,namespace:a,groupName:f,encoding:o,source:s})}if(e.type==="boolean"){let C=qr(e,bn.BOOLEAN_LITERAL);return C!=null?s_a({nameOverride:p,generatedName:m,title:h,literal:nA.boolean(C),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f}):SS({nameOverride:p,generatedName:m,title:h,primitive:Si.boolean({default:Ygf(e.default),example:n_a({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f})}if(e.type==="number")return GRi({nameOverride:p,generatedName:m,title:h,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Rke(e.exclusiveMinimum),exclusiveMaximum:Rke(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,example:R_r({schema:e,logger:n.logger,fallback:l}),namespace:a,groupName:f});if(e.type==="integer")return JCa({nameOverride:p,generatedName:m,title:h,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Rke(e.exclusiveMinimum),exclusiveMaximum:Rke(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,example:R_r({schema:e,logger:n.logger,fallback:l}),namespace:a,groupName:f,defaultIntegerFormat:n.options.defaultIntegerFormat});if(e.type==="float")return GRi({nameOverride:p,generatedName:m,title:h,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Rke(e.exclusiveMinimum),exclusiveMaximum:Rke(e.exclusiveMaximum),multipleOf:e.multipleOf,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,example:R_r({schema:e,logger:n.logger,fallback:l}),namespace:a,groupName:f});if(e.type==="string"){if(e.format==null&&e.contentMediaType==="application/octet-stream"&&(e={...e,format:"binary"}),e.format==="date-time")return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.datetime({example:Yq({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f});if(e.format==="date-time-rfc-2822")return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.datetimeRfc2822({example:Yq({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f});if(e.format==="date"&&n.options.typeDatesAsStrings===!1)return SS({nameOverride:p,generatedName:m,title:h,primitive:Si.date({example:Yq({schema:e,logger:n.logger,fallback:l})}),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f});if(e.format==="json-string"){let x=jr.unknown({nameOverride:p,generatedName:m,title:h,description:A,availability:y,namespace:a,groupName:f,example:void 0});return r&&(x=jr.nullable({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:x})),t&&(x=jr.optional({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:x})),x}let C=p_a(e,"const");return C!=null?s_a({nameOverride:p,generatedName:m,title:h,literal:nA.string(C),wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y,namespace:a,groupName:f}):SS({nameOverride:p,generatedName:m,title:h,primitive:Si.string({default:ZXe(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Yq({schema:e,logger:n.logger,fallback:l})}),namespace:a,groupName:f,wrapAsOptional:t,wrapAsNullable:r,description:A,availability:y})}if(e.type==="array")return $Ca({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,item:e.items,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,example:i_a({schema:e,logger:n.logger,fallback:l}),source:s,minItems:e.minItems,maxItems:e.maxItems});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&F_r(e)&&o_a(e))return GCa({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,additionalProperties:e.additionalProperties,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,example:e.example,source:s,minProperties:e.minProperties,maxProperties:e.maxProperties});if(e.oneOf!=null&&e.oneOf.length>0&&qr(e,bn.IS_DISCRIMINATED)===!1)return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf,namespace:a,groupName:f,encoding:o,source:s});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return n.options.discriminatedUnionV2?$Ri({nameOverride:p,generatedName:m,title:h,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,discriminator:e.discriminator,encoding:o,source:s}):T_r({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,source:s});if(e.oneOf!=null&&e.oneOf.length>0){let C=qr(e,bn.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return n.options.discriminatedUnionV2||C?$Ri({nameOverride:p,generatedName:m,title:h,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,discriminator:e.discriminator,encoding:o,source:s}):T_r({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,source:s});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(n.options.preserveSingleSchemaOneOf)return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf.filter(R=>Hn(R)||R.type!=="null"),encoding:o,namespace:a,groupName:f,source:s});let x=Za(e.oneOf[0],t,r,n,i,s,a,c);return oY(x,A,a,f)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let U=e.oneOf[0],q=e.oneOf[1];if(!Hn(U)&&U.type==="null"){let te=Za(q,t,!0,n,i,s,a);return oY(te,A,a,f)}else if(!Hn(q)&&q.type==="null"){let te=Za(U,t,!0,n,i,s,a);return oY(te,A,a,f)}}let x=Zgf({schemas:e.oneOf});if(x!=null)return Dwe({nameOverride:p,generatedName:m,title:h,fernEnum:void 0,enumVarNames:void 0,enumValues:x,_default:e.default,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,namespace:a,groupName:f,context:n,source:s,inline:void 0});let R=a_a({schemas:e.oneOf,context:n});if(R!=null&&!n.options.discriminatedUnionV2&&!C)return VRi({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,properties:e.properties??{},required:e.required,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,discriminant:R.discriminant,variants:R.schemas,context:n,namespace:a,groupName:f,encoding:o,source:s});let z=e.oneOf.filter(U=>!Hn(U)&&U.type==="null").length>0;return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r||z,context:n,subtypes:e.oneOf.filter(U=>Hn(U)||U.type!=="null"),encoding:o,namespace:a,groupName:f,source:s})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let R=Za(e.anyOf[0],t,r,n,i,s,a,c);return oY(R,A,a,f)}if(e.anyOf.length===2){let[R,z]=e.anyOf;if(R!=null&&z!=null){if(!Hn(R)&&R.type==="null"){let U=Za(z,t,!0,n,i,s,a);return oY(U,A,a,f)}else if(!Hn(z)&&z.type==="null"){let U=Za(R,t,!0,n,i,s,a);return oY(U,A,a,f)}}}let C=a_a({schemas:e.anyOf,context:n});if(C!=null&&!n.options.discriminatedUnionV2)return VRi({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,properties:e.properties??{},required:e.required,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,discriminant:C.discriminant,variants:C.schemas,context:n,namespace:a,groupName:f,encoding:o,source:s});let x=e.anyOf.filter(R=>!Hn(R)&&R.type==="null").length>0;return Fwe({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r||x,context:n,subtypes:e.anyOf.filter(R=>Hn(R)||R.type!=="null"),encoding:o,namespace:a,groupName:f,source:s})}if(e.discriminator?.mapping!=null&&Object.keys(e.discriminator.mapping).length>0&&e.oneOf==null&&e.anyOf==null)return T_r({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,description:A,availability:y,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:a,groupName:f,encoding:o,source:s});if(e.allOf!=null||e.properties!=null){let C=[];for(let R of e.allOf??[])(Hn(R)||Object.keys(R).length>0)&&C.push(R);if((e.properties==null||F_r(e))&&C.length===1&&C[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let R=Za(C[0],t,r,n,i,s,a,c);return oY(R,A,a,f)}let x=C.filter(R=>{let z=j_r(R);return z||n.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(R)}`),z});if((e.properties==null||F_r(e))&&x.length===1&&x[0]!=null&&(e.additionalProperties==null||e.additionalProperties===!1)){let R=Za(x[0],t,r,n,i,s,a,c);return oY(R,A,a,f)}return ZCa({nameOverride:p,generatedName:m,title:h,breadcrumbs:i,properties:e.properties??{},description:A,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:x,context:n,propertiesToExclude:u,namespace:a,groupName:f,fullExamples:v,additionalProperties:e.additionalProperties,availability:y,encoding:o,source:s,minProperties:e.minProperties,maxProperties:e.maxProperties})}if(e.type==="object"&&Xgf(e)&&o_a(e)&&F_r(e))return zRi({nameOverride:p,generatedName:m,title:h,description:A,availability:y,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${m}Key`,title:void 0,description:void 0,availability:void 0,schema:Si.string({default:ZXe(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:Yq({schema:e,logger:n.logger,fallback:l})}),namespace:a,groupName:f},valueSchema:jr.unknown({nameOverride:void 0,generatedName:`${m}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:a,groupName:f}),namespace:a,groupName:f,encoding:o,example:e.example,minProperties:e.minProperties,maxProperties:e.maxProperties});e.type!=null&&n.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${i.join("->")}. Coercing to unknown.`);let w=e.example??e.default,_=jr.unknown({nameOverride:p,generatedName:m,title:h,description:A,availability:y,namespace:a,groupName:f,example:w});return r&&(_=jr.nullable({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:_})),t&&(_=jr.optional({availability:y,namespace:a,groupName:f,description:A,generatedName:m,inline:void 0,nameOverride:p,title:h,value:_})),_}catch(w){return n.logger.debug(`Error converting schema: ${w.message}
|
|
1677
1677
|
Location: ${i.join("-> ")}`),jr.unknown({nameOverride:p,generatedName:m,title:h,description:A,availability:y,namespace:a,groupName:f,example:void 0})}}function Ygf(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 Rwe(e){if(e.$ref.startsWith(Fke))return e.$ref.replace(Fke,"")}function WRi(e,t,r,n,i){let o=qr(e,bn.TYPE_NAME),s=Gy(t,n),a=e.description,u=cO(e),c=Rwe(e);if(c==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return ya.reference({generatedName:s,nameOverride:o,title:void 0,schema:c,description:a??void 0,availability:u,namespace:i.getNamespace(c),groupName:void 0,source:r})}function Xgf(e){return e.oneOf==null||e.oneOf.length===0}function o_a(e){return e.allOf==null||e.allOf.length===0}function F_r(e){return e.properties==null||fm(e.properties)===0}function Q_r(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function oY(e,t,r,n){if(e.type==="reference")return jr.reference({...e,description:t,availability:e.availability,namespace:r,groupName:n});if(e.type==="optional"){let i=oY(e.value,t,r,n);return jr.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0})}else if(e.type==="nullable"){let i=oY(e.value,t,r,n);return jr.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0})}else if(e.type==="primitive"&&t!=null&&e.description==null)return jr.primitive({...e,description:t});return e}function j_r(e){return Hn(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>j_r(t)):e.oneOf!=null?e.oneOf.every(t=>j_r(t)):e.anyOf!=null?e.anyOf.every(t=>j_r(t)):!1}function s_a({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:o,availability:s,nameOverride:a,generatedName:u,title:c}){let l=jr.literal({nameOverride:a,generatedName:u,title:c,value:e,namespace:n,groupName:i,description:o,availability:s});return r&&(l=jr.nullable({nameOverride:a,generatedName:u,title:c,value:l,namespace:n,groupName:i,description:o,availability:s,inline:void 0})),t&&(l=jr.optional({nameOverride:a,generatedName:u,title:c,value:l,namespace:n,groupName:i,description:o,availability:s,inline:void 0})),l}function SS({primitive:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:o,availability:s,generatedName:a,nameOverride:u,title:c}){i=typeof i=="string"?[i]:i;let l=jr.primitive({nameOverride:u,generatedName:a,title:c,schema:e,description:o,availability:s,namespace:n,groupName:i});return r&&(l=jr.nullable({nameOverride:u,generatedName:a,title:c,value:l,namespace:n,groupName:i,description:o,availability:s,inline:void 0})),t&&(l=jr.optional({nameOverride:u,generatedName:a,title:c,value:l,namespace:n,groupName:i,description:o,availability:s,inline:void 0})),l}function Zgf({schemas:e}){let t=new Set;for(let r of e){if(Hn(r))return;if(r.enum!=null&&Q_r(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function a_a({schemas:e,context:t}){let r={};for(let n of e){let i=l_a({schema:n,context:t});for(let[o,s]of Object.entries(i)){let a=r[o];a!=null?a[s]=n:r[o]={[s]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function l_a({schema:e,context:t}){let r=Hn(e)?t.resolveSchemaReference(e):e;return eAf({schema:r,context:t})}function eAf({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=l_a({schema:n,context:t});for(let[o,s]of Object.entries(i??{}))r[o]=s}return r}for(let[n,i]of Object.entries(e.properties??{})){let o=Hn(i)?t.resolveSchemaReference(i):i;o.type==="string"&&o.enum!=null&&Q_r(o.enum)&&tAf(o.enum).length===1&&o.enum[0]!=null&&(r[n]=o.enum[0]);let s=p_a(o,"const");o.type==="string"&&s!=null&&(r[n]=s),n==="type"&&o.example!=null&&(r[n]=o.example)}return r}function tAf(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 p_a(e,t){let r=e[t];if(r!=null)return r}function rAf({schema:e,logger:t}){let r=UCa({schema:e,logger:t});if(r!=null)return KCa(r)}var eZe=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(Fke))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let n=t.$ref.substring(Fke.length).split("/"),i=this.document.components;if(i==null||i.schemas==null)throw new Error("Document does not have components.schemas.");let[o,s,a]=n;if(o==null||o==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let u=i.schemas[o];if(u==null)throw new Error(`Schema "${o}" is undefined in document.components.schemas.`);if(Hn(u)&&(u=this.resolveSchemaReference(u)),s==="properties"&&a!=null){let c=u.properties?.[a];if(c==null)throw new Error(`Property "${a}" not found on "${o}". Full ref: ${t.$ref}`);Hn(c)?u=this.resolveSchemaReference(c):u=c}return u}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}getNamespace(t){return this.namespace}};var k_r=class extends eZe{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",n=this.document.components;if(n==null||n.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let i=t.$ref.substring(r.length),o=n.messages[i];if(o==null)throw new Error(`${t.$ref} is undefined`);return o}};Nt();function tZe(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let n={};for(let[i,o]of Object.entries(t))switch(o.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(o.namespace==null){r[i]=o;continue}let s=o.namespace;n[s]??={},n[s][i]=o;continue}case"oneOf":case"unknown":r[i]=o;continue;default:xe(o)}return{rootSchemas:r,namespacedSchemas:n}}Nt();var rZe=Ce(require("fs"),1),jke=Ce(require("path"),1);Nt();function jwe(e){if(typeof e=="string")return nu.primitive(ms.string(e));if(typeof e=="number")return Number.isInteger(e)?nu.primitive(ms.int(e)):nu.primitive(ms.double(e));if(typeof e=="boolean")return nu.primitive(ms.boolean(e));if(Array.isArray(e)){let t=e.map(r=>jwe(r));return t.length===0?void 0:nu.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=jwe(n);i!=null&&t.push({key:ms.string(r),value:i})}return nu.map(t)}}function MDt(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function f_a(e){if(e!=null&&Array.isArray(e))return e}var Qwe=class e{schemas;nonRequestReferencedSchemas;context;constructor(t,r,n){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=n}buildExample({schema:t,exampleId:r,example:n,options:i,skipReadonly:o}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:o??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:o,options:s,skipReadonly:a}){switch(n.type){case"enum":if(typeof r=="string"&&d_a({schema:n,value:r}))return nu.enum(r);if(r!=null){let u=n.values.map(l=>l.value),c=e.truncateExample(r);this.context.logger.warn(`Example value ${c} is not a valid enum value${s.name!=null?` for '${s.name}'`:""}. Allowed values: [${u.join(", ")}]. Using fallback value instead.`)}return n.values[0]!=null?nu.enum(n.values[0]?.value):void 0;case"literal":return nu.literal(n.value);case"nullable":{if(r===null)return nu.null({});if(r==null&&!this.hasExample(n.value,0,o,s)&&this.exceedsMaxDepth(i,s))return nu.null({});let u=this.buildExampleHelper({schema:n.value,visitedSchemaIds:o,exampleId:t,example:r,depth:i,options:s,skipReadonly:a});return u??nu.null({})}case"optional":{if(r==null&&!this.hasExample(n.value,0,o,s)&&(s.ignoreOptionals||this.exceedsMaxDepth(i,s))||Object.is(r,null))return;let u=this.buildExampleHelper({schema:n.value,visitedSchemaIds:o,exampleId:t,example:r,depth:i,options:s,skipReadonly:a});return u!=null&&u.type==="array"&&u.value.length===0||u!=null&&u.type==="map"&&u.value.length===0||u!=null&&u.type==="object"&&Object.keys(u.properties).length===0?void 0:u}case"primitive":{let u=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:s});return nu.primitive(u)}case"reference":{let u=this.schemas[n.schema];if(u!=null&&!o.has(n.schema)){o.add(n.schema);let c=u?.type==="object"&&!this.nonRequestReferencedSchemas.has(n.schema),l=this.buildExampleHelper({example:r,schema:u,exampleId:t,visitedSchemaIds:o,depth:i,options:s,skipReadonly:c||this.context.options.respectReadonlySchemas?a:!1});return o.delete(n.schema),l}return}case"oneOf":switch(n.value.type){case"discriminated":{let u={},c={},l={},p=MDt(r),d=p?.[n.value.discriminantProperty],f=n.value.schemas[d],m=[],h=this.getDiscriminatedUnionVariantSchema(n.value,p);h!=null&&m.push(h),m.push(...Object.entries(n.value.schemas));for(let A of m)if(d!=null&&f!=null&&f.type==="object"){c=this.getAllProperties(f),l=this.getAllRequiredProperties(f),u[n.value.discriminantProperty]=nu.primitive(ms.string(d));break}else{let y=this.buildExampleHelper({exampleId:t,schema:A[1],example:void 0,visitedSchemaIds:o,depth:i,options:s,skipReadonly:a});if(y!=null){this.mergeExampleWith(y,u),u[n.value.discriminantProperty]=nu.primitive(ms.string(A[0]));break}}for(let A of n.value.commonProperties){c[A.key]={schema:A.schema,readonly:!1};let y=this.getResolvedSchema(A.schema);y.type!=="optional"&&y.type!=="nullable"&&(l[A.key]=A.schema)}for(let[A,y]of Object.entries(c)){let v=A in l;if(v&&p?.[A]!=null){let E=this.buildExampleHelper({schema:y.schema,exampleId:t,example:p[A],visitedSchemaIds:o,depth:i+1,options:s,skipReadonly:a});if(E!=null)u[A]=E;else return}else{let E=this.buildExampleHelper({exampleId:t,schema:y.schema,example:p?.[A],visitedSchemaIds:o,depth:i+1,options:s,skipReadonly:a});if(E!=null)u[A]=E;else if(v)return}}return nu.oneOf(vwe.discriminated(u))}case"undiscriminated":{let u=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(u!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:u,visitedSchemaIds:o,depth:i,options:s,skipReadonly:a});break}}return;case"unknown":if(r!=null){let u=jwe(r);if(u!=null)return nu.unknown(u)}return s.ignoreOptionals||this.exceedsMaxDepth(i,s)?void 0:s.isParameter?nu.primitive(ms.string(s.name??"string")):nu.map([{key:ms.string("key"),value:nu.primitive(ms.string("value"))}]);case"array":{let u=f_a(r),c=[];if(u!=null&&u.length>0)for(let l of u){let p=this.buildExampleHelper({exampleId:t,example:l,schema:n.value,depth:i+1,visitedSchemaIds:o,options:s,skipReadonly:a});p!=null&&c.push(p)}else if(n.example!=null&&n.example.length>0)for(let l of n.example){let p=this.buildExampleHelper({exampleId:t,example:l,schema:n.value,depth:i+1,visitedSchemaIds:o,options:s,skipReadonly:a});p!=null&&c.push(p)}else{let l=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:o,options:s,skipReadonly:a});l!=null&&c.push(l)}return nu.array(c)}case"map":{let u=MDt(r??n.example);if(u!=null&&Object.entries(u).length>0){let p=[];for(let[d,f]of Object.entries(u)){let m=this.buildExampleFromPrimitive({schema:n.key.schema,example:d,options:s}),h=this.buildExampleHelper({exampleId:t,example:f,schema:n.value,visitedSchemaIds:o,depth:i+1,options:s,skipReadonly:a});h!=null&&p.push({key:m,value:h})}return nu.map(p)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return nu.map([{key:ms.string("key"),value:nu.unknown(nu.primitive(ms.string("value")))}]);let c=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...s,name:"key"}}),l=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:o,depth:i+1,options:{...s,name:"value"},skipReadonly:a});return l!=null&&l.type!=="null"?nu.map([{key:c,value:l}]):nu.map([])}case"object":{let u={},c=n.fullExamples?.find(f=>f.name===t)??n.fullExamples?.find(f=>f.name==null)??n.fullExamples?.[0],l=MDt(r)??(c!=null?MDt(c.value):{})??{},p=this.getAllProperties(n),d=this.getAllRequiredProperties(n);for(let[f,m]of Object.entries(p)){if(a&&m.readonly||m.schema._visit({optional:I=>typeof I.availability=="string"&&I.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 h=f in d,A=Object.keys(l).includes(f),y=l[f],v=this.getSchemaExample(m.schema),E=A?y:v,b=this.buildExampleHelper({schema:m.schema,exampleId:t,example:E,visitedSchemaIds:o,depth:i+1,options:{...s,name:f},skipReadonly:a});if(h&&b!=null)u[f]=b;else{if(h)return;(A&&b!=null||!s.ignoreOptionals&&b!=null)&&(u[f]=b)}}if(n.additionalProperties){for(let[f,m]of Object.entries(l))if(!(f in u)){let h=this.buildExampleHelper({schema:jr.unknown({example:m,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:m,visitedSchemaIds:o,depth:i+1,options:{...s,name:f},skipReadonly:a});h!=null&&(u[f]=h)}}return nu.object({properties:u})}default:xe(n)}}mergeExampleWith(t,r){t._visit({array:pt,enum:pt,literal:pt,map:n=>{for(let i of n){let o=i.key;o.type==="string"&&(r[o.value]=i.value)}},object:n=>{for(let[i,o]of Object.entries(n.properties))r[i]=o},oneOf:n=>{if(n.type==="discriminated")for(let[i,o]of Object.entries(n.value))r[i]=o;else this.mergeExampleWith(n.value,r)},primitive:pt,unknown:pt,null:pt,_other:pt})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r?.[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){if(r==null){let o=t.schemas.find(a=>this.hasExample(a,0,new Set,{ignoreOptionals:!1,isParameter:!1}));if(o!=null)return o;let s=t.schemas.find(a=>this.hasInherentExample(a));return s??t.schemas[0]}return t.schemas.map(o=>({schema:o,heuristic:this.calcExampleHeuristic(o,r)})).sort((o,s)=>s.heuristic-o.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return d_a({schema:t,value:r})?5:0;case"object":{if(!Oa(r))return 0;let n=this.getAllProperties(t),i=0;for(let[o,s]of Object.entries(n))r[o]!=null?(i++,i+=this.calcExampleHeuristic(s.schema,r[o])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!Oa(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,o)=>o-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",datetimeRfc2822:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let s of t.properties)if(this.hasExample(s.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let o=this.schemas[t.schema];if(o!=null&&!n.has(t.schema)){n.add(t.schema);let s=this.hasExample(o,r,n,i);return n.delete(t.schema),s}return!1}case"unknown":return t.example!=null;case"nullable":case"optional":return this.hasExample(t.value,r,n,i);case"oneOf":return Object.values(t.value.schemas).some(o=>this.hasExample(o,r,n,i));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 n of t.properties)r[n.key]={schema:n.schema,readonly:n.readonly??!1};for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let o=this.getResolvedSchema(i);o.type==="object"&&(r={...this.getAllProperties(o),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let o=this.getResolvedSchema(i);o.type==="object"&&(r={...this.getAllRequiredProperties(o),...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 n=this.schemas[r.schema];return n!=null?this.getSchemaExample(n):void 0},literal:()=>{},oneOf:()=>{},nullable:r=>this.getSchemaExample(r.value),unknown:r=>r.example,_other:()=>{}})}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?ms.string(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"string",schemaType:r.type,options:n}),ms.string(r.example??n.name??yi.STRING));case"base64":return t!=null&&typeof t=="string"?ms.base64(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"string (base64)",schemaType:r.type,options:n}),ms.base64(r.example??yi.BASE64));case"boolean":return t!=null&&typeof t=="boolean"?ms.boolean(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"boolean",schemaType:r.type,options:n}),ms.boolean(r.example??yi.BOOLEAN));case"date":return t!=null&&typeof t=="string"?ms.date(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"string (date)",schemaType:r.type,options:n}),ms.date(r.example??yi.DATE));case"datetime":return t!=null&&typeof t=="string"?ms.datetime(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"string (datetime)",schemaType:r.type,options:n}),ms.datetime(r.example??yi.DATE_TIME));case"datetimeRfc2822":return t!=null&&typeof t=="string"?ms.datetimeRfc2822(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"string (datetime RFC 2822)",schemaType:r.type,options:n}),ms.datetimeRfc2822(r.example??yi.DATE_TIME_RFC_2822));case"double":return t!=null&&typeof t=="number"?ms.double(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"number (double)",schemaType:r.type,options:n}),ms.double(r.example??yi.DOUBLE));case"float":return t!=null&&typeof t=="number"?ms.float(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"number (float)",schemaType:r.type,options:n}),ms.float(r.example??yi.FLOAT));case"int":return t!=null&&typeof t=="number"?ms.int(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"number (int)",schemaType:r.type,options:n}),ms.int(r.example??yi.INT));case"int64":return t!=null&&typeof t=="number"?ms.int64(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"number (int64)",schemaType:r.type,options:n}),ms.int64(r.example??yi.INT64));case"uint":return t!=null&&typeof t=="number"?ms.uint(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"number (uint)",schemaType:r.type,options:n}),ms.uint(r.example??yi.UINT));case"uint64":return t!=null&&typeof t=="number"?ms.uint64(t):(t!=null&&this.warnTypeMismatch({example:t,expected:"number (uint64)",schemaType:r.type,options:n}),ms.uint64(r.example??yi.UINT64));default:xe(r)}}warnTypeMismatch({example:t,expected:r,schemaType:n,options:i}){let o=i.name!=null?` for '${i.name}'`:"",s=typeof t,a=e.truncateExample(t);this.context.logger.warn(`Invalid example${o}: expected ${r} but got ${s} (${a}). The provided example does not match the '${n}' schema and will be replaced with a generated value.`)}static truncateExample(t,r=100){let n=JSON.stringify(t);return n.length<=r?n:n.slice(0,r)+"..."}};function d_a({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}Nt();function Xq(e){switch(e.type){case"object":return jr.object({allOf:e.allOf,properties:e.properties.map(t=>iAf(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,minProperties:e.minProperties,maxProperties:e.maxProperties});case"array":return jr.array({description:e.description,availability:e.availability,value:Xq(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0,minItems:e.minItems,maxItems:e.maxItems});case"enum":return jr.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 jr.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 jr.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Xq(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return jr.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:Xq(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return jr.primitive({description:e.description,availability:e.availability,schema:m_a(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return jr.map({description:e.description,availability:e.availability,key:jr.primitive({description:e.key.description,availability:e.key.availability,schema:m_a(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:Xq(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,minProperties:e.minProperties,maxProperties:e.maxProperties});case"reference":return jr.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 jr.oneOf(nAf(e.value));case"unknown":return jr.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:xe(e)}}function nAf(e){switch(e.type){case"discriminated":return p2.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:Xq(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,discriminantPropertyNameOverride:e.discriminantPropertyNameOverride,discriminatorContext:e.discriminatorContext,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,Xq(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return p2.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>Xq(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:xe(e)}}function m_a(e){switch(e.type){case"string":return Si.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Si.base64({example:void 0});case"boolean":return Si.boolean({default:e.default,example:void 0});case"date":return Si.date({example:void 0});case"datetime":return Si.datetime({example:void 0});case"datetimeRfc2822":return Si.datetimeRfc2822({example:void 0});case"double":return Si.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 Si.float({example:void 0});case"int":return Si.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 Si.int64({default:e.default,example:void 0});case"uint":return Si.uint({default:void 0,example:void 0});case"uint64":return Si.uint64({default:void 0,example:void 0});default:xe(e)}}function iAf(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:Xq(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function M_r(e){return e.type!=="optional"&&e.type!=="nullable"}function HRi(e){return e==="POST"||e==="PUT"||e==="PATCH"}function LDt(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 L_r=class{schemas;context;globalHeaders;exampleTypeFactory;logger;missingExamples=[];constructor(t,r,n){this.schemas=t,this.context=r,this.globalHeaders=n,this.schemas=t,this.exampleTypeFactory=new Qwe(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}addMissingExampleRecord(t,r,n,i,o={}){this.missingExamples.push({endpoint:t.path,method:t.method.toUpperCase(),type:r,schemaType:n,reason:i,operationSummary:t.summary,operationDescription:t.description,schemaDescription:o.schemaDescription,autoGeneratedExample:o.autoGeneratedExample})}writeMissingExamplesLog(){if(this.missingExamples.length===0)return;let t;if(this.context.source.type==="openapi"){let o=this.context.source.file,s=jke.dirname(o),a=s;for(;a!==jke.dirname(a);){let u=jke.join(a,"fern");if(rZe.existsSync(u)&&rZe.statSync(u).isDirectory()){t=u;break}a=jke.dirname(a)}t||(t=s)}else t=process.cwd();let r=t??process.cwd(),n=jke.join(r,"schemas_missing_examples.txt"),i=["# Schemas Missing Examples Report",`# Generated on: ${new Date().toISOString()}`,`# Total missing examples: ${this.missingExamples.length}`,"",...this.missingExamples.flatMap(o=>{let s=[];if(s.push(`${o.method} ${o.endpoint} - ${o.type.toUpperCase()} (${o.schemaType}): ${o.reason}`),o.operationSummary&&s.push(` Operation: ${o.operationSummary}`),o.operationDescription&&o.operationDescription!==o.operationSummary&&s.push(` Description: ${o.operationDescription}`),o.schemaDescription&&s.push(` ${o.type==="request"?"Request":"Response"} Schema: ${o.schemaDescription}`),o.autoGeneratedExample){s.push(" Auto-generated example:");let u=JSON.stringify(o.autoGeneratedExample,null,4).split(`
|
|
1678
1678
|
`).map(c=>` ${c}`).join(`
|
|
1679
1679
|
`);s.push(u)}return s.push(""),s}),""].join(`
|
|
@@ -2125,7 +2125,7 @@ https://buildwithfern.com/learn/docs/getting-started/project-structure#api-defin
|
|
|
2125
2125
|
Learn more about project structure:
|
|
2126
2126
|
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=_t.V1.SlugGenerator.init(_t.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),n=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:n,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(i=>_t.RoleId(i)),featureFlags:void 0}}async toRootChild(t){return kE(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 n=_t.PageId(this.toRelativeFilepath(t.absolutePath)),i=r.apply({urlSlug:t.slug??pm(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(n),title:t.title,slug:i.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:n,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:n}){let i=this.#e.get("unversioned"),o=t!=null?this.toLandingPageNode(t,n):void 0,s=r.type==="tabbed"?await this.convertTabbedNavigation(i,r.items,n):await this.toSidebarRootNode(i,r.items,n);return{type:"unversioned",id:i,landingPage:o,child:s}}async toVersionedNode(t,r){let n=this.#e.get("versioned"),i=t.versions[0];if(i?.hidden===!0)throw new Error(`The default version "${i.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.`);let o=5,s=[];for(let a=0;a<t.versions.length;a+=o){let u=t.versions.slice(a,a+o),c=await Promise.all(u.map((l,p)=>this.toVersionNode(l,r,a+p===0)));s.push(...c)}return{id:n,type:"versioned",children:s}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:n}){let i=this.#e.get("productgroup"),o=r!=null?this.toLandingPageNode(r,n):void 0;return{id:i,type:"productgroup",landingPage:o,children:await Promise.all(t.products.map(s=>this.toProductNode(s,n)))}}async toProductNode(t,r){if(t.type==="internal"){let n=r.setProductSlug(t.slug??pm(t.product)),i;switch(t.navigation.type){case"tabbed":i={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,n)};break;case"untabbed":i={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,n)};break;case"versioned":i=await this.toVersionedNode(t.navigation,n);break;default:xe(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:_t.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:n.get(),child:i,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:_t.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:mP.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,n){let i=this.#e.get(t.version),o=r.setVersionSlug(t.slug??pm(t.version)),s=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(i,t.navigation.items,o):await this.toSidebarRootNode(i,t.navigation.items,o);return{type:"version",id:i,versionId:_t.VersionId(t.version),title:t.version,slug:o.get(),child:s,default:n,availability:t.availability!=null?Lid(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,o):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,n){let i=this.#e.get(`${t}/root`),s=(await Promise.all(r.map(u=>this.toNavigationChild({prefix:i,item:u,parentSlug:n})))).filter(u=>u!=null),a=[];return s.forEach(u=>{if(u.type==="apiReference"){a.push(u);return}let c=u.type==="section"&&(u.collapsible===!0||u.collapsible==null&&u.collapsed===!0);if(u.type==="section"&&!c){a.push(u);return}let l=a.length>0?a[a.length-1]:void 0,p;l?.type==="sidebarGroup"?p=l:(p={id:this.#e.get(`${i}/group`),type:"sidebarGroup",children:[]},a.push(p)),p.children.push(u)}),{type:"sidebarRoot",id:i,children:a}}async toSidebarRootNodeWithVariants(t,r,n){let i=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:i,children:[{type:"varianted",id:i,children:await Promise.all(r.map(o=>this.toVariantNode(o,i,n)))}]}}async toVariantNode(t,r,n){let i=this.#e.get(`${r}/variant/${t.slug??pm(t.title)}`),o=n.apply({urlSlug:t.slug??pm(t.title),skipUrlSlug:t.skipUrlSlug}),a=(await Promise.all(t.layout.map(u=>this.toVariantChild(u,i,o)))).filter(u=>u!=null);return{type:"variant",id:i,variantId:_t.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:a,title:t.title,slug:o.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,n){return kE(t)._visit({page:async i=>this.toPageNode({item:i,parentSlug:n}),apiSection:async i=>this.toApiSectionNode({item:i,parentSlug:n}),section:async i=>this.toSectionNode({prefix:r,item:i,parentSlug:n}),link:async i=>this.toLinkNode(i),changelog:async i=>this.toChangelogNode(i,n),librarySection:async i=>this.handleLibrarySection(i,n)})}async toNavigationChild({prefix:t,item:r,parentSlug:n,hideChildren:i,parentAvailability:o}){return kE(r)._visit({page:async s=>this.toPageNode({item:s,parentSlug:n,hideChildren:i,parentAvailability:o}),apiSection:async s=>this.toApiSectionNode({item:s,parentSlug:n,hideChildren:i,parentAvailability:o}),section:async s=>this.toSectionNode({prefix:t,item:s,parentSlug:n,hideChildren:i,parentAvailability:o}),link:async s=>this.toLinkNode(s),changelog:async s=>this.toChangelogNode(s,n,i),librarySection:async s=>this.handleLibrarySection(s,n)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:n,parentAvailability:i}){let o=L7a(t.snippetsConfiguration),s,a,u,c,l=this.parsedDocsConfig.experimental?.openapiParserV3,p=l==null||l;if(p)try{u=this.getOpenApiWorkspaceForApiSection(t),s=await u.getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1})}catch(b){c=b}let d;if(t.tagDescriptionPages&&p)try{let I=await(u??this.getOpenApiWorkspaceForApiSection(t)).getOpenAPIIr({context:this.taskContext,loadAiExamples:!0});I.tags.tagsById&&(d=Object.fromEntries(Object.entries(I.tags.tagsById).filter(([w,_])=>_.description&&_.description.trim().length>0).map(([w,_])=>[$n(w),{id:String(_.id),description:_.description}])))}catch(b){this.taskContext.logger.warn("Failed to extract OpenAPI tags for tag description pages",String(b))}if(s==null){if(this.apiWorkspaces.length===0&&c!=null)throw c;a=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),s=Bg({workspace:a,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 Sh(this.taskContext,a)})}else try{a=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0})}catch(b){this.taskContext.logger.debug(`Could not load workspace: ${b}. Dynamic snippets and AI examples may not be available.`)}this.docsWorkspace.config.settings?.substituteEnvVars&&(s=bv(s,{onError:b=>this.taskContext.failAndThrow(`Error substituting environment variables in API spec: ${b}`)},{substituteAsEmpty:!1}));let f=await this.extractGraphQLData(),m=t.apiName??a?.workspaceName??u?.workspaceName,h=`__pending_api_${this.pendingApiCounter++}__`,A=JQt({ir:s,apiDefinitionId:h,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext,graphqlOperations:f.operations,graphqlTypes:f.types}),y=new njr(t,A,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,a,n,i??t.availability,d,f.namespacesByOperationId),v=y.getTagDescriptionContent();for(let[b,I]of v.entries()){let w=b.split("/").pop()||b,_=Se.of(w),C=I;this.docsWorkspace.config.settings?.substituteEnvVars&&(C=bv(I,{onError:x=>this.taskContext.logger.error(`Error in tag description environment variable substitution: ${x}`)},{substituteAsEmpty:!1})),this.rawMarkdownFiles[_]=C,this.parsedDocsConfig.pages[_]=C}let E=y.get();return this.pendingApiRegistrations.push({ir:s,snippetsConfig:o,playgroundConfig:{oauth:t.playground?.oauth},apiName:m,workspace:a,graphqlOperations:f.operations,graphqlTypes:f.types,tempApiDefinitionId:h,apiReferenceNode:E}),E}async toChangelogNode(t,r,n){return new V4e(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:n||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:_t.V1.Url(t.url),icon:this.resolveIconFileId(t.icon),target:t.target}}async extractGraphQLData(){let t={},r={},n=new Map;for(let i of this.ossWorkspaces){let o=i.allSpecs.filter(s=>s.type==="graphql");for(let s of o)try{let u=await new jtt({context:this.taskContext,filePath:s.absoluteFilepath,namespace:s.namespace}).convert();if(Object.assign(t,u.graphqlOperations),Object.assign(r,u.types),s.namespace)for(let c of Object.keys(u.graphqlOperations))n.set(wr.GraphQlOperationId(c),s.namespace)}catch(a){this.taskContext.logger.error(`Failed to process GraphQL spec ${s.absoluteFilepath}:`,String(a))}}return{operations:t,types:r,namespacesByOperationId:n}}async handleLibrarySection(t,r){let n=this.parsedDocsConfig.libraries?.[t.libraryName];if(n==null)return this.taskContext.logger.warn(`Library '${t.libraryName}' not found in libraries config. Skipping.`),null;let i=Go(this.docsWorkspace.absoluteFilePath,n.output.path),o=await this.loadLibraryNavNodes(t.libraryName,i);if(o==null)return null;let s=t.title??t.libraryName,a=r.apply({urlSlug:t.slug??pm(s)}),u=this.#e.get(`library/${t.libraryName}`),c;if(o.length>0){let p=o[0]?.slug.split("/").slice(0,-1).join("/");p&&(c=await this.registerLibraryMdxPage(i,`${p}.mdx`))}let l=await this.convertLibraryNavNodes(o,i,a);return{id:u,type:"section",overviewPageId:c,slug:a.get(),title:s,icon:void 0,collapsed:void 0,hidden:!1,viewers:t.viewers,orphaned:t.orphaned,children:l,authed:void 0,pointsTo:void 0,noindex:void 0,featureFlags:t.featureFlags,availability:void 0}}async loadLibraryNavNodes(t,r){let n=We(r,Se.of("_navigation.yml"));if(!(0,r6i.existsSync)(n))return this.taskContext.logger.warn(`No _navigation.yml found for library '${t}' at ${n}. Run 'fern docs md generate' first.`),null;let o=(await(0,y_e.readFile)(n,"utf-8")).split(`
|
|
2127
2127
|
`).filter(s=>!s.startsWith("#")).join(`
|
|
2128
|
-
`);try{return Tr.load(o)??[]}catch(s){return this.taskContext.logger.warn(`Failed to parse _navigation.yml for library '${t}': ${s instanceof Error?s.message:String(s)}`),null}}async registerLibraryMdxPage(t,r){let n=We(t,Se.of(r));if(!(0,r6i.existsSync)(n)){this.taskContext.logger.warn(`Library MDX file not found: ${n}`);return}let i=Ra(this.docsWorkspace.absoluteFilePath,n),o=await(0,y_e.readFile)(n,"utf-8");return this.parsedDocsConfig.pages[i]=o,_t.PageId(i)}async convertLibraryNavNodes(t,r,n){let i=[];for(let o of t)if(o.type==="page"&&o.pageId!=null){let s=await this.registerLibraryMdxPage(r,o.pageId);if(s==null)continue;let a=n.apply({fullSlug:o.slug.split("/"),urlSlug:pm(o.title)});i.push({id:this.#e.get(s),type:"page",slug:a.get(),title:o.title,icon:void 0,hidden:!1,viewers:void 0,orphaned:void 0,pageId:s,authed:void 0,noindex:void 0,featureFlags:void 0,availability:void 0})}else if(o.type==="section"){let s=n.apply({fullSlug:o.slug.split("/"),urlSlug:pm(o.title)}),a=this.#e.get(`library-section/${o.slug}`),u=await this.registerLibraryMdxPage(r,`${o.slug}.mdx`),c=(o.children??[]).filter(p=>!(p.type==="page"&&p.slug===o.slug)),l=await this.convertLibraryNavNodes(c,r,s);i.push({id:a,type:"section",overviewPageId:u,slug:s.get(),title:o.title,icon:void 0,collapsed:void 0,hidden:!1,viewers:void 0,orphaned:void 0,children:l,authed:void 0,pointsTo:void 0,noindex:void 0,featureFlags:void 0,availability:void 0})}return i}async toPageNode({item:t,parentSlug:r,hideChildren:n,parentAvailability:i}){let o=_t.PageId(this.toRelativeFilepath(t.absolutePath)),s=r.apply({urlSlug:t.slug??pm(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")}),a=this.#e.get(o),u=this.markdownFilesToAvailability.get(t.absolutePath);return{id:a,type:"page",slug:s.get(),title:this.markdownFilesToSidebarTitle.get(t.absolutePath)??t.title,icon:this.resolveIconFileId(t.icon),hidden:n||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:o,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:u??t.availability??i}}async toSectionNode({prefix:t,item:r,parentSlug:n,hideChildren:i,parentAvailability:o}){let s=this.toRelativeFilepath(r.overviewAbsolutePath),a=s?_t.PageId(s):void 0,u=this.#e.get(a??`${t}/section`),c=n.apply({urlSlug:r.slug??pm(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),l=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,p=r.overviewAbsolutePath!=null?this.markdownFilesToAvailability.get(r.overviewAbsolutePath):void 0,d=i||r.hidden,m=(await Promise.all(r.contents.map(h=>this.toNavigationChild({prefix:u,item:h,parentSlug:c,hideChildren:d,parentAvailability:r.availability??o})))).filter(h=>h!=null);if(a==null){let h=m.find(A=>A.type==="apiReference"&&A.hideTitle===!0&&A.overviewPageId!=null);h!=null&&(a=h.overviewPageId)}return{id:u,type:"section",overviewPageId:a,slug:c.get(),title:r.overviewAbsolutePath!=null?this.markdownFilesToSidebarTitle.get(r.overviewAbsolutePath)??r.title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,collapsible:r.collapsible??(r.collapsed===!0?!0:void 0),collapsedByDefault:r.collapsedByDefault??(r.collapsed===!0?!0:void 0),hidden:d,viewers:r.viewers,orphaned:r.orphaned,children:m,authed:void 0,pointsTo:void 0,noindex:l,featureFlags:r.featureFlags,availability:p??r.availability??o}}async convertTabbedNavigation(t,r,n){let i=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:i,children:await Promise.all(r.map(o=>this.toTabChild(i,o,n)))}}async toTabChild(t,r,n){return kE(r.child)._visit({link:({href:i,target:o})=>this.toTabLinkNode(r,i,o),layout:({layout:i})=>this.toTabNode(t,r,i,n),changelog:({changelog:i})=>this.toTabChangelogNode(r,i,n),variants:({variants:i})=>this.toTabNodeWithVariants(t,r,i,n)})}async toTabChangelogNode(t,r,n){return new V4e(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:n,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r,n){return{type:"link",id:this.#e.get(r),title:t.title,url:_t.V1.Url(r),target:n,icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,n,i){let o=this.#e.get(`${t}/tab`),s=i.apply({urlSlug:r.slug??pm(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:o,title:r.title,slug:s.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(o,n,s),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,n,i){let o=this.#e.get(`${t}/tab`),s=i.apply({urlSlug:r.slug??pm(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:o,title:r.title,slug:s.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(o,n,s),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):mP.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:n}=this.parsedDocsConfig,i=r?.[t],o=n?.[t];return{logo:this.getFileId(i),backgroundImage:this.getFileId(o)}}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 n=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${n}`,variants:t.variants.map(i=>({fontFile:this.getFileId(i.absolutePath),weight:i.weight,style:i.style!=null?[i.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(Ca),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:mP.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":n,...i}=this.parsedDocsConfig.metadata;return{...i,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(n)}}convertFileIdOrUrl(t){if(t!=null)return kE(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:mP.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}resolveLinksInIrDocs(t,r){let n={absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absolutePathToMarkdownFile:this.docsWorkspace.absoluteFilePath};djr(t,r,n)}};function Mid(e,t){let r=e?.launch??"github";if(e?.github==null)return{url:void 0,launch:r};let{owner:n,repo:i,branch:o="main",host:s="https://github.com"}=e.github;return{url:`${ET(s)}/${n}/${i}/blob/${o}/fern/${t}?plain=1`,launch:r}}function Lid(e){switch(e){case"beta":return _t.V1.NavigationV1Availability.Beta;case"deprecated":return _t.V1.NavigationV1Availability.Deprecated;case"ga":return _t.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return _t.V1.NavigationV1Availability.Stable;default:xe(e)}}Nt();async function US(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof Kp?t:null))).filter(Ca)}async function n6i(e,t,r){if(e instanceof IO){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Kp))return;let n=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return vT({ir:n,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 Ea={};X(Ea,{AlgoliaSearchIndex:()=>sWa,ApiDefinitionId:()=>SWa,ApiId:()=>TWa,Availability:()=>WWa,DocsConfigId:()=>DWa,EndpointId:()=>FWa,EndpointPathLiteral:()=>qWa,EnvironmentId:()=>RWa,FileId:()=>MWa,HttpMethod:()=>GWa,IndexSegmentId:()=>aWa,JqString:()=>UWa,OrgId:()=>BWa,PageId:()=>kWa,PayloadLocation:()=>b$a,PropertyKey:()=>zWa,PullRequestState:()=>m$a,RoleId:()=>VWa,TokenId:()=>PWa,TypeId:()=>NWa,Url:()=>LWa,VersionId:()=>OWa,WebSocketId:()=>jWa,WebhookId:()=>QWa,algolia:()=>i6i,api:()=>m6i,commons:()=>h6i,diff:()=>$Wa,docs:()=>C6i,generators:()=>x6i,git:()=>S6i,navigation:()=>P6i,sdks:()=>D6i,snippets:()=>A$a,snippetsFactory:()=>y$a,templates:()=>R6i,tokens:()=>v$a});var i6i={};X(i6i,{AlgoliaSearchIndex:()=>sWa,IndexSegmentId:()=>aWa});function sWa(e){return e}function aWa(e){return e}var m6i={};X(m6i,{latest:()=>a6i,v1:()=>d6i});var a6i={};X(a6i,{AuthSchemeId:()=>uWa,WebhookHttpMethod:()=>fWa,auth:()=>o6i,commons:()=>cWa,endpoint:()=>lWa,type_:()=>pWa,webhook:()=>s6i,websocket:()=>dWa});var o6i={};X(o6i,{AuthSchemeId:()=>uWa});function uWa(e){return e}var cWa={};var lWa={};var pWa={};var s6i={};X(s6i,{WebhookHttpMethod:()=>fWa});var fWa={Get:"GET",Post:"POST"};var dWa={};var d6i={};X(d6i,{SubpackageId:()=>wWa,WebSocketMessageId:()=>CWa,WebSocketMessageOrigin:()=>_Wa,WebhookHttpMethod:()=>xWa,commons:()=>f6i,db:()=>u6i,read:()=>l6i,register:()=>p6i});var u6i={};X(u6i,{endpoint:()=>mWa});var mWa={};var l6i={};X(l6i,{SupportedLanguage:()=>hWa,endpoint:()=>c6i,type_:()=>gWa,webhook:()=>AWa,websocket:()=>yWa});var c6i={};X(c6i,{SupportedLanguage:()=>hWa});var hWa={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var gWa={};var AWa={};var yWa={};var p6i={};X(p6i,{SourceId:()=>Uid,endpoint:()=>bWa,type_:()=>vWa,webhook:()=>EWa,websocket:()=>IWa});var bWa={};var vWa={};var EWa={};var IWa={};function Uid(e){return e}var f6i={};X(f6i,{SubpackageId:()=>wWa,WebSocketMessageId:()=>CWa,WebSocketMessageOrigin:()=>_Wa,WebhookHttpMethod:()=>xWa});function wWa(e){return e}function CWa(e){return e}var _Wa={Client:"client",Server:"server"};var xWa={Get:"GET",Post:"POST"};var h6i={};X(h6i,{ApiDefinitionId:()=>SWa,ApiId:()=>TWa,Availability:()=>WWa,DocsConfigId:()=>DWa,EndpointId:()=>FWa,EndpointPathLiteral:()=>qWa,EnvironmentId:()=>RWa,FileId:()=>MWa,HttpMethod:()=>GWa,JqString:()=>UWa,OrgId:()=>BWa,PageId:()=>kWa,PropertyKey:()=>zWa,RoleId:()=>VWa,TokenId:()=>PWa,TypeId:()=>NWa,Url:()=>LWa,VersionId:()=>OWa,WebSocketId:()=>jWa,WebhookId:()=>QWa});function SWa(e){return e}function OWa(e){return e}function BWa(e){return e}function PWa(e){return e}function TWa(e){return e}function DWa(e){return e}function RWa(e){return e}function FWa(e){return e}function jWa(e){return e}function QWa(e){return e}function NWa(e){return e}function kWa(e){return e}function MWa(e){return e}function LWa(e){return e}function UWa(e){return e}function zWa(e){return e}function VWa(e){return e}function qWa(e){return e}var GWa={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var WWa={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var $Wa={};var C6i={};X(C6i,{latest:()=>y6i,v1:()=>I6i,v2:()=>w6i});var y6i={};X(y6i,{Layout:()=>KWa,MdxEngine:()=>zid,TwitterCardSetting:()=>JWa,commons:()=>HWa,frontmatter:()=>g6i,seo:()=>A6i});var zid={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var HWa={};var g6i={};X(g6i,{Layout:()=>KWa});var KWa={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var A6i={};X(A6i,{TwitterCardSetting:()=>JWa});var JWa={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var I6i={};X(I6i,{commons:()=>E6i,db:()=>YWa,read:()=>XWa,write:()=>b6i});var YWa={};var XWa={};var b6i={};X(b6i,{DocsRegistrationId:()=>qid,FilePath:()=>Vid});function Vid(e){return e}function qid(e){return e}var E6i={};X(E6i,{ContentAlignment:()=>r$a,FontDisplay:()=>a$a,FontStyle:()=>s$a,HeaderPosition:()=>n$a,JsScriptStrategy:()=>o$a,ProgrammingLanguage:()=>ZWa,SearchbarPlacement:()=>e$a,TabsPlacement:()=>t$a,TwitterCardSetting:()=>i$a,commons:()=>v6i});var v6i={};X(v6i,{ContentAlignment:()=>r$a,FontDisplay:()=>a$a,FontStyle:()=>s$a,HeaderPosition:()=>n$a,JsScriptStrategy:()=>o$a,ProgrammingLanguage:()=>ZWa,SearchbarPlacement:()=>e$a,TabsPlacement:()=>t$a,TwitterCardSetting:()=>i$a});var ZWa={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 e$a={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var t$a={Header:"HEADER",Sidebar:"SIDEBAR"};var r$a={Center:"CENTER",Left:"LEFT"};var n$a={Fixed:"FIXED",Absolute:"ABSOLUTE"};var i$a={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var o$a={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var s$a={Normal:"normal",Italic:"italic"};var a$a={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var w6i={};X(w6i,{read:()=>u$a,write:()=>c$a});var u$a={};var c$a={};var x6i={};X(x6i,{ChangelogEntryType:()=>p$a,GeneratorId:()=>Gid,GeneratorLanguage:()=>Wid,ReleaseType:()=>f$a,cli:()=>l$a,commons:()=>_6i,versions:()=>d$a});var l$a={};var _6i={};X(_6i,{ChangelogEntryType:()=>p$a,ReleaseType:()=>f$a});var p$a={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var f$a={Ga:"GA",Rc:"RC"};var d$a={};function Gid(e){return e}var Wid={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var S6i={};X(S6i,{PullRequestState:()=>m$a});var m$a={Open:"open",Closed:"closed",Merged:"merged"};var P6i={};X(P6i,{latest:()=>O6i,v1:()=>B6i});var O6i={};X(O6i,{NodeId:()=>Kid,ProductId:()=>Jid,Slug:()=>$id,TabId:()=>Hid});function $id(e){return e}function Hid(e){return e}function Kid(e){return e}function Jid(e){return e}var B6i={};X(B6i,{NavigationV1Availability:()=>tod,NodeId:()=>Zid,ProductId:()=>eod,Slug:()=>Yid,TabId:()=>Xid});function Yid(e){return e}function Xid(e){return e}function Zid(e){return e}function eod(e){return e}var tod={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var D6i={};X(D6i,{Language:()=>h$a,VersionBump:()=>g$a,versions:()=>T6i});var T6i={};X(T6i,{Language:()=>h$a,VersionBump:()=>g$a});var h$a={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var g$a={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var A$a={};var y$a={};var R6i={};X(R6i,{PayloadLocation:()=>b$a});var b$a={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var v$a={};var gjr=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function E$a({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(n=>{let i=[];n.namespace?.forEach(o=>{let s=[...i,o],a=Ea.api.v1.SubpackageId(s.join("."));r[a]={id:a,name:o,displayName:LS(o)},i.push(o)})}),r}var Ajr=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 I$a(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var qo=class extends Ajr{context;accessPath;pathId;constructor({input:t,context:r,accessPath:n,pathId:i}){if(super(t,r),this.context=r,this.accessPath=[...n],this.pathId=i,i!=null){let o=Array.isArray(this.pathId)?this.pathId:[this.pathId];o.every((s,a)=>s===this.accessPath[this.accessPath.length-o.length+a])||this.accessPath.push(...o)}r.logger.debug(`Processing ${I$a(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})}}},zv=class extends qo{},fj=class extends zv{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var w$a="x-fern-base-path",C$a="x-fern-availability",yjr="x-fern-sdk-group-name",_$a="x-fern-global-headers",x$a="x-fern-sdk-method-name";var S$a="x-fern-webhook",O$a="x-fern-access-token-locator",B$a="x-fern-basic",P$a="x-fern-username-variable-name",T$a="x-fern-password-variable-name",D$a="x-fern-bearer",R$a="x-fern-token-variable-name",F$a="x-fern-header",j$a="x-fern-header-variable-name",Q$a="x-fern-server-name",N$a="x-fern-examples";var bjr=class extends qo{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[Q$a]}convert(){if(this.serverName!=null)return this.serverName}};var vjr=class extends qo{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,n])=>t.replace(`{${r}}`,n.default),this.input.url)??this.input.url,this.serverName=new bjr({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:Ea.EnvironmentId(t),baseUrl:this.url}}};function b_e(e,t,r,n){let i=e??[],o=new Set(i.map(a=>a.url)),s=(t??[]).filter(a=>!o.has(a.url)).map((a,u)=>new vjr({input:a,context:r,accessPath:n,pathId:["servers",`${u}`]}));return[...i,...s]}function Mp(e){return typeof e=="object"&&Yo(e)&&"$ref"in e&&typeof e.$ref=="string"}function zS(e,t,r){let n=e.$ref.substring(2).split("/").map(o=>o.replace(/~1/g,"/")),i=t;for(let o of n){if(typeof i!="object"||i==null)return r;i=i[o]}return i==null?r:(Mp(i)&&(i=zS(i,t,r)),i)}function Ejr(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return Mp(r)?zS(r,t,void 0):r}var nHa=Ce(Oy());var Ijr=class extends qo{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[B$a];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var wjr=class extends qo{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[T$a]}convert(){return this.passwordVariableName}};var Cjr=class extends qo{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[P$a]}convert(){return this.usernameVariableName}};var _jr=class extends qo{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[D$a];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var xjr=class extends qo{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[R$a]}convert(){return this.tokenVariableName}};function k$a(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var M$a="x-bearer-format",L$a="x-code-samples",U$a="x-codeSamples";var Sjr=class extends qo{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[M$a]}convert(){return this.bearerFormat}};var Ojr=class extends qo{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[F$a];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var Bjr=class extends qo{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[j$a]}convert(){return this.headerVariableName}};function z$a(e){return e.type==="apiKey"}var frt=class extends qo{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){z$a(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new Ojr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new Bjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new Sjr({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()}}};yKn();N9o();function Pjr(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function drt(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function q4e(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(q4e).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function Tjr(e){if(Array.isArray(e))return e.map(drt);if(typeof e=="symbol")return[e];e=q4e(e);let t=[],r=e.length;if(r===0)return t;let n=0,i="",o="",s=!1;for(e.charCodeAt(0)===46&&(t.push(""),n++);n<r;){let a=e[n];o?a==="\\"&&n+1<r?(n++,i+=e[n]):a===o?o="":i+=a:s?a==='"'||a==="'"?o=a:a==="]"?(s=!1,t.push(i),i=""):i+=a:a==="["?(s=!0,i&&(t.push(i),i="")):a==="."?i&&(t.push(i),i=""):i+=a,n++}return i&&t.push(i),t}function YQt(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(MVt(t))return r;let n=e[t];return n===void 0?Pjr(t)?YQt(e,Tjr(t),r):r:n}case"number":case"symbol":{typeof t=="number"&&(t=drt(t));let n=e[t];return n===void 0?r:n}default:{if(Array.isArray(t))return rod(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),MVt(t))return r;let n=e[t];return n===void 0?r:n}}}function rod(e,t,r){if(t.length===0)return r;let n=e;for(let i=0;i<t.length;i++){if(n==null||MVt(t[i]))return r;n=n[t[i]]}return n===void 0?r:n}function V$a(e){return function(t){return YQt(t,e)}}function q$a(e){return e!==null&&(typeof e=="object"||typeof e=="function")}K$n();function F6i(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Q6i(e,t,r){return typeof r!="function"?Q6i(e,t,()=>{}):j6i(e,t,function n(i,o,s,a,u,c){let l=r(i,o,s,a,u,c);return l!==void 0?!!l:j6i(i,o,n,c)},new Map)}function j6i(e,t,r,n){if(t===e)return!0;switch(typeof t){case"object":return nod(e,t,r,n);case"function":return Object.keys(t).length>0?j6i(e,{...t},r,n):F6i(e,t);default:return q$a(e)?typeof t=="string"?t==="":!0:F6i(e,t)}}function nod(e,t,r,n){if(t==null)return!0;if(Array.isArray(t))return G$a(e,t,r,n);if(t instanceof Map)return iod(e,t,r,n);if(t instanceof Set)return ood(e,t,r,n);let i=Object.keys(t);if(e==null||JEt(e))return i.length===0;if(i.length===0)return!0;if(n?.has(t))return n.get(t)===e;n?.set(t,e);try{for(let o=0;o<i.length;o++){let s=i[o];if(!JEt(e)&&!(s in e)||t[s]===void 0&&e[s]!==void 0||t[s]===null&&e[s]!==null||!r(e[s],t[s],s,e,t,n))return!1}return!0}finally{n?.delete(t)}}function iod(e,t,r,n){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[i,o]of t.entries()){let s=e.get(i);if(r(s,o,i,e,t,n)===!1)return!1}return!0}function G$a(e,t,r,n){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let i=new Set;for(let o=0;o<t.length;o++){let s=t[o],a=!1;for(let u=0;u<e.length;u++){if(i.has(u))continue;let c=e[u],l=!1;if(r(c,s,o,e,t,n)&&(l=!0),l){i.add(u),a=!0;break}}if(!a)return!1}return!0}function ood(e,t,r,n){return t.size===0?!0:e instanceof Set?G$a([...e],[...t],r,n):!1}function Djr(e,t){return Q6i(e,t,()=>{})}Q9o();function W$a(e){return e=j9o(e),t=>Djr(t,e)}Y$n();RVt();J$n();function $$a(e,t){return F9o(e,(r,n,i,o)=>{let s=t?.(r,n,i,o);if(s!==void 0)return s;if(typeof e=="object"){if(KVe(e)===kVt&&typeof e.constructor!="function"){let a={};return o.set(e,a),gM(a,e,i,o),a}switch(Object.prototype.toString.call(e)){case jVt:case FVt:case QVt:{let a=new e.constructor(e?.valueOf());return gM(a,e),a}case NVt:{let a={};return gM(a,e),a.length=e.length,a[Symbol.iterator]=e[Symbol.iterator],a}default:return}}})}function H$a(e){return $$a(e)}var sod=/^(?:0|[1-9]\d*)$/;function K$a(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 sod.test(e)}}RVt();function J$a(e){return e!==null&&typeof e=="object"&&KVe(e)==="[object Arguments]"}function Y$a(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&Pjr(t)&&e?.[t]==null?r=Tjr(t):r=[t],r.length===0)return!1;let n=e;for(let i=0;i<r.length;i++){let o=r[i];if((n==null||!Object.hasOwn(n,o))&&!((Array.isArray(n)||J$a(n))&&K$a(o)&&o<n.length))return!1;n=n[o]}return!0}function X$a(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=drt(e);break}}return t=H$a(t),function(r){let n=YQt(r,e);return n===void 0?Y$a(r,e):t===void 0?n===void 0:Djr(n,t)}}function Z$a(e){if(e==null)return Zqt;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?X$a(e[0],e[1]):W$a(e);case"string":case"symbol":case"number":return V$a(e)}}yKn();X$n();function Rjr(e,t=Zqt){return e==null?{}:xx(e,Z$a(t))}sJo();function eHa(e){return oJo(q4e(e))}U9o();function tHa(e){return typeof e!="string"&&(e=q4e(e)),e.replace(/['\u2019]/g,"")}function Q9(e){return L9o(tHa(eHa(e)))}function Nm(e){if(e!=null)return Array.isArray(e)?e:[e]}function Fjr({namespace:e,path:t,method:r,sdkMethodName:n,operationId:i,displayName:o,isWebhook:s}){if(t==null)return;let a=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(n==null&&i==null&&o==null&&a==null))return`${aod(s)}${uod(e)}.${cod(n,i,o,a)}`}function aod(e){return e?"webhook_":"endpoint_"}function uod(e){return e!=null?Nm(e)?.map(t=>Q9(t)).join("/"):""}function cod(e,t,r,n){return e||t||Q9(r??"")||Q9(n??"")}function rHa(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var jjr=class extends qo{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[O$a],this.accessTokenLocator!=null&&(rHa(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 Qjr=class extends qo{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 frt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new jjr({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=Fjr({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:Ea.EndpointId(r),accessTokenLocator:Ea.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var mrt=class extends qo{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 Ijr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new Cjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new wjr({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 _jr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new xjr({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":{k$a(this.input)?(this.authScheme="header",this.headerAuthNode=new frt({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 Qjr({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 nHa.UnreachableCaseError(this.authScheme);return}}};var hrt=class extends qo{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(n=>{let i=Ejr(n,this.context.document);if(i==null){this.context.errors.warning({message:`No auth scheme found for ${n}. Inline security schemes are not supported.`,path:this.accessPath});return}let o=new mrt({input:i,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});o.convert()!=null?(this.authNodesMap??={},this.authNodesMap[n]=o):this.context.errors.warning({message:`No auth scheme found for ${n}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[t,n]}).filter(Yo))}};var Njr=class extends qo{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[w$a],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 iHa(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function oHa(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function grt(e,t){return e==null?void 0:Object.entries(e).map(([n,i])=>Nm(i.convert())?.map(s=>((t!=null&&!t.includes(n)||t==null&&!iHa(i))&&(s=oHa(s,s.type==="enum"?s.default:void 0)),{key:Ea.PropertyKey(n),valueShape:s,description:i.description,availability:i.availability?.convert()})).filter(Yo)).filter(Yo).reduce((n,i)=>n.flatMap(o=>i.length>0?i.map(s=>[...o,s]):[[...o]]),[[]])}function kjr(e,t){return Mp(e)?zS(e,t,void 0):e}function v_e(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function sHa(e,t){let r={...e};for(let[n,i]of Object.entries(t??{}))r[n]=[...r[n]??[],...i];return Object.keys(r).length>0?r:void 0}function aHa(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let n of e)for(let i of t)r.push({path:n.path??i.path,responseStatusCode:n.responseStatusCode??i.responseStatusCode,name:n.name??i.name,description:n.description??i.description,pathParameters:n.pathParameters??i.pathParameters,queryParameters:n.queryParameters??i.queryParameters,headers:n.headers??i.headers,requestBody:n.requestBody??i.requestBody,responseBody:n.responseBody??i.responseBody,snippets:{...i.snippets,...n.snippets}});return r}var uHa=Ce(Oy());var N6i=["decimal","decimal128","double-int","double","float","sf-decimal"],k6i=["int16","int32","int64","int8","sf-integer","uint8"],M6i=["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"],L6i=["beta","pre-release","in-development","generally-available","deprecated"];function Vv(e,t){return Mp(e)?zS(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var vU=class extends qo{availability;constructor(t){super(t),this.safeParse()}parse(){if(Vv(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[C$a];r!=null&&(L6i.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${L6i.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return Ea.Availability.Beta;case"in-development":return Ea.Availability.InDevelopment;case"generally-available":return Ea.Availability.GenerallyAvailable;case"deprecated":return Ea.Availability.Deprecated;case void 0:return;default:new uHa.UnreachableCaseError(this.availability);return}}};var Ljr=Ce(Oy());function cHa(e){return typeof e=="object"&&e!=null&&"language"in e}function lHa(e){return typeof e=="object"&&e!=null&&"sdk"in e}function pHa(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function fHa(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function Mjr(e){return typeof e=="object"&&e!=null&&"event"in e}function U6i(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(Mjr)}function E_e(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function dHa(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var Ujr=class extends qo{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,n,i,o){super(t),this.path=r,this.successResponseStatusCode=n,this.requestBodyByContentType=i,this.responseBodies=o,this.safeParse()}parse(){this.examples=this.input[N$a]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([i,o])=>{let s=typeof r=="object"?r[i]:void 0;switch(o.multipartType){case"file":return E_e(s)?[i,{type:"filenameWithData",filename:s.filename,data:Ea.FileId(s.data)}]:s!=null?[i,{type:"filename",value:s}]:void 0;case"files":{if(Array.isArray(s)){if(s.every(a=>E_e(a)))return[i,{type:"filenamesWithData",value:s.map(a=>({filename:a.filename,data:Ea.FileId(a.data)}))}];if(s.every(a=>typeof a=="string"))return[i,{type:"filenames",value:s}]}return}case"property":return[i,{type:"json",value:s}];case void 0:return;default:new Ljr.UnreachableCaseError(o.multipartType);return}}).filter(Yo))};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(n=>{let i=t!=null?this.requestBodyByContentType?.[t]:void 0,o;if(i!=null)switch(i.contentType){case"form-data":o=dHa(r.request)?this.convertFormDataExampleRequest(i,r.request):void 0;break;case"json":o=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":o=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new Ljr.UnreachableCaseError(i.contentType);break}let s;switch(n.contentType){case"application/json":{pHa(r.response)&&(s={type:"json",value:r.response.body});break}case"text/event-stream":{U6i(r.response)&&(s={type:"sse",value:r.response.stream.map(p=>({event:p.event,data:p.data}))});break}case"application/octet-stream":!U6i(r.response)&&fHa(r.response)&&(s={type:"stream",value:r.response.stream});break;case void 0:break;default:new Ljr.UnreachableCaseError(n.contentType);break}let a={};r["code-samples"]?.forEach(p=>{cHa(p)?p.language!=null&&(a[p.language]??=[],a[p.language]?.push({name:p.name,language:p.language,install:p.install,code:p.code,generated:!1,description:p.docs})):lHa(p)&&p.sdk!=null&&(a[p.sdk]??=[],a[p.sdk]?.push({name:p.name,language:p.sdk,install:void 0,code:p.code,generated:!1,description:p.docs}))});let u=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([p,d])=>[Ea.PropertyKey(p),d])),c=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([p,d])=>[Ea.PropertyKey(p),d])),l=Object.fromEntries(Object.entries(r.headers??{}).map(([p,d])=>[Ea.PropertyKey(p),d]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(u).length>0?u:void 0,queryParameters:Object.keys(c).length>0?c:void 0,headers:Object.keys(l).length>0?l:void 0,requestBody:o,responseBody:s,snippets:a}}))}};var XQt=class extends qo{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[yjr]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>Ea.api.v1.SubpackageId(Q9(r)))}};var zjr=class extends qo{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[x$a]}convert(){return this.sdkMethodName}};var Vjr=class extends qo{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[S$a]}convert(){return this.isWebhook}};var qjr=class extends qo{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[L$a]??[],...this.input[U$a]??[]],this.codeSamples.forEach(t=>{[...Object.values(Ea.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 G4e=Ce(Oy());function z6i(e,t){return Mp(e)?zS(e,t,void 0):e}function mHa(e,t){return e.replace(/{(\w+)}/g,(r,n)=>t[n]!=null&&typeof t[n]=="string"||typeof t[n]=="number"||typeof t[n]=="boolean"?`${t[n]}`:r)}var o_="",WY=class extends qo{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,n,i,o){super(t),this.path=r,this.responseStatusCode=n,this.name=i,this.shapes=o,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,n])=>{let i=this.resolvedRequestInput?.value[r];switch(n.multipartType){case"file":return t&&(E_e(i)||typeof i=="string");case"files":return t&&Array.isArray(i)&&i.every(o=>E_e(o)||typeof o=="string");case"property":return t;case void 0:return t&&!1;default:return new G4e.UnreachableCaseError(n.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=z6i(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=z6i(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 G4e.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(Mjr)){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 G4e.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,n])=>{let i=this.resolvedRequestInput?.value?.[r];switch(n.multipartType){case"file":return E_e(i)?[r,{type:"filenameWithData",filename:i.filename,data:Ea.FileId(i.data)}]:[r,{type:"filename",value:i}];case"files":{if(Array.isArray(i)){if(i.every(o=>E_e(o)))return[r,{type:"filenamesWithData",value:i.map(o=>({filename:o.filename,data:Ea.FileId(o.data)}))}];if(i.every(o=>typeof o=="string"))return[r,{type:"filenames",value:i}]}return}case"property":return[r,{type:"json",value:i}];case void 0:return;default:new G4e.UnreachableCaseError(n.multipartType);return}}).filter(Yo))};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 G4e.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 G4e.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let n=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([s,a])=>[s,a.example({includeOptionals:!1,override:s})]));n=Object.keys(n).length>0?n:void 0;let i=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([s,a])=>a.required||a.inputExample!=null?[s,a.example({includeOptionals:!1,override:s})]:void 0).filter(Yo));i=Object.keys(i).length>0?i:void 0;let o=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([s,a])=>a.required||a.inputExample!=null?[s,a.example({includeOptionals:!1,override:s})]:void 0).filter(Yo));if(o=Object.keys(o).length>0?o:void 0,!(this.path==null&&t==null&&r==null&&o==null&&i==null&&n==null))return{path:mHa(this.path,n??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?LS(this.name):this.summary!=null?LS(this.summary):void 0,description:this.convertDescription(),pathParameters:n,queryParameters:i,headers:o,requestBody:t,responseBody:r,snippets:void 0}}};function hHa(e,t){return Mp(e)?zS(e,t,void 0):e}var OHa=Ce(Oy());var gHa="#/components/schemas/";function Art(e){if(e.$ref.startsWith(gHa))return e.$ref.replace(gHa,"")}function $ge(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function I_e(e){return typeof e.type=="string"&&e.type==="array"}function AHa(e){return e.type==="boolean"}function yHa(e){return e.type==="integer"}function w_e(e){return!Array.isArray(e.type)&&!I_e(e)}function bHa(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||w_e(t)||I_e(t))}function vHa(e){return"nullable"in e&&typeof e.nullable=="boolean"}function EHa(e){return e.type==="null"}function IHa(e){return e.type==="number"}function V6i(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function wHa(e){return e.type==="string"}var Gjr=class extends fj{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new Rg({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 Nm(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 Wjr=class extends zv{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 vU({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 $jr=class extends fj{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 Rg({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Yo)}convert(){if(this.typeNodes==null)return;let n=this.typeNodes.map(i=>Nm(i.convert())?.map(s=>({displayName:i.name,shape:s,description:i.description,availability:i.availability?.convert()}))).filter(Yo).reduce((i,o)=>i.flatMap(s=>o.length>0?o.map(a=>[...s,a]):[[...s]]),[[]]).map(i=>({type:"undiscriminatedUnion",variants:i}));return this.nullable?n.map($ge).filter(Yo):n}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function Hjr(e){return e!=null&&e.length>0?e:[void 0]}var yrt=class extends fj{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 Rg({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 Rg({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(Mp(t))return Art(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([n,i])=>[n,new Rg({input:i,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",n],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Yo))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return grt(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}}}]:Nm(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(Yo)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(n=>Hjr(r).map(i=>(this.extends==null||this.extends.length===0)&&n.length===0&&i!=null?{type:"alias",value:i}:{type:"object",extends:this.extends.map(o=>Ea.TypeId(o)),properties:n,extraProperties:i}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(n=>{let i=Vv(n,this.context.document);i!=null&&(r={...r,...Object.fromEntries(Object.entries(i.properties??{}).map(([o,s])=>[o,new Rg({input:s,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((n,i)=>{let o=r?.[i];return n[i]=o?.example({includeOptionals:t,override:i}),n},{}):Object.entries(r).reduce((n,[i,o])=>(n[i]=o?.example({includeOptionals:t,override:i}),n),{}))}};var Kjr=class extends fj{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=>Vv(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>Vv(t,this.context.document)?.type!=="null"?new Rg({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Yo);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(([n,i])=>{let o=Vv({$ref:i},this.context.document);if(o==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${i}`,path:[...this.accessPath,"discriminator","mapping",n]});return}r[n]=new Rg({input:o,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",n],pathId:n,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let i=this.undiscriminatedMapping?.flatMap(o=>o.convert()).filter(Yo);return this.isNullable&&i!=null?i.map($ge).filter(Yo):i}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:Ea.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([i,o])=>Nm(o.convert())?.map(a=>{if(!(a==null||a.type!=="object"))return{discriminantValue:i,displayName:o.name??LS(i),availability:o.availability?.convert(),description:o.description,...a}}).filter(Yo)).filter(Yo)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(i=>Nm(i.convert())?.map(s=>{if(s==null)return;t+=1;let a=s.type==="object"?LS(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:i.name??(s.type==="alias"&&s.value.type==="id"?LS(s.value.id):a),shape:s,description:i.description,availability:i.availability?.convert()}}).filter(Yo)).filter(Yo)}:void 0,n=this.isNullable?$ge(r):r;return n!=null?[n]: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 Jjr=class extends zv{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 C_e=class extends zv{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,n)=>{if(t){if(Mp(r)){let i=Vv(r,this.context.document);r=typeof i=="string"?i:typeof i?.default=="string"?i?.default:typeof i?.example=="string"?i.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${n}]`]}),t=!1;return}return r}}).filter(Yo),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 CHa=Ce(Oy());function lod(e){return k6i.includes(e)}var Yjr=class extends zv{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&&(lod(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${k6i.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 CHa.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 Xjr=class extends zv{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return $ge({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var _Ha=Ce(Oy());function pod(e){return N6i.includes(e)}var Zjr=class extends zv{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&&(pod(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${N6i.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 _Ha.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 xHa=Ce(Oy());function fod(e){return M6i.includes(e)}var eQr=class extends zv{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 xHa.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&&(fod(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${M6i.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new C_e({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 SHa=Ce(Oy());var tQr=class extends zv{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,SHa.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var W4e=class extends fj{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=Art(this.input);let t=Vv(this.input,this.context.document);t?.enum!=null&&w_e(t)&&(this.maybeEnumConverterNode=new C_e({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:Ea.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=Vv(this.input,this.context.document);if(r!=null)return new Rg({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var Rg=class e extends fj{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 vU({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),w_e(this.input)&&vHa(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),Mp(this.input)){let t=Art(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 W4e({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 Wjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(bHa(this.input))this.typeShapeNode=new $jr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(w_e(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new Kjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(V6i(this.input)&&this.input.allOf!=null)this.typeShapeNode=new yrt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(w_e(this.input)&&this.input.enum!=null)this.typeShapeNode=new C_e({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":V6i(this.input)&&(this.typeShapeNode=new yrt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":I_e(this.input)&&(this.typeShapeNode=new Gjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":AHa(this.input)&&(this.typeShapeNode=new Jjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":yHa(this.input)&&(this.typeShapeNode=new Yjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":IHa(this.input)&&(this.typeShapeNode=new Zjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":wHa(this.input)&&(this.typeShapeNode=new eQr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":EHa(this.input)&&(this.typeShapeNode=new Xjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new OHa.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 yrt({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 tQr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!Mp(this.input)&&(!I_e(this.input)&&this.input==null||I_e(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=Nm(t)?.map(n=>this.nullable?$ge(n):n).filter(Yo);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function __e(e){if(e!=null)return grt(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Yo))}var $Y=class extends zv{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;Mp(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 vU({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new Rg({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let n=hHa(this.input,this.context.document);this.inputExample=n?.example??Object.values(n?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function BHa(e,t){return Mp(e)?zS(e,t,void 0):e}var q6i=Ce(Oy());function rQr(e){let{uniqueId:t,type:r,contextTypes:n,description:i,availability:o}=e;n[Ea.TypeId(t)]={name:t,shape:r,description:i,availability:o}}var PHa=Ce(pli(),1),brt=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,n,i,o,s){this.type=t,this.subtype=r,this.essence=n,this.parameters=i,this.mimeType=o,this.input=s}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=PHa.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 dod(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var nQr=class extends qo{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 Rg({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),dod(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],n)=>{let i;if(Mp(r)?i=Ejr(r.$ref,this.context.document):i=r,i!=null)return[t,new mrt({input:i,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${n}`]})]}).filter(Yo)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[Ea.api.latest.AuthSchemeId(t),n]}).filter(Yo)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let n=r.name??t,i=Nm(r.convert());return i==null?[t,void 0]:[Ea.TypeId(t),{name:n,shape:i[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Yo(r))):void 0}}};var iQr=class extends Rg{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=Vv(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${Mp(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=Vv(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 oQr=class extends qo{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 n=Vv(this.input.schema,this.context.document);this.availability=new vU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=Mp(this.input.schema)?new W4e({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 i=brt.parse(t);i?.containsJSON()?(this.contentType="json",this.schema=this.schema??new Rg({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):i?.isOctetStream()?(this.contentType="bytes",this.isOptional=n?.required==null):i?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=n?.required,this.fields=Object.fromEntries(Object.entries(n?.properties??{}).map(([o,s])=>{if(s!=null)return[o,new iQr({input:s,context:this.context,accessPath:this.accessPath,pathId:`schema.${o}`,seenSchemas:new Set,nullable:void 0,schemaName:o})]}).filter(Yo))):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?{[o_]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[o_]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:Nm(t)?.map(n=>{let i=n.type;switch(i){case"object":case"alias":return n;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let o=Q9([this.method,this.path,this.contentType,"request"].join("_"));return rQr({uniqueId:o,type:n,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Ea.TypeId(o),default:n.type==="enum"&&n.default!=null?{type:"enum",value:n.default}:void 0}}}case void 0:return;default:new q6i.UnreachableCaseError(i);return}}).filter(Yo)}convert(){if(this.schema instanceof W4e)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(([n,i])=>{switch(i.multipartType){case"file":return[{type:i.multipartType,key:Ea.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"files":return[{type:i.multipartType,key:Ea.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"property":{let o=Nm(i.convert()),s=i.multipartType;return o?.map(a=>({type:s,key:Ea.PropertyKey(n),contentType:i.contentType,exploded:void 0,valueShape:a,description:i.description,availability:i.availability?.convert()}))}case void 0:return[];default:return new q6i.UnreachableCaseError(i.multipartType),[]}}).filter(Yo).reduce((n,i)=>n.flatMap(o=>i.length>0?i.map(s=>[...o,s]):[[...o]]),[[]]).map(n=>({type:"formData",fields:n,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var sQr=class extends qo{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let n=BHa(this.input,this.context.document);if(n==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(n.content).forEach(([i,o])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[i]=new oQr({input:o,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:i,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>Nm(r.convert())?.map(i=>({description:this.description,contentType:t,body:i}))).filter(Yo)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>Nm(t.convert())?.map(n=>{if(!(n.type!=="alias"&&n.type!=="object"))return{description:this.description,shape:n}})).filter(Yo)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var THa={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 DHa(e,t){if(Mp(e)){let r=zS(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var aQr=Ce(Oy());var RHa="application/json";var FHa="application/octet-stream";function jHa(e,t){return e===t||t===o_||e===o_}var ZQt=class extends qo{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,n,i,o,s,a,u){super(t),this.streamingFormat=n,this.path=i,this.method=o,this.statusCode=s,this.requests=a,this.shapes=u,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,n){for(let i of t)for(let[o,s]of Object.entries(i?.examples??{}))for(let[a,u]of Object.entries(r))for(let c of u)jHa(a,o)&&(n.add(a),this.examples?.push(new WY({input:{requestExample:s,responseExample:c},context:this.context,accessPath:this.accessPath,pathId:o!=null&&o!==""?["examples",o]:"examples"},this.path,this.statusCode,v_e(o,a),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let n=0;for(let i of t){let o=0;for(let[s,a]of r){if(o===n){let[u,c,l]=i??[void 0,void 0,void 0];this.examples?.push(...a.map(p=>new WY({input:{requestExample:l,responseExample:p},context:this.context,accessPath:this.accessPath,pathId:c!=null&&c!==""?["examples",c]:"examples"},this.path,this.statusCode,v_e(c,s),{requestBody:u,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}o++}n++}if(t.length>r.length)for(let i of t.slice(r.length)){let[o,s]=r[r.length-1]??[void 0,void 0],[a,u,c]=i??[void 0,void 0,void 0];this.examples?.push(...(s??[void 0]).map(l=>new WY({input:{requestExample:c,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:u!=null&&u!==""?["examples",u]:"examples"},this.path,this.statusCode,v_e(u,o),{requestBody:a,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[i,o,s]=t[t.length-1]??[void 0,void 0,void 0];for(let[a,u]of r.slice(t.length))this.examples?.push(...u.map(c=>new WY({input:{requestExample:s,responseExample:c},context:this.context,accessPath:this.accessPath,pathId:o!=null&&o!==""?["examples",o]:"examples"},this.path,this.statusCode,v_e(o,a),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,n,i){let o=t[o_];if(o!=null)for(let s of o)this.examples?.push(new WY({input:{requestExample:i,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:n!=null&&n!==""?["examples",n]:"examples"},this.path,this.statusCode,v_e(n,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 n of t)if(Object.keys(n.examples??{}).length===0)this.pushResponseExample(r,n,void 0,void 0);else for(let[i,o]of Object.entries(n.examples??{}))this.pushResponseExample(r,n,i,o)}parse(t){if(t==="empty")this.empty=!0;else{let a=brt.parse(t);if(a?.isJSON()||a?.isEventStream())this.contentType=RHa,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 Rg({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(a?.isOctetStream())this.contentType=FHa,this.contentSubtype=Vv(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 Rg({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=Rjr(this.input.examples,a=>[a])),this.input.example!=null&&Object.keys(r).length===0&&(r[o_]??=[],r[o_]=[{value:this.input.example}]);let n=Vv(this.input.schema,this.context.document);if(n!=null&&(n.examples!=null&&Object.keys(r).length===0&&(r=Rjr(n.examples,a=>[a])),n.example!=null&&Object.keys(r).length===0&&(r[o_]??=[],r[o_]?.push({value:n.example}))),Object.keys(r).length===0){let a=this.schema?.example({includeOptionals:!0,override:void 0});r[o_]??=[],r[o_]?.push(a!=null?{value:a}:void 0)}this.examples??=[];let i=new Set;this.matchRequestResponseExamplesByName(this.requests,r,i);let o=[];for(let a of this.requests)o.push(...Object.entries(a.examples??{}).filter(([u])=>!i.has(u)&&u!==o_).map(([u,c])=>[a,u,c]));let s=Object.entries(r).filter(([a,u])=>!i.has(a)&&Yo(u)&&a!==o_);Object.keys(r).every(a=>a===o_)||this.matchExamplesByIndex(o,s),!i.has(o_)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return Nm(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new aQr.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return Nm(this.schema?.convert())?.map(r=>{let n=r.type;switch(n){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let i=Q9([this.method,this.path,this.statusCode,"response"].join("_"));return rQr({uniqueId:i,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Ea.TypeId(i),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new aQr.UnreachableCaseError(n);return}}).filter(Yo)}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 aQr.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var eNt=class extends qo{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,n,i,o,s){super(t),this.path=r,this.method=n,this.statusCode=i,this.requests=o,this.shapes=s,this.safeParse()}parse(t){this.description=this.input.description;let r=DHa(this.input,this.context.document);if(r==null){this.context.errors.error({message:Mp(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([n,i])=>{this.headers??={},this.headers[n]=new $Y({input:i,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:n})}),r.content==null?(this.responses??=[],this.responses.push(new ZQt({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(([n,i])=>{this.responses??=[],this.responses.push(new ZQt({input:i,context:this.context,accessPath:this.accessPath,pathId:["content",n]},n,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(Yo)}};var uQr=class extends qo{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,n,i,o){super(t),this.path=r,this.method=n,this.requests=i,this.shapes=o,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,n])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new eNt({input:{...t,...n},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new eNt({input:n,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 n=r.convert();if(n!=null)return Hjr(__e(r.headers)).flatMap(i=>n?.map(o=>({headers:i,response:{statusCode:parseInt(t),body:o,description:r.description},examples:(r.responses??[]).flatMap(s=>(s.examples??[]).map(a=>a.convert()).filter(Yo))})))}).filter(Yo)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(n=>{let i=n.schema,o=Nm(i?.convert());if(i!=null)return o?.map(s=>({statusCode:parseInt(t),shape:s,description:r.description??i.description,availability:i.availability?.convert(),name:i.name??THa[parseInt(t)]??"UNKNOWN ERROR",examples:n.examples?.map(a=>{let u=a.convert();if(u!=null&&u.responseBody?.type==="json")return{name:u.name,description:u.description,responseBody:u.responseBody}}).filter(Yo)})).filter(Yo)})).filter(Yo)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var x_e=class extends qo{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,n){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new WY({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,v_e(n,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 vU({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=b_e(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new Vjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((n,i)=>{if(Mp(n)){let o=kjr(n,this.context.document);if(o!=null)n=o;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${n.$ref}`,path:[...this.accessPath,`parameters[${i}]`]});return}}n.in==="path"?n.schema!=null&&(this.pathParameters??={},this.pathParameters[n.name]=new $Y({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="query"?n.schema!=null&&(this.queryParameters??={},this.queryParameters[n.name]=new $Y({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="header"&&n.schema!=null&&(this.requestHeaders??={},this.requestHeaders[n.name]=new $Y({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name}))});for(let n of this.extractPathParameterIds()??[])this.pathParameters?.[n]==null&&this.context.errors.warning({message:`Path parameter not defined: ${n}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new qjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new sQr({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 uQr({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 n=this.requests?.requestBodiesByContentType;n==null||Object.keys(n).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(n).forEach(i=>{if(Object.keys(i.examples??{}).length===0){let o=i.schema?.example({includeOptionals:!1,override:void 0});o!=null&&this.pushEmptyResponseExample({value:o},i,void 0)}else Object.entries(i.examples??{}).forEach(([o,s])=>{this.pushEmptyResponseExample(s,i,o)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(n=>Number(n)>=200&&Number(n)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new hrt({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new XQt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(n=>n.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((n,i)=>new XQt({input:{[yjr]:n},context:this.context,accessPath:this.accessPath,pathId:["tags",`${i}`]})));let r=new zjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(n=>Fjr({namespace:Nm(n?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Yo),this.xFernExamplesNode=new Ujr({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(Yo)}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((i,o)=>(i.push({type:"literal",value:"/"}),o.startsWith("{")&&o.endsWith("}")?i.push({type:"pathParameter",value:Ea.PropertyKey(o.slice(1,-1).trim())}):i.push({type:"literal",value:o}),i),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},n=this.emptyResponseExamples?.map(l=>l.convert()).filter(Yo),i=aHa(this.xFernExamplesNode?.convert(),[...n??[],...t?.flatMap(l=>l.examples)??[]])?.map(l=>({...l,snippets:sHa(l.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((l,p)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:Ea.WebhookId(l),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[p]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(d=>d.value.toString())??[],queryParameters:__e(this.queryParameters)?.flat(),headers:__e(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Yo)}}).filter(Yo);let o=this.servers?.map(l=>l.convert()).filter(Yo),s=this.convertPathToPathParts();if(s==null)return;let a,u=this.auth?.convert();u!=null&&(a=Object.keys(u));let c=t?.flatMap(l=>l.headers).filter(Yo);return this.endpointIds.map((l,p)=>({id:Ea.EndpointId(l),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[p]?.convert()?.map(d=>Ea.api.v1.SubpackageId(d)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:s,auth:a?.map(d=>Ea.api.latest.AuthSchemeId(d)),defaultEnvironment:o?.[0]?.id,environments:o,pathParameters:__e(this.pathParameters)?.flat(),queryParameters:__e(this.queryParameters)?.flat(),requestHeaders:__e(this.requestHeaders)?.flat(),responseHeaders:c!=null&&c.length>0?c:void 0,requests:this.requests?.convert(),responses:t?.map(d=>d.response),errors:r,examples:i,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var vrt=class extends qo{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n,isWebhook:i}){this.description=this.input.description;let o=b_e(t,this.input.servers,this.context,this.accessPath),s=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new x_e({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:o,globalAuth:r,path:s,method:"GET",basePath:n,isWebhook:i})),this.input.post!=null&&(this.post=new x_e({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:o,globalAuth:r,path:s,method:"POST",basePath:n,isWebhook:i})),this.input.put!=null&&(this.put=new x_e({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:o,globalAuth:r,path:s,method:"PUT",basePath:n,isWebhook:!1})),this.input.patch!=null&&(this.patch=new x_e({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:o,globalAuth:r,path:s,method:"PATCH",basePath:n,isWebhook:!1})),this.input.delete!=null&&(this.delete=new x_e({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:o,globalAuth:r,path:s,method:"DELETE",basePath:n,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(Yo)}};function cQr(e){return"payloads"in e}var lQr=class extends qo{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.paths=Object.entries(this.input).map(([i,o])=>{if(o!=null)return new vrt({input:o,context:this.context,accessPath:this.accessPath,pathId:i,servers:b_e(t,o.servers,this.context,this.accessPath),globalAuth:r,basePath:n,isWebhook:void 0})}).filter(Yo)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(n=>{let i=n.convert();i?.forEach(o=>{cQr(o)?r[Ea.WebhookId(o.id)]=o:t[Ea.EndpointId(o.id)]=o})}),{endpoints:t,webhookEndpoints:r}}};var pQr=class extends qo{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[_$a]?.map(r=>{let{header:n,...i}=r;return(i.optional!=null&&!i.optional||kjr(i,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(n)),[n,new $Y({input:i,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:n})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return grt(this.globalHeaders,this.requiredProperties)?.flat()}};function QHa(e,t){if(Mp(e)){let r=zS(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var fQr=class extends qo{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.webhooks=Object.entries(this.input??{}).map(([i,o])=>{let s=QHa(o,this.context.document);if(s!=null)return new vrt({input:s,context:this.context,accessPath:this.accessPath,pathId:i,servers:t,globalAuth:r,basePath:n,isWebhook:!0})}).filter(Yo)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(n=>{cQr(n)&&(t[Ea.WebhookId(n.id)]=n)}),t),{})}};var dQr=class extends qo{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=b_e(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new hrt({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new Njr({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 lQr({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 fQr({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 nQr({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new pQr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=yC(),{webhookEndpoints:r,endpoints:n}=this.paths?.convert()??{},i={...this.webhooks?.convert()??{},...r??{}},o=E$a({endpoints:n,webhookEndpoints:i}),{types:s,auths:a}=this.components?.convert()??{};return{id:Ea.ApiDefinitionId(t),endpoints:n??{},websockets:{},webhooks:i,types:{...s,...this.context.generatedTypes},subpackages:o,auths:{...a,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};xi();async function G6i(e,t){if(e instanceof IO){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Kp))return;let r=new v9(e.absoluteFilePath),n=await oU({context:t,specs:e.specs}),i=await r.loadDocuments({context:t,specs:n,loadAiExamples:!0}),o;for(let s of i){if(s.type!=="openapi")continue;let a={document:s.value,logger:t.logger,errors:new gjr,generatedTypes:{}},u=new dQr({input:s.value,context:a,accessPath:[],pathId:e.workspaceName??"openapi parser"});o=q7e(o,u.convert())}return o}dg();Wt();var Hsu=Ce(H6i(),1),Ksu=Ce(ZQr(),1),Q2r=require("fs/promises"),Jsu=Ce(require("http"),1),Ysu=Ce(require("path"),1);var FZa=require("events"),iNr=Ce(require("fs"),1),rLe=Ce(require("path"),1);var gZa=Ce(require("os"),1),AZa=300,R_e=20,_Nt=1e7,yZa=gZa.default.platform();var Ofd=yZa==="darwin",dqi=yZa==="win32",F_e=Ofd||dqi,bZa=3e3,vZa=2e4,mqi=1250;var YY;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(YY||(YY={}));var tLe;(function(e){e.CHANGE="change",e.RENAME="rename"})(tLe||(tLe={}));var xNt;(function(e){e.CHANGE="change",e.ERROR="error"})(xNt||(xNt={}));var cu;(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"})(cu||(cu={}));var CT;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(CT||(CT={}));var Bfd=(e,t=1,r)=>{t=Math.max(1,t);let n=r?.leading??!1,i=r?.trailing??!0,o=Math.max(r?.maxWait??1/0,t),s,a,u=0,c=0,l=()=>{let b=Date.now(),I=b-u,w=b-c,_=I>=t||w>=o;return[b,_]},p=b=>{if(c=b,!s)return;let I=s;s=void 0,e.apply(void 0,I)},d=()=>{v(0)},f=()=>{a&&(d(),p(Date.now()))},m=b=>{if(c=b,n)return p(b)},h=b=>{if(i&&s)return p(b);s=void 0},A=()=>{a=void 0;let[b,I]=l();return I?h(b):y(b)},y=b=>{let I=b-u,w=b-c,_=t-I,C=o-w,x=Math.min(_,C);return v(x)},v=b=>{a&&clearTimeout(a),!(b<=0)&&(a=setTimeout(A,b))},E=(...b)=>{let[I,w]=l(),_=!!a;if(s=b,u=I,(w||!a)&&v(t),w)return _?p(I):m(I)};return E.cancel=d,E.flush=f,E},eNr=Bfd;var yqi=Ce(require("fs"),1),rNr=Ce(require("path"),1);var jf=Ce(require("fs"),1),VS=require("util");var Kge=(e,t)=>function(...n){return e.apply(void 0,n).catch(t)},XY=(e,t)=>function(...n){try{return e.apply(void 0,n)}catch(i){return t(i)}};var hqi=Ce(require("process"),1),EZa=hqi.default.getuid?!hqi.default.getuid():!1,IZa=1e4,gj=()=>{};var SNt={isChangeErrorOk:e=>{if(!SNt.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!EZa&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!SNt.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(!SNt.isNodeError(e))throw e;if(!SNt.isChangeErrorOk(e))throw e}},qv=SNt;var gqi=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=IZa,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(n),n=()=>t(r);this.add(n)}),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()}}}}},wZa=new gqi;var Jge=(e,t)=>function(n){return function i(...o){return wZa.schedule().then(s=>{let a=c=>(s(),c),u=c=>{if(s(),Date.now()>=n)throw c;if(t(c)){let l=Math.round(100*Math.random());return new Promise(d=>setTimeout(d,l)).then(()=>i.apply(void 0,o))}throw c};return e.apply(void 0,o).then(a,u)})}},Yge=(e,t)=>function(n){return function i(...o){try{return e.apply(void 0,o)}catch(s){if(Date.now()>n)throw s;if(t(s))return i.apply(void 0,o);throw s}}};var Pfd={attempt:{chmod:Kge((0,VS.promisify)(jf.default.chmod),qv.onChangeError),chown:Kge((0,VS.promisify)(jf.default.chown),qv.onChangeError),close:Kge((0,VS.promisify)(jf.default.close),gj),fsync:Kge((0,VS.promisify)(jf.default.fsync),gj),mkdir:Kge((0,VS.promisify)(jf.default.mkdir),gj),realpath:Kge((0,VS.promisify)(jf.default.realpath),gj),stat:Kge((0,VS.promisify)(jf.default.stat),gj),unlink:Kge((0,VS.promisify)(jf.default.unlink),gj),chmodSync:XY(jf.default.chmodSync,qv.onChangeError),chownSync:XY(jf.default.chownSync,qv.onChangeError),closeSync:XY(jf.default.closeSync,gj),existsSync:XY(jf.default.existsSync,gj),fsyncSync:XY(jf.default.fsync,gj),mkdirSync:XY(jf.default.mkdirSync,gj),realpathSync:XY(jf.default.realpathSync,gj),statSync:XY(jf.default.statSync,gj),unlinkSync:XY(jf.default.unlinkSync,gj)},retry:{close:Jge((0,VS.promisify)(jf.default.close),qv.isRetriableError),fsync:Jge((0,VS.promisify)(jf.default.fsync),qv.isRetriableError),open:Jge((0,VS.promisify)(jf.default.open),qv.isRetriableError),readFile:Jge((0,VS.promisify)(jf.default.readFile),qv.isRetriableError),rename:Jge((0,VS.promisify)(jf.default.rename),qv.isRetriableError),stat:Jge((0,VS.promisify)(jf.default.stat),qv.isRetriableError),write:Jge((0,VS.promisify)(jf.default.write),qv.isRetriableError),writeFile:Jge((0,VS.promisify)(jf.default.writeFile),qv.isRetriableError),closeSync:Yge(jf.default.closeSync,qv.isRetriableError),fsyncSync:Yge(jf.default.fsyncSync,qv.isRetriableError),openSync:Yge(jf.default.openSync,qv.isRetriableError),readFileSync:Yge(jf.default.readFileSync,qv.isRetriableError),renameSync:Yge(jf.default.renameSync,qv.isRetriableError),statSync:Yge(jf.default.statSync,qv.isRetriableError),writeSync:Yge(jf.default.writeSync,qv.isRetriableError),writeFileSync:Yge(jf.default.writeFileSync,qv.isRetriableError)}},CZa=Pfd;var tNr=Ce(require("fs"),1),ONt=Ce(require("path"),1);var Aqi=()=>{};var Tfd=()=>{let e=Aqi,t=Aqi,r=!1,n=!1;return{promise:new Promise((u,c)=>{e=l=>(r=!0,u(l)),t=l=>(n=!0,c(l))}),resolve:e,reject:t,isPending:()=>!r&&!n,isResolved:()=>r,isRejected:()=>n}},_Za=Tfd;var Dfd=()=>{let{promise:e,resolve:t,isPending:r}=_Za(),n=0,i=()=>{n+=1},o=()=>{n-=1,!n&&t()};return i(),queueMicrotask(o),{promise:e,isPending:r,increment:i,decrement:o}},xZa=Dfd;var SZa={then:e=>{e()}};var OZa=e=>Array.isArray(e)?e:[e],BZa=e=>typeof e=="function";var Rfd=(e,t)=>{let r=t?.followSymlinks??!1,n=t?.depth??1/0,i=t?.limit??1/0,o=t?.ignore??[],s=OZa(o).map(H=>BZa(H)?H:J=>H.test(J)),a=H=>s.some(J=>J(H)),u=t?.signal??{aborted:!1},c=t?.onDirents||(()=>{}),l=[],p=new Set,d={},f=[],m=new Set,h={},A=[],y=new Set,v={},E={},b=new Set,I={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},w={directories:l,directoriesNames:p,directoriesNamesToPaths:d,files:f,filesNames:m,filesNamesToPaths:h,symlinks:A,symlinksNames:y,symlinksNamesToPaths:v,map:E},{promise:_,increment:C,decrement:x}=xZa(),R=0,z=(H,J,Ae,ge)=>{b.has(J)||R>=i||(R+=1,H.directories.push(J),H.directoriesNames.add(Ae),l.push(J),p.add(Ae),d.propertyIsEnumerable(Ae)||(d[Ae]=[]),d[Ae].push(J),b.add(J),!(ge>=n)&&(R>=i||K(J,ge+1)))},U=(H,J,Ae)=>{b.has(J)||R>=i||(R+=1,H.files.push(J),H.filesNames.add(Ae),f.push(J),m.add(Ae),h.propertyIsEnumerable(Ae)||(h[Ae]=[]),h[Ae].push(J),b.add(J))},q=(H,J,Ae,ge)=>{b.has(J)||R>=i||(R+=1,H.symlinks.push(J),H.symlinksNames.add(Ae),A.push(J),y.add(Ae),v.propertyIsEnumerable(Ae)||(v[Ae]=[]),v[Ae].push(J),b.add(J),r&&(ge>=n||R>=i||Ee(J,ge+1)))},te=(H,J,Ae,ge,we)=>{u.aborted||a(J)||(ge.isDirectory()?z(H,J,Ae,we):ge.isFile()?U(H,J,Ae):ge.isSymbolicLink()&&q(H,J,Ae,we))},ie=(H,J,Ae,ge)=>{if(u.aborted)return;let we=J===ONt.default.sep?"":ONt.default.sep,_e=Ae.name,pe=`${J}${we}${_e}`;a(pe)||(Ae.isDirectory()?z(H,pe,_e,ge):Ae.isFile()?U(H,pe,_e):Ae.isSymbolicLink()&&q(H,pe,_e,ge))},V=(H,J,Ae,ge)=>{for(let we=0,_e=Ae.length;we<_e;we++)ie(H,J,Ae[we],ge)},K=(H,J)=>{u.aborted||J>n||R>=i||(C(),tNr.default.readdir(H,{withFileTypes:!0},(Ae,ge)=>{if(Ae||u.aborted||!ge.length)return x();(c(ge)||SZa).then(()=>{let _e=E[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};V(_e,H,ge,J),x()})}))},Ee=(H,J)=>{C(),tNr.default.realpath(H,(Ae,ge)=>{if(Ae||u.aborted)return x();tNr.default.stat(ge,(we,_e)=>{if(we||u.aborted)return x();let pe=ONt.default.basename(ge),le=E[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};te(le,ge,pe,_e,J),x()})})};return(async(H,J=1)=>(H=ONt.default.normalize(H),b.add(H),K(H,J),await _,u.aborted?I:w))(e)},PZa=Rfd;var ZY={lang:{debounce:eNr,attempt:e=>{try{return e()}catch(t){return ZY.lang.castError(t)}},castArray:e=>ZY.lang.isArray(e)?e:[e],castError:e=>ZY.lang.isError(e)?e:ZY.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(ZY.lang.isNaN(e))return ZY.lang.isNaN(t);if(ZY.lang.isPrimitive(e)||ZY.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(rNr.default.sep).length-1),getRealPath:(e,t)=>{try{return t?yqi.default.realpathSync.native(e):yqi.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===rNr.default.sep&&t.length-e.length>rNr.default.sep.length,poll:(e,t=vZa)=>CZa.retry.stat(t)(e,{bigint:!0}).catch(ZY.lang.noop),readdir:async(e,t,r=1/0,n=1/0,i,o)=>{if(o&&r===1&&e in o){let s=o[e];return[s.directories,s.files]}else{let s=await PZa(e,{depth:r,limit:n,ignore:t,signal:i});return[s.directories,s.files]}}}},yl=ZY;var nNr=Ce(require("path"),1);var bqi=class{constructor(t,r,n){this.base=n,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||yl.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=AZa){return(()=>{let r=this.watcher._readyWait,n=[],i=new Set,o=async(a,u)=>{let c=this.options.ignoreInitial?[]:a,l=await this.eventsPopulate([...u]),p=this.eventsDeduplicate([...c,...l]);this.onTargetEvents(p)},s=yl.lang.debounce(()=>{this.watcher.isClosed()||(r=o(n,i),n=[],i=new Set)},t);return async(a,u="",c=!1)=>{c?await this.eventsPopulate([u],n,!0):i.add(u),r.then(s)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((n,i)=>{let[o,s]=i,a=r[s];return o===a||o===cu.CHANGE&&a===cu.ADD||(r[s]=o,n.push(i)),n},[])}async eventsPopulate(t,r=[],n=!1){return await Promise.all(t.map(async i=>{let o=await this.watcher._poller.update(i,this.options.pollingTimeout);await Promise.all(o.map(async s=>{r.push([s,i]),s===cu.ADD_DIR?await this.eventsPopulateAddDir(t,i,r,n):s===cu.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,i,r,n)}))})),r}async eventsPopulateAddDir(t,r,n=[],i=!1){if(i)return n;let o=this.options.recursive?this.options.depth??R_e:Math.min(1,this.options.depth??R_e),s=this.options.limit??_Nt,[a,u]=await yl.fs.readdir(r,this.options.ignore,o,s,this.watcher._closeSignal),c=[...a,...u];return await Promise.all(c.map(l=>{if(!this.watcher.isIgnored(l,this.options.ignore)&&!t.includes(l))return this.eventsPopulate([l],n,!0)})),n}async eventsPopulateUnlinkDir(t,r,n=[],i=!1){if(i)return n;for(let o of this.watcher._poller.stats.keys())yl.fs.isSubPath(r,o)&&(t.includes(o)||await this.eventsPopulate([o],n,!0));return n}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(cu.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!F_e&&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(cu.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(cu.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(nNr.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(cu.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(nNr.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(cu.UNLINK_DIR,t))}onTargetEvent(t){let[r,n]=t;r===cu.ADD?this.onTargetAdd(n):r===cu.ADD_DIR?this.onTargetAddDir(n):r===cu.CHANGE?this.onTargetChange(n):r===cu.UNLINK?this.onTargetUnlink(n):r===cu.UNLINK_DIR&&this.onTargetUnlinkDir(n)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,n=!1){return this.handlerBatched(t,r,n)}onWatcherChange(t=tLe.CHANGE,r){if(this.watcher.isClosed())return;let n=nNr.default.resolve(this.folderPath,r||"");this.filePath&&n!==this.folderPath&&n!==this.filePath||this.watcher.isIgnored(n,this.options.ignore)||this.onWatcherEvent(t,n)}onWatcherError(t){dqi&&t.code==="EPERM"?this.onWatcherChange(tLe.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(xNt.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(xNt.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(tLe.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&F_e&&this.options.native!==!1?this.options.depth??R_e:Math.min(1,this.options.depth??R_e),n=this.options.limit??_Nt,[i,o]=await yl.fs.readdir(this.folderPath,this.options.ignore,r,n,this.watcher._closeSignal,this.options.readdirMap),s=[this.folderPath,...i,...o];await Promise.all(s.map(a=>{if(!this.watcher._poller.stats.has(a)&&!this.watcher.isIgnored(a,this.options.ignore))return this.onWatcherEvent(tLe.CHANGE,a,t)}))}}},TZa=bqi;var _T={interval:100,intervalId:void 0,fns:new Map,init:()=>{_T.intervalId||(_T.intervalId=setInterval(_T.resolve,_T.interval))},reset:()=>{_T.intervalId&&(clearInterval(_T.intervalId),delete _T.intervalId)},add:(e,t)=>{_T.fns.set(e,Date.now()+t),_T.init()},remove:e=>{_T.fns.delete(e)},resolve:()=>{if(!_T.fns.size)return _T.reset();let e=Date.now();for(let[t,r]of _T.fns)r>=e||(_T.remove(t),t())}},BNt=_T;var PNt=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=mqi){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{let p=this._watcher._poller.paths.find(n||-1,d=>d!==i);if(p&&p!==i){if(yl.fs.getRealPath(i,!0)===p)return;this._watcher.event(o.rename,p,i)}else this._watcher.event(o.add,i)};if(!n)return a();let u=()=>{s.add.delete(n),BNt.remove(c)},c=()=>{u(),a()};BNt.add(c,r);let l=()=>{let p=s.unlink.get(n);if(!p)return;u();let d=p();i===d?o.change&&this._watcher._poller.stats.has(i)&&this._watcher.event(o.change,i):this._watcher.event(o.rename,d,i)};s.add.set(n,l),l()}getLockUnlink(t,r=mqi){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{this._watcher.event(o.unlink,i)};if(!n)return a();let u=()=>{s.unlink.delete(n),BNt.remove(c)},c=()=>{u(),a()};BNt.add(c,r);let l=()=>(u(),i);s.unlink.set(n,l),s.add.get(n)?.()}getLockTargetAdd(t,r){let n=this._watcher._poller.getIno(t,cu.ADD,YY.FILE);return this.getLockAdd({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let n=this._watcher._poller.getIno(t,cu.ADD_DIR,YY.DIR);return this.getLockAdd({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let n=this._watcher._poller.getIno(t,cu.UNLINK,YY.FILE);return this.getLockUnlink({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let n=this._watcher._poller.getIno(t,cu.UNLINK_DIR,YY.DIR);return this.getLockUnlink({ino:n,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}}};PNt.DIR_EVENTS={add:cu.ADD_DIR,rename:cu.RENAME_DIR,unlink:cu.UNLINK_DIR};PNt.FILE_EVENTS={add:cu.ADD,change:cu.CHANGE,rename:cu.RENAME,unlink:cu.UNLINK};var DZa=PNt;var vqi=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(yl.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let n=this.map.get(t);if(yl.lang.isSet(n)){let i=n.delete(r);return n.size||this.map.delete(t),i}else if(n===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let n=this.map.get(t);if(yl.lang.isSet(n))return Array.from(n).find(r);if(r(n))return n}}get(t){return this.map.get(t)}has(t,r){if(yl.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let n=this.map.get(t);return yl.lang.isSet(n)?n.has(r):n===r}return!1}set(t,r){if(this.map.has(t)){let n=this.map.get(t);yl.lang.isSet(n)?n.add(r):n!==r&&this.map.set(t,new Set([n,r]))}else this.map.set(t,r);return this}},Eqi=vqi;var Iqi=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}},RZa=Iqi;var wqi=class{constructor(){this.inos={},this.paths=new Eqi,this.stats=new Map}getIno(t,r,n){let i=this.inos[r];if(!i)return;let o=i[t];if(o&&!(n&&o[1]!==n))return o[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let n=await yl.fs.poll(t,r);if(!(!n||!(n.isFile()||n.isDirectory())))return new RZa(n)}reset(){this.inos={},this.paths=new Eqi,this.stats=new Map}async update(t,r){let n=this.getStats(t),i=await this.poll(t,r);if(this.updateStats(t,i),!n&&i){if(i.isFile())return this.updateIno(t,cu.ADD,i),[cu.ADD];if(i.isDirectory())return this.updateIno(t,cu.ADD_DIR,i),[cu.ADD_DIR]}else if(n&&!i){if(n.isFile())return this.updateIno(t,cu.UNLINK,n),[cu.UNLINK];if(n.isDirectory())return this.updateIno(t,cu.UNLINK_DIR,n),[cu.UNLINK_DIR]}else if(n&&i){if(n.isFile()){if(i.isFile())return n.ino===i.ino&&!n.size&&!i.size?[]:(this.updateIno(t,cu.CHANGE,i),[cu.CHANGE]);if(i.isDirectory())return this.updateIno(t,cu.UNLINK,n),this.updateIno(t,cu.ADD_DIR,i),[cu.UNLINK,cu.ADD_DIR]}else if(n.isDirectory()){if(i.isFile())return this.updateIno(t,cu.UNLINK_DIR,n),this.updateIno(t,cu.ADD,i),[cu.UNLINK_DIR,cu.ADD];if(i.isDirectory())return n.ino===i.ino?[]:(this.updateIno(t,cu.UNLINK_DIR,n),this.updateIno(t,cu.ADD_DIR,i),[cu.UNLINK_DIR,cu.ADD_DIR])}}return[]}updateIno(t,r,n){let i=this.inos[r]=this.inos[r]||(this.inos[r]={}),o=n.isFile()?YY.FILE:YY.DIR;i[t]=[n.ino,o]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let n=this.stats.get(t)?.ino||-1;this.paths.delete(n,t),this.stats.delete(t)}}},Cqi=wqi;var _qi=class e extends FZa.EventEmitter{constructor(t,r,n){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(CT.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(i=>this.on(CT.CLOSE,i)),this._readyWait=new Promise(i=>this.on(CT.READY,i)),this._locker=new DZa(this),this._roots=new Set,this._poller=new Cqi,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,n)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(yl.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(CT.CLOSE))}error(t){if(this.isClosed())return!1;let r=yl.lang.castError(t);return this.emit(CT.ERROR,r)}event(t,r,n){return this.isClosed()?!1:(this.emit(CT.ALL,t,r,n),this.emit(t,r,n))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(CT.READY))}pollerExists(t,r){for(let n of this._pollers)if(n.targetPath===t&&yl.lang.isShallowEqual(n.options,r))return!0;return!1}subwatcherExists(t,r){for(let n of this._subwatchers)if(n.targetPath===t&&yl.lang.isShallowEqual(n.options,r))return!0;return!1}watchersClose(t,r,n=!0){if(t){let i=this._watchers[t];if(i)for(let o of[...i])r&&o.filePath!==r||this.watcherClose(o);if(n)for(let o in this._watchers)yl.fs.isSubPath(t,o)&&this.watchersClose(o,r,!1)}else for(let i in this._watchers)this.watchersClose(i,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,n]of t)this.watchPath(r,n.options,n.handler)}async watcherAdd(t,r){let{folderPath:n}=t;(this._watchers[n]=this._watchers[n]||[]).push(t);let o=new TZa(this,t,r);return await o.init(),o}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let o=r.indexOf(t);r.splice(o,1),r.length||delete this._watchers[t.folderPath]}let n=t.filePath||t.folderPath;this._roots.has(n)&&(this._watchersRestorable[n]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=yl.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,n,i){if(this._watchers[t]?.find(a=>a.handler===n&&(!a.filePath||a.filePath===i)&&a.options.ignore===r.ignore&&!!a.options.native==!!r.native&&(!r.recursive||a.options.recursive)))return!0;let s=rLe.default.dirname(t);for(let a=1;a<1/0;a++){if(this._watchers[s]?.find(l=>(a===1||l.options.recursive&&a<=(l.options.depth??R_e))&&l.handler===n&&(!l.filePath||l.filePath===i)&&l.options.ignore===r.ignore&&!!l.options.native==!!r.native&&(!r.recursive||l.options.recursive&&F_e&&l.options.native!==!1)))return!0;if(!F_e)break;let c=rLe.default.dirname(t);if(s===c)break;s=c}return!1}async watchDirectories(t,r,n,i,o){if(this.isClosed())return;t=yl.lang.uniq(t).sort();let s;for(let a of t)if(!this.isIgnored(a,r.ignore)&&!this.watcherExists(a,r,n,i))try{let u=!r.recursive||F_e&&r.native!==!1?r:{...r,recursive:!1},l={watcher:iNr.default.watch(a,u),handler:n,options:r,folderPath:a,filePath:i},p=s=await this.watcherAdd(l,o);if(this._roots.has(i||a)){let f={...r,ignoreInitial:!0,recursive:!1},m=rLe.default.dirname(a),h=a;await this.watchDirectories([m],f,n,h,p)}}catch(u){this.error(u)}return s}async watchDirectory(t,r,n,i,o){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||F_e&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,n,i,o));{r={...r,recursive:!0};let s=r.depth??R_e,a=r.limit??_Nt,[u]=await yl.fs.readdir(t,r.ignore,s,a,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let c=await this.watchDirectories([t],r,n,i,o);if(u.length){let l=yl.fs.getDepth(t);for(let p of u){let d=yl.fs.getDepth(p),f=Math.max(0,s-(d-l)),m={...r,depth:f};await this.watchDirectories([p],m,n,i,o||c)}}})}}}async watchFileOnce(t,r,n){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let i={targetPath:t,options:r},o=(c,l)=>{l===t&&(u(),n())},s=new e(o),a=()=>{this._subwatchers.add(i),this.on(CT.CLOSE,u),s.watchFile(t,r,o)},u=()=>{this._subwatchers.delete(i),this.removeListener(CT.CLOSE,u),s.close()};return a()}async watchFile(t,r,n){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let i=rLe.default.dirname(t);return this.watchDirectory(i,r,n,t)}async watchPollingOnce(t,r,n){if(this.isClosed())return;let i=!1,o=new Cqi,s=await this.watchPolling(t,r,async()=>{i||!(await o.update(t,r.pollingTimeout)).length||i||(i=!0,s(),n())})}async watchPolling(t,r,n){if(this.isClosed())return yl.lang.noop;if(this.pollerExists(t,r))return yl.lang.noop;let i={...r,interval:r.pollingInterval??bZa},o={targetPath:t,options:r},s=()=>{this._pollers.add(o),this.on(CT.CLOSE,a),iNr.default.watchFile(t,i,n)},a=()=>{this._pollers.delete(o),this.removeListener(CT.CLOSE,a),iNr.default.unwatchFile(t,n)};return yl.lang.attempt(s),()=>yl.lang.attempt(a)}async watchUnknownChild(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchFileOnce(t,r,i)}async watchUnknownTarget(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchPollingOnce(t,r,i)}async watchPaths(t,r,n){if(this.isClosed())return;if(t=yl.lang.uniq(t).sort(),t.every((o,s)=>t.every((a,u)=>u===s||!yl.fs.isSubPath(o,a))))await Promise.all(t.map(o=>this.watchPath(o,r,n)));else for(let o of t)await this.watchPath(o,r,n)}async watchPath(t,r,n){if(this.isClosed()||(t=rLe.default.resolve(t),this.isIgnored(t,r.ignore)))return;let i=await yl.fs.poll(t,r.pollingTimeout);if(i){if(i.isFile())return this.watchFile(t,r,n);if(i.isDirectory())return this.watchDirectory(t,r,n);this.error(`"${t}" is not supported`)}else{let o=rLe.default.dirname(t);return(await yl.fs.poll(o,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,n):this.watchUnknownTarget(t,r,n)}}async watch(t,r,n=yl.lang.noop){if(yl.lang.isFunction(t))return this.watch([],{},t);if(yl.lang.isUndefined(t))return this.watch([],r,n);if(yl.lang.isFunction(r))return this.watch(t,{},r);if(yl.lang.isUndefined(r))return this.watch(t,{},n);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let i=yl.lang.castArray(t);i.forEach(o=>this._roots.add(o)),await this.watchPaths(i,r,n),!this.isClosed()&&(n!==yl.lang.noop&&this.on(CT.ALL,n),r.readdirMap=void 0,this.ready())}},oNr=_qi;bNr();Wt();var qrt=require("fs/promises"),Leu=require("os"),Ueu=Ce(require("path"),1),rmd=".fern",nmd="logs";function imd(){return"cli@4.0.0"}var uLe=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=We(Vt.of((0,Leu.homedir)()),Se.of(rmd)),r=We(t,Se.of(nmd));await nr(r)||await(0,qrt.mkdir)(r,{recursive:!0});let i=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=We(r,Se.of(i));let o=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${Ueu.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
2128
|
+
`);try{return Tr.load(o)??[]}catch(s){return this.taskContext.logger.warn(`Failed to parse _navigation.yml for library '${t}': ${s instanceof Error?s.message:String(s)}`),null}}async registerLibraryMdxPage(t,r){let n=We(t,Se.of(r));if(!(0,r6i.existsSync)(n)){this.taskContext.logger.warn(`Library MDX file not found: ${n}`);return}let i=Ra(this.docsWorkspace.absoluteFilePath,n),o=await(0,y_e.readFile)(n,"utf-8");return this.parsedDocsConfig.pages[i]=o,_t.PageId(i)}async convertLibraryNavNodes(t,r,n){let i=[];for(let o of t)if(o.type==="page"&&o.pageId!=null){let s=await this.registerLibraryMdxPage(r,o.pageId);if(s==null)continue;let a=n.apply({fullSlug:o.slug.split("/"),urlSlug:pm(o.title)});i.push({id:this.#e.get(s),type:"page",slug:a.get(),title:o.title,icon:void 0,hidden:!1,viewers:void 0,orphaned:void 0,pageId:s,authed:void 0,noindex:void 0,featureFlags:void 0,availability:void 0})}else if(o.type==="section"){let s=n.apply({fullSlug:o.slug.split("/"),urlSlug:pm(o.title)}),a=this.#e.get(`library-section/${o.slug}`),u=await this.registerLibraryMdxPage(r,`${o.slug}.mdx`),c=(o.children??[]).filter(p=>!(p.type==="page"&&p.slug===o.slug)),l=await this.convertLibraryNavNodes(c,r,s);i.push({id:a,type:"section",overviewPageId:u,slug:s.get(),title:o.title,icon:void 0,collapsed:void 0,hidden:!1,viewers:void 0,orphaned:void 0,children:l,authed:void 0,pointsTo:void 0,noindex:void 0,featureFlags:void 0,availability:void 0})}return i}async toPageNode({item:t,parentSlug:r,hideChildren:n,parentAvailability:i}){let o=_t.PageId(this.toRelativeFilepath(t.absolutePath)),s=r.apply({urlSlug:t.slug??pm(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")}),a=this.#e.get(o),u=this.markdownFilesToAvailability.get(t.absolutePath);return{id:a,type:"page",slug:s.get(),title:this.markdownFilesToSidebarTitle.get(t.absolutePath)??t.title,icon:this.resolveIconFileId(t.icon),hidden:n||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:o,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:u??t.availability??i}}async toSectionNode({prefix:t,item:r,parentSlug:n,hideChildren:i,parentAvailability:o}){let s=this.toRelativeFilepath(r.overviewAbsolutePath),a=s?_t.PageId(s):void 0,u=this.#e.get(a??`${t}/section`),c=n.apply({urlSlug:r.slug??pm(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),l=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,p=r.overviewAbsolutePath!=null?this.markdownFilesToAvailability.get(r.overviewAbsolutePath):void 0,d=i||r.hidden,m=(await Promise.all(r.contents.map(h=>this.toNavigationChild({prefix:u,item:h,parentSlug:c,hideChildren:d,parentAvailability:r.availability??o})))).filter(h=>h!=null);if(a==null){let h=m.find(A=>A.type==="apiReference"&&A.hideTitle===!0&&A.overviewPageId!=null);h!=null&&(a=h.overviewPageId)}return{id:u,type:"section",overviewPageId:a,slug:c.get(),title:r.overviewAbsolutePath!=null?this.markdownFilesToSidebarTitle.get(r.overviewAbsolutePath)??r.title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,collapsible:r.collapsible??(r.collapsed===!0?!0:void 0),collapsedByDefault:r.collapsedByDefault??(r.collapsed===!0?!0:void 0),hidden:d,viewers:r.viewers,orphaned:r.orphaned,children:m,authed:void 0,pointsTo:void 0,noindex:l,featureFlags:r.featureFlags,availability:p??r.availability??o}}async convertTabbedNavigation(t,r,n){let i=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:i,children:await Promise.all(r.map(o=>this.toTabChild(i,o,n)))}}async toTabChild(t,r,n){return kE(r.child)._visit({link:({href:i,target:o})=>this.toTabLinkNode(r,i,o),layout:({layout:i})=>this.toTabNode(t,r,i,n),changelog:({changelog:i})=>this.toTabChangelogNode(r,i,n),variants:({variants:i})=>this.toTabNodeWithVariants(t,r,i,n)})}async toTabChangelogNode(t,r,n){return new V4e(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:n,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r,n){return{type:"link",id:this.#e.get(r),title:t.title,url:_t.V1.Url(r),target:n,icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,n,i){let o=this.#e.get(`${t}/tab`),s=i.apply({urlSlug:r.slug??pm(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:o,title:r.title,slug:s.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(o,n,s),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,n,i){let o=this.#e.get(`${t}/tab`),s=i.apply({urlSlug:r.slug??pm(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:o,title:r.title,slug:s.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(o,n,s),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):mP.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:n}=this.parsedDocsConfig,i=r?.[t],o=n?.[t];return{logo:this.getFileId(i),backgroundImage:this.getFileId(o)}}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 n=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${n}`,variants:t.variants.map(i=>({fontFile:this.getFileId(i.absolutePath),weight:i.weight,style:i.style!=null?[i.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(Ca),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:mP.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":n,...i}=this.parsedDocsConfig.metadata;return{...i,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(n)}}convertFileIdOrUrl(t){if(t!=null)return kE(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:mP.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}resolveLinksInIrDocs(t,r){let n={absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absolutePathToMarkdownFile:this.docsWorkspace.absoluteFilePath};djr(t,r,n)}};function Mid(e,t){let r=e?.launch??"github";if(e?.github==null)return{url:void 0,launch:r};let{owner:n,repo:i,branch:o="main",host:s="https://github.com"}=e.github;return{url:`${ET(s)}/${n}/${i}/blob/${o}/fern/${t}?plain=1`,launch:r}}function Lid(e){switch(e){case"beta":return _t.V1.NavigationV1Availability.Beta;case"deprecated":return _t.V1.NavigationV1Availability.Deprecated;case"ga":return _t.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return _t.V1.NavigationV1Availability.Stable;default:xe(e)}}Nt();async function US(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof Kp?t:null))).filter(Ca)}async function n6i(e,t,r){if(e instanceof IO){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Kp))return;let n=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1,logWarnings:!1});return vT({ir:n,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 Ea={};X(Ea,{AlgoliaSearchIndex:()=>sWa,ApiDefinitionId:()=>SWa,ApiId:()=>TWa,Availability:()=>WWa,DocsConfigId:()=>DWa,EndpointId:()=>FWa,EndpointPathLiteral:()=>qWa,EnvironmentId:()=>RWa,FileId:()=>MWa,HttpMethod:()=>GWa,IndexSegmentId:()=>aWa,JqString:()=>UWa,OrgId:()=>BWa,PageId:()=>kWa,PayloadLocation:()=>b$a,PropertyKey:()=>zWa,PullRequestState:()=>m$a,RoleId:()=>VWa,TokenId:()=>PWa,TypeId:()=>NWa,Url:()=>LWa,VersionId:()=>OWa,WebSocketId:()=>jWa,WebhookId:()=>QWa,algolia:()=>i6i,api:()=>m6i,commons:()=>h6i,diff:()=>$Wa,docs:()=>C6i,generators:()=>x6i,git:()=>S6i,navigation:()=>P6i,sdks:()=>D6i,snippets:()=>A$a,snippetsFactory:()=>y$a,templates:()=>R6i,tokens:()=>v$a});var i6i={};X(i6i,{AlgoliaSearchIndex:()=>sWa,IndexSegmentId:()=>aWa});function sWa(e){return e}function aWa(e){return e}var m6i={};X(m6i,{latest:()=>a6i,v1:()=>d6i});var a6i={};X(a6i,{AuthSchemeId:()=>uWa,WebhookHttpMethod:()=>fWa,auth:()=>o6i,commons:()=>cWa,endpoint:()=>lWa,type_:()=>pWa,webhook:()=>s6i,websocket:()=>dWa});var o6i={};X(o6i,{AuthSchemeId:()=>uWa});function uWa(e){return e}var cWa={};var lWa={};var pWa={};var s6i={};X(s6i,{WebhookHttpMethod:()=>fWa});var fWa={Get:"GET",Post:"POST"};var dWa={};var d6i={};X(d6i,{SubpackageId:()=>wWa,WebSocketMessageId:()=>CWa,WebSocketMessageOrigin:()=>_Wa,WebhookHttpMethod:()=>xWa,commons:()=>f6i,db:()=>u6i,read:()=>l6i,register:()=>p6i});var u6i={};X(u6i,{endpoint:()=>mWa});var mWa={};var l6i={};X(l6i,{SupportedLanguage:()=>hWa,endpoint:()=>c6i,type_:()=>gWa,webhook:()=>AWa,websocket:()=>yWa});var c6i={};X(c6i,{SupportedLanguage:()=>hWa});var hWa={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var gWa={};var AWa={};var yWa={};var p6i={};X(p6i,{SourceId:()=>Uid,endpoint:()=>bWa,type_:()=>vWa,webhook:()=>EWa,websocket:()=>IWa});var bWa={};var vWa={};var EWa={};var IWa={};function Uid(e){return e}var f6i={};X(f6i,{SubpackageId:()=>wWa,WebSocketMessageId:()=>CWa,WebSocketMessageOrigin:()=>_Wa,WebhookHttpMethod:()=>xWa});function wWa(e){return e}function CWa(e){return e}var _Wa={Client:"client",Server:"server"};var xWa={Get:"GET",Post:"POST"};var h6i={};X(h6i,{ApiDefinitionId:()=>SWa,ApiId:()=>TWa,Availability:()=>WWa,DocsConfigId:()=>DWa,EndpointId:()=>FWa,EndpointPathLiteral:()=>qWa,EnvironmentId:()=>RWa,FileId:()=>MWa,HttpMethod:()=>GWa,JqString:()=>UWa,OrgId:()=>BWa,PageId:()=>kWa,PropertyKey:()=>zWa,RoleId:()=>VWa,TokenId:()=>PWa,TypeId:()=>NWa,Url:()=>LWa,VersionId:()=>OWa,WebSocketId:()=>jWa,WebhookId:()=>QWa});function SWa(e){return e}function OWa(e){return e}function BWa(e){return e}function PWa(e){return e}function TWa(e){return e}function DWa(e){return e}function RWa(e){return e}function FWa(e){return e}function jWa(e){return e}function QWa(e){return e}function NWa(e){return e}function kWa(e){return e}function MWa(e){return e}function LWa(e){return e}function UWa(e){return e}function zWa(e){return e}function VWa(e){return e}function qWa(e){return e}var GWa={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var WWa={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var $Wa={};var C6i={};X(C6i,{latest:()=>y6i,v1:()=>I6i,v2:()=>w6i});var y6i={};X(y6i,{Layout:()=>KWa,MdxEngine:()=>zid,TwitterCardSetting:()=>JWa,commons:()=>HWa,frontmatter:()=>g6i,seo:()=>A6i});var zid={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var HWa={};var g6i={};X(g6i,{Layout:()=>KWa});var KWa={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var A6i={};X(A6i,{TwitterCardSetting:()=>JWa});var JWa={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var I6i={};X(I6i,{commons:()=>E6i,db:()=>YWa,read:()=>XWa,write:()=>b6i});var YWa={};var XWa={};var b6i={};X(b6i,{DocsRegistrationId:()=>qid,FilePath:()=>Vid});function Vid(e){return e}function qid(e){return e}var E6i={};X(E6i,{ContentAlignment:()=>r$a,FontDisplay:()=>a$a,FontStyle:()=>s$a,HeaderPosition:()=>n$a,JsScriptStrategy:()=>o$a,ProgrammingLanguage:()=>ZWa,SearchbarPlacement:()=>e$a,TabsPlacement:()=>t$a,TwitterCardSetting:()=>i$a,commons:()=>v6i});var v6i={};X(v6i,{ContentAlignment:()=>r$a,FontDisplay:()=>a$a,FontStyle:()=>s$a,HeaderPosition:()=>n$a,JsScriptStrategy:()=>o$a,ProgrammingLanguage:()=>ZWa,SearchbarPlacement:()=>e$a,TabsPlacement:()=>t$a,TwitterCardSetting:()=>i$a});var ZWa={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 e$a={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var t$a={Header:"HEADER",Sidebar:"SIDEBAR"};var r$a={Center:"CENTER",Left:"LEFT"};var n$a={Fixed:"FIXED",Absolute:"ABSOLUTE"};var i$a={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var o$a={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var s$a={Normal:"normal",Italic:"italic"};var a$a={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var w6i={};X(w6i,{read:()=>u$a,write:()=>c$a});var u$a={};var c$a={};var x6i={};X(x6i,{ChangelogEntryType:()=>p$a,GeneratorId:()=>Gid,GeneratorLanguage:()=>Wid,ReleaseType:()=>f$a,cli:()=>l$a,commons:()=>_6i,versions:()=>d$a});var l$a={};var _6i={};X(_6i,{ChangelogEntryType:()=>p$a,ReleaseType:()=>f$a});var p$a={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var f$a={Ga:"GA",Rc:"RC"};var d$a={};function Gid(e){return e}var Wid={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var S6i={};X(S6i,{PullRequestState:()=>m$a});var m$a={Open:"open",Closed:"closed",Merged:"merged"};var P6i={};X(P6i,{latest:()=>O6i,v1:()=>B6i});var O6i={};X(O6i,{NodeId:()=>Kid,ProductId:()=>Jid,Slug:()=>$id,TabId:()=>Hid});function $id(e){return e}function Hid(e){return e}function Kid(e){return e}function Jid(e){return e}var B6i={};X(B6i,{NavigationV1Availability:()=>tod,NodeId:()=>Zid,ProductId:()=>eod,Slug:()=>Yid,TabId:()=>Xid});function Yid(e){return e}function Xid(e){return e}function Zid(e){return e}function eod(e){return e}var tod={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var D6i={};X(D6i,{Language:()=>h$a,VersionBump:()=>g$a,versions:()=>T6i});var T6i={};X(T6i,{Language:()=>h$a,VersionBump:()=>g$a});var h$a={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var g$a={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var A$a={};var y$a={};var R6i={};X(R6i,{PayloadLocation:()=>b$a});var b$a={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var v$a={};var gjr=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function E$a({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(n=>{let i=[];n.namespace?.forEach(o=>{let s=[...i,o],a=Ea.api.v1.SubpackageId(s.join("."));r[a]={id:a,name:o,displayName:LS(o)},i.push(o)})}),r}var Ajr=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 I$a(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var qo=class extends Ajr{context;accessPath;pathId;constructor({input:t,context:r,accessPath:n,pathId:i}){if(super(t,r),this.context=r,this.accessPath=[...n],this.pathId=i,i!=null){let o=Array.isArray(this.pathId)?this.pathId:[this.pathId];o.every((s,a)=>s===this.accessPath[this.accessPath.length-o.length+a])||this.accessPath.push(...o)}r.logger.debug(`Processing ${I$a(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})}}},zv=class extends qo{},fj=class extends zv{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var w$a="x-fern-base-path",C$a="x-fern-availability",yjr="x-fern-sdk-group-name",_$a="x-fern-global-headers",x$a="x-fern-sdk-method-name";var S$a="x-fern-webhook",O$a="x-fern-access-token-locator",B$a="x-fern-basic",P$a="x-fern-username-variable-name",T$a="x-fern-password-variable-name",D$a="x-fern-bearer",R$a="x-fern-token-variable-name",F$a="x-fern-header",j$a="x-fern-header-variable-name",Q$a="x-fern-server-name",N$a="x-fern-examples";var bjr=class extends qo{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[Q$a]}convert(){if(this.serverName!=null)return this.serverName}};var vjr=class extends qo{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,n])=>t.replace(`{${r}}`,n.default),this.input.url)??this.input.url,this.serverName=new bjr({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:Ea.EnvironmentId(t),baseUrl:this.url}}};function b_e(e,t,r,n){let i=e??[],o=new Set(i.map(a=>a.url)),s=(t??[]).filter(a=>!o.has(a.url)).map((a,u)=>new vjr({input:a,context:r,accessPath:n,pathId:["servers",`${u}`]}));return[...i,...s]}function Mp(e){return typeof e=="object"&&Yo(e)&&"$ref"in e&&typeof e.$ref=="string"}function zS(e,t,r){let n=e.$ref.substring(2).split("/").map(o=>o.replace(/~1/g,"/")),i=t;for(let o of n){if(typeof i!="object"||i==null)return r;i=i[o]}return i==null?r:(Mp(i)&&(i=zS(i,t,r)),i)}function Ejr(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return Mp(r)?zS(r,t,void 0):r}var nHa=Ce(Oy());var Ijr=class extends qo{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[B$a];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var wjr=class extends qo{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[T$a]}convert(){return this.passwordVariableName}};var Cjr=class extends qo{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[P$a]}convert(){return this.usernameVariableName}};var _jr=class extends qo{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[D$a];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var xjr=class extends qo{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[R$a]}convert(){return this.tokenVariableName}};function k$a(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var M$a="x-bearer-format",L$a="x-code-samples",U$a="x-codeSamples";var Sjr=class extends qo{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[M$a]}convert(){return this.bearerFormat}};var Ojr=class extends qo{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[F$a];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var Bjr=class extends qo{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[j$a]}convert(){return this.headerVariableName}};function z$a(e){return e.type==="apiKey"}var frt=class extends qo{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){z$a(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new Ojr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new Bjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new Sjr({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()}}};yKn();N9o();function Pjr(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function drt(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function q4e(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(q4e).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function Tjr(e){if(Array.isArray(e))return e.map(drt);if(typeof e=="symbol")return[e];e=q4e(e);let t=[],r=e.length;if(r===0)return t;let n=0,i="",o="",s=!1;for(e.charCodeAt(0)===46&&(t.push(""),n++);n<r;){let a=e[n];o?a==="\\"&&n+1<r?(n++,i+=e[n]):a===o?o="":i+=a:s?a==='"'||a==="'"?o=a:a==="]"?(s=!1,t.push(i),i=""):i+=a:a==="["?(s=!0,i&&(t.push(i),i="")):a==="."?i&&(t.push(i),i=""):i+=a,n++}return i&&t.push(i),t}function YQt(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(MVt(t))return r;let n=e[t];return n===void 0?Pjr(t)?YQt(e,Tjr(t),r):r:n}case"number":case"symbol":{typeof t=="number"&&(t=drt(t));let n=e[t];return n===void 0?r:n}default:{if(Array.isArray(t))return rod(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),MVt(t))return r;let n=e[t];return n===void 0?r:n}}}function rod(e,t,r){if(t.length===0)return r;let n=e;for(let i=0;i<t.length;i++){if(n==null||MVt(t[i]))return r;n=n[t[i]]}return n===void 0?r:n}function V$a(e){return function(t){return YQt(t,e)}}function q$a(e){return e!==null&&(typeof e=="object"||typeof e=="function")}K$n();function F6i(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Q6i(e,t,r){return typeof r!="function"?Q6i(e,t,()=>{}):j6i(e,t,function n(i,o,s,a,u,c){let l=r(i,o,s,a,u,c);return l!==void 0?!!l:j6i(i,o,n,c)},new Map)}function j6i(e,t,r,n){if(t===e)return!0;switch(typeof t){case"object":return nod(e,t,r,n);case"function":return Object.keys(t).length>0?j6i(e,{...t},r,n):F6i(e,t);default:return q$a(e)?typeof t=="string"?t==="":!0:F6i(e,t)}}function nod(e,t,r,n){if(t==null)return!0;if(Array.isArray(t))return G$a(e,t,r,n);if(t instanceof Map)return iod(e,t,r,n);if(t instanceof Set)return ood(e,t,r,n);let i=Object.keys(t);if(e==null||JEt(e))return i.length===0;if(i.length===0)return!0;if(n?.has(t))return n.get(t)===e;n?.set(t,e);try{for(let o=0;o<i.length;o++){let s=i[o];if(!JEt(e)&&!(s in e)||t[s]===void 0&&e[s]!==void 0||t[s]===null&&e[s]!==null||!r(e[s],t[s],s,e,t,n))return!1}return!0}finally{n?.delete(t)}}function iod(e,t,r,n){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[i,o]of t.entries()){let s=e.get(i);if(r(s,o,i,e,t,n)===!1)return!1}return!0}function G$a(e,t,r,n){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let i=new Set;for(let o=0;o<t.length;o++){let s=t[o],a=!1;for(let u=0;u<e.length;u++){if(i.has(u))continue;let c=e[u],l=!1;if(r(c,s,o,e,t,n)&&(l=!0),l){i.add(u),a=!0;break}}if(!a)return!1}return!0}function ood(e,t,r,n){return t.size===0?!0:e instanceof Set?G$a([...e],[...t],r,n):!1}function Djr(e,t){return Q6i(e,t,()=>{})}Q9o();function W$a(e){return e=j9o(e),t=>Djr(t,e)}Y$n();RVt();J$n();function $$a(e,t){return F9o(e,(r,n,i,o)=>{let s=t?.(r,n,i,o);if(s!==void 0)return s;if(typeof e=="object"){if(KVe(e)===kVt&&typeof e.constructor!="function"){let a={};return o.set(e,a),gM(a,e,i,o),a}switch(Object.prototype.toString.call(e)){case jVt:case FVt:case QVt:{let a=new e.constructor(e?.valueOf());return gM(a,e),a}case NVt:{let a={};return gM(a,e),a.length=e.length,a[Symbol.iterator]=e[Symbol.iterator],a}default:return}}})}function H$a(e){return $$a(e)}var sod=/^(?:0|[1-9]\d*)$/;function K$a(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 sod.test(e)}}RVt();function J$a(e){return e!==null&&typeof e=="object"&&KVe(e)==="[object Arguments]"}function Y$a(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&Pjr(t)&&e?.[t]==null?r=Tjr(t):r=[t],r.length===0)return!1;let n=e;for(let i=0;i<r.length;i++){let o=r[i];if((n==null||!Object.hasOwn(n,o))&&!((Array.isArray(n)||J$a(n))&&K$a(o)&&o<n.length))return!1;n=n[o]}return!0}function X$a(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=drt(e);break}}return t=H$a(t),function(r){let n=YQt(r,e);return n===void 0?Y$a(r,e):t===void 0?n===void 0:Djr(n,t)}}function Z$a(e){if(e==null)return Zqt;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?X$a(e[0],e[1]):W$a(e);case"string":case"symbol":case"number":return V$a(e)}}yKn();X$n();function Rjr(e,t=Zqt){return e==null?{}:xx(e,Z$a(t))}sJo();function eHa(e){return oJo(q4e(e))}U9o();function tHa(e){return typeof e!="string"&&(e=q4e(e)),e.replace(/['\u2019]/g,"")}function Q9(e){return L9o(tHa(eHa(e)))}function Nm(e){if(e!=null)return Array.isArray(e)?e:[e]}function Fjr({namespace:e,path:t,method:r,sdkMethodName:n,operationId:i,displayName:o,isWebhook:s}){if(t==null)return;let a=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(n==null&&i==null&&o==null&&a==null))return`${aod(s)}${uod(e)}.${cod(n,i,o,a)}`}function aod(e){return e?"webhook_":"endpoint_"}function uod(e){return e!=null?Nm(e)?.map(t=>Q9(t)).join("/"):""}function cod(e,t,r,n){return e||t||Q9(r??"")||Q9(n??"")}function rHa(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var jjr=class extends qo{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[O$a],this.accessTokenLocator!=null&&(rHa(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 Qjr=class extends qo{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 frt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new jjr({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=Fjr({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:Ea.EndpointId(r),accessTokenLocator:Ea.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var mrt=class extends qo{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 Ijr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new Cjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new wjr({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 _jr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new xjr({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":{k$a(this.input)?(this.authScheme="header",this.headerAuthNode=new frt({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 Qjr({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 nHa.UnreachableCaseError(this.authScheme);return}}};var hrt=class extends qo{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(n=>{let i=Ejr(n,this.context.document);if(i==null){this.context.errors.warning({message:`No auth scheme found for ${n}. Inline security schemes are not supported.`,path:this.accessPath});return}let o=new mrt({input:i,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});o.convert()!=null?(this.authNodesMap??={},this.authNodesMap[n]=o):this.context.errors.warning({message:`No auth scheme found for ${n}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[t,n]}).filter(Yo))}};var Njr=class extends qo{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[w$a],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 iHa(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function oHa(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function grt(e,t){return e==null?void 0:Object.entries(e).map(([n,i])=>Nm(i.convert())?.map(s=>((t!=null&&!t.includes(n)||t==null&&!iHa(i))&&(s=oHa(s,s.type==="enum"?s.default:void 0)),{key:Ea.PropertyKey(n),valueShape:s,description:i.description,availability:i.availability?.convert()})).filter(Yo)).filter(Yo).reduce((n,i)=>n.flatMap(o=>i.length>0?i.map(s=>[...o,s]):[[...o]]),[[]])}function kjr(e,t){return Mp(e)?zS(e,t,void 0):e}function v_e(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function sHa(e,t){let r={...e};for(let[n,i]of Object.entries(t??{}))r[n]=[...r[n]??[],...i];return Object.keys(r).length>0?r:void 0}function aHa(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let n of e)for(let i of t)r.push({path:n.path??i.path,responseStatusCode:n.responseStatusCode??i.responseStatusCode,name:n.name??i.name,description:n.description??i.description,pathParameters:n.pathParameters??i.pathParameters,queryParameters:n.queryParameters??i.queryParameters,headers:n.headers??i.headers,requestBody:n.requestBody??i.requestBody,responseBody:n.responseBody??i.responseBody,snippets:{...i.snippets,...n.snippets}});return r}var uHa=Ce(Oy());var N6i=["decimal","decimal128","double-int","double","float","sf-decimal"],k6i=["int16","int32","int64","int8","sf-integer","uint8"],M6i=["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"],L6i=["beta","pre-release","in-development","generally-available","deprecated"];function Vv(e,t){return Mp(e)?zS(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var vU=class extends qo{availability;constructor(t){super(t),this.safeParse()}parse(){if(Vv(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[C$a];r!=null&&(L6i.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${L6i.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return Ea.Availability.Beta;case"in-development":return Ea.Availability.InDevelopment;case"generally-available":return Ea.Availability.GenerallyAvailable;case"deprecated":return Ea.Availability.Deprecated;case void 0:return;default:new uHa.UnreachableCaseError(this.availability);return}}};var Ljr=Ce(Oy());function cHa(e){return typeof e=="object"&&e!=null&&"language"in e}function lHa(e){return typeof e=="object"&&e!=null&&"sdk"in e}function pHa(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function fHa(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function Mjr(e){return typeof e=="object"&&e!=null&&"event"in e}function U6i(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(Mjr)}function E_e(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function dHa(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var Ujr=class extends qo{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,n,i,o){super(t),this.path=r,this.successResponseStatusCode=n,this.requestBodyByContentType=i,this.responseBodies=o,this.safeParse()}parse(){this.examples=this.input[N$a]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([i,o])=>{let s=typeof r=="object"?r[i]:void 0;switch(o.multipartType){case"file":return E_e(s)?[i,{type:"filenameWithData",filename:s.filename,data:Ea.FileId(s.data)}]:s!=null?[i,{type:"filename",value:s}]:void 0;case"files":{if(Array.isArray(s)){if(s.every(a=>E_e(a)))return[i,{type:"filenamesWithData",value:s.map(a=>({filename:a.filename,data:Ea.FileId(a.data)}))}];if(s.every(a=>typeof a=="string"))return[i,{type:"filenames",value:s}]}return}case"property":return[i,{type:"json",value:s}];case void 0:return;default:new Ljr.UnreachableCaseError(o.multipartType);return}}).filter(Yo))};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(n=>{let i=t!=null?this.requestBodyByContentType?.[t]:void 0,o;if(i!=null)switch(i.contentType){case"form-data":o=dHa(r.request)?this.convertFormDataExampleRequest(i,r.request):void 0;break;case"json":o=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":o=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new Ljr.UnreachableCaseError(i.contentType);break}let s;switch(n.contentType){case"application/json":{pHa(r.response)&&(s={type:"json",value:r.response.body});break}case"text/event-stream":{U6i(r.response)&&(s={type:"sse",value:r.response.stream.map(p=>({event:p.event,data:p.data}))});break}case"application/octet-stream":!U6i(r.response)&&fHa(r.response)&&(s={type:"stream",value:r.response.stream});break;case void 0:break;default:new Ljr.UnreachableCaseError(n.contentType);break}let a={};r["code-samples"]?.forEach(p=>{cHa(p)?p.language!=null&&(a[p.language]??=[],a[p.language]?.push({name:p.name,language:p.language,install:p.install,code:p.code,generated:!1,description:p.docs})):lHa(p)&&p.sdk!=null&&(a[p.sdk]??=[],a[p.sdk]?.push({name:p.name,language:p.sdk,install:void 0,code:p.code,generated:!1,description:p.docs}))});let u=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([p,d])=>[Ea.PropertyKey(p),d])),c=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([p,d])=>[Ea.PropertyKey(p),d])),l=Object.fromEntries(Object.entries(r.headers??{}).map(([p,d])=>[Ea.PropertyKey(p),d]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(u).length>0?u:void 0,queryParameters:Object.keys(c).length>0?c:void 0,headers:Object.keys(l).length>0?l:void 0,requestBody:o,responseBody:s,snippets:a}}))}};var XQt=class extends qo{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[yjr]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>Ea.api.v1.SubpackageId(Q9(r)))}};var zjr=class extends qo{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[x$a]}convert(){return this.sdkMethodName}};var Vjr=class extends qo{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[S$a]}convert(){return this.isWebhook}};var qjr=class extends qo{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[L$a]??[],...this.input[U$a]??[]],this.codeSamples.forEach(t=>{[...Object.values(Ea.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 G4e=Ce(Oy());function z6i(e,t){return Mp(e)?zS(e,t,void 0):e}function mHa(e,t){return e.replace(/{(\w+)}/g,(r,n)=>t[n]!=null&&typeof t[n]=="string"||typeof t[n]=="number"||typeof t[n]=="boolean"?`${t[n]}`:r)}var o_="",WY=class extends qo{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,n,i,o){super(t),this.path=r,this.responseStatusCode=n,this.name=i,this.shapes=o,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,n])=>{let i=this.resolvedRequestInput?.value[r];switch(n.multipartType){case"file":return t&&(E_e(i)||typeof i=="string");case"files":return t&&Array.isArray(i)&&i.every(o=>E_e(o)||typeof o=="string");case"property":return t;case void 0:return t&&!1;default:return new G4e.UnreachableCaseError(n.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=z6i(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=z6i(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 G4e.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(Mjr)){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 G4e.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,n])=>{let i=this.resolvedRequestInput?.value?.[r];switch(n.multipartType){case"file":return E_e(i)?[r,{type:"filenameWithData",filename:i.filename,data:Ea.FileId(i.data)}]:[r,{type:"filename",value:i}];case"files":{if(Array.isArray(i)){if(i.every(o=>E_e(o)))return[r,{type:"filenamesWithData",value:i.map(o=>({filename:o.filename,data:Ea.FileId(o.data)}))}];if(i.every(o=>typeof o=="string"))return[r,{type:"filenames",value:i}]}return}case"property":return[r,{type:"json",value:i}];case void 0:return;default:new G4e.UnreachableCaseError(n.multipartType);return}}).filter(Yo))};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 G4e.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 G4e.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let n=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([s,a])=>[s,a.example({includeOptionals:!1,override:s})]));n=Object.keys(n).length>0?n:void 0;let i=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([s,a])=>a.required||a.inputExample!=null?[s,a.example({includeOptionals:!1,override:s})]:void 0).filter(Yo));i=Object.keys(i).length>0?i:void 0;let o=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([s,a])=>a.required||a.inputExample!=null?[s,a.example({includeOptionals:!1,override:s})]:void 0).filter(Yo));if(o=Object.keys(o).length>0?o:void 0,!(this.path==null&&t==null&&r==null&&o==null&&i==null&&n==null))return{path:mHa(this.path,n??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?LS(this.name):this.summary!=null?LS(this.summary):void 0,description:this.convertDescription(),pathParameters:n,queryParameters:i,headers:o,requestBody:t,responseBody:r,snippets:void 0}}};function hHa(e,t){return Mp(e)?zS(e,t,void 0):e}var OHa=Ce(Oy());var gHa="#/components/schemas/";function Art(e){if(e.$ref.startsWith(gHa))return e.$ref.replace(gHa,"")}function $ge(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function I_e(e){return typeof e.type=="string"&&e.type==="array"}function AHa(e){return e.type==="boolean"}function yHa(e){return e.type==="integer"}function w_e(e){return!Array.isArray(e.type)&&!I_e(e)}function bHa(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||w_e(t)||I_e(t))}function vHa(e){return"nullable"in e&&typeof e.nullable=="boolean"}function EHa(e){return e.type==="null"}function IHa(e){return e.type==="number"}function V6i(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function wHa(e){return e.type==="string"}var Gjr=class extends fj{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new Rg({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 Nm(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 Wjr=class extends zv{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 vU({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 $jr=class extends fj{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 Rg({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(Yo)}convert(){if(this.typeNodes==null)return;let n=this.typeNodes.map(i=>Nm(i.convert())?.map(s=>({displayName:i.name,shape:s,description:i.description,availability:i.availability?.convert()}))).filter(Yo).reduce((i,o)=>i.flatMap(s=>o.length>0?o.map(a=>[...s,a]):[[...s]]),[[]]).map(i=>({type:"undiscriminatedUnion",variants:i}));return this.nullable?n.map($ge).filter(Yo):n}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function Hjr(e){return e!=null&&e.length>0?e:[void 0]}var yrt=class extends fj{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 Rg({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 Rg({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(Mp(t))return Art(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([n,i])=>[n,new Rg({input:i,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",n],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(Yo))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return grt(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}}}]:Nm(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(Yo)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(n=>Hjr(r).map(i=>(this.extends==null||this.extends.length===0)&&n.length===0&&i!=null?{type:"alias",value:i}:{type:"object",extends:this.extends.map(o=>Ea.TypeId(o)),properties:n,extraProperties:i}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(n=>{let i=Vv(n,this.context.document);i!=null&&(r={...r,...Object.fromEntries(Object.entries(i.properties??{}).map(([o,s])=>[o,new Rg({input:s,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((n,i)=>{let o=r?.[i];return n[i]=o?.example({includeOptionals:t,override:i}),n},{}):Object.entries(r).reduce((n,[i,o])=>(n[i]=o?.example({includeOptionals:t,override:i}),n),{}))}};var Kjr=class extends fj{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=>Vv(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>Vv(t,this.context.document)?.type!=="null"?new Rg({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(Yo);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(([n,i])=>{let o=Vv({$ref:i},this.context.document);if(o==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${i}`,path:[...this.accessPath,"discriminator","mapping",n]});return}r[n]=new Rg({input:o,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",n],pathId:n,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let i=this.undiscriminatedMapping?.flatMap(o=>o.convert()).filter(Yo);return this.isNullable&&i!=null?i.map($ge).filter(Yo):i}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:Ea.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([i,o])=>Nm(o.convert())?.map(a=>{if(!(a==null||a.type!=="object"))return{discriminantValue:i,displayName:o.name??LS(i),availability:o.availability?.convert(),description:o.description,...a}}).filter(Yo)).filter(Yo)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(i=>Nm(i.convert())?.map(s=>{if(s==null)return;t+=1;let a=s.type==="object"?LS(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:i.name??(s.type==="alias"&&s.value.type==="id"?LS(s.value.id):a),shape:s,description:i.description,availability:i.availability?.convert()}}).filter(Yo)).filter(Yo)}:void 0,n=this.isNullable?$ge(r):r;return n!=null?[n]: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 Jjr=class extends zv{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 C_e=class extends zv{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,n)=>{if(t){if(Mp(r)){let i=Vv(r,this.context.document);r=typeof i=="string"?i:typeof i?.default=="string"?i?.default:typeof i?.example=="string"?i.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${n}]`]}),t=!1;return}return r}}).filter(Yo),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 CHa=Ce(Oy());function lod(e){return k6i.includes(e)}var Yjr=class extends zv{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&&(lod(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${k6i.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 CHa.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 Xjr=class extends zv{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return $ge({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var _Ha=Ce(Oy());function pod(e){return N6i.includes(e)}var Zjr=class extends zv{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&&(pod(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${N6i.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 _Ha.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 xHa=Ce(Oy());function fod(e){return M6i.includes(e)}var eQr=class extends zv{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 xHa.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&&(fod(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${M6i.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new C_e({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 SHa=Ce(Oy());var tQr=class extends zv{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,SHa.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var W4e=class extends fj{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=Art(this.input);let t=Vv(this.input,this.context.document);t?.enum!=null&&w_e(t)&&(this.maybeEnumConverterNode=new C_e({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:Ea.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=Vv(this.input,this.context.document);if(r!=null)return new Rg({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var Rg=class e extends fj{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 vU({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),w_e(this.input)&&vHa(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),Mp(this.input)){let t=Art(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 W4e({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 Wjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(bHa(this.input))this.typeShapeNode=new $jr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(w_e(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new Kjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(V6i(this.input)&&this.input.allOf!=null)this.typeShapeNode=new yrt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(w_e(this.input)&&this.input.enum!=null)this.typeShapeNode=new C_e({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":V6i(this.input)&&(this.typeShapeNode=new yrt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":I_e(this.input)&&(this.typeShapeNode=new Gjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":AHa(this.input)&&(this.typeShapeNode=new Jjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":yHa(this.input)&&(this.typeShapeNode=new Yjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":IHa(this.input)&&(this.typeShapeNode=new Zjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":wHa(this.input)&&(this.typeShapeNode=new eQr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":EHa(this.input)&&(this.typeShapeNode=new Xjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new OHa.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 yrt({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 tQr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!Mp(this.input)&&(!I_e(this.input)&&this.input==null||I_e(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=Nm(t)?.map(n=>this.nullable?$ge(n):n).filter(Yo);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function __e(e){if(e!=null)return grt(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(Yo))}var $Y=class extends zv{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;Mp(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 vU({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new Rg({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let n=hHa(this.input,this.context.document);this.inputExample=n?.example??Object.values(n?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function BHa(e,t){return Mp(e)?zS(e,t,void 0):e}var q6i=Ce(Oy());function rQr(e){let{uniqueId:t,type:r,contextTypes:n,description:i,availability:o}=e;n[Ea.TypeId(t)]={name:t,shape:r,description:i,availability:o}}var PHa=Ce(pli(),1),brt=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,n,i,o,s){this.type=t,this.subtype=r,this.essence=n,this.parameters=i,this.mimeType=o,this.input=s}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=PHa.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 dod(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var nQr=class extends qo{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 Rg({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),dod(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],n)=>{let i;if(Mp(r)?i=Ejr(r.$ref,this.context.document):i=r,i!=null)return[t,new mrt({input:i,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${n}`]})]}).filter(Yo)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[Ea.api.latest.AuthSchemeId(t),n]}).filter(Yo)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let n=r.name??t,i=Nm(r.convert());return i==null?[t,void 0]:[Ea.TypeId(t),{name:n,shape:i[0],description:r.description,availability:void 0}]}).filter(([t,r])=>Yo(r))):void 0}}};var iQr=class extends Rg{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=Vv(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${Mp(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=Vv(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 oQr=class extends qo{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 n=Vv(this.input.schema,this.context.document);this.availability=new vU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=Mp(this.input.schema)?new W4e({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 i=brt.parse(t);i?.containsJSON()?(this.contentType="json",this.schema=this.schema??new Rg({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):i?.isOctetStream()?(this.contentType="bytes",this.isOptional=n?.required==null):i?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=n?.required,this.fields=Object.fromEntries(Object.entries(n?.properties??{}).map(([o,s])=>{if(s!=null)return[o,new iQr({input:s,context:this.context,accessPath:this.accessPath,pathId:`schema.${o}`,seenSchemas:new Set,nullable:void 0,schemaName:o})]}).filter(Yo))):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?{[o_]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[o_]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:Nm(t)?.map(n=>{let i=n.type;switch(i){case"object":case"alias":return n;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let o=Q9([this.method,this.path,this.contentType,"request"].join("_"));return rQr({uniqueId:o,type:n,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Ea.TypeId(o),default:n.type==="enum"&&n.default!=null?{type:"enum",value:n.default}:void 0}}}case void 0:return;default:new q6i.UnreachableCaseError(i);return}}).filter(Yo)}convert(){if(this.schema instanceof W4e)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(([n,i])=>{switch(i.multipartType){case"file":return[{type:i.multipartType,key:Ea.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"files":return[{type:i.multipartType,key:Ea.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"property":{let o=Nm(i.convert()),s=i.multipartType;return o?.map(a=>({type:s,key:Ea.PropertyKey(n),contentType:i.contentType,exploded:void 0,valueShape:a,description:i.description,availability:i.availability?.convert()}))}case void 0:return[];default:return new q6i.UnreachableCaseError(i.multipartType),[]}}).filter(Yo).reduce((n,i)=>n.flatMap(o=>i.length>0?i.map(s=>[...o,s]):[[...o]]),[[]]).map(n=>({type:"formData",fields:n,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var sQr=class extends qo{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let n=BHa(this.input,this.context.document);if(n==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(n.content).forEach(([i,o])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[i]=new oQr({input:o,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:i,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>Nm(r.convert())?.map(i=>({description:this.description,contentType:t,body:i}))).filter(Yo)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>Nm(t.convert())?.map(n=>{if(!(n.type!=="alias"&&n.type!=="object"))return{description:this.description,shape:n}})).filter(Yo)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var THa={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 DHa(e,t){if(Mp(e)){let r=zS(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var aQr=Ce(Oy());var RHa="application/json";var FHa="application/octet-stream";function jHa(e,t){return e===t||t===o_||e===o_}var ZQt=class extends qo{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,n,i,o,s,a,u){super(t),this.streamingFormat=n,this.path=i,this.method=o,this.statusCode=s,this.requests=a,this.shapes=u,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,n){for(let i of t)for(let[o,s]of Object.entries(i?.examples??{}))for(let[a,u]of Object.entries(r))for(let c of u)jHa(a,o)&&(n.add(a),this.examples?.push(new WY({input:{requestExample:s,responseExample:c},context:this.context,accessPath:this.accessPath,pathId:o!=null&&o!==""?["examples",o]:"examples"},this.path,this.statusCode,v_e(o,a),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let n=0;for(let i of t){let o=0;for(let[s,a]of r){if(o===n){let[u,c,l]=i??[void 0,void 0,void 0];this.examples?.push(...a.map(p=>new WY({input:{requestExample:l,responseExample:p},context:this.context,accessPath:this.accessPath,pathId:c!=null&&c!==""?["examples",c]:"examples"},this.path,this.statusCode,v_e(c,s),{requestBody:u,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}o++}n++}if(t.length>r.length)for(let i of t.slice(r.length)){let[o,s]=r[r.length-1]??[void 0,void 0],[a,u,c]=i??[void 0,void 0,void 0];this.examples?.push(...(s??[void 0]).map(l=>new WY({input:{requestExample:c,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:u!=null&&u!==""?["examples",u]:"examples"},this.path,this.statusCode,v_e(u,o),{requestBody:a,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[i,o,s]=t[t.length-1]??[void 0,void 0,void 0];for(let[a,u]of r.slice(t.length))this.examples?.push(...u.map(c=>new WY({input:{requestExample:s,responseExample:c},context:this.context,accessPath:this.accessPath,pathId:o!=null&&o!==""?["examples",o]:"examples"},this.path,this.statusCode,v_e(o,a),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,n,i){let o=t[o_];if(o!=null)for(let s of o)this.examples?.push(new WY({input:{requestExample:i,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:n!=null&&n!==""?["examples",n]:"examples"},this.path,this.statusCode,v_e(n,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 n of t)if(Object.keys(n.examples??{}).length===0)this.pushResponseExample(r,n,void 0,void 0);else for(let[i,o]of Object.entries(n.examples??{}))this.pushResponseExample(r,n,i,o)}parse(t){if(t==="empty")this.empty=!0;else{let a=brt.parse(t);if(a?.isJSON()||a?.isEventStream())this.contentType=RHa,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 Rg({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(a?.isOctetStream())this.contentType=FHa,this.contentSubtype=Vv(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 Rg({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=Rjr(this.input.examples,a=>[a])),this.input.example!=null&&Object.keys(r).length===0&&(r[o_]??=[],r[o_]=[{value:this.input.example}]);let n=Vv(this.input.schema,this.context.document);if(n!=null&&(n.examples!=null&&Object.keys(r).length===0&&(r=Rjr(n.examples,a=>[a])),n.example!=null&&Object.keys(r).length===0&&(r[o_]??=[],r[o_]?.push({value:n.example}))),Object.keys(r).length===0){let a=this.schema?.example({includeOptionals:!0,override:void 0});r[o_]??=[],r[o_]?.push(a!=null?{value:a}:void 0)}this.examples??=[];let i=new Set;this.matchRequestResponseExamplesByName(this.requests,r,i);let o=[];for(let a of this.requests)o.push(...Object.entries(a.examples??{}).filter(([u])=>!i.has(u)&&u!==o_).map(([u,c])=>[a,u,c]));let s=Object.entries(r).filter(([a,u])=>!i.has(a)&&Yo(u)&&a!==o_);Object.keys(r).every(a=>a===o_)||this.matchExamplesByIndex(o,s),!i.has(o_)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return Nm(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new aQr.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return Nm(this.schema?.convert())?.map(r=>{let n=r.type;switch(n){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let i=Q9([this.method,this.path,this.statusCode,"response"].join("_"));return rQr({uniqueId:i,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Ea.TypeId(i),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new aQr.UnreachableCaseError(n);return}}).filter(Yo)}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 aQr.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var eNt=class extends qo{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,n,i,o,s){super(t),this.path=r,this.method=n,this.statusCode=i,this.requests=o,this.shapes=s,this.safeParse()}parse(t){this.description=this.input.description;let r=DHa(this.input,this.context.document);if(r==null){this.context.errors.error({message:Mp(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([n,i])=>{this.headers??={},this.headers[n]=new $Y({input:i,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:n})}),r.content==null?(this.responses??=[],this.responses.push(new ZQt({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(([n,i])=>{this.responses??=[],this.responses.push(new ZQt({input:i,context:this.context,accessPath:this.accessPath,pathId:["content",n]},n,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(Yo)}};var uQr=class extends qo{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,n,i,o){super(t),this.path=r,this.method=n,this.requests=i,this.shapes=o,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,n])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new eNt({input:{...t,...n},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new eNt({input:n,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 n=r.convert();if(n!=null)return Hjr(__e(r.headers)).flatMap(i=>n?.map(o=>({headers:i,response:{statusCode:parseInt(t),body:o,description:r.description},examples:(r.responses??[]).flatMap(s=>(s.examples??[]).map(a=>a.convert()).filter(Yo))})))}).filter(Yo)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(n=>{let i=n.schema,o=Nm(i?.convert());if(i!=null)return o?.map(s=>({statusCode:parseInt(t),shape:s,description:r.description??i.description,availability:i.availability?.convert(),name:i.name??THa[parseInt(t)]??"UNKNOWN ERROR",examples:n.examples?.map(a=>{let u=a.convert();if(u!=null&&u.responseBody?.type==="json")return{name:u.name,description:u.description,responseBody:u.responseBody}}).filter(Yo)})).filter(Yo)})).filter(Yo)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var x_e=class extends qo{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,n){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new WY({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,v_e(n,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 vU({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=b_e(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new Vjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((n,i)=>{if(Mp(n)){let o=kjr(n,this.context.document);if(o!=null)n=o;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${n.$ref}`,path:[...this.accessPath,`parameters[${i}]`]});return}}n.in==="path"?n.schema!=null&&(this.pathParameters??={},this.pathParameters[n.name]=new $Y({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="query"?n.schema!=null&&(this.queryParameters??={},this.queryParameters[n.name]=new $Y({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="header"&&n.schema!=null&&(this.requestHeaders??={},this.requestHeaders[n.name]=new $Y({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name}))});for(let n of this.extractPathParameterIds()??[])this.pathParameters?.[n]==null&&this.context.errors.warning({message:`Path parameter not defined: ${n}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new qjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new sQr({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 uQr({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 n=this.requests?.requestBodiesByContentType;n==null||Object.keys(n).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(n).forEach(i=>{if(Object.keys(i.examples??{}).length===0){let o=i.schema?.example({includeOptionals:!1,override:void 0});o!=null&&this.pushEmptyResponseExample({value:o},i,void 0)}else Object.entries(i.examples??{}).forEach(([o,s])=>{this.pushEmptyResponseExample(s,i,o)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(n=>Number(n)>=200&&Number(n)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new hrt({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new XQt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(n=>n.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((n,i)=>new XQt({input:{[yjr]:n},context:this.context,accessPath:this.accessPath,pathId:["tags",`${i}`]})));let r=new zjr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(n=>Fjr({namespace:Nm(n?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(Yo),this.xFernExamplesNode=new Ujr({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(Yo)}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((i,o)=>(i.push({type:"literal",value:"/"}),o.startsWith("{")&&o.endsWith("}")?i.push({type:"pathParameter",value:Ea.PropertyKey(o.slice(1,-1).trim())}):i.push({type:"literal",value:o}),i),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},n=this.emptyResponseExamples?.map(l=>l.convert()).filter(Yo),i=aHa(this.xFernExamplesNode?.convert(),[...n??[],...t?.flatMap(l=>l.examples)??[]])?.map(l=>({...l,snippets:sHa(l.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((l,p)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:Ea.WebhookId(l),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[p]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(d=>d.value.toString())??[],queryParameters:__e(this.queryParameters)?.flat(),headers:__e(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(Yo)}}).filter(Yo);let o=this.servers?.map(l=>l.convert()).filter(Yo),s=this.convertPathToPathParts();if(s==null)return;let a,u=this.auth?.convert();u!=null&&(a=Object.keys(u));let c=t?.flatMap(l=>l.headers).filter(Yo);return this.endpointIds.map((l,p)=>({id:Ea.EndpointId(l),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[p]?.convert()?.map(d=>Ea.api.v1.SubpackageId(d)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:s,auth:a?.map(d=>Ea.api.latest.AuthSchemeId(d)),defaultEnvironment:o?.[0]?.id,environments:o,pathParameters:__e(this.pathParameters)?.flat(),queryParameters:__e(this.queryParameters)?.flat(),requestHeaders:__e(this.requestHeaders)?.flat(),responseHeaders:c!=null&&c.length>0?c:void 0,requests:this.requests?.convert(),responses:t?.map(d=>d.response),errors:r,examples:i,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var vrt=class extends qo{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n,isWebhook:i}){this.description=this.input.description;let o=b_e(t,this.input.servers,this.context,this.accessPath),s=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new x_e({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:o,globalAuth:r,path:s,method:"GET",basePath:n,isWebhook:i})),this.input.post!=null&&(this.post=new x_e({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:o,globalAuth:r,path:s,method:"POST",basePath:n,isWebhook:i})),this.input.put!=null&&(this.put=new x_e({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:o,globalAuth:r,path:s,method:"PUT",basePath:n,isWebhook:!1})),this.input.patch!=null&&(this.patch=new x_e({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:o,globalAuth:r,path:s,method:"PATCH",basePath:n,isWebhook:!1})),this.input.delete!=null&&(this.delete=new x_e({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:o,globalAuth:r,path:s,method:"DELETE",basePath:n,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(Yo)}};function cQr(e){return"payloads"in e}var lQr=class extends qo{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.paths=Object.entries(this.input).map(([i,o])=>{if(o!=null)return new vrt({input:o,context:this.context,accessPath:this.accessPath,pathId:i,servers:b_e(t,o.servers,this.context,this.accessPath),globalAuth:r,basePath:n,isWebhook:void 0})}).filter(Yo)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(n=>{let i=n.convert();i?.forEach(o=>{cQr(o)?r[Ea.WebhookId(o.id)]=o:t[Ea.EndpointId(o.id)]=o})}),{endpoints:t,webhookEndpoints:r}}};var pQr=class extends qo{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[_$a]?.map(r=>{let{header:n,...i}=r;return(i.optional!=null&&!i.optional||kjr(i,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(n)),[n,new $Y({input:i,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:n})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return grt(this.globalHeaders,this.requiredProperties)?.flat()}};function QHa(e,t){if(Mp(e)){let r=zS(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var fQr=class extends qo{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.webhooks=Object.entries(this.input??{}).map(([i,o])=>{let s=QHa(o,this.context.document);if(s!=null)return new vrt({input:s,context:this.context,accessPath:this.accessPath,pathId:i,servers:t,globalAuth:r,basePath:n,isWebhook:!0})}).filter(Yo)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(n=>{cQr(n)&&(t[Ea.WebhookId(n.id)]=n)}),t),{})}};var dQr=class extends qo{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=b_e(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new hrt({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new Njr({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 lQr({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 fQr({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 nQr({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new pQr({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=yC(),{webhookEndpoints:r,endpoints:n}=this.paths?.convert()??{},i={...this.webhooks?.convert()??{},...r??{}},o=E$a({endpoints:n,webhookEndpoints:i}),{types:s,auths:a}=this.components?.convert()??{};return{id:Ea.ApiDefinitionId(t),endpoints:n??{},websockets:{},webhooks:i,types:{...s,...this.context.generatedTypes},subpackages:o,auths:{...a,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};xi();async function G6i(e,t){if(e instanceof IO){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof Kp))return;let r=new v9(e.absoluteFilePath),n=await oU({context:t,specs:e.specs}),i=await r.loadDocuments({context:t,specs:n,loadAiExamples:!0}),o;for(let s of i){if(s.type!=="openapi")continue;let a={document:s.value,logger:t.logger,errors:new gjr,generatedTypes:{}},u=new dQr({input:s.value,context:a,accessPath:[],pathId:e.workspaceName??"openapi parser"});o=q7e(o,u.convert())}return o}dg();Wt();var Hsu=Ce(H6i(),1),Ksu=Ce(ZQr(),1),Q2r=require("fs/promises"),Jsu=Ce(require("http"),1),Ysu=Ce(require("path"),1);var FZa=require("events"),iNr=Ce(require("fs"),1),rLe=Ce(require("path"),1);var gZa=Ce(require("os"),1),AZa=300,R_e=20,_Nt=1e7,yZa=gZa.default.platform();var Ofd=yZa==="darwin",dqi=yZa==="win32",F_e=Ofd||dqi,bZa=3e3,vZa=2e4,mqi=1250;var YY;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(YY||(YY={}));var tLe;(function(e){e.CHANGE="change",e.RENAME="rename"})(tLe||(tLe={}));var xNt;(function(e){e.CHANGE="change",e.ERROR="error"})(xNt||(xNt={}));var cu;(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"})(cu||(cu={}));var CT;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(CT||(CT={}));var Bfd=(e,t=1,r)=>{t=Math.max(1,t);let n=r?.leading??!1,i=r?.trailing??!0,o=Math.max(r?.maxWait??1/0,t),s,a,u=0,c=0,l=()=>{let b=Date.now(),I=b-u,w=b-c,_=I>=t||w>=o;return[b,_]},p=b=>{if(c=b,!s)return;let I=s;s=void 0,e.apply(void 0,I)},d=()=>{v(0)},f=()=>{a&&(d(),p(Date.now()))},m=b=>{if(c=b,n)return p(b)},h=b=>{if(i&&s)return p(b);s=void 0},A=()=>{a=void 0;let[b,I]=l();return I?h(b):y(b)},y=b=>{let I=b-u,w=b-c,_=t-I,C=o-w,x=Math.min(_,C);return v(x)},v=b=>{a&&clearTimeout(a),!(b<=0)&&(a=setTimeout(A,b))},E=(...b)=>{let[I,w]=l(),_=!!a;if(s=b,u=I,(w||!a)&&v(t),w)return _?p(I):m(I)};return E.cancel=d,E.flush=f,E},eNr=Bfd;var yqi=Ce(require("fs"),1),rNr=Ce(require("path"),1);var jf=Ce(require("fs"),1),VS=require("util");var Kge=(e,t)=>function(...n){return e.apply(void 0,n).catch(t)},XY=(e,t)=>function(...n){try{return e.apply(void 0,n)}catch(i){return t(i)}};var hqi=Ce(require("process"),1),EZa=hqi.default.getuid?!hqi.default.getuid():!1,IZa=1e4,gj=()=>{};var SNt={isChangeErrorOk:e=>{if(!SNt.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!EZa&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!SNt.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(!SNt.isNodeError(e))throw e;if(!SNt.isChangeErrorOk(e))throw e}},qv=SNt;var gqi=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=IZa,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(n),n=()=>t(r);this.add(n)}),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()}}}}},wZa=new gqi;var Jge=(e,t)=>function(n){return function i(...o){return wZa.schedule().then(s=>{let a=c=>(s(),c),u=c=>{if(s(),Date.now()>=n)throw c;if(t(c)){let l=Math.round(100*Math.random());return new Promise(d=>setTimeout(d,l)).then(()=>i.apply(void 0,o))}throw c};return e.apply(void 0,o).then(a,u)})}},Yge=(e,t)=>function(n){return function i(...o){try{return e.apply(void 0,o)}catch(s){if(Date.now()>n)throw s;if(t(s))return i.apply(void 0,o);throw s}}};var Pfd={attempt:{chmod:Kge((0,VS.promisify)(jf.default.chmod),qv.onChangeError),chown:Kge((0,VS.promisify)(jf.default.chown),qv.onChangeError),close:Kge((0,VS.promisify)(jf.default.close),gj),fsync:Kge((0,VS.promisify)(jf.default.fsync),gj),mkdir:Kge((0,VS.promisify)(jf.default.mkdir),gj),realpath:Kge((0,VS.promisify)(jf.default.realpath),gj),stat:Kge((0,VS.promisify)(jf.default.stat),gj),unlink:Kge((0,VS.promisify)(jf.default.unlink),gj),chmodSync:XY(jf.default.chmodSync,qv.onChangeError),chownSync:XY(jf.default.chownSync,qv.onChangeError),closeSync:XY(jf.default.closeSync,gj),existsSync:XY(jf.default.existsSync,gj),fsyncSync:XY(jf.default.fsync,gj),mkdirSync:XY(jf.default.mkdirSync,gj),realpathSync:XY(jf.default.realpathSync,gj),statSync:XY(jf.default.statSync,gj),unlinkSync:XY(jf.default.unlinkSync,gj)},retry:{close:Jge((0,VS.promisify)(jf.default.close),qv.isRetriableError),fsync:Jge((0,VS.promisify)(jf.default.fsync),qv.isRetriableError),open:Jge((0,VS.promisify)(jf.default.open),qv.isRetriableError),readFile:Jge((0,VS.promisify)(jf.default.readFile),qv.isRetriableError),rename:Jge((0,VS.promisify)(jf.default.rename),qv.isRetriableError),stat:Jge((0,VS.promisify)(jf.default.stat),qv.isRetriableError),write:Jge((0,VS.promisify)(jf.default.write),qv.isRetriableError),writeFile:Jge((0,VS.promisify)(jf.default.writeFile),qv.isRetriableError),closeSync:Yge(jf.default.closeSync,qv.isRetriableError),fsyncSync:Yge(jf.default.fsyncSync,qv.isRetriableError),openSync:Yge(jf.default.openSync,qv.isRetriableError),readFileSync:Yge(jf.default.readFileSync,qv.isRetriableError),renameSync:Yge(jf.default.renameSync,qv.isRetriableError),statSync:Yge(jf.default.statSync,qv.isRetriableError),writeSync:Yge(jf.default.writeSync,qv.isRetriableError),writeFileSync:Yge(jf.default.writeFileSync,qv.isRetriableError)}},CZa=Pfd;var tNr=Ce(require("fs"),1),ONt=Ce(require("path"),1);var Aqi=()=>{};var Tfd=()=>{let e=Aqi,t=Aqi,r=!1,n=!1;return{promise:new Promise((u,c)=>{e=l=>(r=!0,u(l)),t=l=>(n=!0,c(l))}),resolve:e,reject:t,isPending:()=>!r&&!n,isResolved:()=>r,isRejected:()=>n}},_Za=Tfd;var Dfd=()=>{let{promise:e,resolve:t,isPending:r}=_Za(),n=0,i=()=>{n+=1},o=()=>{n-=1,!n&&t()};return i(),queueMicrotask(o),{promise:e,isPending:r,increment:i,decrement:o}},xZa=Dfd;var SZa={then:e=>{e()}};var OZa=e=>Array.isArray(e)?e:[e],BZa=e=>typeof e=="function";var Rfd=(e,t)=>{let r=t?.followSymlinks??!1,n=t?.depth??1/0,i=t?.limit??1/0,o=t?.ignore??[],s=OZa(o).map(H=>BZa(H)?H:J=>H.test(J)),a=H=>s.some(J=>J(H)),u=t?.signal??{aborted:!1},c=t?.onDirents||(()=>{}),l=[],p=new Set,d={},f=[],m=new Set,h={},A=[],y=new Set,v={},E={},b=new Set,I={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},w={directories:l,directoriesNames:p,directoriesNamesToPaths:d,files:f,filesNames:m,filesNamesToPaths:h,symlinks:A,symlinksNames:y,symlinksNamesToPaths:v,map:E},{promise:_,increment:C,decrement:x}=xZa(),R=0,z=(H,J,Ae,ge)=>{b.has(J)||R>=i||(R+=1,H.directories.push(J),H.directoriesNames.add(Ae),l.push(J),p.add(Ae),d.propertyIsEnumerable(Ae)||(d[Ae]=[]),d[Ae].push(J),b.add(J),!(ge>=n)&&(R>=i||K(J,ge+1)))},U=(H,J,Ae)=>{b.has(J)||R>=i||(R+=1,H.files.push(J),H.filesNames.add(Ae),f.push(J),m.add(Ae),h.propertyIsEnumerable(Ae)||(h[Ae]=[]),h[Ae].push(J),b.add(J))},q=(H,J,Ae,ge)=>{b.has(J)||R>=i||(R+=1,H.symlinks.push(J),H.symlinksNames.add(Ae),A.push(J),y.add(Ae),v.propertyIsEnumerable(Ae)||(v[Ae]=[]),v[Ae].push(J),b.add(J),r&&(ge>=n||R>=i||Ee(J,ge+1)))},te=(H,J,Ae,ge,we)=>{u.aborted||a(J)||(ge.isDirectory()?z(H,J,Ae,we):ge.isFile()?U(H,J,Ae):ge.isSymbolicLink()&&q(H,J,Ae,we))},ie=(H,J,Ae,ge)=>{if(u.aborted)return;let we=J===ONt.default.sep?"":ONt.default.sep,_e=Ae.name,pe=`${J}${we}${_e}`;a(pe)||(Ae.isDirectory()?z(H,pe,_e,ge):Ae.isFile()?U(H,pe,_e):Ae.isSymbolicLink()&&q(H,pe,_e,ge))},V=(H,J,Ae,ge)=>{for(let we=0,_e=Ae.length;we<_e;we++)ie(H,J,Ae[we],ge)},K=(H,J)=>{u.aborted||J>n||R>=i||(C(),tNr.default.readdir(H,{withFileTypes:!0},(Ae,ge)=>{if(Ae||u.aborted||!ge.length)return x();(c(ge)||SZa).then(()=>{let _e=E[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};V(_e,H,ge,J),x()})}))},Ee=(H,J)=>{C(),tNr.default.realpath(H,(Ae,ge)=>{if(Ae||u.aborted)return x();tNr.default.stat(ge,(we,_e)=>{if(we||u.aborted)return x();let pe=ONt.default.basename(ge),le=E[H]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};te(le,ge,pe,_e,J),x()})})};return(async(H,J=1)=>(H=ONt.default.normalize(H),b.add(H),K(H,J),await _,u.aborted?I:w))(e)},PZa=Rfd;var ZY={lang:{debounce:eNr,attempt:e=>{try{return e()}catch(t){return ZY.lang.castError(t)}},castArray:e=>ZY.lang.isArray(e)?e:[e],castError:e=>ZY.lang.isError(e)?e:ZY.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(ZY.lang.isNaN(e))return ZY.lang.isNaN(t);if(ZY.lang.isPrimitive(e)||ZY.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(rNr.default.sep).length-1),getRealPath:(e,t)=>{try{return t?yqi.default.realpathSync.native(e):yqi.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===rNr.default.sep&&t.length-e.length>rNr.default.sep.length,poll:(e,t=vZa)=>CZa.retry.stat(t)(e,{bigint:!0}).catch(ZY.lang.noop),readdir:async(e,t,r=1/0,n=1/0,i,o)=>{if(o&&r===1&&e in o){let s=o[e];return[s.directories,s.files]}else{let s=await PZa(e,{depth:r,limit:n,ignore:t,signal:i});return[s.directories,s.files]}}}},yl=ZY;var nNr=Ce(require("path"),1);var bqi=class{constructor(t,r,n){this.base=n,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||yl.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=AZa){return(()=>{let r=this.watcher._readyWait,n=[],i=new Set,o=async(a,u)=>{let c=this.options.ignoreInitial?[]:a,l=await this.eventsPopulate([...u]),p=this.eventsDeduplicate([...c,...l]);this.onTargetEvents(p)},s=yl.lang.debounce(()=>{this.watcher.isClosed()||(r=o(n,i),n=[],i=new Set)},t);return async(a,u="",c=!1)=>{c?await this.eventsPopulate([u],n,!0):i.add(u),r.then(s)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((n,i)=>{let[o,s]=i,a=r[s];return o===a||o===cu.CHANGE&&a===cu.ADD||(r[s]=o,n.push(i)),n},[])}async eventsPopulate(t,r=[],n=!1){return await Promise.all(t.map(async i=>{let o=await this.watcher._poller.update(i,this.options.pollingTimeout);await Promise.all(o.map(async s=>{r.push([s,i]),s===cu.ADD_DIR?await this.eventsPopulateAddDir(t,i,r,n):s===cu.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,i,r,n)}))})),r}async eventsPopulateAddDir(t,r,n=[],i=!1){if(i)return n;let o=this.options.recursive?this.options.depth??R_e:Math.min(1,this.options.depth??R_e),s=this.options.limit??_Nt,[a,u]=await yl.fs.readdir(r,this.options.ignore,o,s,this.watcher._closeSignal),c=[...a,...u];return await Promise.all(c.map(l=>{if(!this.watcher.isIgnored(l,this.options.ignore)&&!t.includes(l))return this.eventsPopulate([l],n,!0)})),n}async eventsPopulateUnlinkDir(t,r,n=[],i=!1){if(i)return n;for(let o of this.watcher._poller.stats.keys())yl.fs.isSubPath(r,o)&&(t.includes(o)||await this.eventsPopulate([o],n,!0));return n}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(cu.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!F_e&&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(cu.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(cu.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(nNr.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(cu.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(nNr.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(cu.UNLINK_DIR,t))}onTargetEvent(t){let[r,n]=t;r===cu.ADD?this.onTargetAdd(n):r===cu.ADD_DIR?this.onTargetAddDir(n):r===cu.CHANGE?this.onTargetChange(n):r===cu.UNLINK?this.onTargetUnlink(n):r===cu.UNLINK_DIR&&this.onTargetUnlinkDir(n)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,n=!1){return this.handlerBatched(t,r,n)}onWatcherChange(t=tLe.CHANGE,r){if(this.watcher.isClosed())return;let n=nNr.default.resolve(this.folderPath,r||"");this.filePath&&n!==this.folderPath&&n!==this.filePath||this.watcher.isIgnored(n,this.options.ignore)||this.onWatcherEvent(t,n)}onWatcherError(t){dqi&&t.code==="EPERM"?this.onWatcherChange(tLe.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(xNt.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(xNt.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(tLe.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&F_e&&this.options.native!==!1?this.options.depth??R_e:Math.min(1,this.options.depth??R_e),n=this.options.limit??_Nt,[i,o]=await yl.fs.readdir(this.folderPath,this.options.ignore,r,n,this.watcher._closeSignal,this.options.readdirMap),s=[this.folderPath,...i,...o];await Promise.all(s.map(a=>{if(!this.watcher._poller.stats.has(a)&&!this.watcher.isIgnored(a,this.options.ignore))return this.onWatcherEvent(tLe.CHANGE,a,t)}))}}},TZa=bqi;var _T={interval:100,intervalId:void 0,fns:new Map,init:()=>{_T.intervalId||(_T.intervalId=setInterval(_T.resolve,_T.interval))},reset:()=>{_T.intervalId&&(clearInterval(_T.intervalId),delete _T.intervalId)},add:(e,t)=>{_T.fns.set(e,Date.now()+t),_T.init()},remove:e=>{_T.fns.delete(e)},resolve:()=>{if(!_T.fns.size)return _T.reset();let e=Date.now();for(let[t,r]of _T.fns)r>=e||(_T.remove(t),t())}},BNt=_T;var PNt=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=mqi){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{let p=this._watcher._poller.paths.find(n||-1,d=>d!==i);if(p&&p!==i){if(yl.fs.getRealPath(i,!0)===p)return;this._watcher.event(o.rename,p,i)}else this._watcher.event(o.add,i)};if(!n)return a();let u=()=>{s.add.delete(n),BNt.remove(c)},c=()=>{u(),a()};BNt.add(c,r);let l=()=>{let p=s.unlink.get(n);if(!p)return;u();let d=p();i===d?o.change&&this._watcher._poller.stats.has(i)&&this._watcher.event(o.change,i):this._watcher.event(o.rename,d,i)};s.add.set(n,l),l()}getLockUnlink(t,r=mqi){let{ino:n,targetPath:i,events:o,locks:s}=t,a=()=>{this._watcher.event(o.unlink,i)};if(!n)return a();let u=()=>{s.unlink.delete(n),BNt.remove(c)},c=()=>{u(),a()};BNt.add(c,r);let l=()=>(u(),i);s.unlink.set(n,l),s.add.get(n)?.()}getLockTargetAdd(t,r){let n=this._watcher._poller.getIno(t,cu.ADD,YY.FILE);return this.getLockAdd({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let n=this._watcher._poller.getIno(t,cu.ADD_DIR,YY.DIR);return this.getLockAdd({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let n=this._watcher._poller.getIno(t,cu.UNLINK,YY.FILE);return this.getLockUnlink({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let n=this._watcher._poller.getIno(t,cu.UNLINK_DIR,YY.DIR);return this.getLockUnlink({ino:n,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}}};PNt.DIR_EVENTS={add:cu.ADD_DIR,rename:cu.RENAME_DIR,unlink:cu.UNLINK_DIR};PNt.FILE_EVENTS={add:cu.ADD,change:cu.CHANGE,rename:cu.RENAME,unlink:cu.UNLINK};var DZa=PNt;var vqi=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(yl.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let n=this.map.get(t);if(yl.lang.isSet(n)){let i=n.delete(r);return n.size||this.map.delete(t),i}else if(n===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let n=this.map.get(t);if(yl.lang.isSet(n))return Array.from(n).find(r);if(r(n))return n}}get(t){return this.map.get(t)}has(t,r){if(yl.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let n=this.map.get(t);return yl.lang.isSet(n)?n.has(r):n===r}return!1}set(t,r){if(this.map.has(t)){let n=this.map.get(t);yl.lang.isSet(n)?n.add(r):n!==r&&this.map.set(t,new Set([n,r]))}else this.map.set(t,r);return this}},Eqi=vqi;var Iqi=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}},RZa=Iqi;var wqi=class{constructor(){this.inos={},this.paths=new Eqi,this.stats=new Map}getIno(t,r,n){let i=this.inos[r];if(!i)return;let o=i[t];if(o&&!(n&&o[1]!==n))return o[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let n=await yl.fs.poll(t,r);if(!(!n||!(n.isFile()||n.isDirectory())))return new RZa(n)}reset(){this.inos={},this.paths=new Eqi,this.stats=new Map}async update(t,r){let n=this.getStats(t),i=await this.poll(t,r);if(this.updateStats(t,i),!n&&i){if(i.isFile())return this.updateIno(t,cu.ADD,i),[cu.ADD];if(i.isDirectory())return this.updateIno(t,cu.ADD_DIR,i),[cu.ADD_DIR]}else if(n&&!i){if(n.isFile())return this.updateIno(t,cu.UNLINK,n),[cu.UNLINK];if(n.isDirectory())return this.updateIno(t,cu.UNLINK_DIR,n),[cu.UNLINK_DIR]}else if(n&&i){if(n.isFile()){if(i.isFile())return n.ino===i.ino&&!n.size&&!i.size?[]:(this.updateIno(t,cu.CHANGE,i),[cu.CHANGE]);if(i.isDirectory())return this.updateIno(t,cu.UNLINK,n),this.updateIno(t,cu.ADD_DIR,i),[cu.UNLINK,cu.ADD_DIR]}else if(n.isDirectory()){if(i.isFile())return this.updateIno(t,cu.UNLINK_DIR,n),this.updateIno(t,cu.ADD,i),[cu.UNLINK_DIR,cu.ADD];if(i.isDirectory())return n.ino===i.ino?[]:(this.updateIno(t,cu.UNLINK_DIR,n),this.updateIno(t,cu.ADD_DIR,i),[cu.UNLINK_DIR,cu.ADD_DIR])}}return[]}updateIno(t,r,n){let i=this.inos[r]=this.inos[r]||(this.inos[r]={}),o=n.isFile()?YY.FILE:YY.DIR;i[t]=[n.ino,o]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let n=this.stats.get(t)?.ino||-1;this.paths.delete(n,t),this.stats.delete(t)}}},Cqi=wqi;var _qi=class e extends FZa.EventEmitter{constructor(t,r,n){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(CT.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(i=>this.on(CT.CLOSE,i)),this._readyWait=new Promise(i=>this.on(CT.READY,i)),this._locker=new DZa(this),this._roots=new Set,this._poller=new Cqi,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,n)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(yl.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(CT.CLOSE))}error(t){if(this.isClosed())return!1;let r=yl.lang.castError(t);return this.emit(CT.ERROR,r)}event(t,r,n){return this.isClosed()?!1:(this.emit(CT.ALL,t,r,n),this.emit(t,r,n))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(CT.READY))}pollerExists(t,r){for(let n of this._pollers)if(n.targetPath===t&&yl.lang.isShallowEqual(n.options,r))return!0;return!1}subwatcherExists(t,r){for(let n of this._subwatchers)if(n.targetPath===t&&yl.lang.isShallowEqual(n.options,r))return!0;return!1}watchersClose(t,r,n=!0){if(t){let i=this._watchers[t];if(i)for(let o of[...i])r&&o.filePath!==r||this.watcherClose(o);if(n)for(let o in this._watchers)yl.fs.isSubPath(t,o)&&this.watchersClose(o,r,!1)}else for(let i in this._watchers)this.watchersClose(i,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,n]of t)this.watchPath(r,n.options,n.handler)}async watcherAdd(t,r){let{folderPath:n}=t;(this._watchers[n]=this._watchers[n]||[]).push(t);let o=new TZa(this,t,r);return await o.init(),o}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let o=r.indexOf(t);r.splice(o,1),r.length||delete this._watchers[t.folderPath]}let n=t.filePath||t.folderPath;this._roots.has(n)&&(this._watchersRestorable[n]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=yl.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,n,i){if(this._watchers[t]?.find(a=>a.handler===n&&(!a.filePath||a.filePath===i)&&a.options.ignore===r.ignore&&!!a.options.native==!!r.native&&(!r.recursive||a.options.recursive)))return!0;let s=rLe.default.dirname(t);for(let a=1;a<1/0;a++){if(this._watchers[s]?.find(l=>(a===1||l.options.recursive&&a<=(l.options.depth??R_e))&&l.handler===n&&(!l.filePath||l.filePath===i)&&l.options.ignore===r.ignore&&!!l.options.native==!!r.native&&(!r.recursive||l.options.recursive&&F_e&&l.options.native!==!1)))return!0;if(!F_e)break;let c=rLe.default.dirname(t);if(s===c)break;s=c}return!1}async watchDirectories(t,r,n,i,o){if(this.isClosed())return;t=yl.lang.uniq(t).sort();let s;for(let a of t)if(!this.isIgnored(a,r.ignore)&&!this.watcherExists(a,r,n,i))try{let u=!r.recursive||F_e&&r.native!==!1?r:{...r,recursive:!1},l={watcher:iNr.default.watch(a,u),handler:n,options:r,folderPath:a,filePath:i},p=s=await this.watcherAdd(l,o);if(this._roots.has(i||a)){let f={...r,ignoreInitial:!0,recursive:!1},m=rLe.default.dirname(a),h=a;await this.watchDirectories([m],f,n,h,p)}}catch(u){this.error(u)}return s}async watchDirectory(t,r,n,i,o){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||F_e&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,n,i,o));{r={...r,recursive:!0};let s=r.depth??R_e,a=r.limit??_Nt,[u]=await yl.fs.readdir(t,r.ignore,s,a,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let c=await this.watchDirectories([t],r,n,i,o);if(u.length){let l=yl.fs.getDepth(t);for(let p of u){let d=yl.fs.getDepth(p),f=Math.max(0,s-(d-l)),m={...r,depth:f};await this.watchDirectories([p],m,n,i,o||c)}}})}}}async watchFileOnce(t,r,n){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let i={targetPath:t,options:r},o=(c,l)=>{l===t&&(u(),n())},s=new e(o),a=()=>{this._subwatchers.add(i),this.on(CT.CLOSE,u),s.watchFile(t,r,o)},u=()=>{this._subwatchers.delete(i),this.removeListener(CT.CLOSE,u),s.close()};return a()}async watchFile(t,r,n){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let i=rLe.default.dirname(t);return this.watchDirectory(i,r,n,t)}async watchPollingOnce(t,r,n){if(this.isClosed())return;let i=!1,o=new Cqi,s=await this.watchPolling(t,r,async()=>{i||!(await o.update(t,r.pollingTimeout)).length||i||(i=!0,s(),n())})}async watchPolling(t,r,n){if(this.isClosed())return yl.lang.noop;if(this.pollerExists(t,r))return yl.lang.noop;let i={...r,interval:r.pollingInterval??bZa},o={targetPath:t,options:r},s=()=>{this._pollers.add(o),this.on(CT.CLOSE,a),iNr.default.watchFile(t,i,n)},a=()=>{this._pollers.delete(o),this.removeListener(CT.CLOSE,a),iNr.default.unwatchFile(t,n)};return yl.lang.attempt(s),()=>yl.lang.attempt(a)}async watchUnknownChild(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchFileOnce(t,r,i)}async watchUnknownTarget(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchPollingOnce(t,r,i)}async watchPaths(t,r,n){if(this.isClosed())return;if(t=yl.lang.uniq(t).sort(),t.every((o,s)=>t.every((a,u)=>u===s||!yl.fs.isSubPath(o,a))))await Promise.all(t.map(o=>this.watchPath(o,r,n)));else for(let o of t)await this.watchPath(o,r,n)}async watchPath(t,r,n){if(this.isClosed()||(t=rLe.default.resolve(t),this.isIgnored(t,r.ignore)))return;let i=await yl.fs.poll(t,r.pollingTimeout);if(i){if(i.isFile())return this.watchFile(t,r,n);if(i.isDirectory())return this.watchDirectory(t,r,n);this.error(`"${t}" is not supported`)}else{let o=rLe.default.dirname(t);return(await yl.fs.poll(o,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,n):this.watchUnknownTarget(t,r,n)}}async watch(t,r,n=yl.lang.noop){if(yl.lang.isFunction(t))return this.watch([],{},t);if(yl.lang.isUndefined(t))return this.watch([],r,n);if(yl.lang.isFunction(r))return this.watch(t,{},r);if(yl.lang.isUndefined(r))return this.watch(t,{},n);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let i=yl.lang.castArray(t);i.forEach(o=>this._roots.add(o)),await this.watchPaths(i,r,n),!this.isClosed()&&(n!==yl.lang.noop&&this.on(CT.ALL,n),r.readdirMap=void 0,this.ready())}},oNr=_qi;bNr();Wt();var qrt=require("fs/promises"),Leu=require("os"),Ueu=Ce(require("path"),1),rmd=".fern",nmd="logs";function imd(){return"cli@4.0.1"}var uLe=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=We(Vt.of((0,Leu.homedir)()),Se.of(rmd)),r=We(t,Se.of(nmd));await nr(r)||await(0,qrt.mkdir)(r,{recursive:!0});let i=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=We(r,Se.of(i));let o=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${Ueu.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
2129
2129
|
`);await(0,qrt.writeFile)(this.logFilePath,o,"utf-8"),this.initialized=!0}getLogFilePath(){return this.logFilePath}async writeEntry(t){if(!this.initialized||!this.logFilePath)return;let r=JSON.stringify(t)+`
|
|
2130
2130
|
`;try{await(0,qrt.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 n={timestamp:t.timestamp,source:imd(),level:r,eventType:t.type,data:{durationMs:t.durationMs,metadata:t.metadata}};await this.writeEntry(n)}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 n={type:"cli_reload_finish",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(n)}async logCliDocsGeneration(t,r){let n={type:"cli_docs_generation",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(n)}async logCliValidation(t,r){let n={type:"cli_validation",timestamp:new Date().toISOString(),durationMs:t,metadata:{success:r}};await this.logCliMetric(n)}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 $qi={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"};function zeu(e){let t=omd();if(t==null)return;let{port:r,debugLogger:n,getDocsLoadResponse:i}=e,o=new Map;function s(u){let c=JSON.stringify(u),l=[];for(let[p]of o)try{p.send(c)}catch{l.push(p)}for(let p of l){let d=o.get(p);d&&(clearInterval(d.pingInterval),o.delete(p))}}let a=t.serve({port:r,fetch(u,c){if(u.method==="OPTIONS")return new Response(null,{status:204,headers:$qi});let l=new URL(u.url);if(u.headers.get("upgrade")?.toLowerCase()==="websocket"){c.upgrade(u,{data:{connectionId:`${Date.now()}`}});return}if(u.method==="POST"&&l.pathname==="/v2/registry/docs/load-with-url")return new Response(JSON.stringify(i()),{headers:{"Content-Type":"application/json",...$qi}});let p=/^\/_local\/(.*)/.exec(l.pathname);return u.method==="GET"&&p!=null?new Response(t.file(`/${p[1]}`),{headers:$qi}):new Response("Not Found",{status:404})},websocket:{open(u){let{connectionId:c}=u.data,l=setInterval(()=>{let p=o.get(u);if(!p)return;let d=Date.now();if(d-p.lastPong>9e4){u.close();return}try{u.send(JSON.stringify({type:"ping",timestamp:d}))}catch{u.close()}},3e4);o.set(u,{pingInterval:l,lastPong:Date.now()});try{u.send(JSON.stringify({type:"connected",connectionId:c}))}catch{}},message(u,c){try{let l=JSON.parse(c.toString());if(l.type==="pong"){let p=o.get(u);p&&(p.lastPong=Date.now())}else uLe.isMetricsMessage(l)&&n.logFrontendMetrics(l)}catch{}},close(u){let c=o.get(u);c&&(clearInterval(c.pingInterval),o.delete(u))}}});return{sendData:s,stop:u=>a.stop(u)}}function omd(){return globalThis.Bun}Wt();var BGi=Ce(r9i(),1),Lsu=Ce(AGi(),1),Aj=require("fs/promises"),Usu=require("os"),zsu=Ce(lC(),1),Vsu=Ce(ksu(),1),P2r=process.platform==="win32",OGi=Te.cyan("[docs]:"),jyd="etag",Qyd=23,Msu=e=>e.padEnd(Qyd," "),Nyd="preview",kyd="app-preview",Myd="bundle",Lyd=".next",Uyd="standalone",zyd=".fern",Vyd="packages/fern-docs/bundle/.next/server/instrumentation.js",qyd=".npmrc",Gyd=".pnpmfile.cjs",Wyd="pnpm-workspace.yaml",$yd='Cannot find matching keyid: {"signatures":';function Hyd(){return We(Vt.of((0,Usu.homedir)()),Se.of(zyd))}function unt({app:e=!1}){return We(Hyd(),Se.of(e?kyd:Nyd))}function W_e({app:e=!1}){return We(unt({app:e}),Se.of(e?Lyd:Myd))}function c2t({app:e=!1}){return We(W_e({app:e}),Se.of(Uyd))}function Kyd({app:e=!1}){return We(c2t({app:e}),Se.of(Vyd))}function Jyd({app:e=!1}){return We(c2t({app:e}),Se.of(Wyd))}function Yyd({app:e=!1}){return We(c2t({app:e}),Se.of(Gyd))}function Xyd({app:e=!1}){return We(c2t({app:e}),Se.of(qyd))}function ALe(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function Zyd({app:e=!1}){return We(unt({app:e}),Se.of(jyd))}var ebd=`module.exports = {
|
|
2131
2131
|
hooks: {
|
|
@@ -2901,7 +2901,7 @@ For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides
|
|
|
2901
2901
|
Run ${Te.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
2902
2902
|
Run ${Te.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),dHe(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function fko({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!$0c(e))return;let i=t??"",o=e.filter(a=>a.isUpgradeAvailable);r!=null&&(o=o.slice(0,r+1));let s=o.sort((a,u)=>a.generatorName.localeCompare(u.generatorName)||a.currentVersion.localeCompare(u.currentVersion));for(let a of s)i+=`
|
|
2903
2903
|
${await Q5h(a.generatorName)} (${a.apiName!=null?"API: "+a.apiName+", ":""}Group: ${a.generatorGroup}) `+Te.dim(a.currentVersion)+Te.reset(" \u2192 ")+Te.green(a.latestVersion);return i+=`
|
|
2904
|
-
`,n?dHe(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Q5h(e){let r=await new W0c.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 N5h({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){if(t.length===1){let a={type:"singleApi",versions:{}};return await K0c({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(u,c,l,p)=>{a.versions[c]==null&&(a.versions[c]={});let d=_Me(l.name);if(d==null){p.logger.debug(`Skipping unknown generator: ${l.name}`);return}let f=await y2({generatorName:d,cliVersion:e.environment.packageVersion,currentGeneratorVersion:l.version,channel:i,includeMajor:o,context:p});f!=null&&(a.versions[c][l.name]={previousVersion:l.version,latestVersion:f})},generatorFilter:r,groupFilter:n}),a}let s={type:"multiApi",versions:{}};return await K0c({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(a,u,c,l)=>{if(a==null)return;s.versions[a]==null&&(s.versions[a]={}),s.versions[a][u]==null&&(s.versions[a][u]={});let p=_Me(c.name);if(p==null){l.logger.debug(`Skipping unknown generator: ${c.name}`);return}let d=await y2({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:o,context:l});d!=null&&(s.versions[a][u][c.name]={previousVersion:c.version,latestVersion:d})},generatorFilter:r,groupFilter:n}),s}async function K0c({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async o=>{await e.runTaskForWorkspace(o,async s=>{let a=await b2({absolutePathToWorkspace:o.absoluteFilePath,context:s});if(a==null||a.groups==null)return;let u=n!=null?KC(n):void 0;for(let c of a.groups)if(!(i!=null&&c.groupName!==i))for(let l of c.generators)u!=null&&l.name!==u||await r(o.workspaceName,c.groupName,l,s)})}))}function J0c(e,t,r){let n=[];for(let[i,o]of Object.entries(e))for(let[s,a]of Object.entries(o)){r.debug(`Checking if ${s} in group ${i} has an upgrade available...`);let u=YF(a.latestVersion,a.previousVersion);r.debug(`Latest version: ${a.latestVersion}. `+(u?"Upgrade available.":"No upgrade available.")),n.push({generatorName:s,generatorGroup:i,apiName:t,isUpgradeAvailable:u,currentVersion:a.previousVersion,latestVersion:a.latestVersion})}return n}async function YVn({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){let s=[];if(e!=null){let a=await N5h({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o});if(a.type==="multiApi")for(let[u,c]of Object.entries(a.versions))s.push(...J0c(c,u,t.logger));else s.push(...J0c(a.versions,void 0,t.logger))}return s}async function _Re({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:XTt(e.packageName,{version:t?"prerelease":"latest"})}var Y0c=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],XVn=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Un.Info;isLocal;stdoutRedirector=new JVn;jsonMode=!1;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new n2e(t,r),this.isLocal=n??!1;let i=this.getPackageName(),o=this.getPackageVersion(),s=this.getCliName();(i==null||o==null||s==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:o,cliName:s}}getPackageName(){return"fern-api"}getPackageVersion(){return"4.0.
|
|
2904
|
+
`,n?dHe(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Q5h(e){let r=await new W0c.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 N5h({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){if(t.length===1){let a={type:"singleApi",versions:{}};return await K0c({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(u,c,l,p)=>{a.versions[c]==null&&(a.versions[c]={});let d=_Me(l.name);if(d==null){p.logger.debug(`Skipping unknown generator: ${l.name}`);return}let f=await y2({generatorName:d,cliVersion:e.environment.packageVersion,currentGeneratorVersion:l.version,channel:i,includeMajor:o,context:p});f!=null&&(a.versions[c][l.name]={previousVersion:l.version,latestVersion:f})},generatorFilter:r,groupFilter:n}),a}let s={type:"multiApi",versions:{}};return await K0c({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(a,u,c,l)=>{if(a==null)return;s.versions[a]==null&&(s.versions[a]={}),s.versions[a][u]==null&&(s.versions[a][u]={});let p=_Me(c.name);if(p==null){l.logger.debug(`Skipping unknown generator: ${c.name}`);return}let d=await y2({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:o,context:l});d!=null&&(s.versions[a][u][c.name]={previousVersion:c.version,latestVersion:d})},generatorFilter:r,groupFilter:n}),s}async function K0c({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async o=>{await e.runTaskForWorkspace(o,async s=>{let a=await b2({absolutePathToWorkspace:o.absoluteFilePath,context:s});if(a==null||a.groups==null)return;let u=n!=null?KC(n):void 0;for(let c of a.groups)if(!(i!=null&&c.groupName!==i))for(let l of c.generators)u!=null&&l.name!==u||await r(o.workspaceName,c.groupName,l,s)})}))}function J0c(e,t,r){let n=[];for(let[i,o]of Object.entries(e))for(let[s,a]of Object.entries(o)){r.debug(`Checking if ${s} in group ${i} has an upgrade available...`);let u=YF(a.latestVersion,a.previousVersion);r.debug(`Latest version: ${a.latestVersion}. `+(u?"Upgrade available.":"No upgrade available.")),n.push({generatorName:s,generatorGroup:i,apiName:t,isUpgradeAvailable:u,currentVersion:a.previousVersion,latestVersion:a.latestVersion})}return n}async function YVn({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o}){let s=[];if(e!=null){let a=await N5h({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:o});if(a.type==="multiApi")for(let[u,c]of Object.entries(a.versions))s.push(...J0c(c,u,t.logger));else s.push(...J0c(a.versions,void 0,t.logger))}return s}async function _Re({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:XTt(e.packageName,{version:t?"prerelease":"latest"})}var Y0c=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],XVn=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Un.Info;isLocal;stdoutRedirector=new JVn;jsonMode=!1;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new n2e(t,r),this.isLocal=n??!1;let i=this.getPackageName(),o=this.getPackageVersion(),s=this.getCliName();(i==null||o==null||s==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:o,cliName:s}}getPackageName(){return"fern-api"}getPackageVersion(){return"4.0.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Te.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Jg}failWithoutThrowing(t,r){this.didSucceed=!1,KOt({message:t,error:r,logger:this.logger})}enableJsonMode(){this.jsonMode||(this.jsonMode=!0,this.stdoutRedirector.redirect())}get isJsonMode(){return this.jsonMode}writeJsonToStdout(t){this.stdoutRedirector.restore(),process.stdout.write(JSON.stringify(t,null,2)+`
|
|
2905
2905
|
`),this.jsonMode&&this.stdoutRedirector.redirect()}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await rHe()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await H0c({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2906
2906
|
`)||(r+=`
|
|
2907
2907
|
`),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=eli(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new Y5t(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 n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(o){throw o.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,o),new Jg}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await rHe()).sendEvent(t)}logger=TP((t,...r)=>this.log(t,...r));stderr=TP((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=X0c(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?X0c(this.longestWorkspaceName):r).length,i=r.padEnd(n),o=Y0c[this.numTasks++%Y0c.length],s=Te.hex(o)(i);return{...this.constructTaskInit(),logPrefix:s}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===Od.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 n=t.filter(i=>nS.indexOf(i.level)>=nS.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===Un.Debug,stderr:r||this.jsonMode})}_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 _Re({cliEnvironment:this.environment,includePreReleases:t}),n=YF(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},o=await YVn({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:o}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await lko({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Te.yellow("?"),style:{answer:i=>Te.cyan(i),message:i=>Te.bold(i),highlight:i=>Te.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
|