fern-api 0.85.1 → 0.86.0

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.
Files changed (2) hide show
  1. package/cli.cjs +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -2161,7 +2161,7 @@ ${Zby.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&k_f(th
2161
2161
  `+$ua.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?$ua.default.cyan(ugy(t,this.opt.mask)):$ua.default.italic($ua.default.dim("[hidden]")):this.opt.mask?ugy(t,this.opt.mask):$ua.default.italic($ua.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 Vjs=fa(Gue(),1);var u0y=fa(qhf(),1),Ljs=require("child_process"),oZa=require("fs"),Qjs=fa(require("path"),1),s0y=fa(require("os"),1),c0y=require("crypto"),byf=fa(a0y(),1);var Fjs=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var KGo=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var xjs=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var zjs=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function Ujs(e="",t,r){let n=new gyf(e,r);n.runAsync((i,a)=>{if(i)setImmediate(t,i,void 0);else try{n.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function o0y(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function ykD(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 gyf=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=ykD(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??s0y.default.tmpdir(),r=(0,c0y.randomUUID)(),n=o0y(this.fileOptions.prefix),i=o0y(this.fileOptions.postfix),a=`${n}${r}${i}`,o=Qjs.default.resolve(t,a),c=Qjs.default.resolve(t)+Qjs.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let d={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(d.mode=this.fileOptions.mode),(0,oZa.writeFileSync)(this.tempFile,this.text,d)}catch(t){throw new Fjs(t)}}readTemporaryFile(){try{let t=(0,oZa.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,u0y.detect)(t)??"utf8";byf.default.encodingExists(r)||(r="utf8"),this.text=byf.default.decode(t,r)}}catch(t){throw new xjs(t)}}removeTemporaryFile(){try{(0,oZa.unlinkSync)(this.tempFile)}catch(t){throw new zjs(t)}}launchEditor(){try{let t=(0,Ljs.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new KGo(t)}}launchEditorAsync(t){try{(0,Ljs.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new KGo(r)}}};var l0y=fa(fnt(),1);var $Go=class extends Jue{_run(t){this.done=t,this.editorResult=new l0y.Subject;let r=Ebe(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"?Vjs.default.dim("Received"):Vjs.default.dim("Press <enter> to launch your preferred editor."),t&&(r=Vjs.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),Ujs(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 h0y=require("stream");var p0y=fa(require("readline"),1),_0y=fa(d0y(),1),kua=class{constructor(t){this.rl||=p0y.default.createInterface(bkD(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 bkD(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 _0y.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var YGo=class extends kua{constructor(t={}){super(t),this.log=new h0y.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return TGo(this.rl,this.bottomBar.split(`
2162
2162
  `).length),this}updateBottomBar(t){return TGo(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+`
2163
2163
  `}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&&fjs(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var q6=fa(fnt(),1),b0y=fa(eGo(),1);var Wjs=fa(fnt(),1),y0y=fa(eGo(),1),Hjs=function(e,t,r){return typeof e[t]!="function"?(0,Wjs.of)(e):(0,Wjs.from)((0,y0y.default)(e[t])(r).then(n=>(e[t]=n,e)))};var v0y={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,a,o)=>{i==="__proto__"||i==="constructor"||(a===o.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},uZa=class extends kua{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,q6.from)(t):(0,q6.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,q6.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,q6.from)([t]),this.process=n.pipe((0,q6.concatMap)(this.processQuestion.bind(this)),(0,q6.publish)()),this.process.connect(),this.process.pipe((0,q6.reduce)((i,a)=>(v0y.set(i,a.name,a.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,q6.defer)(()=>(0,q6.of)(t).pipe((0,q6.concatMap)(this.setDefaultType.bind(this)),(0,q6.concatMap)(this.filterIfRunnable.bind(this)),(0,q6.concatMap)(()=>Hjs(t,"message",this.answers)),(0,q6.concatMap)(()=>Hjs(t,"default",this.answers)),(0,q6.concatMap)(()=>Hjs(t,"choices",this.answers)),(0,q6.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,q6.defer)(()=>(0,q6.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,q6.defer)(()=>(0,q6.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&v0y.get(this.answers,t.name)!==void 0)return q6.EMPTY;if(t.when===!1)return q6.EMPTY;if(typeof t.when!="function")return(0,q6.of)(t);let{answers:r}=this;return(0,q6.defer)(()=>(0,q6.from)((0,b0y.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,q6.filter)(n=>n!=null)))}};function g0y(e){let t=function(r,n){let i;try{i=new uZa(t.prompts,e)}catch(o){return Promise.reject(o)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",RGo),this.registerPrompt("input",Kua),this.registerPrompt("number",NGo),this.registerPrompt("confirm",FGo),this.registerPrompt("rawlist",xGo),this.registerPrompt("expand",zGo),this.registerPrompt("checkbox",QGo),this.registerPrompt("password",LGo),this.registerPrompt("editor",$Go)},t.restoreDefaultPrompts(),t}var Oyf=g0y();function mkD(e,t){Oyf.registerPrompt(e,t)}function OkD(){Oyf.restoreDefaultPrompts()}var AkD={prompt:Oyf,ui:{BottomBar:YGo,Prompt:uZa},createPromptModule:g0y,registerPrompt:mkD,restoreDefaultPrompts:OkD,Separator:Pxe},Gjs=AkD;var mZa=require("path"),aOy=require("fs"),oOy=require("readline"),Mmy="posthog-node";function crC(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"]}={}){return a=>{if(!(i==="*"||i.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[h1s.POSTHOG_ID_TAG];if(c===void 0)return a;let d=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,d).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(A=>({...A,stacktrace:A.stacktrace?{...A.stacktrace,type:"raw",frames:(A.stacktrace.frames||[]).map(P=>({...P,platform:"node:javascript"}))}:void 0})),m={$exception_message:u[0]?.value||a.message,$exception_type:u[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:u[0]?.value||a.message,$sentry_exception_type:u[0]?.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:m}),a}}var h1s=class{constructor(t,r,n,i){this.name=Mmy,this.name=Mmy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(crC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};h1s.POSTHOG_ID_TAG="posthog_distinct_id";var l1s="0123456789abcdef",y1s=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,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 a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=l1s.charAt(this.bytes[r]>>>4),t+=l1s.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=l1s.charAt(this.bytes[r]>>>4),t+=l1s.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},cvf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??lrC()}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)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return y1s.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,y1s.ofInner(t)}},lrC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Imy,lvf=()=>frC().toString(),frC=()=>(Imy||(Imy=new cvf)).generate();function drC(e,t){let r=!1;return Object.assign(n=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function prC(e,t){global.process.on("uncaughtException",drC(e,t))}function _rC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var f1s,Bmy,d1s;function hrC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return d1s&&r.length===Bmy||(Bmy=r.length,d1s=r.reduce((n,i)=>{f1s||(f1s={});let a=f1s[i];if(a)n[a[0]]=a[1];else{let o=e(i);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[i];if(s&&u){n[s]=u,f1s[i]=[s,u];break}}}return n},{})),d1s}function yrC(e){return typeof Event<"u"&&uOy(e,Event)}function vrC(e){return sOy(e,"Object")}function bvf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return uOy(e,Error)}}function uOy(e,t){try{return e instanceof t}catch{return!1}}function brC(e){return sOy(e,"ErrorEvent")}function sOy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function grC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=cOy(a,r,n);return{$exception_list:await Promise.all(o.map(async s=>{let u=await ErC(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function cOy(e,t,r){let n=mrC(e,t,r);return n.cause?[n,...cOy(e,n.cause,r)]:[n]}function mrC(e,t,r){if(bvf(t))return t;if(e.synthetic=!0,vrC(t)){let i=OrC(t);if(i)return i;let a=ArC(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let n=r?.syntheticException||new Error(t);return n.message=`${t}`,n}function OrC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(bvf(r))return r}}function ArC(e){if("name"in e&&typeof e.name=="string"){let n=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(n+=` with message '${e.message}'`),n}else if("message"in e&&typeof e.message=="string")return e.message;let t=wrC(e);if(brC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=PrC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function PrC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function wrC(e,t=40){let r=Object.keys(jrC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return Tmy(n,t);for(let i=r.length;i>0;i--){let a=r.slice(0,i).join(", ");if(!(a.length>t))return i===r.length?a:Tmy(a,t)}return""}function Tmy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function jrC(e){return bvf(e)?{message:e.message,name:e.name,stack:e.stack,...qmy(e)}:yrC(e)?{type:e.type,target:Rmy(e.target),currentTarget:Rmy(e.currentTarget),...qmy(e)}:e}function qmy(e){if(typeof e=="object"&&e!==null){let t={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}else return{}}function Rmy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function ErC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=SrC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function SrC(e,t){return DrC(e(t.stack||"",1),e)}function DrC(e,t){let r=hrC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var CrC=2e3,vZa=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await grC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||lvf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(prC(this.onException.bind(this),this.onFatalError.bind(this)),_rC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(CrC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function MrC(e=process.argv[1]?(0,mZa.dirname)(process.argv[1]):process.cwd(),t=mZa.sep==="\\"){let r=t?Nmy(e):e;return n=>{if(!n)return;let i=t?Nmy(n):n,{dir:a,base:o,ext:c}=mZa.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let d=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${d}`:d}return d}}function Nmy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var v1s=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)}}},_1s=new v1s(25),lOy=new v1s(20),gvf=7,IrC=1e3,BrC=1e4;async function TrC(e){let t={};for(let i=e.length-1;i>=0;i--){let a=e[i],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||FrC(o)||xrC(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(lOy.get(i))continue;let a=t[i];if(!a)continue;a.sort((d,s)=>d-s);let o=QrC(a);if(o.every(d=>zrC(i,d)))continue;let c=LrC(_1s,i,{});n.push(qrC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&RrC(e,_1s),_1s.reduce(),e}function qrC(e,t,r){return new Promise(n=>{let i=(0,aOy.createReadStream)(e),a=(0,oOy.createInterface)({input:i});function o(){i.destroy(),n()}let c=0,d=0,s=t[d];if(s===void 0){o();return}let u=s[0],l=s[1];function m(){lOy.set(e,1),a.close(),a.removeAllListeners(),o()}i.on("error",m),a.on("error",m),a.on("close",o),a.on("line",A=>{if(c++,!(c<u)&&(r[c]=UrC(A,0),c>=l)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let P=t[d];if(P===void 0){a.close(),a.removeAllListeners();return}u=P[0],l=P[1]}})})}function RrC(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;NrC(r.lineno,r,n)}}function NrC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=fOy(e);i<e;i++){let a=r[i];if(a===void 0){Fmy(t);return}t.pre_context.push(a)}if(r[e]===void 0){Fmy(t);return}t.context_line=r[e];let n=dOy(e);t.post_context=[];for(let i=e+1;i<=n;i++){let a=r[i];if(a===void 0)break;t.post_context.push(a)}}function Fmy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function FrC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function xrC(e){return e.lineno!==void 0&&e.lineno>BrC||e.colno!==void 0&&e.colno>IrC}function zrC(e,t){let r=_1s.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 QrC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=xmy(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let a=e[t+1];if(typeof a!="number")break;a<=n[1]?n[1]=a+gvf:(i.push(n),n=xmy(a)),t++}return i}function xmy(e){return[fOy(e),dOy(e)]}function fOy(e){return Math.max(1,e-gvf)}function dOy(e){return e+gvf}function LrC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function UrC(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 a=Math.min(i+140,n);return a>n-5&&(a=n),a===n&&(i=Math.max(a-140,0)),r=r.slice(i,a),i>0&&(r=`...${r}`),a<n&&(r+="..."),r}var VrC="4.18.0",Dxe;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(Dxe||(Dxe={}));var zmy;(function(e){e.Left="left",e.Right="right",e.Center="center"})(zmy||(zmy={}));var Qmy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(Qmy||(Qmy={}));var Lmy;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(Lmy||(Lmy={}));var Umy;(function(e){e.Html="html",e.Text="text"})(Umy||(Umy={}));var Vmy;(function(e){e.Number="number",e.Emoji="emoji"})(Vmy||(Vmy={}));var Wmy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(Wmy||(Wmy={}));var Hmy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(Hmy||(Hmy={}));var Gmy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(Gmy||(Gmy={}));var Jmy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(Jmy||(Jmy={}));var WrC=e=>{if("flags"in e){let t=GrC(e.flags),r=JrC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,pOy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,HrC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function HrC(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 GrC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,mvf(r)]).filter(([,t])=>t!==void 0)),JrC=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?pOy(n):void 0]}))},mvf=e=>e===void 0?void 0:e.variant??e.enabled,pOy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},KrC=1,$rC=new Set(["61be3dd8","96f6df5f","8cfdba9b","bf027177","e59430a8","7fa5500b","569798e9","04809ff7","0ebc61a5","32de7f98","3beeb69a","12d34ad9","733853ec","0645bb64","5dcbee21","b1f95fa3","2189e408","82b460c2","3a8cc979","29ef8843","2cdbf767","38084b54","50f9f8de","41d0df91","5c236689","c11aedd3","ada46672","f4331ee1","42fed62a","c957462c","d62f705a","e0162666","01b3e5cf","441cef7f","bb9cafee","8f348eb0","b2553f3a","97469d7d","39f21a76","03706dcc","27d50569","307584a7","6433e92e","150c7fbb","49f57f22","3772f65b","01eb8256","3c9e9234","f853c7f7","c0ac4b67","cd609d40","10ca9b1a","8a87f11b","8e8e5216","1f6b63b3","db7943dd","79b7164c","07f78e33","2d21b6fd","952db5ee","a7d3b43f","1924dd9c","84e1b8f6","dff631b6","c5aa8a79","fa133a95","498a4508","24748755","98f3d658","21bbda67","7dbfed69","be3ec24c","fc80b8e2","75cc0998"]),YrC="utf8";function XrC(e,t){if(!e||typeof e!="string"||ZrC(e))throw new Error(t)}function ZrC(e){return e.trim().length===0}function krC(e){return e?.replace(/\/+$/,"")}async function enC(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 Kmy(){return new Date().getTime()}function uvf(){return new Date().toISOString()}function b1s(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function tnC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function rnC(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16).padStart(8,"0")}function nnC(e,t=0,r){let n=rnC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function $my(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var oJo=String.fromCharCode,Ymy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p1s={};function inC(e,t){if(!p1s[e]){p1s[e]={};for(let r=0;r<e.length;r++)p1s[e][e.charAt(r)]=r}return p1s[e][t]}var hZa={compressToBase64:function(e){if(e==null)return"";let t=hZa._compress(e,6,function(r){return Ymy.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:hZa._decompress(e.length,32,function(t){return inC(Ymy,e.charAt(t))})},compress:function(e){return hZa._compress(e,16,function(t){return oJo(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],o,c,d="",s="",u="",l=2,m=3,A=2,P=0,C=0,I;for(I=0;I<e.length;I+=1)if(d=e.charAt(I),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=m++,i[d]=!0),s=u+d,Object.prototype.hasOwnProperty.call(n,s))u=s;else{if(Object.prototype.hasOwnProperty.call(i,u)){if(u.charCodeAt(0)<256){for(o=0;o<A;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=u.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<A;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[u]}else for(c=n[u],o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++),n[s]=m++,u=String(d)}if(u!==""){if(Object.prototype.hasOwnProperty.call(i,u)){if(u.charCodeAt(0)<256){for(o=0;o<A;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=u.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<A;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[u]}else for(c=n[u],o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++)}for(c=2,o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;for(;;)if(P=P<<1,C==t-1){a.push(r(P));break}else C++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:hZa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},o=4,c=4,d=3,s="",u,l,m,A,P,C,I;for(u=0;u<3;u+=1)n[u]=u;for(m=0,P=Math.pow(2,2),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;I=oJo(m);break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;I=oJo(m);break;case 2:return""}for(n[3]=I,l=I,i.push(I);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,d),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(I=m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=oJo(m),I=c-1,o--;break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=oJo(m),I=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,d),d++),n[I])s=n[I];else if(I===c)s=l+l.charAt(0);else return null;i.push(s),n[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,d),d++)}}},fvf=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)}},bZa=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()}},uJo=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function Xmy(e){if(e instanceof bZa){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 svf(e){return typeof e=="object"&&(e instanceof bZa||e instanceof uJo)}function Zmy(e){return typeof e=="object"&&e instanceof bZa&&e.status===413}var dvf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(dvf||(dvf={}));var pvf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new fvf,this._isInitialized=!1,XrC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=krC(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.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:svf},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}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(Dxe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(Dxe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(Dxe.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",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){let r=lvf();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),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 a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}async captureStatelessImmediate(t,r,n,i){let a=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",a,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}async aliasStatelessImmediate(t,r,n,i){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,i)}groupIdentifyStateless(t,r,n,i,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...o||{}}});this.enqueue("capture",c,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.logMsgIfDebug(()=>console.error("Remote config could not be loaded",i)),this._events.emit("error",i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let c=nnC(this.apiKey,KrC,$rC)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,d={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,d,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>WrC(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,n,i,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let d=mvf(c.response);return d===void 0&&(d=!1),{response:d,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,n,i,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,n,i,a,o,[t]);if(!c)return;let d=c[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,n,i,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let d=await this.getDecide(t,r,n,i,c);if(d!==void 0)return d.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),d.quotaLimited?.includes(dvf.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:d?.requestId}):d}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","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(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return i&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(i))),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(Dxe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(Dxe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(Dxe.Props,this.props)})}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i=this.prepareMessage(t,r,n),a=this.getPersistedProperty(Dxe.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:i}),this.setPersistedProperty(Dxe.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=b1s(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={api_key:this.apiKey,batch:[this.prepareMessage(t,r,n)],sent_at:uvf()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${Kmy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,c=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(hZa.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(d){this._events.emit("error",d)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:uvf(),uuid:n?.uuid?n.uuid:lvf()};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 Xmy(t)})}async flush(){let t=$my([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),$my([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(Dxe.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),a=i.map(m=>m.message),o=()=>{let A=(this.getPersistedProperty(Dxe.Queue)||[]).slice(i.length);this.setPersistedProperty(Dxe.Queue,A),t=A},c={api_key:this.apiKey,batch:a,sent_at:uvf()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${Kmy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,u=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(hZa.compressToBase64(d))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:d},l={retryCheck:m=>Zmy(m)?!1:svf(m)};try{await this.fetchWithRetry(s,u,l)}catch(m){if(Zmy(m)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw m instanceof uJo||o(),this._events.emit("error",m),m}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let u=new AbortController;return setTimeout(()=>u.abort(),s),u.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,YrC)}catch{c=new TextEncoder().encode(o).length}return await enC(async()=>{let d=null;try{d=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(u){throw new uJo(u)}if(!(r.mode==="no-cors")&&(d.status<200||d.status>=400))throw new bZa(d,c);return d},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(Dxe.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!svf(i))throw i;await Xmy(i)}};return Promise.race([new Promise((i,a)=>{b1s(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.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}},_vf=tnC();if(!_vf){let e=Cmy();_vf=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var _Oy=_vf,g1s=class{constructor(t){this.factory=t}async getValue(){return this.value!==void 0?this.value:(this.initializationPromise===void 0&&(this.initializationPromise=(async()=>{try{let t=await this.factory();return this.value=t,t}finally{this.initializationPromise=void 0}})()),this.initializationPromise)}isInitialized(){return this.value!==void 0}async waitForInitialization(){this.isInitialized()||await this.getValue()}},hOy=new g1s(async()=>{try{return await import("crypto")}catch{return}});async function anC(){return await hOy.getValue()}var onC=new g1s(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await hOy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function unC(){return await onC.getValue()}async function snC(e){let t=await anC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await unC();if(r){let n=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var cnC=60*1e3,lnC=1152921504606847e3,fnC=["is_not"],yZa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},Kue=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},hvf=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=c.fetch||_Oy,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let d of this.featureFlags)if(t===d.key){c=d;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(d){d instanceof Kue?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async d=>{try{let s=await this.computeFlagLocally(d,t,r,n,i);a[d.key]=s;let u=await this.computeFeatureFlagPayloadLocally(d.key,s);u&&(o[d.key]=u)}catch(s){s instanceof Kue||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new Kue("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let d=this.groupTypeMapping[String(c)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new Kue("Flag has unknown group type index");if(!(d in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return await this.matchFeatureFlagProperties(t,n[d],s)}else return await this.matchFeatureFlagProperties(t,r,i)}async matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],o=!1,c,d=[...a].sort((s,u)=>{let l=!!s.variant,m=!!u.variant;return l&&m?0:l?-1:m?1:0});for(let s of d)try{if(await this.isConditionMatch(t,r,s,n)){let u=s.variant,l=i.multivariate?.variants||[];u&&l.some(m=>m.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof Kue)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new Kue("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i){let a=n.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let d=c.type,s=!1;if(d==="cohort"?s=vOy(c,i,this.cohorts,this.debugMode):s=yOy(c,i,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await kmy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await kmy(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{i=n+c.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:c.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(cnC,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new yZa(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new yZa(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new yZa(`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 r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof yZa&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=b1s(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,n=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;i=b1s(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function kmy(e,t,r=""){let n=await snC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/lnC}function yOy(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new Kue("Operator is_not_set is not supported")}else throw new Kue(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!fnC.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function d(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(i,o);case"is_not":return!c(i,o);case"is_set":return n in t;case"icontains":return String(o).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(i).toLowerCase());case"regex":return eOy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return eOy(String(i))&&String(o).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof i=="number"?i:null;if(typeof i=="string")try{s=parseFloat(i)}catch{}return s!=null&&o!=null?typeof o=="string"?d(o,String(i),a):d(o,s,a):d(String(o),String(i),a)}case"is_date_after":case"is_date_before":{let s=dnC(String(i));if(s==null&&(s=tOy(i)),s==null)throw new Kue(`Invalid date: ${i}`);let u=tOy(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new Kue(`Unknown operator: ${a}`)}}function vOy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new Kue("can't match cohort without a given cohort property value");let a=r[i];return bOy(a,t,r,n)}function bOy(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let d=bOy(c,t,r,n);if(i==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof Kue)n&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new Kue("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let c of a)try{let d;c.type==="cohort"?d=vOy(c,t,r,n):d=yOy(c,t);let s=c.negation||!1;if(i==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof Kue)n&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new Kue("can't match cohort without a given cohort property value");return i==="AND"}}function eOy(e){try{return new RegExp(e),!0}catch{return!1}}function tOy(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 Kue(`${e} is in an invalid date format`)}else throw new Kue(`The date provided ${e} must be a string, number, or date object`)}function dnC(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var yvf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},pnC=100,rOy=30*1e3,_nC=50*1e3,vvf=class extends pvf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new yvf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,pnC):rOy,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.');this.featureFlagsPoller=new hvf({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new vZa(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||_nC}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):_Oy(t,r)}getLibraryVersion(){return VrC}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.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s}=t,u=A=>{super.captureStateless(r,n,A,{timestamp:c,disableGeoip:d,uuid:s})},l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags,m=Promise.resolve().then(async()=>{if(o)return await l(r,a,d);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[I,T]of Object.entries(A))P[`$feature/${I}`]=T;let C=Object.keys(A||{}).filter(I=>A?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{u({...A,...i,$groups:a})});this.addPendingPromise(m)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s}=t,u=A=>super.captureStatelessImmediate(r,n,A,{timestamp:c,disableGeoip:d,uuid:s}),l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,d);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[I,T]of Object.entries(A))P[`$feature/${I}`]=T;let C=Object.keys(A||{}).filter(I=>A?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{u({...A,...i,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:i},{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:i},{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=rOy){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(n),i(),r(a>0)})})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:d,groupProperties:s}=n||{},u=this.addLocalPersonAndGroupProperties(r,i,d,s);d=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,d,s),m=l!==void 0,A,P;if(!m&&!o){let I=await super.getFeatureFlagDetailStateless(t,r,i,d,s,a);if(I===void 0)return;P=I.response,l=mvf(P),A=I?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id:A},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:o}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:d,personProperties:s,groupProperties:u}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=l.allGroupProperties;let m;return this.featureFlagsPoller!==void 0&&(n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n))),c==null&&(c=!1),d==null&&(d=!0),c==null&&(c=!1),!(m!==void 0)&&!c&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,s,u,o)),m}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}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}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},d=this.addLocalPersonAndGroupProperties(t,n,o,c);o=d.allPersonProperties,c=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,o,c),u={},l={},m=!0;if(s&&(u=s.response,l=s.payloads,m=s.fallbackToDecide),m&&!a){let A=await super.getFeatureFlagsAndPayloadsStateless(t,n,o,c,i);u={...u,...A.flags||{}},l={...l,...A.payloads||{}}}return{featureFlags:u,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...i?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,n){let i=new Error("PostHog syntheticException");vZa.captureException(this,t,{syntheticException:i},r,n)}},nOy=/\(error: (.*)\)/,gOy=50,mOy="?";function hnC(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return n=>{let i=n.match(r);if(i){let a,o,c,d,s;if(i[1]){c=i[1];let m=c.lastIndexOf(".");if(c[m-1]==="."&&m--,m>0){a=c.slice(0,m),o=c.slice(m+1);let A=a.indexOf(".Module");A>0&&(c=c.slice(A+1),a=a.slice(0,A))}d=void 0}o&&(d=a,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||mOy,c=d?`${d}.${s}`:s);let u=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&i[5]&&!l&&(u=i[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:iOy(i[3]),colno:iOy(i[4]),in_app:ynC(u||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function ynC(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 iOy(e){return parseInt(e||"",10)||void 0}function vnC(e){return[90,hnC(e)]}function bnC(e){let r=[vnC(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],o=n.split(`
2164
- `);for(let c=i;c<o.length;c++){let d=o[c];if(d.length>1024)continue;let s=nOy.test(d)?d.replace(nOy,"$1"):d;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=gOy)break}}return gnC(a)}}function gnC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,gOy).map(r=>({...r,filename:r.filename||mnC(t).filename,function:r.function||mOy}))}function mnC(e){return e[e.length-1]||{}}vZa.stackParser=bnC(MrC());vZa.frameModifiers=[TrC];var gZa=class extends vvf{getLibraryId(){return"posthog-node"}};var m1s=class{posthog;constructor({posthogApiKey:t}){this.posthog=new gZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.85.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var sJo=class{async sendEvent(){}async identify(){}async flush(){}};var OZa=require("fs/promises"),wOy=require("os"),jOy=require("path");var OOy=fa(require("crypto")),A1s=new Uint8Array(256),O1s=A1s.length;function Ovf(){return O1s>A1s.length-16&&(OOy.default.randomFillSync(A1s),O1s=0),A1s.slice(O1s,O1s+=16)}var Dbe=[];for(let e=0;e<256;++e)Dbe.push((e+256).toString(16).slice(1));function AOy(e,t=0){return Dbe[e[t+0]]+Dbe[e[t+1]]+Dbe[e[t+2]]+Dbe[e[t+3]]+"-"+Dbe[e[t+4]]+Dbe[e[t+5]]+"-"+Dbe[e[t+6]]+Dbe[e[t+7]]+"-"+Dbe[e[t+8]]+Dbe[e[t+9]]+"-"+Dbe[e[t+10]]+Dbe[e[t+11]]+Dbe[e[t+12]]+Dbe[e[t+13]]+Dbe[e[t+14]]+Dbe[e[t+15]]}var POy=fa(require("crypto")),Avf={randomUUID:POy.default.randomUUID};function OnC(e,t,r){if(Avf.randomUUID&&!t&&!e)return Avf.randomUUID();e=e||{};let n=e.random||(e.rng||Ovf)();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 AOy(n)}var sht=OnC;var AnC="id",PnC=".fern",cJo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new gZa(r),this.userId=t==null?void 0:Ncf(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.85.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Jl(F_.of((0,wOy.homedir)()),ys.of(PnC),ys.of(AnC));await Mv(t)||(await(0,OZa.mkdir)((0,jOy.dirname)(t),{recursive:!0}),await(0,OZa.writeFile)(t,sht())),this.persistedDistinctId=(await(0,OZa.readFile)(t)).toString()}return this.persistedDistinctId}};var Pvf;async function AZa(){return Pvf==null&&(Pvf=await wnC()),Pvf}async function wnC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new sJo;let r=await I0s();return r!=null?new cJo({token:r,posthogApiKey:e}):await AYa()!=null?new m1s({posthogApiKey:e}):new cJo({token:void 0,posthogApiKey:e})}catch{return new sJo}}function lJo(e,t){return function(){return e.apply(t,arguments)}}var{toString:jnC}=Object.prototype,{getPrototypeOf:jvf}=Object,{iterator:w1s,toStringTag:SOy}=Symbol,j1s=(e=>t=>{let r=jnC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),QTr=e=>(e=e.toLowerCase(),t=>j1s(t)===e),E1s=e=>t=>typeof t===e,{isArray:wZa}=Array,PZa=E1s("undefined");function fJo(e){return e!==null&&!PZa(e)&&e.constructor!==null&&!PZa(e.constructor)&&Cxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var DOy=QTr("ArrayBuffer");function EnC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&DOy(e.buffer),t}var SnC=E1s("string"),Cxe=E1s("function"),COy=E1s("number"),dJo=e=>e!==null&&typeof e=="object",DnC=e=>e===!0||e===!1,P1s=e=>{if(j1s(e)!=="object")return!1;let t=jvf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(SOy in e)&&!(w1s in e)},CnC=e=>{if(!dJo(e)||fJo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},MnC=QTr("Date"),InC=QTr("File"),BnC=QTr("Blob"),TnC=QTr("FileList"),qnC=e=>dJo(e)&&Cxe(e.pipe),RnC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Cxe(e.append)&&((t=j1s(e))==="formdata"||t==="object"&&Cxe(e.toString)&&e.toString()==="[object FormData]"))},NnC=QTr("URLSearchParams"),[FnC,xnC,znC,QnC]=["ReadableStream","Request","Response","Headers"].map(QTr),LnC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pJo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),wZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(fJo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function MOy(e,t){if(fJo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var asa=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,IOy=e=>!PZa(e)&&e!==asa;function wvf(){let{caseless:e,skipUndefined:t}=IOy(this)&&this||{},r={},n=(i,a)=>{let o=e&&MOy(r,a)||a;P1s(r[o])&&P1s(i)?r[o]=wvf(r[o],i):P1s(i)?r[o]=wvf({},i):wZa(i)?r[o]=i.slice():(!t||!PZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&pJo(arguments[i],n);return r}var UnC=(e,t,r,{allOwnKeys:n}={})=>(pJo(t,(i,a)=>{r&&Cxe(i)?e[a]=lJo(i,r):e[a]=i},{allOwnKeys:n}),e),VnC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),WnC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},HnC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&jvf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},GnC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},JnC=e=>{if(!e)return null;if(wZa(e))return e;let t=e.length;if(!COy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},KnC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&jvf(Uint8Array)),$nC=(e,t)=>{let n=(e&&e[w1s]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},YnC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},XnC=QTr("HTMLFormElement"),ZnC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),EOy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),knC=QTr("RegExp"),BOy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};pJo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},eiC=e=>{BOy(e,(t,r)=>{if(Cxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Cxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},tiC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return wZa(e)?n(e):n(String(e).split(t)),r},riC=()=>{},niC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function iiC(e){return!!(e&&Cxe(e.append)&&e[SOy]==="FormData"&&e[w1s])}var aiC=e=>{let t=new Array(10),r=(n,i)=>{if(dJo(n)){if(t.indexOf(n)>=0)return;if(fJo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=wZa(n)?[]:{};return pJo(n,(o,c)=>{let d=r(o,i+1);!PZa(d)&&(a[c]=d)}),t[i]=void 0,a}}return n};return r(e,0)},oiC=QTr("AsyncFunction"),uiC=e=>e&&(dJo(e)||Cxe(e))&&Cxe(e.then)&&Cxe(e.catch),TOy=((e,t)=>e?setImmediate:t?((r,n)=>(asa.addEventListener("message",({source:i,data:a})=>{i===asa&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),asa.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Cxe(asa.postMessage)),siC=typeof queueMicrotask<"u"?queueMicrotask.bind(asa):typeof process<"u"&&process.nextTick||TOy,ciC=e=>e!=null&&Cxe(e[w1s]),Yf={isArray:wZa,isArrayBuffer:DOy,isBuffer:fJo,isFormData:RnC,isArrayBufferView:EnC,isString:SnC,isNumber:COy,isBoolean:DnC,isObject:dJo,isPlainObject:P1s,isEmptyObject:CnC,isReadableStream:FnC,isRequest:xnC,isResponse:znC,isHeaders:QnC,isUndefined:PZa,isDate:MnC,isFile:InC,isBlob:BnC,isRegExp:knC,isFunction:Cxe,isStream:qnC,isURLSearchParams:NnC,isTypedArray:KnC,isFileList:TnC,forEach:pJo,merge:wvf,extend:UnC,trim:LnC,stripBOM:VnC,inherits:WnC,toFlatObject:HnC,kindOf:j1s,kindOfTest:QTr,endsWith:GnC,toArray:JnC,forEachEntry:$nC,matchAll:YnC,isHTMLForm:XnC,hasOwnProperty:EOy,hasOwnProp:EOy,reduceDescriptors:BOy,freezeMethods:eiC,toObjectSet:tiC,toCamelCase:ZnC,noop:riC,toFiniteNumber:niC,findKey:MOy,global:asa,isContextDefined:IOy,isSpecCompliantForm:iiC,toJSONObject:aiC,isAsyncFn:oiC,isThenable:uiC,setImmediate:TOy,asap:siC,isIterable:ciC};function jZa(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Yf.inherits(jZa,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Yf.toJSONObject(this.config),code:this.code,status:this.status}}});var qOy=jZa.prototype,ROy={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ROy[e]={value:e}});Object.defineProperties(jZa,ROy);Object.defineProperty(qOy,"isAxiosError",{value:!0});jZa.from=(e,t,r,n,i,a)=>{let o=Object.create(qOy);Yf.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return jZa.call(o,c,d,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Pm=jZa;var NOy=fa($js(),1),S1s=NOy.default;function Evf(e){return Yf.isPlainObject(e)||Yf.isArray(e)}function xOy(e){return Yf.endsWith(e,"[]")?e.slice(0,-2):e}function FOy(e,t,r){return e?e.concat(t).map(function(i,a){return i=xOy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function liC(e){return Yf.isArray(e)&&!e.some(Evf)}var fiC=Yf.toFlatObject(Yf,{},null,function(t){return/^is[A-Z]/.test(t)});function diC(e,t,r){if(!Yf.isObject(e))throw new TypeError("target must be an object");t=t||new(S1s||FormData),r=Yf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Yf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Yf.isSpecCompliantForm(t);if(!Yf.isFunction(i))throw new TypeError("visitor must be a function");function s(P){if(P===null)return"";if(Yf.isDate(P))return P.toISOString();if(Yf.isBoolean(P))return P.toString();if(!d&&Yf.isBlob(P))throw new Pm("Blob is not supported. Use a Buffer instead.");return Yf.isArrayBuffer(P)||Yf.isTypedArray(P)?d&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function u(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Yf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Yf.isArray(P)&&liC(P)||(Yf.isFileList(P)||Yf.endsWith(C,"[]"))&&(T=Yf.toArray(P)))return C=xOy(C),T.forEach(function(U,R){!(Yf.isUndefined(U)||U===null)&&t.append(o===!0?FOy([C],R,a):o===null?C:C+"[]",s(U))}),!1}return Evf(P)?!0:(t.append(FOy(I,C,a),s(P)),!1)}let l=[],m=Object.assign(fiC,{defaultVisitor:u,convertValue:s,isVisitable:Evf});function A(P,C){if(!Yf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Yf.forEach(P,function(T,z){(!(Yf.isUndefined(T)||T===null)&&i.call(t,T,Yf.isString(z)?z.trim():z,C,m))===!0&&A(T,C?C.concat(z):[z])}),l.pop()}}if(!Yf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var Y6i=diC;function zOy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function QOy(e,t){this._pairs=[],e&&Y6i(e,this,t)}var LOy=QOy.prototype;LOy.append=function(t,r){this._pairs.push([t,r])};LOy.toString=function(t){let r=t?function(n){return t.call(this,n,zOy)}:zOy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var UOy=QOy;function piC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function osa(e,t,r){if(!t)return e;let n=r&&r.encode||piC;Yf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Yf.isURLSearchParams(t)?t.toString():new UOy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Svf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Yf.forEach(this.handlers,function(n){n!==null&&t(n)})}},Dvf=Svf;var EZa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var GOy=fa(require("crypto"),1);var VOy=fa(require("url"),1),WOy=VOy.default.URLSearchParams;var Cvf="abcdefghijklmnopqrstuvwxyz",HOy="0123456789",JOy={DIGIT:HOy,ALPHA:Cvf,ALPHA_DIGIT:Cvf+Cvf.toUpperCase()+HOy},_iC=(e=16,t=JOy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);GOy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},KOy={isNode:!0,classes:{URLSearchParams:WOy,FormData:S1s,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:JOy,generateString:_iC,protocols:["http","https","file","data"]};var Bvf={};ff(Bvf,{hasBrowserEnv:()=>Ivf,hasStandardBrowserEnv:()=>hiC,hasStandardBrowserWebWorkerEnv:()=>yiC,navigator:()=>Mvf,origin:()=>viC});var Ivf=typeof window<"u"&&typeof document<"u",Mvf=typeof navigator=="object"&&navigator||void 0,hiC=Ivf&&(!Mvf||["ReactNative","NativeScript","NS"].indexOf(Mvf.product)<0),yiC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",viC=Ivf&&window.location.href||"http://localhost";var T2={...Bvf,...KOy};function Tvf(e,t){return Y6i(e,new T2.classes.URLSearchParams,{visitor:function(r,n,i,a){return T2.isNode&&Yf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function biC(e){return Yf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function giC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function miC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),d=a>=r.length;return o=!o&&Yf.isArray(i)?i.length:o,d?(Yf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Yf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Yf.isArray(i[o])&&(i[o]=giC(i[o])),!c)}if(Yf.isFormData(e)&&Yf.isFunction(e.entries)){let r={};return Yf.forEachEntry(e,(n,i)=>{t(biC(n),i,r,0)}),r}return null}var D1s=miC;function OiC(e,t,r){if(Yf.isString(e))try{return(t||JSON.parse)(e),Yf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var qvf={transitional:EZa,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Yf.isObject(t);if(a&&Yf.isHTMLForm(t)&&(t=new FormData(t)),Yf.isFormData(t))return i?JSON.stringify(D1s(t)):t;if(Yf.isArrayBuffer(t)||Yf.isBuffer(t)||Yf.isStream(t)||Yf.isFile(t)||Yf.isBlob(t)||Yf.isReadableStream(t))return t;if(Yf.isArrayBufferView(t))return t.buffer;if(Yf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Tvf(t,this.formSerializer).toString();if((c=Yf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Y6i(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),OiC(t)):t}],transformResponse:[function(t){let r=this.transitional||qvf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Yf.isResponse(t)||Yf.isReadableStream(t))return t;if(t&&Yf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Pm.from(c,Pm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:T2.classes.FormData,Blob:T2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Yf.forEach(["delete","get","head","post","put","patch"],e=>{qvf.headers[e]={}});var SZa=qvf;var AiC=Yf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$Oy=e=>{let t={},r,n,i;return e&&e.split(`
2164
+ `);for(let c=i;c<o.length;c++){let d=o[c];if(d.length>1024)continue;let s=nOy.test(d)?d.replace(nOy,"$1"):d;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=gOy)break}}return gnC(a)}}function gnC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,gOy).map(r=>({...r,filename:r.filename||mnC(t).filename,function:r.function||mOy}))}function mnC(e){return e[e.length-1]||{}}vZa.stackParser=bnC(MrC());vZa.frameModifiers=[TrC];var gZa=class extends vvf{getLibraryId(){return"posthog-node"}};var m1s=class{posthog;constructor({posthogApiKey:t}){this.posthog=new gZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.86.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var sJo=class{async sendEvent(){}async identify(){}async flush(){}};var OZa=require("fs/promises"),wOy=require("os"),jOy=require("path");var OOy=fa(require("crypto")),A1s=new Uint8Array(256),O1s=A1s.length;function Ovf(){return O1s>A1s.length-16&&(OOy.default.randomFillSync(A1s),O1s=0),A1s.slice(O1s,O1s+=16)}var Dbe=[];for(let e=0;e<256;++e)Dbe.push((e+256).toString(16).slice(1));function AOy(e,t=0){return Dbe[e[t+0]]+Dbe[e[t+1]]+Dbe[e[t+2]]+Dbe[e[t+3]]+"-"+Dbe[e[t+4]]+Dbe[e[t+5]]+"-"+Dbe[e[t+6]]+Dbe[e[t+7]]+"-"+Dbe[e[t+8]]+Dbe[e[t+9]]+"-"+Dbe[e[t+10]]+Dbe[e[t+11]]+Dbe[e[t+12]]+Dbe[e[t+13]]+Dbe[e[t+14]]+Dbe[e[t+15]]}var POy=fa(require("crypto")),Avf={randomUUID:POy.default.randomUUID};function OnC(e,t,r){if(Avf.randomUUID&&!t&&!e)return Avf.randomUUID();e=e||{};let n=e.random||(e.rng||Ovf)();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 AOy(n)}var sht=OnC;var AnC="id",PnC=".fern",cJo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new gZa(r),this.userId=t==null?void 0:Ncf(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.86.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Jl(F_.of((0,wOy.homedir)()),ys.of(PnC),ys.of(AnC));await Mv(t)||(await(0,OZa.mkdir)((0,jOy.dirname)(t),{recursive:!0}),await(0,OZa.writeFile)(t,sht())),this.persistedDistinctId=(await(0,OZa.readFile)(t)).toString()}return this.persistedDistinctId}};var Pvf;async function AZa(){return Pvf==null&&(Pvf=await wnC()),Pvf}async function wnC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new sJo;let r=await I0s();return r!=null?new cJo({token:r,posthogApiKey:e}):await AYa()!=null?new m1s({posthogApiKey:e}):new cJo({token:void 0,posthogApiKey:e})}catch{return new sJo}}function lJo(e,t){return function(){return e.apply(t,arguments)}}var{toString:jnC}=Object.prototype,{getPrototypeOf:jvf}=Object,{iterator:w1s,toStringTag:SOy}=Symbol,j1s=(e=>t=>{let r=jnC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),QTr=e=>(e=e.toLowerCase(),t=>j1s(t)===e),E1s=e=>t=>typeof t===e,{isArray:wZa}=Array,PZa=E1s("undefined");function fJo(e){return e!==null&&!PZa(e)&&e.constructor!==null&&!PZa(e.constructor)&&Cxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var DOy=QTr("ArrayBuffer");function EnC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&DOy(e.buffer),t}var SnC=E1s("string"),Cxe=E1s("function"),COy=E1s("number"),dJo=e=>e!==null&&typeof e=="object",DnC=e=>e===!0||e===!1,P1s=e=>{if(j1s(e)!=="object")return!1;let t=jvf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(SOy in e)&&!(w1s in e)},CnC=e=>{if(!dJo(e)||fJo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},MnC=QTr("Date"),InC=QTr("File"),BnC=QTr("Blob"),TnC=QTr("FileList"),qnC=e=>dJo(e)&&Cxe(e.pipe),RnC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Cxe(e.append)&&((t=j1s(e))==="formdata"||t==="object"&&Cxe(e.toString)&&e.toString()==="[object FormData]"))},NnC=QTr("URLSearchParams"),[FnC,xnC,znC,QnC]=["ReadableStream","Request","Response","Headers"].map(QTr),LnC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pJo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),wZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(fJo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function MOy(e,t){if(fJo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var asa=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,IOy=e=>!PZa(e)&&e!==asa;function wvf(){let{caseless:e,skipUndefined:t}=IOy(this)&&this||{},r={},n=(i,a)=>{let o=e&&MOy(r,a)||a;P1s(r[o])&&P1s(i)?r[o]=wvf(r[o],i):P1s(i)?r[o]=wvf({},i):wZa(i)?r[o]=i.slice():(!t||!PZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&pJo(arguments[i],n);return r}var UnC=(e,t,r,{allOwnKeys:n}={})=>(pJo(t,(i,a)=>{r&&Cxe(i)?e[a]=lJo(i,r):e[a]=i},{allOwnKeys:n}),e),VnC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),WnC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},HnC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&jvf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},GnC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},JnC=e=>{if(!e)return null;if(wZa(e))return e;let t=e.length;if(!COy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},KnC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&jvf(Uint8Array)),$nC=(e,t)=>{let n=(e&&e[w1s]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},YnC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},XnC=QTr("HTMLFormElement"),ZnC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),EOy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),knC=QTr("RegExp"),BOy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};pJo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},eiC=e=>{BOy(e,(t,r)=>{if(Cxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Cxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},tiC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return wZa(e)?n(e):n(String(e).split(t)),r},riC=()=>{},niC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function iiC(e){return!!(e&&Cxe(e.append)&&e[SOy]==="FormData"&&e[w1s])}var aiC=e=>{let t=new Array(10),r=(n,i)=>{if(dJo(n)){if(t.indexOf(n)>=0)return;if(fJo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=wZa(n)?[]:{};return pJo(n,(o,c)=>{let d=r(o,i+1);!PZa(d)&&(a[c]=d)}),t[i]=void 0,a}}return n};return r(e,0)},oiC=QTr("AsyncFunction"),uiC=e=>e&&(dJo(e)||Cxe(e))&&Cxe(e.then)&&Cxe(e.catch),TOy=((e,t)=>e?setImmediate:t?((r,n)=>(asa.addEventListener("message",({source:i,data:a})=>{i===asa&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),asa.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Cxe(asa.postMessage)),siC=typeof queueMicrotask<"u"?queueMicrotask.bind(asa):typeof process<"u"&&process.nextTick||TOy,ciC=e=>e!=null&&Cxe(e[w1s]),Yf={isArray:wZa,isArrayBuffer:DOy,isBuffer:fJo,isFormData:RnC,isArrayBufferView:EnC,isString:SnC,isNumber:COy,isBoolean:DnC,isObject:dJo,isPlainObject:P1s,isEmptyObject:CnC,isReadableStream:FnC,isRequest:xnC,isResponse:znC,isHeaders:QnC,isUndefined:PZa,isDate:MnC,isFile:InC,isBlob:BnC,isRegExp:knC,isFunction:Cxe,isStream:qnC,isURLSearchParams:NnC,isTypedArray:KnC,isFileList:TnC,forEach:pJo,merge:wvf,extend:UnC,trim:LnC,stripBOM:VnC,inherits:WnC,toFlatObject:HnC,kindOf:j1s,kindOfTest:QTr,endsWith:GnC,toArray:JnC,forEachEntry:$nC,matchAll:YnC,isHTMLForm:XnC,hasOwnProperty:EOy,hasOwnProp:EOy,reduceDescriptors:BOy,freezeMethods:eiC,toObjectSet:tiC,toCamelCase:ZnC,noop:riC,toFiniteNumber:niC,findKey:MOy,global:asa,isContextDefined:IOy,isSpecCompliantForm:iiC,toJSONObject:aiC,isAsyncFn:oiC,isThenable:uiC,setImmediate:TOy,asap:siC,isIterable:ciC};function jZa(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Yf.inherits(jZa,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Yf.toJSONObject(this.config),code:this.code,status:this.status}}});var qOy=jZa.prototype,ROy={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ROy[e]={value:e}});Object.defineProperties(jZa,ROy);Object.defineProperty(qOy,"isAxiosError",{value:!0});jZa.from=(e,t,r,n,i,a)=>{let o=Object.create(qOy);Yf.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",d=t==null&&e?e.code:t;return jZa.call(o,c,d,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Pm=jZa;var NOy=fa($js(),1),S1s=NOy.default;function Evf(e){return Yf.isPlainObject(e)||Yf.isArray(e)}function xOy(e){return Yf.endsWith(e,"[]")?e.slice(0,-2):e}function FOy(e,t,r){return e?e.concat(t).map(function(i,a){return i=xOy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function liC(e){return Yf.isArray(e)&&!e.some(Evf)}var fiC=Yf.toFlatObject(Yf,{},null,function(t){return/^is[A-Z]/.test(t)});function diC(e,t,r){if(!Yf.isObject(e))throw new TypeError("target must be an object");t=t||new(S1s||FormData),r=Yf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Yf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||u,a=r.dots,o=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Yf.isSpecCompliantForm(t);if(!Yf.isFunction(i))throw new TypeError("visitor must be a function");function s(P){if(P===null)return"";if(Yf.isDate(P))return P.toISOString();if(Yf.isBoolean(P))return P.toString();if(!d&&Yf.isBlob(P))throw new Pm("Blob is not supported. Use a Buffer instead.");return Yf.isArrayBuffer(P)||Yf.isTypedArray(P)?d&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function u(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Yf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Yf.isArray(P)&&liC(P)||(Yf.isFileList(P)||Yf.endsWith(C,"[]"))&&(T=Yf.toArray(P)))return C=xOy(C),T.forEach(function(U,R){!(Yf.isUndefined(U)||U===null)&&t.append(o===!0?FOy([C],R,a):o===null?C:C+"[]",s(U))}),!1}return Evf(P)?!0:(t.append(FOy(I,C,a),s(P)),!1)}let l=[],m=Object.assign(fiC,{defaultVisitor:u,convertValue:s,isVisitable:Evf});function A(P,C){if(!Yf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Yf.forEach(P,function(T,z){(!(Yf.isUndefined(T)||T===null)&&i.call(t,T,Yf.isString(z)?z.trim():z,C,m))===!0&&A(T,C?C.concat(z):[z])}),l.pop()}}if(!Yf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var Y6i=diC;function zOy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function QOy(e,t){this._pairs=[],e&&Y6i(e,this,t)}var LOy=QOy.prototype;LOy.append=function(t,r){this._pairs.push([t,r])};LOy.toString=function(t){let r=t?function(n){return t.call(this,n,zOy)}:zOy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var UOy=QOy;function piC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function osa(e,t,r){if(!t)return e;let n=r&&r.encode||piC;Yf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Yf.isURLSearchParams(t)?t.toString():new UOy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Svf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Yf.forEach(this.handlers,function(n){n!==null&&t(n)})}},Dvf=Svf;var EZa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var GOy=fa(require("crypto"),1);var VOy=fa(require("url"),1),WOy=VOy.default.URLSearchParams;var Cvf="abcdefghijklmnopqrstuvwxyz",HOy="0123456789",JOy={DIGIT:HOy,ALPHA:Cvf,ALPHA_DIGIT:Cvf+Cvf.toUpperCase()+HOy},_iC=(e=16,t=JOy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);GOy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},KOy={isNode:!0,classes:{URLSearchParams:WOy,FormData:S1s,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:JOy,generateString:_iC,protocols:["http","https","file","data"]};var Bvf={};ff(Bvf,{hasBrowserEnv:()=>Ivf,hasStandardBrowserEnv:()=>hiC,hasStandardBrowserWebWorkerEnv:()=>yiC,navigator:()=>Mvf,origin:()=>viC});var Ivf=typeof window<"u"&&typeof document<"u",Mvf=typeof navigator=="object"&&navigator||void 0,hiC=Ivf&&(!Mvf||["ReactNative","NativeScript","NS"].indexOf(Mvf.product)<0),yiC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",viC=Ivf&&window.location.href||"http://localhost";var T2={...Bvf,...KOy};function Tvf(e,t){return Y6i(e,new T2.classes.URLSearchParams,{visitor:function(r,n,i,a){return T2.isNode&&Yf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function biC(e){return Yf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function giC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function miC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),d=a>=r.length;return o=!o&&Yf.isArray(i)?i.length:o,d?(Yf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Yf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Yf.isArray(i[o])&&(i[o]=giC(i[o])),!c)}if(Yf.isFormData(e)&&Yf.isFunction(e.entries)){let r={};return Yf.forEachEntry(e,(n,i)=>{t(biC(n),i,r,0)}),r}return null}var D1s=miC;function OiC(e,t,r){if(Yf.isString(e))try{return(t||JSON.parse)(e),Yf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var qvf={transitional:EZa,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Yf.isObject(t);if(a&&Yf.isHTMLForm(t)&&(t=new FormData(t)),Yf.isFormData(t))return i?JSON.stringify(D1s(t)):t;if(Yf.isArrayBuffer(t)||Yf.isBuffer(t)||Yf.isStream(t)||Yf.isFile(t)||Yf.isBlob(t)||Yf.isReadableStream(t))return t;if(Yf.isArrayBufferView(t))return t.buffer;if(Yf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Tvf(t,this.formSerializer).toString();if((c=Yf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Y6i(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),OiC(t)):t}],transformResponse:[function(t){let r=this.transitional||qvf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Yf.isResponse(t)||Yf.isReadableStream(t))return t;if(t&&Yf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Pm.from(c,Pm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:T2.classes.FormData,Blob:T2.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Yf.forEach(["delete","get","head","post","put","patch"],e=>{qvf.headers[e]={}});var SZa=qvf;var AiC=Yf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$Oy=e=>{let t={},r,n,i;return e&&e.split(`
2165
2165
  `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&AiC[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var YOy=Symbol("internals");function _Jo(e){return e&&String(e).trim().toLowerCase()}function C1s(e){return e===!1||e==null?e:Yf.isArray(e)?e.map(C1s):String(e)}function PiC(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var wiC=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Rvf(e,t,r,n,i){if(Yf.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Yf.isString(t)){if(Yf.isString(n))return t.indexOf(n)!==-1;if(Yf.isRegExp(n))return n.test(t)}}function jiC(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function EiC(e,t){let r=Yf.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,o){return this[n].call(this,t,i,a,o)},configurable:!0})})}var DZa=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,d,s){let u=_Jo(d);if(!u)throw new Error("header name must be a non-empty string");let l=Yf.findKey(i,u);(!l||i[l]===void 0||s===!0||s===void 0&&i[l]!==!1)&&(i[l||d]=C1s(c))}let o=(c,d)=>Yf.forEach(c,(s,u)=>a(s,u,d));if(Yf.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(Yf.isString(t)&&(t=t.trim())&&!wiC(t))o($Oy(t),r);else if(Yf.isObject(t)&&Yf.isIterable(t)){let c={},d,s;for(let u of t){if(!Yf.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(d=c[s])?Yf.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=_Jo(t),t){let n=Yf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return PiC(i);if(Yf.isFunction(r))return r.call(this,i,n);if(Yf.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=_Jo(t),t){let n=Yf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Rvf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=_Jo(o),o){let c=Yf.findKey(n,o);c&&(!r||Rvf(n,n[c],c,r))&&(delete n[c],i=!0)}}return Yf.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||Rvf(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Yf.forEach(this,(i,a)=>{let o=Yf.findKey(n,a);if(o){r[o]=C1s(i),delete r[a];return}let c=t?jiC(a):String(a).trim();c!==a&&delete r[a],r[c]=C1s(i),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Yf.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Yf.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
2166
2166
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[YOy]=this[YOy]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=_Jo(o);n[c]||(EiC(i,o),n[c]=!0)}return Yf.isArray(t)?t.forEach(a):a(t),this}};DZa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Yf.reduceDescriptors(DZa.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Yf.freezeMethods(DZa);var _$=DZa;function hJo(e,t){let r=this||SZa,n=t||r,i=_$.from(n.headers),a=n.data;return Yf.forEach(e,function(c){a=c.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function yJo(e){return!!(e&&e.__CANCEL__)}function XOy(e,t,r){Pm.call(this,e??"canceled",Pm.ERR_CANCELED,t,r),this.name="CanceledError"}Yf.inherits(XOy,Pm,{__CANCEL__:!0});var pnt=XOy;function o9r(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Pm("Request failed with status code "+r.status,[Pm.ERR_BAD_REQUEST,Pm.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Nvf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Fvf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function usa(e,t,r){let n=!Nvf(t);return e&&(n||r==!1)?Fvf(e,t):t}var pAy=fa(Yjs(),1),_Ay=fa(require("http"),1),hAy=fa(require("https"),1),yAy=fa(require("util"),1),vAy=fa(xyf(),1),GOi=fa(require("zlib"),1);var ssa="1.12.2";function vJo(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var SiC=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function xvf(e,t,r){let n=r&&r.Blob||T2.classes.Blob,i=vJo(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=SiC.exec(e);if(!a)throw new Pm("Invalid URL",Pm.ERR_INVALID_URL);let o=a[1],c=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),c?"base64":"utf8");if(t){if(!n)throw new Pm("Blob is not supported",Pm.ERR_NOT_SUPPORT);return new n([s],{type:o})}return s}throw new Pm("Unsupported protocol "+i,Pm.ERR_NOT_SUPPORT)}var lsa=fa(require("stream"),1);var ZOy=fa(require("stream"),1);var zvf=Symbol("internals"),Qvf=class extends ZOy.default.Transform{constructor(t){t=Yf.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Yf.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[zvf]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[zvf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[zvf],a=i.maxRate,o=this.readableHighWaterMark,c=i.timeWindow,d=1e3/c,s=a/d,u=i.minChunkSize!==!1?Math.max(i.minChunkSize,s*.01):0,l=(A,P)=>{let C=Buffer.byteLength(A);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(A)?process.nextTick(P):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(P)}},m=(A,P)=>{let C=Buffer.byteLength(A),I=null,T=o,z,U=0;if(a){let R=Date.now();(!i.ts||(U=R-i.ts)>=c)&&(i.ts=R,z=s-i.bytes,i.bytes=z<0?-z:0,U=0),z=s-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,A)},c-U);z<T&&(T=z)}T&&C>T&&C-T>u&&(I=A.subarray(T),A=A.subarray(0,T)),l(A,I?()=>{process.nextTick(P,null,I)}:P)};m(t,function A(P,C){if(P)return n(P);C?m(C,A):n(null)})}},Lvf=Qvf;var bAy=require("events");var eAy=fa(require("util"),1),tAy=require("stream");var{asyncIterator:kOy}=Symbol,DiC=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[kOy]?yield*e[kOy]():yield e},M1s=DiC;var CiC=T2.ALPHABET.ALPHA_DIGIT+"-_",bJo=typeof TextEncoder=="function"?new TextEncoder:new eAy.default.TextEncoder,csa=`\r
2167
2167
  `,MiC=bJo.encode(csa),IiC=2,Uvf=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Yf.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${csa}`;i?r=bJo.encode(String(r).replace(/\r?\n|\r\n?/g,csa)):a+=`Content-Type: ${r.type||"application/octet-stream"}${csa}`,this.headers=bJo.encode(a+csa),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+IiC,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Yf.isTypedArray(t)?yield t:yield*M1s(t),yield MiC}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},BiC=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+T2.generateString(i,CiC)}=r||{};if(!Yf.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=bJo.encode("--"+a+csa),c=bJo.encode("--"+a+"--"+csa),d=c.byteLength,s=Array.from(e.entries()).map(([l,m])=>{let A=new Uvf(l,m);return d+=A.size,A});d+=o.byteLength*s.length,d=Yf.toFiniteNumber(d);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(u["Content-Length"]=d),t&&t(u),tAy.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},rAy=BiC;var nAy=fa(require("stream"),1),Vvf=class extends nAy.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},iAy=Vvf;var TiC=(e,t)=>Yf.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,aAy=TiC;function qiC(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,o;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),u=n[a];o||(o=s),r[i]=d,n[i]=s;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),s-o<t)return;let A=u&&s-u;return A?Math.round(m*1e3/A):void 0}}var oAy=qiC;function RiC(e,t){let r=0,n=1e3/t,i,a,o=(s,u=Date.now())=>{r=u,i=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=n?o(s,u):(i=s,a||(a=setTimeout(()=>{a=null,o(i)},n-l)))},()=>i&&o(i)]}var uAy=RiC;var HOi=(e,t,r=3)=>{let n=0,i=oAy(50,250);return uAy(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,d=o-n,s=i(d),u=o<=c;n=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:d,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},CZa=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},MZa=e=>(...t)=>Yf.asap(()=>e(...t));function Wvf(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let m=0;m<o;m++)if(n.charCodeAt(m)===37&&m+2<o){let A=n.charCodeAt(m+1),P=n.charCodeAt(m+2);(A>=48&&A<=57||A>=65&&A<=70||A>=97&&A<=102)&&(P>=48&&P<=57||P>=65&&P<=70||P>=97&&P<=102)&&(a-=2,m+=2)}let c=0,d=o-1,s=m=>m>=2&&n.charCodeAt(m-2)===37&&n.charCodeAt(m-1)===51&&(n.charCodeAt(m)===68||n.charCodeAt(m)===100);d>=0&&(n.charCodeAt(d)===61?(c++,d--):s(d)&&(c++,d-=3)),c===1&&d>=0&&(n.charCodeAt(d)===61||s(d))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var sAy={flush:GOi.default.constants.Z_SYNC_FLUSH,finishFlush:GOi.default.constants.Z_SYNC_FLUSH},NiC={flush:GOi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:GOi.default.constants.BROTLI_OPERATION_FLUSH},cAy=Yf.isFunction(GOi.default.createBrotliDecompress),{http:FiC,https:xiC}=vAy.default,ziC=/https:?/,lAy=T2.protocols.map(e=>e+":"),fAy=(e,[t,r])=>(e.on("end",r).on("error",r),t);function QiC(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function gAy(e,t,r){let n=t;if(!n&&n!==!1){let i=pAy.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){gAy(a,t,a.href)}}var LiC=typeof process<"u"&&Yf.kindOf(process)==="process",UiC=e=>new Promise((t,r)=>{let n,i,a=(d,s)=>{i||(i=!0,n&&n(d,s))},o=d=>{a(d),t(d)},c=d=>{a(d,!0),r(d)};e(o,c,d=>n=d).catch(c)}),ViC=({address:e,family:t})=>{if(!Yf.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},dAy=(e,t)=>ViC(Yf.isObject(e)?e:{address:e,family:t}),mAy=LiC&&function(t){return UiC(async function(n,i,a){let{data:o,lookup:c,family:d}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),m,A=!1,P;if(c){let Se=aAy(c,St=>Yf.isArray(St)?St:[St]);c=(St,yt,Re)=>{Se(St,yt,(De,Lt,Xe)=>{if(De)return Re(De);let Yt=Yf.isArray(Lt)?Lt.map(It=>dAy(It)):[dAy(Lt,Xe)];yt.all?Re(De,Yt):Re(De,Yt[0].address,Yt[0].family)})}}let C=new bAy.EventEmitter,I=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Se,St)=>{m=!0,St&&(A=!0,I())});function T(Se){C.emit("abort",!Se||Se.type?new pnt(null,t,P):Se)}C.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(T),t.signal&&(t.signal.aborted?T():t.signal.addEventListener("abort",T)));let z=usa(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,T2.hasBrowserEnv?T2.origin:void 0),R=U.protocol||lAy[0];if(R==="data:"){if(t.maxContentLength>-1){let St=String(t.url||z||"");if(Wvf(St)>t.maxContentLength)return i(new Pm("maxContentLength size of "+t.maxContentLength+" exceeded",Pm.ERR_BAD_RESPONSE,t))}let Se;if(l!=="GET")return o9r(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=xvf(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(St){throw Pm.from(St,Pm.ERR_BAD_REQUEST,t)}return s==="text"?(Se=Se.toString(u),(!u||u==="utf8")&&(Se=Yf.stripBOM(Se))):s==="stream"&&(Se=lsa.default.Readable.from(Se)),o9r(n,i,{data:Se,status:200,statusText:"OK",headers:new _$,config:t})}if(lAy.indexOf(R)===-1)return i(new Pm("Unsupported protocol "+R,Pm.ERR_BAD_REQUEST,t));let V=_$.from(t.headers).normalize();V.set("User-Agent","axios/"+ssa,!1);let{onUploadProgress:$,onDownloadProgress:re}=t,Y=t.maxRate,te,ne;if(Yf.isSpecCompliantForm(o)){let Se=V.getContentType(/boundary=([-_\w\d]{10,70})/i);o=rAy(o,St=>{V.set(St)},{tag:`axios-${ssa}-boundary`,boundary:Se&&Se[1]||void 0})}else if(Yf.isFormData(o)&&Yf.isFunction(o.getHeaders)){if(V.set(o.getHeaders()),!V.hasContentLength())try{let Se=await yAy.default.promisify(o.getLength).call(o);Number.isFinite(Se)&&Se>=0&&V.setContentLength(Se)}catch{}}else if(Yf.isBlob(o)||Yf.isFile(o))o.size&&V.setContentType(o.type||"application/octet-stream"),V.setContentLength(o.size||0),o=lsa.default.Readable.from(M1s(o));else if(o&&!Yf.isStream(o)){if(!Buffer.isBuffer(o))if(Yf.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(Yf.isString(o))o=Buffer.from(o,"utf-8");else return i(new Pm("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Pm.ERR_BAD_REQUEST,t));if(V.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return i(new Pm("Request body larger than maxBodyLength limit",Pm.ERR_BAD_REQUEST,t))}let Oe=Yf.toFiniteNumber(V.getContentLength());Yf.isArray(Y)?(te=Y[0],ne=Y[1]):te=ne=Y,o&&($||te)&&(Yf.isStream(o)||(o=lsa.default.Readable.from(o,{objectMode:!1})),o=lsa.default.pipeline([o,new Lvf({maxRate:Yf.toFiniteNumber(te)})],Yf.noop),$&&o.on("progress",fAy(o,CZa(Oe,HOi(MZa($),!1,3)))));let ge;if(t.auth){let Se=t.auth.username||"",St=t.auth.password||"";ge=Se+":"+St}if(!ge&&U.username){let Se=U.username,St=U.password;ge=Se+":"+St}ge&&V.delete("authorization");let ve;try{ve=osa(U.pathname+U.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Se){let St=new Error(Se.message);return St.config=t,St.url=t.url,St.exists=!0,i(St)}V.set("Accept-Encoding","gzip, compress, deflate"+(cAy?", br":""),!1);let be={path:ve,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:ge,protocol:R,family:d,beforeRedirect:QiC,beforeRedirects:{}};!Yf.isUndefined(c)&&(be.lookup=c),t.socketPath?be.socketPath=t.socketPath:(be.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,be.port=U.port,gAy(be,t.proxy,R+"//"+U.hostname+(U.port?":"+U.port:"")+be.path));let Ie,Be=ziC.test(be.protocol);if(be.agent=Be?t.httpsAgent:t.httpAgent,t.transport?Ie=t.transport:t.maxRedirects===0?Ie=Be?hAy.default:_Ay.default:(t.maxRedirects&&(be.maxRedirects=t.maxRedirects),t.beforeRedirect&&(be.beforeRedirects.config=t.beforeRedirect),Ie=Be?xiC:FiC),t.maxBodyLength>-1?be.maxBodyLength=t.maxBodyLength:be.maxBodyLength=1/0,t.insecureHTTPParser&&(be.insecureHTTPParser=t.insecureHTTPParser),P=Ie.request(be,function(St){if(P.destroyed)return;let yt=[St],Re=+St.headers["content-length"];if(re||ne){let It=new Lvf({maxRate:Yf.toFiniteNumber(ne)});re&&It.on("progress",fAy(It,CZa(Re,HOi(MZa(re),!0,3)))),yt.push(It)}let De=St,Lt=St.req||P;if(t.decompress!==!1&&St.headers["content-encoding"])switch((l==="HEAD"||St.statusCode===204)&&delete St.headers["content-encoding"],(St.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":yt.push(GOi.default.createUnzip(sAy)),delete St.headers["content-encoding"];break;case"deflate":yt.push(new iAy),yt.push(GOi.default.createUnzip(sAy)),delete St.headers["content-encoding"];break;case"br":cAy&&(yt.push(GOi.default.createBrotliDecompress(NiC)),delete St.headers["content-encoding"])}De=yt.length>1?lsa.default.pipeline(yt,Yf.noop):yt[0];let Xe=lsa.default.finished(De,()=>{Xe(),I()}),Yt={status:St.statusCode,statusText:St.statusMessage,headers:new _$(St.headers),config:t,request:Lt};if(s==="stream")Yt.data=De,o9r(n,i,Yt);else{let It=[],Ke=0;De.on("data",function(sr){It.push(sr),Ke+=sr.length,t.maxContentLength>-1&&Ke>t.maxContentLength&&(A=!0,De.destroy(),i(new Pm("maxContentLength size of "+t.maxContentLength+" exceeded",Pm.ERR_BAD_RESPONSE,t,Lt)))}),De.on("aborted",function(){if(A)return;let sr=new Pm("stream has been aborted",Pm.ERR_BAD_RESPONSE,t,Lt);De.destroy(sr),i(sr)}),De.on("error",function(sr){P.destroyed||i(Pm.from(sr,null,t,Lt))}),De.on("end",function(){try{let sr=It.length===1?It[0]:Buffer.concat(It);s!=="arraybuffer"&&(sr=sr.toString(u),(!u||u==="utf8")&&(sr=Yf.stripBOM(sr))),Yt.data=sr}catch(sr){return i(Pm.from(sr,null,t,Yt.request,Yt))}o9r(n,i,Yt)})}C.once("abort",It=>{De.destroyed||(De.emit("error",It),De.destroy())})}),C.once("abort",Se=>{i(Se),P.destroy(Se)}),P.on("error",function(St){i(Pm.from(St,null,t,P))}),P.on("socket",function(St){St.setKeepAlive(!0,1e3*60)}),t.timeout){let Se=parseInt(t.timeout,10);if(Number.isNaN(Se)){i(new Pm("error trying to parse `config.timeout` to int",Pm.ERR_BAD_OPTION_VALUE,t,P));return}P.setTimeout(Se,function(){if(m)return;let yt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Re=t.transitional||EZa;t.timeoutErrorMessage&&(yt=t.timeoutErrorMessage),i(new Pm(yt,Re.clarifyTimeoutError?Pm.ETIMEDOUT:Pm.ECONNABORTED,t,P)),T()})}if(Yf.isStream(o)){let Se=!1,St=!1;o.on("end",()=>{Se=!0}),o.once("error",yt=>{St=!0,P.destroy(yt)}),o.on("close",()=>{!Se&&!St&&T(new pnt("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var OAy=T2.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,T2.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(T2.origin),T2.navigator&&/(msie|trident)/i.test(T2.navigator.userAgent)):()=>!0;var AAy=T2.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let o=[e+"="+encodeURIComponent(t)];Yf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Yf.isString(n)&&o.push("path="+n),Yf.isString(i)&&o.push("domain="+i),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var PAy=e=>e instanceof _$?{...e}:e;function LTr(e,t){t=t||{};let r={};function n(s,u,l,m){return Yf.isPlainObject(s)&&Yf.isPlainObject(u)?Yf.merge.call({caseless:m},s,u):Yf.isPlainObject(u)?Yf.merge({},u):Yf.isArray(u)?u.slice():u}function i(s,u,l,m){if(Yf.isUndefined(u)){if(!Yf.isUndefined(s))return n(void 0,s,l,m)}else return n(s,u,l,m)}function a(s,u){if(!Yf.isUndefined(u))return n(void 0,u)}function o(s,u){if(Yf.isUndefined(u)){if(!Yf.isUndefined(s))return n(void 0,s)}else return n(void 0,u)}function c(s,u,l){if(l in t)return n(s,u);if(l in e)return n(void 0,s)}let d={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>i(PAy(s),PAy(u),l,!0)};return Yf.forEach(Object.keys({...e,...t}),function(u){let l=d[u]||i,m=l(e[u],t[u],u);Yf.isUndefined(m)&&l!==c||(r[u]=m)}),r}var I1s=e=>{let t=LTr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=_$.from(o),t.url=osa(usa(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Yf.isFormData(r)){if(T2.hasStandardBrowserEnv||T2.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Yf.isFunction(r.getHeaders)){let d=r.getHeaders(),s=["content-type","content-length"];Object.entries(d).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(T2.hasStandardBrowserEnv&&(n&&Yf.isFunction(n)&&(n=n(t)),n||n!==!1&&OAy(t.url))){let d=i&&a&&AAy.read(a);d&&o.set(i,d)}return t};var WiC=typeof XMLHttpRequest<"u",wAy=WiC&&function(e){return new Promise(function(r,n){let i=I1s(e),a=i.data,o=_$.from(i.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:s}=i,u,l,m,A,P;function C(){A&&A(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let I=new XMLHttpRequest;I.open(i.method.toUpperCase(),i.url,!0),I.timeout=i.timeout;function T(){if(!I)return;let U=_$.from("getAllResponseHeaders"in I&&I.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?I.responseText:I.response,status:I.status,statusText:I.statusText,headers:U,config:e,request:I};o9r(function(re){r(re),C()},function(re){n(re),C()},V),I=null}"onloadend"in I?I.onloadend=T:I.onreadystatechange=function(){!I||I.readyState!==4||I.status===0&&!(I.responseURL&&I.responseURL.indexOf("file:")===0)||setTimeout(T)},I.onabort=function(){I&&(n(new Pm("Request aborted",Pm.ECONNABORTED,e,I)),I=null)},I.onerror=function(R){let V=R&&R.message?R.message:"Network Error",$=new Pm(V,Pm.ERR_NETWORK,e,I);$.event=R||null,n($),I=null},I.ontimeout=function(){let R=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||EZa;i.timeoutErrorMessage&&(R=i.timeoutErrorMessage),n(new Pm(R,V.clarifyTimeoutError?Pm.ETIMEDOUT:Pm.ECONNABORTED,e,I)),I=null},a===void 0&&o.setContentType(null),"setRequestHeader"in I&&Yf.forEach(o.toJSON(),function(R,V){I.setRequestHeader(V,R)}),Yf.isUndefined(i.withCredentials)||(I.withCredentials=!!i.withCredentials),c&&c!=="json"&&(I.responseType=i.responseType),s&&([m,P]=HOi(s,!0),I.addEventListener("progress",m)),d&&I.upload&&([l,A]=HOi(d),I.upload.addEventListener("progress",l),I.upload.addEventListener("loadend",A)),(i.cancelToken||i.signal)&&(u=U=>{I&&(n(!U||U.type?new pnt(null,e,I):U),I.abort(),I=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));let z=vJo(i.url);if(z&&T2.protocols.indexOf(z)===-1){n(new Pm("Unsupported protocol "+z+":",Pm.ERR_BAD_REQUEST,e));return}I.send(a||null)})};var HiC=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(s){if(!i){i=!0,c();let u=s instanceof Error?s:this.reason;n.abort(u instanceof Pm?u:new pnt(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new Pm(`timeout ${t} of ms exceeded`,Pm.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=n;return d.unsubscribe=()=>Yf.asap(c),d}},jAy=HiC;var GiC=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},JiC=async function*(e,t){for await(let r of KiC(e))yield*GiC(r,t)},KiC=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Hvf=(e,t,r,n)=>{let i=JiC(e,t),a=0,o,c=d=>{o||(o=!0,n&&n(d))};return new ReadableStream({async pull(d){try{let{done:s,value:u}=await i.next();if(s){c(),d.close();return}let l=u.byteLength;if(r){let m=a+=l;r(m)}d.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(d){return c(d),i.return()}},{highWaterMark:2})};var EAy=64*1024,{isFunction:B1s}=Yf,$iC=(({Request:e,Response:t})=>({Request:e,Response:t}))(Yf.global),{ReadableStream:SAy,TextEncoder:DAy}=Yf.global,CAy=(e,...t)=>{try{return!!e(...t)}catch{return!1}},YiC=e=>{e=Yf.merge.call({skipUndefined:!0},$iC,e);let{fetch:t,Request:r,Response:n}=e,i=t?B1s(t):typeof fetch=="function",a=B1s(r),o=B1s(n);if(!i)return!1;let c=i&&B1s(SAy),d=i&&(typeof DAy=="function"?(P=>C=>P.encode(C))(new DAy):async P=>new Uint8Array(await new r(P).arrayBuffer())),s=a&&c&&CAy(()=>{let P=!1,C=new r(T2.origin,{body:new SAy,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),u=o&&c&&CAy(()=>Yf.isReadableStream(new n("").body)),l={stream:u&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,I)=>{let T=C&&C[P];if(T)return T.call(C);throw new Pm(`Response type '${P}' is not supported`,Pm.ERR_NOT_SUPPORT,I)})});let m=async P=>{if(P==null)return 0;if(Yf.isBlob(P))return P.size;if(Yf.isSpecCompliantForm(P))return(await new r(T2.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(Yf.isArrayBufferView(P)||Yf.isArrayBuffer(P))return P.byteLength;if(Yf.isURLSearchParams(P)&&(P=P+""),Yf.isString(P))return(await d(P)).byteLength},A=async(P,C)=>{let I=Yf.toFiniteNumber(P.getContentLength());return I??m(C)};return async P=>{let{url:C,method:I,data:T,signal:z,cancelToken:U,timeout:R,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:Y,withCredentials:te="same-origin",fetchOptions:ne}=I1s(P),Oe=t||fetch;re=re?(re+"").toLowerCase():"text";let ge=jAy([z,U&&U.toAbortSignal()],R),ve=null,be=ge&&ge.unsubscribe&&(()=>{ge.unsubscribe()}),Ie;try{if($&&s&&I!=="get"&&I!=="head"&&(Ie=await A(Y,T))!==0){let De=new r(C,{method:"POST",body:T,duplex:"half"}),Lt;if(Yf.isFormData(T)&&(Lt=De.headers.get("content-type"))&&Y.setContentType(Lt),De.body){let[Xe,Yt]=CZa(Ie,HOi(MZa($)));T=Hvf(De.body,EAy,Xe,Yt)}}Yf.isString(te)||(te=te?"include":"omit");let Be=a&&"credentials"in r.prototype,Se={...ne,signal:ge,method:I.toUpperCase(),headers:Y.normalize().toJSON(),body:T,duplex:"half",credentials:Be?te:void 0};ve=a&&new r(C,Se);let St=await(a?Oe(ve,ne):Oe(C,Se)),yt=u&&(re==="stream"||re==="response");if(u&&(V||yt&&be)){let De={};["status","statusText","headers"].forEach(It=>{De[It]=St[It]});let Lt=Yf.toFiniteNumber(St.headers.get("content-length")),[Xe,Yt]=V&&CZa(Lt,HOi(MZa(V),!0))||[];St=new n(Hvf(St.body,EAy,Xe,()=>{Yt&&Yt(),be&&be()}),De)}re=re||"text";let Re=await l[Yf.findKey(l,re)||"text"](St,P);return!yt&&be&&be(),await new Promise((De,Lt)=>{o9r(De,Lt,{data:Re,headers:_$.from(St.headers),status:St.status,statusText:St.statusText,config:P,request:ve})})}catch(Be){throw be&&be(),Be&&Be.name==="TypeError"&&/Load failed|fetch/i.test(Be.message)?Object.assign(new Pm("Network Error",Pm.ERR_NETWORK,P,ve),{cause:Be.cause||Be}):Pm.from(Be,Be&&Be.code,P,ve)}}},XiC=new Map,Gvf=e=>{let t=e?e.env:{},{fetch:r,Request:n,Response:i}=t,a=[n,i,r],o=a.length,c=o,d,s,u=XiC;for(;c--;)d=a[c],s=u.get(d),s===void 0&&u.set(d,s=c?new Map:YiC(t)),u=s;return s},yC9=Gvf();var Jvf={http:mAy,xhr:wAy,fetch:{get:Gvf}};Yf.forEach(Jvf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var MAy=e=>`- ${e}`,kiC=e=>Yf.isFunction(e)||e===null||e===!1,T1s={getAdapter:(e,t)=>{e=Yf.isArray(e)?e:[e];let{length:r}=e,n,i,a={};for(let o=0;o<r;o++){n=e[o];let c;if(i=n,!kiC(n)&&(i=Jvf[(c=String(n)).toLowerCase()],i===void 0))throw new Pm(`Unknown adapter '${c}'`);if(i&&(Yf.isFunction(i)||(i=i.get(t))))break;a[c||"#"+o]=i}if(!i){let o=Object.entries(a).map(([d,s])=>`adapter ${d} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
@@ -2402,10 +2402,10 @@ ${R}${z}${V}${gro}`});function Yqs({message:e,error:t,logger:r,logLevel:n=z1.Err
2402
2402
  Run ${md.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
2403
2403
  Run ${md.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),BZa(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function eIf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!w9y(e))return;let i=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,d)=>c.generatorName.localeCompare(d.generatorName)||c.currentVersion.localeCompare(d.currentVersion));for(let c of o)i+=`
2404
2404
  ${await Q8C(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+md.dim(c.currentVersion)+md.reset(" \u2192 ")+md.green(c.latestVersion);return i+=`
2405
- `,n?BZa(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Q8C(e){let r=await new P9y.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 L8C({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await E9y({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let m=N3i(u.name,l),A=await tLr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await E9y({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let l=N3i(s.name,u),m=await tLr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:u});m!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function E9y({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await bTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(i!=null&&d.groupName!==i))for(let s of d.generators)n!=null&&s.name!==n||await r(a.workspaceName,d.groupName,s,o)}})}))}function S9y(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let d=Gxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function eRs({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await L8C({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...S9y(s,d,t.logger));else o.push(...S9y(c.versions,void 0,t.logger))}return o}var oXo=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var Pro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var tIf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),D9y=typeof globalThis.AbortController=="function",C9y=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",M9y=typeof globalThis.ReadableStream=="function",I9y=typeof globalThis.FormData=="function",tRs=["get","post","put","patch","head","delete"],U8C=()=>{};U8C();var B9y={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},rRs=2147483647,T9y=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,nRs=Symbol("stop"),q9y={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},R9y={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var V8C=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=T9y,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},N9y=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},F9y=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(N9y(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},x9y=(e,t,r)=>{if(!e.body)return e;let n=V8C(r??e.body);return new Request(e,{duplex:"half",body:N9y(e.body,n,t)})};var wro=e=>e!==null&&typeof e=="object";var uXo=(...e)=>{for(let t of e)if((!wro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return iIf({},...e)},rIf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iRs(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:iIf(e[r]??[],t[r]??[])}var nIf=(e={},t={})=>({beforeRequest:iRs(e,t,"beforeRequest"),beforeRetry:iRs(e,t,"beforeRetry"),afterResponse:iRs(e,t,"afterResponse"),beforeError:iRs(e,t,"beforeError")}),iIf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(wro(i)){for(let[a,o]of Object.entries(i))wro(o)&&a in t&&(o=iIf(t[a],o)),t={...t,[a]:o};wro(i.hooks)&&(n=nIf(n,i.hooks),t.hooks=n),wro(i.headers)&&(r=rIf(r,i.headers),t.headers=r)}return t};var Q9y=e=>tRs.includes(e)?e.toUpperCase():e,W8C=["get","put","head","delete","options","trace"],H8C=[408,413,429,500,502,503,504],G8C=[413,429,503],z9y={limit:2,methods:W8C,statusCodes:H8C,afterStatusCodes:G8C,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},L9y=(e={})=>{if(typeof e=="number")return{...z9y,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...z9y,...e}};async function aIf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Pro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function oIf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var U9y=(e,t)=>{let r={};for(let n in t)!(n in R9y)&&!(n in q9y)&&!(n in e)&&(r[n]=t[n]);return r},V9y=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var sXo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>rRs)throw new RangeError(`The \`timeout\` option cannot be greater than ${rRs}`);await Promise.resolve();let c=await n._fetch();for(let d of n._options.hooks.afterResponse){let s=await d(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let d=new oXo(c,n.request,n._options);for(let s of n._options.hooks.beforeError)d=await s(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!M9y)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return F9y(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,d=[];c&&!c.bodyUsed&&d.push(c.body?.cancel()),n.request.bodyUsed||d.push(n.request.body?.cancel()),await Promise.all(d)});for(let[c,d]of Object.entries(B9y))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:rIf(this._input.headers,r.headers),hooks:nIf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Q9y(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:L9y(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(D9y&&C9y){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(tIf&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),V9y(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(I9y&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!tIf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=x9y(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Pro)throw t;if(t instanceof oXo){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),rRs);if(this._retryCount<1)throw r;await oIf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===nRs)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=U9y(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):aIf(this._originalRequest,t,this.abortController,this._options)}};var uIf=e=>{let t=(r,n)=>sXo.create(r,uXo(e,n));for(let r of tRs)t[r]=(n,i)=>sXo.create(n,uXo(e,i,{method:r}));return t.create=r=>uIf(uXo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),uIf(uXo(e,r))),t.stop=nRs,t},J8C=uIf(),W9y=J8C;var pVy=fa(dVy(),1);function dIf(e){let t=(0,pVy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var uWy=fa(oWy(),1),sWy=fa(e5r(),1),jIf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},EIf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function SIf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??dIf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,uWy.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await W9y(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new jIf(e):l}if(t.allVersions)return s;let u=new EIf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,P]of Object.entries(s.versions))P.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=sWy.default.maxSatisfying(A,r),!r)throw u}let{time:m}=s;if(s=s.versions[r],s.time=m,!s)throw u}return s}async function _Xo(e,t){let{version:r}=await SIf(e.toLowerCase(),t);return r}async function m2i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:_Xo(e.packageName,{version:t?"prerelease":"latest"})}var cWy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],yRs=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=z1.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new kqs(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.85.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${md.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Cue}failWithoutThrowing(t,r){this.didSucceed=!1,Yqs({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await AZa()).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 j9y({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2405
+ `,n?BZa(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function Q8C(e){let r=await new P9y.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 L8C({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await E9y({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let m=N3i(u.name,l),A=await tLr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await E9y({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let l=N3i(s.name,u),m=await tLr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:u});m!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function E9y({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await bTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(i!=null&&d.groupName!==i))for(let s of d.generators)n!=null&&s.name!==n||await r(a.workspaceName,d.groupName,s,o)}})}))}function S9y(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let d=Gxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function eRs({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await L8C({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...S9y(s,d,t.logger));else o.push(...S9y(c.versions,void 0,t.logger))}return o}var oXo=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var Pro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var tIf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),D9y=typeof globalThis.AbortController=="function",C9y=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",M9y=typeof globalThis.ReadableStream=="function",I9y=typeof globalThis.FormData=="function",tRs=["get","post","put","patch","head","delete"],U8C=()=>{};U8C();var B9y={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},rRs=2147483647,T9y=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,nRs=Symbol("stop"),q9y={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},R9y={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var V8C=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=T9y,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},N9y=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},F9y=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(N9y(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},x9y=(e,t,r)=>{if(!e.body)return e;let n=V8C(r??e.body);return new Request(e,{duplex:"half",body:N9y(e.body,n,t)})};var wro=e=>e!==null&&typeof e=="object";var uXo=(...e)=>{for(let t of e)if((!wro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return iIf({},...e)},rIf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iRs(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:iIf(e[r]??[],t[r]??[])}var nIf=(e={},t={})=>({beforeRequest:iRs(e,t,"beforeRequest"),beforeRetry:iRs(e,t,"beforeRetry"),afterResponse:iRs(e,t,"afterResponse"),beforeError:iRs(e,t,"beforeError")}),iIf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(wro(i)){for(let[a,o]of Object.entries(i))wro(o)&&a in t&&(o=iIf(t[a],o)),t={...t,[a]:o};wro(i.hooks)&&(n=nIf(n,i.hooks),t.hooks=n),wro(i.headers)&&(r=rIf(r,i.headers),t.headers=r)}return t};var Q9y=e=>tRs.includes(e)?e.toUpperCase():e,W8C=["get","put","head","delete","options","trace"],H8C=[408,413,429,500,502,503,504],G8C=[413,429,503],z9y={limit:2,methods:W8C,statusCodes:H8C,afterStatusCodes:G8C,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},L9y=(e={})=>{if(typeof e=="number")return{...z9y,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...z9y,...e}};async function aIf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Pro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function oIf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var U9y=(e,t)=>{let r={};for(let n in t)!(n in R9y)&&!(n in q9y)&&!(n in e)&&(r[n]=t[n]);return r},V9y=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var sXo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>rRs)throw new RangeError(`The \`timeout\` option cannot be greater than ${rRs}`);await Promise.resolve();let c=await n._fetch();for(let d of n._options.hooks.afterResponse){let s=await d(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let d=new oXo(c,n.request,n._options);for(let s of n._options.hooks.beforeError)d=await s(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!M9y)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return F9y(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,d=[];c&&!c.bodyUsed&&d.push(c.body?.cancel()),n.request.bodyUsed||d.push(n.request.body?.cancel()),await Promise.all(d)});for(let[c,d]of Object.entries(B9y))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:rIf(this._input.headers,r.headers),hooks:nIf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Q9y(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:L9y(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(D9y&&C9y){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(tIf&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),V9y(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(I9y&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!tIf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=x9y(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Pro)throw t;if(t instanceof oXo){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),rRs);if(this._retryCount<1)throw r;await oIf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===nRs)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=U9y(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):aIf(this._originalRequest,t,this.abortController,this._options)}};var uIf=e=>{let t=(r,n)=>sXo.create(r,uXo(e,n));for(let r of tRs)t[r]=(n,i)=>sXo.create(n,uXo(e,i,{method:r}));return t.create=r=>uIf(uXo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),uIf(uXo(e,r))),t.stop=nRs,t},J8C=uIf(),W9y=J8C;var pVy=fa(dVy(),1);function dIf(e){let t=(0,pVy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var uWy=fa(oWy(),1),sWy=fa(e5r(),1),jIf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},EIf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function SIf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??dIf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,uWy.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await W9y(o,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new jIf(e):l}if(t.allVersions)return s;let u=new EIf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,P]of Object.entries(s.versions))P.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=sWy.default.maxSatisfying(A,r),!r)throw u}let{time:m}=s;if(s=s.versions[r],s.time=m,!s)throw u}return s}async function _Xo(e,t){let{version:r}=await SIf(e.toLowerCase(),t);return r}async function m2i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:_Xo(e.packageName,{version:t?"prerelease":"latest"})}var cWy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],yRs=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=z1.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new kqs(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.86.0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${md.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Cue}failWithoutThrowing(t,r){this.didSucceed=!1,Yqs({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await AZa()).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 j9y({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2406
2406
  `)||(r+=`
2407
2407
  `),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=cKl(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 eXo(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(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new Cue}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await AZa()).sendEvent(t)}logger=v5r((t,...r)=>this.log(t,...r));stderr=v5r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=lWy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?lWy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=cWy[this.numTasks++%cWy.length],o=md.hex(a)(i);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===oV.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=>$xi.indexOf(i.level)>=$xi.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===z1.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await m2i({cliEnvironment:this.environment,includePreReleases:t}),n=Gxe(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await eRs({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await zMf({message:t,default:r})}async getInput(t){return await QMf({message:t.message,default:t.default})}};function lWy(e){return`[${e}]:`}var fqr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};var Qnt=class extends fqr{definition;sources;type="fern";constructor({definition:t,sources:r,...n}){super(n),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var dqr={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,wrapReferencesToNullableInOptional:!0,coerceOptionalSchemasToNullable:!0};function hXo({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??dqr.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??dqr.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??dqr.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??dqr.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??dqr.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??dqr.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??dqr.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??dqr.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??dqr.respectForwardCompatibleEnums,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??dqr.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??dqr.coerceOptionalSchemasToNullable}}var swe={openapi:e=>({...e,type:"openapi",_visit:function(t){return swe._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return swe._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 Iro={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Iro._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Rde={basic:e=>({...e,type:"basic",_visit:function(t){return Rde._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Rde._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Rde._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Rde._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Rde._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 fS={primitive:e=>({value:e,type:"primitive",_visit:function(t){return fS._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return fS._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return fS._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return fS._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return fS._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return fS._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return fS._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return fS._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return fS._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 AO={int:e=>({value:e,type:"int",_visit:function(t){return AO._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return AO._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return AO._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return AO._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return AO._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return AO._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return AO._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return AO._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return AO._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return AO._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return AO._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var O2i={boolean:e=>({value:e,type:"boolean",_visit:function(t){return O2i._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return O2i._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 A2i={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return A2i._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return A2i._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 vRs={};ff(vRs,{Availability:()=>Nde,CustomCodeSample:()=>eVr,EndpointExample:()=>eyt,EndpointResponseExample:()=>tyt,HttpMethod:()=>xde,LiteralSchemaValue:()=>jV,MultipartRequestPropertyEncoding:()=>MIf,MultipartSchema:()=>tVr,OneOfSchema:()=>rVr,Pagination:()=>Lnt,PrimitiveSchemaValue:()=>lq,Request:()=>pqr,Response:()=>qbe,RetriesConfiguration:()=>yXo,Schema:()=>Wj,SupportedSdkLanguage:()=>Fde,WebhookHttpMethod:()=>CIf,WebsocketMessageOrigin:()=>DIf});var DIf={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case DIf.Client:return t.client();case DIf.Server:return t.server();default:return t._other()}}};var CIf={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case CIf.Get:return t.get();case CIf.Post:return t.post();default:return t._other()}}};var Nde={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case Nde.GenerallyAvailable:return t.generallyAvailable();case Nde.Beta:return t.beta();case Nde.Deprecated:return t.deprecated();default:return t._other()}}};var yXo={disabled:e=>({value:e,type:"disabled",_visit:function(t){return yXo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var Lnt={cursor:e=>({...e,type:"cursor",_visit:function(t){return Lnt._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Lnt._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Lnt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var eVr={language:e=>({...e,type:"language",_visit:function(t){return eVr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return eVr._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 Fde={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case Fde.Curl:return t.curl();case Fde.Python:return t.python();case Fde.Javascript:return t.javascript();case Fde.Typescript:return t.typescript();case Fde.Go:return t.go();case Fde.Ruby:return t.ruby();case Fde.Csharp:return t.csharp();case Fde.Java:return t.java();case Fde.Js:return t.js();case Fde.Node:return t.node();case Fde.Ts:return t.ts();case Fde.Nodets:return t.nodets();case Fde.Golang:return t.golang();case Fde.Dotnet:return t.dotnet();case Fde.Jvm:return t.jvm();default:return t._other()}}};var eyt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return eyt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return eyt._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 tyt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return tyt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return tyt._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 xde={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case xde.Get:return t.get();case xde.Post:return t.post();case xde.Put:return t.put();case xde.Patch:return t.patch();case xde.Delete:return t.delete();case xde.Head:return t.head();case xde.Options:return t.options();case xde.Trace:return t.trace();default:return t._other()}}};var pqr={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return pqr._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return pqr._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return pqr._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return pqr._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 MIf={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case MIf.Json:return t.json();case MIf.Form:return t.form();default:return t._other()}}};var tVr={file:e=>({...e,type:"file",_visit:function(t){return tVr._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return tVr._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 qbe={file:e=>({...e,type:"file",_visit:function(t){return qbe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return qbe._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return qbe._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return qbe._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return qbe._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return qbe._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return qbe._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 Wj={primitive:e=>({...e,type:"primitive",_visit:function(t){return Wj._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Wj._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Wj._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Wj._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Wj._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Wj._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Wj._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Wj._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Wj._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Wj._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Wj._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 lq={int:e=>({...e,type:"int",_visit:function(t){return lq._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return lq._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return lq._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return lq._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return lq._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return lq._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return lq._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return lq._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return lq._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return lq._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return lq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var jV={boolean:e=>({value:e,type:"boolean",_visit:function(t){return jV._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return jV._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 rVr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return rVr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return rVr._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 ZCe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return ZCe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return ZCe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return ZCe._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return ZCe._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 QL={file:e=>({...e,type:"file",_visit:function(t){return QL._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return QL._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return QL._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return QL._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return QL._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return QL._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return QL._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 mh={primitive:e=>({...e,type:"primitive",_visit:function(t){return mh._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return mh._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return mh._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return mh._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return mh._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return mh._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return mh._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return mh._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return mh._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return mh._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return mh._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 Unt={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Unt._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Unt._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 z0={int:e=>({...e,type:"int",_visit:function(t){return z0._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return z0._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return z0._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return z0._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return z0._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return z0._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return z0._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return z0._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return z0._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return z0._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return z0._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var Aj={};ff(Aj,{AllOfPropertyConflict:()=>nno,ArraySchema:()=>qNs,ArraySchemaWithExample:()=>fFs,Availability:()=>SRs,Base64WithExample:()=>oFs,BasicSecurityScheme:()=>CRs,BearerSecurityScheme:()=>MRs,BooleanSchema:()=>DNs,BooleanWithExample:()=>uFs,BytesResponse:()=>Jro,CasingOverrides:()=>TRs,CommonProperty:()=>UNs,CommonPropertyWithExample:()=>mFs,CursorPagination:()=>fNs,CustomCodeSample:()=>cNs,CustomCodeSampleLanguage:()=>oNs,CustomCodeSampleSdk:()=>sNs,CustomPagination:()=>pNs,DateWithExample:()=>aFs,DatetimeWithExample:()=>iFs,DiscriminatedOneOfSchema:()=>QNs,DiscriminatedOneOfSchemaWithExample:()=>bFs,DoubleSchema:()=>ENs,DoubleWithExample:()=>rFs,Encoding:()=>ERs,Endpoint:()=>_Ns,EndpointExample:()=>Xro,EndpointResponseExample:()=>aNs,EndpointSdkName:()=>aVr,EndpointSecurity:()=>zro,EndpointWithExample:()=>QWy,EnumSchema:()=>Nro,EnumSchemaWithExample:()=>cFs,EnumValue:()=>j2i,ErrorExample:()=>eNs,FernExample:()=>rNs,FileResponse:()=>Hro,FileSchema:()=>GRs,FloatWithExample:()=>tFs,FormUrlEncodedRequest:()=>XRs,FullEndpointExample:()=>lNs,FullExample:()=>s5,FullObjectExample:()=>LRs,FullOneOfExample:()=>VRs,GlobalHeader:()=>MNs,Header:()=>S2i,HeaderExample:()=>Yro,HeaderSecurityScheme:()=>IRs,HeaderWithExample:()=>M2i,HttpEndpointServer:()=>Kro,HttpError:()=>tNs,HttpErrorWithExample:()=>YNs,HttpMethod:()=>Qro,IdempotencyHeader:()=>INs,Int64WithExample:()=>ZNs,IntSchema:()=>wNs,IntWithExample:()=>XNs,JsonRequest:()=>YRs,JsonRequestWithExample:()=>GNs,JsonResponse:()=>Gro,JsonResponseWithExample:()=>ono,KeyValuePair:()=>URs,LiteralExample:()=>zRs,LiteralSchema:()=>rno,LiteralSchemaValue:()=>BNs,LongSchema:()=>jNs,MapSchema:()=>RNs,MapSchemaWithExample:()=>dFs,MultipartRequest:()=>Wro,MultipartRequestProperty:()=>$Rs,MultipartRequestPropertyEncoding:()=>KRs,MultipartSchema:()=>JRs,NamedFullExample:()=>nyt,Namespace:()=>qRs,NamespaceId:()=>xRs,NullExample:()=>QRs,NullableSchema:()=>FNs,NullableSchemaWithExample:()=>_Fs,OauthSecurityScheme:()=>NRs,ObjectProperty:()=>zNs,ObjectPropertyConflictInfo:()=>ino,ObjectPropertyWithExample:()=>vFs,ObjectSchema:()=>TNs,ObjectSchemaWithExample:()=>hFs,OctetStreamRequest:()=>Vro,OffsetPagination:()=>dNs,OneOfSchema:()=>xNs,OneOfSchemaWithExample:()=>yFs,OpenApiIntermediateRepresentation:()=>xWy,OpenApiSource:()=>ARs,OptionalSchema:()=>NNs,OptionalSchemaWithExample:()=>pFs,Pagination:()=>Zro,ParseFormUrlEncodedRequest:()=>JNs,ParseMultipartRequest:()=>HNs,ParseOctetStreamRequest:()=>WNs,PathParameter:()=>Lro,PathParameterExample:()=>nNs,PathParameterWithExample:()=>VNs,PrimitiveExample:()=>xro,PrimitiveSchema:()=>C2i,PrimitiveSchemaValue:()=>CNs,PrimitiveSchemaValueWithExample:()=>sFs,PrimitiveSchemaWithExample:()=>uno,PropertyKey:()=>Fro,ProtobufEncoding:()=>jRs,ProtobufSource:()=>PRs,QueryParameter:()=>Uro,QueryParameterExample:()=>$ro,QueryParameterWithExample:()=>ano,QuerySecurityScheme:()=>BRs,ReferencedSchema:()=>oVr,Request:()=>ZRs,RequestWithExample:()=>KNs,Response:()=>kRs,ResponseWithExample:()=>$Ns,RetriesConfiguration:()=>kro,Schema:()=>hM,SchemaId:()=>kCe,SchemaWithExample:()=>F6,Schemas:()=>PNs,SdkGroup:()=>RRs,SdkGroupInfo:()=>WRs,SdkGroupName:()=>E2i,SecurityScheme:()=>FRs,SecuritySchemeId:()=>Rro,Server:()=>mXo,Source:()=>wRs,StatusCode:()=>nVr,StreamingResponseExample:()=>iNs,StringSchema:()=>SNs,StringSchemaWithExample:()=>nFs,SupportedSdkLanguage:()=>uNs,Tag:()=>DRs,TagId:()=>eMe,Tags:()=>HRs,TextResponse:()=>D2i,Uint64WithExample:()=>eFs,UintWithExample:()=>kNs,UnDiscriminatedOneOfSchema:()=>LNs,UnDiscriminatedOneOfSchemaWithExample:()=>gFs,UnknownSchemaWithExample:()=>lFs,Webhook:()=>hNs,WebhookExampleCall:()=>tno,WebhookHttpMethod:()=>eno,WebhookWithExample:()=>LWy,WebsocketChannel:()=>ANs,WebsocketHandshake:()=>yNs,WebsocketHandshakeWithExample:()=>zWy,WebsocketMessageExample:()=>mNs,WebsocketMessageOrigin:()=>vNs,WebsocketMessageSchema:()=>bNs,WebsocketServer:()=>gNs,WebsocketSessionExample:()=>ONs,WithAvailability:()=>BP,WithDescription:()=>ky,WithEncoding:()=>Kxe,WithInline:()=>N6,WithName:()=>eD,WithNamespace:()=>dS,WithSdkGroupName:()=>dI,WithSdkMethodName:()=>iVr,WithSource:()=>ZA,WithStatusCode:()=>ryt,WithTitle:()=>fI,commons:()=>RIf,example:()=>NIf,finalIr:()=>FIf,parseIr:()=>xIf});var RIf={};ff(RIf,{BasicSecurityScheme:()=>CRs,BearerSecurityScheme:()=>MRs,Encoding:()=>ERs,HeaderSecurityScheme:()=>IRs,Namespace:()=>qRs,NamespaceId:()=>xRs,OauthSecurityScheme:()=>NRs,OpenApiSource:()=>ARs,ProtobufEncoding:()=>jRs,ProtobufSource:()=>PRs,QuerySecurityScheme:()=>BRs,SchemaId:()=>kCe,SdkGroup:()=>RRs,SdkGroupName:()=>E2i,SecurityScheme:()=>FRs,SecuritySchemeId:()=>Rro,Server:()=>mXo,Source:()=>wRs,StatusCode:()=>nVr,Tag:()=>DRs,TagId:()=>eMe,WithAvailability:()=>BP,WithDescription:()=>ky,WithEncoding:()=>Kxe,WithInline:()=>N6,WithName:()=>eD,WithNamespace:()=>dS,WithSdkGroupName:()=>dI,WithSdkMethodName:()=>iVr,WithSource:()=>ZA,WithStatusCode:()=>ryt,WithTitle:()=>fI});var Gr={};ff(Gr,{JsonError:()=>Bro,ParseError:()=>Tro,any:()=>jWy,bigint:()=>dWy,boolean:()=>EWy,booleanLiteral:()=>wWy,date:()=>pWy,discriminant:()=>RWy,enum_:()=>gRs,getObjectLikeUtils:()=>_qr,getObjectUtils:()=>Pla,getSchemaUtils:()=>u5,isProperty:()=>w2i,lazy:()=>_Wy,lazyObject:()=>OWy,list:()=>ORs,number:()=>SWy,object:()=>mRs,objectWithoutOptionalProperties:()=>mWy,optional:()=>IIf,property:()=>yWy,record:()=>IWy,set:()=>BWy,string:()=>DWy,stringLiteral:()=>PWy,transform:()=>BIf,undiscriminatedUnion:()=>qWy,union:()=>FWy,unknown:()=>CWy,withParsedProperties:()=>qIf});var fq={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function x2(e,t){return`Expected ${t}. Received ${k5C(e)}.`}function k5C(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 zde(e){return{...e,json:fWy(e.json),parse:fWy(e.parse)}}function fWy(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(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
2408
- `)),{ok:!0,value:t}):n}}function bRs(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var Bro=class e extends Error{errors;constructor(t){super(t.map(bRs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Tro=class e extends Error{errors;constructor(t){super(t.map(bRs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function u5(e){return{optional:()=>IIf(e),transform:t=>BIf(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new Tro(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new Bro(n.errors)}}}function IIf(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:()=>fq.OPTIONAL};return{...t,...u5(t)}}function BIf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...u5(r)}}function dWy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:x2(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:x2(t,"bigint")}]},getType:()=>fq.BIGINT};return{...zde(e),...u5(e)}}var eQC=/^([+-]?\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 pWy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:x2(t,"string")}]}:eQC.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:x2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:x2(t,"Date object")}]},getType:()=>fq.DATE};return{...zde(e),...u5(e)}}function cwe(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...zde(r),...u5(r)}}}function gRs(e){let t=new Set(e);return cwe(fq.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:x2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:x2(n,"enum")}]}:{ok:!0,value:n})()}function _Wy(e){let t=TIf(e);return{...t,...u5(t)}}function TIf(e){return{parse:(t,r)=>qro(e).parse(t,r),json:(t,r)=>qro(e).json(t,r),getType:()=>qro(e).getType()}}function qro(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function vXo(e){return Object.entries(e)}function bXo(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function P2i(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function gXo(e){return Object.keys(e)}function hWy(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function _qr(e){return{withParsedProperties:t=>qIf(e,t)}}function qIf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(n,i)=>{if(!P2i(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:x2(n,"object")}]};let a=new Set(Object.keys(t)),o=bXo(n,Object.keys(n).filter(c=>!a.has(c)));return e.json(o,i)},getType:()=>e.getType()};return{...r,...u5(r),..._qr(r)}}function yWy(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function w2i(e){return e.isProperty}function mRs(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>w2i(n)?n.rawKey:r),_getParsedProperties:()=>gXo(e),parse:(r,n)=>{let i={},a=[];for(let[o,c]of vXo(e)){let d=w2i(c)?c.rawKey:o,s=w2i(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};i[d]=u,gWy(s)&&a.push(d)}return vWy({value:r,requiredKeys:a,getProperty:o=>{let c=i[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,o]of vXo(e)){let c=w2i(o)?o.valueSchema:o;gWy(c)&&i.push(a)}return vWy({value:r,requiredKeys:i,getProperty:a=>{let o=e[a];if(o!=null)return w2i(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>fq.OBJECT};return{...zde(t),...u5(t),..._qr(t),...Pla(t)}}function vWy({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!P2i(e))return{ok:!1,errors:[{path:a,message:x2(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let m=l.transform(u);m.ok?d[l.transformedKey]=m.value:(d[s]=u,c.push(...m.errors))}else switch(n){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||i?{ok:!0,value:d}:{ok:!1,errors:c}}function Pla(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>bWy({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>bWy({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>fq.OBJECT};return{...r,...u5(r),..._qr(r),...Pla(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,n)=>{let i=e.parse(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},json:(r,n)=>{let i=e.json(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},getType:()=>fq.OBJECT};return{...t,...u5(t),..._qr(t),...Pla(t)}}}}function bWy({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,o]=hWy(gXo(t),s=>i.has(s)),c=r(bXo(t,o)),d=n(bXo(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function gWy(e){return!tQC(e)}function tQC(e){switch(e.getType()){case fq.ANY:case fq.UNKNOWN:case fq.OPTIONAL:return!0;default:return!1}}function mWy(e){return mRs(e)}function OWy(e){let t={...TIf(e),_getRawProperties:()=>qro(e)._getRawProperties(),_getParsedProperties:()=>qro(e)._getParsedProperties()};return{...t,...u5(t),..._qr(t),...Pla(t)}}function ORs(e){let t={parse:(r,n)=>AWy(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>AWy(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>fq.LIST};return{...zde(t),...u5(t)}}function AWy(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:x2(e,"list"),path:[]}]}}function PWy(e){return cwe(fq.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:x2(r,`"${e}"`)}]})()}function wWy(e){return cwe(fq.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:x2(r,`${e.toString()}`)}]})()}var jWy=cwe(fq.ANY,e=>({ok:!0,value:e}));var EWy=cwe(fq.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:x2(e,"boolean")}]});var SWy=cwe(fq.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:x2(e,"number")}]});var DWy=cwe(fq.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:x2(e,"string")}]});var CWy=cwe(fq.UNKNOWN,e=>({ok:!0,value:e}));function IWy(e,t){let r={parse:(n,i)=>MWy({value:n,isKeyNumeric:e.getType()===fq.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>MWy({value:n,isKeyNumeric:e.getType()===fq.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>fq.RECORD};return{...zde(r),...u5(r)}}function MWy({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return P2i(e)?vXo(e).reduce((a,[o,c])=>{if(c==null)return a;let d=a,s=o;if(t){let A=o.length>0?Number(o):NaN;isNaN(A)||(s=A)}let u=r(s),l=n(c,s);if(d.ok&&u.ok&&l.ok)return{ok:!0,value:{...d.value,[u.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),u.ok||m.push(...u.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:x2(e,"object")}]}}function BWy(e){let t=ORs(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:x2(n,"Set")}]},getType:()=>fq.SET};return{...zde(r),...u5(r)}}function qWy(e){let t={parse:(r,n)=>TWy((i,a)=>i.parse(r,a),e,n),json:(r,n)=>TWy((i,a)=>i.json(r,a),e,n),getType:()=>fq.UNDISCRIMINATED_UNION};return{...zde(t),...u5(t)}}function TWy(e,t,r){let n=[];for(let[i,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)n.push({path:c.path,message:`[Variant ${i}] ${c.message}`})}return{ok:!1,errors:n}}function RWy(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function FWy(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=gRs(gXo(t)),a={parse:(o,c)=>NWy({value:o,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>NWy({value:o,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>fq.UNION};return{...zde(a),...u5(a),..._qr(a)}}function NWy({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!P2i(e))return{ok:!1,errors:[{path:c,message:x2(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=n(d);if(!u.ok)return{ok:!1,errors:u.errors};let l=i(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let m=o(s,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var fI=Gr.objectWithoutOptionalProperties({title:Gr.string().optional()});var ARs=Gr.objectWithoutOptionalProperties({file:Gr.string()});var PRs=Gr.objectWithoutOptionalProperties({file:Gr.string()});var wRs=Gr.union("type",{openapi:ARs,protobuf:PRs}).transform({transform:e=>{switch(e.type){case"openapi":return swe.openapi(e);case"protobuf":return swe.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var ZA=Gr.objectWithoutOptionalProperties({source:wRs.optional()});var jRs=Gr.objectWithoutOptionalProperties({typeName:Gr.string()});var ERs=Gr.union("type",{protobuf:jRs}).transform({transform:e=>{switch(e.type){case"protobuf":return Iro.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Kxe=Gr.objectWithoutOptionalProperties({encoding:ERs.optional()});var ky=Gr.objectWithoutOptionalProperties({description:Gr.string().optional()});var SRs=Gr.enum_(["GenerallyAvailable","Beta","Deprecated"]);var BP=Gr.objectWithoutOptionalProperties({availability:SRs.optional()});var nVr=Gr.number();var ryt=Gr.objectWithoutOptionalProperties({statusCode:nVr.optional()});var eD=Gr.objectWithoutOptionalProperties({nameOverride:Gr.string().optional(),generatedName:Gr.string()});var N6=Gr.objectWithoutOptionalProperties({inline:Gr.boolean().optional()});var kCe=Gr.string();var eMe=Gr.string();var DRs=Gr.objectWithoutOptionalProperties({id:eMe}).extend(ky);var Rro=Gr.string();var CRs=Gr.objectWithoutOptionalProperties({usernameVariableName:Gr.string().optional(),usernameEnvVar:Gr.string().optional(),passwordVariableName:Gr.string().optional(),passwordEnvVar:Gr.string().optional()});var MRs=Gr.objectWithoutOptionalProperties({tokenVariableName:Gr.string().optional(),tokenEnvVar:Gr.string().optional()});var IRs=Gr.objectWithoutOptionalProperties({headerName:Gr.string(),prefix:Gr.string().optional(),headerVariableName:Gr.string().optional(),headerEnvVar:Gr.string().optional()});var BRs=Gr.objectWithoutOptionalProperties({queryParameterName:Gr.string()});var TRs=Gr.objectWithoutOptionalProperties({snake:Gr.string().optional(),camel:Gr.string().optional(),screamingSnake:Gr.string().optional(),pascal:Gr.string().optional()});var j2i=Gr.objectWithoutOptionalProperties({nameOverride:Gr.string().optional(),generatedName:Gr.string(),value:Gr.string(),casing:TRs.optional()}).extend(ky).extend(BP);var qRs=Gr.objectWithoutOptionalProperties({type:Gr.stringLiteral("namespace"),name:Gr.string()});var RRs=Gr.undiscriminatedUnion([Gr.string(),qRs]);var E2i=Gr.list(RRs);var dI=Gr.objectWithoutOptionalProperties({groupName:E2i.optional()});var dS=Gr.objectWithoutOptionalProperties({namespace:Gr.string().optional()});var Nro=Gr.objectWithoutOptionalProperties({default:j2i.optional(),values:Gr.list(j2i)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var NRs=Gr.objectWithoutOptionalProperties({scopesEnum:Nro.optional()});var FRs=Gr.union("type",{basic:CRs,bearer:MRs,header:IRs,query:BRs,oauth:NRs}).transform({transform:e=>{switch(e.type){case"basic":return Rde.basic(e);case"bearer":return Rde.bearer(e);case"header":return Rde.header(e);case"query":return Rde.query(e);case"oauth":return Rde.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var mXo=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),url:Gr.string(),audiences:Gr.list(Gr.string()).optional()}).extend(ky);var xRs=Gr.string();var iVr=Gr.objectWithoutOptionalProperties({sdkMethodName:Gr.string().optional()});var NIf={};ff(NIf,{FullExample:()=>s5,FullObjectExample:()=>LRs,FullOneOfExample:()=>VRs,KeyValuePair:()=>URs,LiteralExample:()=>zRs,NullExample:()=>QRs,PrimitiveExample:()=>xro,PropertyKey:()=>Fro});var Fro=Gr.string();var xro=Gr.union("type",{int:Gr.object({value:Gr.number()}),int64:Gr.object({value:Gr.number()}),uint:Gr.object({value:Gr.number()}),uint64:Gr.object({value:Gr.number()}),float:Gr.object({value:Gr.number()}),double:Gr.object({value:Gr.number()}),string:Gr.object({value:Gr.string()}),datetime:Gr.object({value:Gr.string()}),date:Gr.object({value:Gr.string()}),base64:Gr.object({value:Gr.string()}),boolean:Gr.object({value:Gr.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return AO.int(e.value);case"int64":return AO.int64(e.value);case"uint":return AO.uint(e.value);case"uint64":return AO.uint64(e.value);case"float":return AO.float(e.value);case"double":return AO.double(e.value);case"string":return AO.string(e.value);case"datetime":return AO.datetime(e.value);case"date":return AO.date(e.value);case"base64":return AO.base64(e.value);case"boolean":return AO.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zRs=Gr.union("type",{boolean:Gr.object({value:Gr.boolean()}),string:Gr.object({value:Gr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return O2i.boolean(e.value);case"string":return O2i.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QRs=Gr.objectWithoutOptionalProperties({});var s5=Gr.union("type",{primitive:Gr.object({value:xro}),object:Gr.lazyObject(()=>LRs),array:Gr.object({value:Gr.list(Gr.lazy(()=>s5))}),map:Gr.object({value:Gr.list(Gr.lazyObject(()=>URs))}),enum:Gr.object({value:Gr.string()}),literal:Gr.object({value:zRs}),oneOf:Gr.object({value:Gr.lazy(()=>VRs)}),null:QRs,unknown:Gr.object({value:Gr.lazy(()=>s5)})}).transform({transform:e=>{switch(e.type){case"primitive":return fS.primitive(e.value);case"object":return fS.object(e);case"array":return fS.array(e.value);case"map":return fS.map(e.value);case"enum":return fS.enum(e.value);case"literal":return fS.literal(e.value);case"oneOf":return fS.oneOf(e.value);case"null":return fS.null(e);case"unknown":return fS.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var LRs=Gr.objectWithoutOptionalProperties({properties:Gr.record(Fro,Gr.lazy(()=>s5))});var URs=Gr.objectWithoutOptionalProperties({key:xro,value:Gr.lazy(()=>s5)});var VRs=Gr.union("type",{discriminated:Gr.object({value:Gr.record(Fro,Gr.lazy(()=>s5))}),undiscriminated:Gr.object({value:Gr.lazy(()=>s5)})}).transform({transform:e=>{switch(e.type){case"discriminated":return A2i.discriminated(e.value);case"undiscriminated":return A2i.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var FIf={};ff(FIf,{AllOfPropertyConflict:()=>nno,ArraySchema:()=>qNs,Availability:()=>SRs,BooleanSchema:()=>DNs,BytesResponse:()=>Jro,CasingOverrides:()=>TRs,CommonProperty:()=>UNs,CursorPagination:()=>fNs,CustomCodeSample:()=>cNs,CustomCodeSampleLanguage:()=>oNs,CustomCodeSampleSdk:()=>sNs,CustomPagination:()=>pNs,DiscriminatedOneOfSchema:()=>QNs,DoubleSchema:()=>ENs,Endpoint:()=>_Ns,EndpointExample:()=>Xro,EndpointResponseExample:()=>aNs,EndpointSdkName:()=>aVr,EndpointSecurity:()=>zro,EnumSchema:()=>Nro,EnumValue:()=>j2i,ErrorExample:()=>eNs,FernExample:()=>rNs,FileResponse:()=>Hro,FileSchema:()=>GRs,FormUrlEncodedRequest:()=>XRs,FullEndpointExample:()=>lNs,GlobalHeader:()=>MNs,Header:()=>S2i,HeaderExample:()=>Yro,HttpEndpointServer:()=>Kro,HttpError:()=>tNs,HttpMethod:()=>Qro,IdempotencyHeader:()=>INs,IntSchema:()=>wNs,JsonRequest:()=>YRs,JsonResponse:()=>Gro,LiteralSchema:()=>rno,LiteralSchemaValue:()=>BNs,LongSchema:()=>jNs,MapSchema:()=>RNs,MultipartRequest:()=>Wro,MultipartRequestProperty:()=>$Rs,MultipartRequestPropertyEncoding:()=>KRs,MultipartSchema:()=>JRs,NullableSchema:()=>FNs,ObjectProperty:()=>zNs,ObjectPropertyConflictInfo:()=>ino,ObjectSchema:()=>TNs,OctetStreamRequest:()=>Vro,OffsetPagination:()=>dNs,OneOfSchema:()=>xNs,OpenApiIntermediateRepresentation:()=>xWy,OptionalSchema:()=>NNs,Pagination:()=>Zro,PathParameter:()=>Lro,PathParameterExample:()=>nNs,PrimitiveSchema:()=>C2i,PrimitiveSchemaValue:()=>CNs,QueryParameter:()=>Uro,QueryParameterExample:()=>$ro,ReferencedSchema:()=>oVr,Request:()=>ZRs,Response:()=>kRs,RetriesConfiguration:()=>kro,Schema:()=>hM,Schemas:()=>PNs,SdkGroupInfo:()=>WRs,StreamingResponseExample:()=>iNs,StringSchema:()=>SNs,SupportedSdkLanguage:()=>uNs,Tags:()=>HRs,TextResponse:()=>D2i,UnDiscriminatedOneOfSchema:()=>LNs,Webhook:()=>hNs,WebhookExampleCall:()=>tno,WebhookHttpMethod:()=>eno,WebsocketChannel:()=>ANs,WebsocketHandshake:()=>yNs,WebsocketMessageExample:()=>mNs,WebsocketMessageOrigin:()=>vNs,WebsocketMessageSchema:()=>bNs,WebsocketServer:()=>gNs,WebsocketSessionExample:()=>ONs});var WRs=Gr.objectWithoutOptionalProperties({summary:Gr.string().optional(),description:Gr.string().optional()});var HRs=Gr.objectWithoutOptionalProperties({tagsById:Gr.record(eMe,DRs),orderedTagIds:Gr.list(eMe).optional()});var zro=Gr.list(Gr.record(Rro,Gr.list(Gr.string())));var Qro=Gr.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Lro=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>hM),variableReference:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var Uro=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>hM),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var S2i=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>hM),env:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var aVr=Gr.objectWithoutOptionalProperties({groupName:E2i,methodName:Gr.string()});var Vro=Gr.objectWithoutOptionalProperties({contentType:Gr.string().optional()}).extend(ky).extend(ZA);var GRs=Gr.objectWithoutOptionalProperties({isOptional:Gr.boolean(),isArray:Gr.boolean()}).extend(ky);var JRs=Gr.union("type",{file:GRs,json:Gr.object({value:Gr.lazy(()=>hM)})}).transform({transform:e=>{switch(e.type){case"file":return tVr.file(e);case"json":return tVr.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var KRs=Gr.enum_(["json","form"]);var $Rs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:JRs,contentType:Gr.string().optional(),exploded:Gr.boolean().optional(),encoding:KRs.optional()}).extend(ky);var Wro=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),properties:Gr.list($Rs)}).extend(ky).extend(ZA);var YRs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM),contentType:Gr.string().optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA);var XRs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM),contentType:Gr.string().optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA);var ZRs=Gr.union("type",{octetStream:Vro,multipart:Wro,json:YRs,formUrlEncoded:XRs}).transform({transform:e=>{switch(e.type){case"octetStream":return pqr.octetStream(e);case"multipart":return pqr.multipart(e);case"json":return pqr.json(e);case"formUrlEncoded":return pqr.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var Hro=Gr.objectWithoutOptionalProperties({}).extend(ky).extend(ZA).extend(ryt);var Gro=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM),responseProperty:Gr.string().optional()}).extend(ky).extend(ZA).extend(ryt);var D2i=Gr.objectWithoutOptionalProperties({}).extend(ky).extend(ZA).extend(ryt);var Jro=Gr.objectWithoutOptionalProperties({}).extend(ky).extend(ZA).extend(ryt);var kRs=Gr.union("type",{file:Hro,json:Gro,text:D2i,bytes:Jro,streamingSse:Gro,streamingText:D2i,streamingJson:Gro}).transform({transform:e=>{switch(e.type){case"file":return qbe.file(e);case"json":return qbe.json(e);case"text":return qbe.text(e);case"bytes":return qbe.bytes(e);case"streamingSse":return qbe.streamingSse(e);case"streamingText":return qbe.streamingText(e);case"streamingJson":return qbe.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var eNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),description:Gr.string().optional(),example:Gr.lazy(()=>s5)});var tNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM).optional(),examples:Gr.list(eNs).optional()}).extend(ky).extend(eD).extend(ZA);var Kro=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),url:Gr.string().optional(),audiences:Gr.list(Gr.string()).optional()});var rNs=Gr.unknown();var nNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),parameterNameOverride:Gr.string().optional(),value:Gr.lazy(()=>s5)});var $ro=Gr.objectWithoutOptionalProperties({name:Gr.string(),value:Gr.lazy(()=>s5)});var Yro=Gr.objectWithoutOptionalProperties({name:Gr.string(),value:Gr.lazy(()=>s5)});var iNs=Gr.objectWithoutOptionalProperties({sse:Gr.boolean(),events:Gr.list(Gr.lazy(()=>s5))});var aNs=Gr.union("type",{withStreaming:iNs,withoutStreaming:Gr.object({value:Gr.lazy(()=>s5)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return tyt.withStreaming(e);case"withoutStreaming":return tyt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var oNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),language:Gr.string(),code:Gr.string(),install:Gr.string().optional()}).extend(ky);var uNs=Gr.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var sNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),sdk:uNs,code:Gr.string()}).extend(ky);var cNs=Gr.union("type",{language:oNs,sdk:sNs}).transform({transform:e=>{switch(e.type){case"language":return eVr.language(e);case"sdk":return eVr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var lNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),pathParameters:Gr.list(nNs).optional(),queryParameters:Gr.list($ro).optional(),headers:Gr.list(Yro).optional(),request:Gr.lazy(()=>s5).optional(),response:aNs.optional(),codeSamples:Gr.list(cNs)}).extend(ky);var Xro=Gr.union("type",{unknown:Gr.object({value:rNs}),full:lNs}).transform({transform:e=>{switch(e.type){case"unknown":return eyt.unknown(e.value);case"full":return eyt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var fNs=Gr.objectWithoutOptionalProperties({cursor:Gr.string(),nextCursor:Gr.property("next_cursor",Gr.string()),results:Gr.string()});var dNs=Gr.objectWithoutOptionalProperties({offset:Gr.string(),results:Gr.string(),step:Gr.string().optional(),hasNextPage:Gr.string().optional()});var pNs=Gr.objectWithoutOptionalProperties({results:Gr.string()});var Zro=Gr.union("type",{cursor:fNs,offset:dNs,custom:pNs}).transform({transform:e=>{switch(e.type){case"cursor":return Lnt.cursor(e);case"offset":return Lnt.offset(e);case"custom":return Lnt.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var kro=Gr.union("type",{disabled:Gr.object({value:Gr.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return yXo.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var _Ns=Gr.objectWithoutOptionalProperties({authed:Gr.boolean(),security:zro,internal:Gr.boolean().optional(),idempotent:Gr.boolean().optional(),method:Qro,audiences:Gr.list(Gr.string()),path:Gr.string(),summary:Gr.string().optional(),operationId:Gr.string().optional(),tags:Gr.list(eMe),pathParameters:Gr.list(Lro),queryParameters:Gr.list(Uro),headers:Gr.list(S2i),sdkName:aVr.optional(),generatedRequestName:Gr.string(),requestNameOverride:Gr.string().optional(),request:ZRs.optional(),response:kRs.optional(),errors:Gr.record(nVr,tNs),servers:Gr.list(Kro),examples:Gr.list(Xro),pagination:Zro.optional(),retries:kro.optional()}).extend(ky).extend(BP).extend(ZA).extend(dS);var eno=Gr.enum_(["GET","POST"]);var tno=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),payload:Gr.lazy(()=>s5)}).extend(ky);var hNs=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),sdkName:aVr.optional(),method:eno,summary:Gr.string().optional(),operationId:Gr.string(),tags:Gr.list(eMe),headers:Gr.list(S2i),generatedPayloadName:Gr.string(),payload:Gr.lazy(()=>hM),examples:Gr.list(tno)}).extend(ky).extend(ZA).extend(dS);var yNs=Gr.objectWithoutOptionalProperties({queryParameters:Gr.list(Uro),headers:Gr.list(S2i),pathParameters:Gr.list(Lro)});var vNs=Gr.enum_(["client","server"]);var bNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),origin:vNs,body:Gr.lazy(()=>hM)});var gNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),url:Gr.string()});var mNs=Gr.objectWithoutOptionalProperties({messageType:Gr.string(),payload:Gr.lazy(()=>s5)}).extend(ky);var ONs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),queryParameters:Gr.list($ro).optional(),headers:Gr.list(Yro).optional(),messages:Gr.list(mNs)}).extend(ky);var ANs=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),path:Gr.string(),groupName:E2i,summary:Gr.string().optional(),handshake:yNs,messages:Gr.list(bNs),servers:Gr.list(gNs),examples:Gr.list(ONs)}).extend(ky).extend(ZA);var PNs=Gr.objectWithoutOptionalProperties({rootSchemas:Gr.record(kCe,Gr.lazy(()=>hM)),namespacedSchemas:Gr.record(xRs,Gr.record(kCe,Gr.lazy(()=>hM)))});var wNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional()});var jNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional()});var ENs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional()});var SNs=Gr.objectWithoutOptionalProperties({default:Gr.string().optional(),pattern:Gr.string().optional(),format:Gr.string().optional(),minLength:Gr.number().optional(),maxLength:Gr.number().optional()});var DNs=Gr.objectWithoutOptionalProperties({default:Gr.boolean().optional()});var CNs=Gr.union("type",{int:wNs,int64:jNs,uint:Gr.object({}),uint64:Gr.object({}),float:Gr.object({}),double:ENs,string:SNs,datetime:Gr.object({}),date:Gr.object({}),base64:Gr.object({}),boolean:DNs}).transform({transform:e=>{switch(e.type){case"int":return lq.int(e);case"int64":return lq.int64(e);case"uint":return lq.uint();case"uint64":return lq.uint64();case"float":return lq.float();case"double":return lq.double(e);case"string":return lq.string(e);case"datetime":return lq.datetime();case"date":return lq.date();case"base64":return lq.base64();case"boolean":return lq.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var C2i=Gr.objectWithoutOptionalProperties({schema:CNs}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var MNs=Gr.objectWithoutOptionalProperties({header:Gr.string(),name:Gr.string().optional(),optional:Gr.boolean().optional(),env:Gr.string().optional(),schema:Gr.lazy(()=>hM).optional()});var INs=Gr.objectWithoutOptionalProperties({header:Gr.string(),name:Gr.string().optional(),env:Gr.string().optional(),schema:Gr.lazy(()=>hM).optional()});var xWy=Gr.objectWithoutOptionalProperties({apiVersion:Gr.unknown().optional(),title:Gr.string().optional(),description:Gr.string().optional(),basePath:Gr.string().optional(),servers:Gr.list(mXo),websocketServers:Gr.list(mXo),groups:Gr.record(Gr.string(),WRs),tags:HRs,hasEndpointsMarkedInternal:Gr.boolean(),endpoints:Gr.list(_Ns),webhooks:Gr.list(hNs),channels:Gr.record(Gr.string(),ANs),groupedSchemas:PNs,variables:Gr.record(Gr.string(),C2i),nonRequestReferencedSchemas:Gr.set(kCe),securitySchemes:Gr.record(Rro,FRs),globalHeaders:Gr.list(MNs).optional(),idempotencyHeaders:Gr.list(INs).optional()});var oVr=Gr.objectWithoutOptionalProperties({schema:kCe}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI);var BNs=Gr.union("type",{boolean:Gr.object({value:Gr.boolean()}),string:Gr.object({value:Gr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return jV.boolean(e.value);case"string":return jV.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var rno=Gr.objectWithoutOptionalProperties({value:BNs}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var hM=Gr.union("type",{primitive:C2i,object:Gr.lazyObject(()=>TNs),array:Gr.lazyObject(()=>qNs),map:Gr.lazyObject(()=>RNs),optional:Gr.lazyObject(()=>NNs),enum:Nro,reference:oVr,literal:rno,oneOf:Gr.object({value:Gr.lazy(()=>xNs)}),nullable:Gr.lazyObject(()=>FNs),unknown:eD}).transform({transform:e=>{switch(e.type){case"primitive":return Wj.primitive(e);case"object":return Wj.object(e);case"array":return Wj.array(e);case"map":return Wj.map(e);case"optional":return Wj.optional(e);case"enum":return Wj.enum(e);case"reference":return Wj.reference(e);case"literal":return Wj.literal(e);case"oneOf":return Wj.oneOf(e.value);case"nullable":return Wj.nullable(e);case"unknown":return Wj.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var nno=Gr.objectWithoutOptionalProperties({propertyKey:Gr.string(),allOfSchemaIds:Gr.list(kCe),conflictingTypeSignatures:Gr.boolean()});var TNs=Gr.objectWithoutOptionalProperties({allOf:Gr.list(oVr),properties:Gr.list(Gr.lazyObject(()=>zNs)),allOfPropertyConflicts:Gr.list(nno),additionalProperties:Gr.boolean()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var ino=Gr.objectWithoutOptionalProperties({differentSchema:Gr.boolean()});var zNs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>hM),readonly:Gr.boolean().optional(),writeonly:Gr.boolean().optional(),conflict:Gr.record(kCe,ino),generatedName:Gr.string(),nameOverride:Gr.string().optional(),audiences:Gr.list(Gr.string())}).extend(BP);var qNs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var RNs=Gr.objectWithoutOptionalProperties({key:C2i,value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(fI).extend(N6);var NNs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var FNs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var xNs=Gr.union("type",{discriminated:Gr.lazyObject(()=>QNs),undiscriminated:Gr.lazyObject(()=>LNs)}).transform({transform:e=>{switch(e.type){case"discriminated":return rVr.discriminated(e);case"undiscriminated":return rVr.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var QNs=Gr.objectWithoutOptionalProperties({discriminantProperty:Gr.string(),commonProperties:Gr.list(Gr.lazyObject(()=>UNs)),schemas:Gr.record(Gr.string(),Gr.lazy(()=>hM))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var UNs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>hM)});var LNs=Gr.objectWithoutOptionalProperties({schemas:Gr.list(Gr.lazy(()=>hM))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var xIf={};ff(xIf,{ArraySchemaWithExample:()=>fFs,Base64WithExample:()=>oFs,BooleanWithExample:()=>uFs,CommonPropertyWithExample:()=>mFs,DateWithExample:()=>aFs,DatetimeWithExample:()=>iFs,DiscriminatedOneOfSchemaWithExample:()=>bFs,DoubleWithExample:()=>rFs,EndpointWithExample:()=>QWy,EnumSchemaWithExample:()=>cFs,FloatWithExample:()=>tFs,HeaderWithExample:()=>M2i,HttpErrorWithExample:()=>YNs,Int64WithExample:()=>ZNs,IntWithExample:()=>XNs,JsonRequestWithExample:()=>GNs,JsonResponseWithExample:()=>ono,MapSchemaWithExample:()=>dFs,NamedFullExample:()=>nyt,NullableSchemaWithExample:()=>_Fs,ObjectPropertyWithExample:()=>vFs,ObjectSchemaWithExample:()=>hFs,OneOfSchemaWithExample:()=>yFs,OptionalSchemaWithExample:()=>pFs,ParseFormUrlEncodedRequest:()=>JNs,ParseMultipartRequest:()=>HNs,ParseOctetStreamRequest:()=>WNs,PathParameterWithExample:()=>VNs,PrimitiveSchemaValueWithExample:()=>sFs,PrimitiveSchemaWithExample:()=>uno,QueryParameterWithExample:()=>ano,RequestWithExample:()=>KNs,ResponseWithExample:()=>$Ns,SchemaWithExample:()=>F6,StringSchemaWithExample:()=>nFs,Uint64WithExample:()=>eFs,UintWithExample:()=>kNs,UnDiscriminatedOneOfSchemaWithExample:()=>gFs,UnknownSchemaWithExample:()=>lFs,WebhookWithExample:()=>LWy,WebsocketHandshakeWithExample:()=>zWy});var nyt=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),value:Gr.unknown()}).extend(ky);var ano=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>F6),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var M2i=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>F6),env:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var zWy=Gr.objectWithoutOptionalProperties({queryParameters:Gr.list(ano),headers:Gr.list(M2i)});var VNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>F6),variableReference:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var WNs=Gr.objectWithoutOptionalProperties({}).extend(Vro).extend(iVr);var HNs=Gr.objectWithoutOptionalProperties({}).extend(Wro).extend(iVr);var GNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>F6),contentType:Gr.string().optional(),fullExamples:Gr.list(nyt).optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA).extend(iVr);var JNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>F6),contentType:Gr.string().optional(),fullExamples:Gr.list(nyt).optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA).extend(iVr);var KNs=Gr.union("type",{octetStream:WNs,multipart:HNs,json:GNs,formUrlEncoded:JNs}).transform({transform:e=>{switch(e.type){case"octetStream":return ZCe.octetStream(e);case"multipart":return ZCe.multipart(e);case"json":return ZCe.json(e);case"formUrlEncoded":return ZCe.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var ono=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>F6),responseProperty:Gr.string().optional(),fullExamples:Gr.list(nyt).optional()}).extend(ky).extend(ZA).extend(ryt);var $Ns=Gr.union("type",{file:Hro,json:ono,text:D2i,bytes:Jro,streamingSse:ono,streamingText:D2i,streamingJson:ono}).transform({transform:e=>{switch(e.type){case"file":return QL.file(e);case"json":return QL.json(e);case"text":return QL.text(e);case"bytes":return QL.bytes(e);case"streamingSse":return QL.streamingSse(e);case"streamingText":return QL.streamingText(e);case"streamingJson":return QL.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var YNs=Gr.objectWithoutOptionalProperties({statusCode:nVr,schema:Gr.lazy(()=>F6),fullExamples:Gr.list(nyt).optional()}).extend(ky).extend(eD).extend(ZA);var QWy=Gr.objectWithoutOptionalProperties({authed:Gr.boolean(),security:zro,internal:Gr.boolean().optional(),idempotent:Gr.boolean().optional(),method:Qro,audiences:Gr.list(Gr.string()),path:Gr.string(),summary:Gr.string().optional(),operationId:Gr.string().optional(),tags:Gr.list(eMe),pathParameters:Gr.list(VNs),queryParameters:Gr.list(ano),headers:Gr.list(M2i),sdkName:aVr.optional(),generatedRequestName:Gr.string(),requestNameOverride:Gr.string().optional(),request:KNs.optional(),response:$Ns.optional(),errors:Gr.record(nVr,YNs),servers:Gr.list(Kro),examples:Gr.list(Xro),pagination:Zro.optional(),retries:kro.optional()}).extend(ky).extend(BP).extend(ZA).extend(dS);var LWy=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),sdkName:aVr.optional(),method:eno,summary:Gr.string().optional(),operationId:Gr.string(),tags:Gr.list(eMe),headers:Gr.list(M2i),generatedPayloadName:Gr.string(),payload:Gr.lazy(()=>F6),examples:Gr.list(tno)}).extend(ky).extend(ZA).extend(dS);var XNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional(),example:Gr.number().optional()});var ZNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var kNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var eFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var tFs=Gr.objectWithoutOptionalProperties({example:Gr.number().optional()});var rFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional(),example:Gr.number().optional()});var nFs=Gr.objectWithoutOptionalProperties({default:Gr.string().optional(),pattern:Gr.string().optional(),format:Gr.string().optional(),minLength:Gr.number().optional(),maxLength:Gr.number().optional(),example:Gr.string().optional()});var iFs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var aFs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var oFs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var uFs=Gr.objectWithoutOptionalProperties({default:Gr.boolean().optional(),example:Gr.boolean().optional()});var sFs=Gr.union("type",{int:XNs,int64:ZNs,uint:kNs,uint64:eFs,float:tFs,double:rFs,string:nFs,datetime:iFs,date:aFs,base64:oFs,boolean:uFs}).transform({transform:e=>{switch(e.type){case"int":return z0.int(e);case"int64":return z0.int64(e);case"uint":return z0.uint(e);case"uint64":return z0.uint64(e);case"float":return z0.float(e);case"double":return z0.double(e);case"string":return z0.string(e);case"datetime":return z0.datetime(e);case"date":return z0.date(e);case"base64":return z0.base64(e);case"boolean":return z0.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var uno=Gr.objectWithoutOptionalProperties({schema:sFs}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var cFs=Gr.objectWithoutOptionalProperties({default:j2i.optional(),values:Gr.list(j2i),example:Gr.string().optional()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var lFs=Gr.objectWithoutOptionalProperties({example:Gr.unknown()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var F6=Gr.union("type",{primitive:uno,object:Gr.lazyObject(()=>hFs),array:Gr.lazyObject(()=>fFs),map:Gr.lazyObject(()=>dFs),optional:Gr.lazyObject(()=>pFs),enum:cFs,reference:oVr,literal:rno,oneOf:Gr.object({value:Gr.lazy(()=>yFs)}),nullable:Gr.lazyObject(()=>_Fs),unknown:lFs}).transform({transform:e=>{switch(e.type){case"primitive":return mh.primitive(e);case"object":return mh.object(e);case"array":return mh.array(e);case"map":return mh.map(e);case"optional":return mh.optional(e);case"enum":return mh.enum(e);case"reference":return mh.reference(e);case"literal":return mh.literal(e);case"oneOf":return mh.oneOf(e.value);case"nullable":return mh.nullable(e);case"unknown":return mh.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var fFs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>F6),example:Gr.list(Gr.unknown()).optional()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var dFs=Gr.objectWithoutOptionalProperties({key:uno,value:Gr.lazy(()=>F6),example:Gr.unknown().optional()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(fI).extend(N6);var pFs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>F6)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var _Fs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>F6)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var hFs=Gr.objectWithoutOptionalProperties({allOf:Gr.list(oVr),properties:Gr.list(Gr.lazyObject(()=>vFs)),allOfPropertyConflicts:Gr.list(nno),fullExamples:Gr.list(nyt).optional(),additionalProperties:Gr.boolean()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var vFs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>F6),readonly:Gr.boolean().optional(),writeonly:Gr.boolean().optional(),audiences:Gr.list(Gr.string()),conflict:Gr.record(kCe,ino),nameOverride:Gr.string().optional(),generatedName:Gr.string()}).extend(BP);var yFs=Gr.union("type",{discriminated:Gr.lazyObject(()=>bFs),undiscriminated:Gr.lazyObject(()=>gFs)}).transform({transform:e=>{switch(e.type){case"discriminated":return Unt.discriminated(e);case"undiscriminated":return Unt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var bFs=Gr.objectWithoutOptionalProperties({discriminantProperty:Gr.string(),commonProperties:Gr.list(Gr.lazyObject(()=>mFs)),schemas:Gr.record(Gr.string(),Gr.lazy(()=>F6))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var mFs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>F6)});var gFs=Gr.objectWithoutOptionalProperties({schemas:Gr.list(Gr.lazy(()=>F6))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var UWy=/^(\d+)/,sno=/^[a-zA-Z][a-zA-Z0-9_]*$/,VWy={"<":"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 I2i(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 o=Math.floor(e/10),c=e%10;return c===0?n[o]:`${n[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${I2i(c)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${I2i(a)}`}function OXo(e){let t=e.match(UWy);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=I2i(i);return n.length>0?`${a}_${n}`:a}}}function cno(e){let t=OXo(e),r=VWy[e];return t!=null?GU(EA(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":GU(EA(e)))}function $xe(e,t){return e.type==="primitive"&&t.type==="primitive"?WWy(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?rQC(e.values,t.values):e.type==="array"&&t.type==="array"?$xe(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"?$xe(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?nQC(e.value,t.value):e.type==="object"&&t.type==="object"?iQC(e,t):e.type==="map"&&t.type==="map"?WWy(e.key.schema,t.key.schema)&&$xe(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function WWy(e,t){return e.type===t.type}function rQC(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return Due(r,n)}function nQC(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:$xe(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:$xe(r,i)}):!1}function iQC(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 a=r[n];return a==null?!1:$xe(a,i.schema)})}function wJ(e){switch(e){case Nde.Deprecated:return"deprecated";case Nde.Beta:return"pre-release";case Nde.GenerallyAvailable:return"generally-available";default:return}}function aQC(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 HWy(e){let t=e?aQC(e):void 0;if(t==null||t.length===0)return Yia;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(EA(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(EA(i.name)):r.push(i.name,Yia);break}default:tc(i.type)}else tc(i);return r.join("/")}function B2i(e){return nw.of(`${HWy(e)}.yml`)}function zIf({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Yia:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,HWy(r))}function GWy({sdkName:e,namespaceOverride:t}){return nw.of(`${zIf({sdkName:e,namespaceOverride:t})}.yml`)}function JWy({location:e,namespaceOverride:t}){return t!=null?TX(nw.of(t),e):e}function OFs(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:tc(e.type)}}function lno(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:tc(e)}}function x6(e){return typeof e=="string"?e:e.type}function fno(e){if(typeof e!="string")return e.docs}function AXo(e){if(typeof e!="string")return e.default}function QIf(e){if(typeof e!="string")return e.validation}function $Wy(e){let t=x6(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?KWy(e):{...e,type:KWy(e.type)}}function KWy(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function wla(e){return x6(e).startsWith("optional<")?e:typeof e=="string"?YWy(e):{...e,type:YWy(e.type)}}function YWy(e){return e.startsWith("optional<")?e:`optional<${e}>`}var oQC=-2147483648,uQC=2147483647,sQC=-17976931348623157e292,cQC=17976931348623157e292;function UD({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:a}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return AFs(e);case"array":return VIf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"map":return WIf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"reference":return UIf({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return GIf();case"optional":return PFs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"nullable":return HIf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"enum":return bQC({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:a});case"literal":return e.value,JIf(e);case"object":return gQC({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"oneOf":return mQC({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});default:tc(e)}}function AFs(e){switch(e.schema.type){case"string":return dQC({description:e.description,schema:e.schema});case"int":return pQC({description:e.description,schema:e.schema});case"float":return _QC({description:e.description,schema:e.schema});case"double":return hQC({description:e.description,schema:e.schema});case"boolean":return lQC({description:e.description,schema:e.schema});case"int64":return fQC({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function lQC({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 fQC({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 dQC({description:e,schema:t}){let r="string",n=yQC(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 pQC({description:e,schema:t}){let r="integer",n=XWy(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 _QC({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function hQC({description:e,schema:t}){let r="double",n=XWy(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 yQC(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=vQC(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function vQC(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 XWy(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=LIf(r,t),n=LIf(n,t),i=LIf(i,t),!(r==null&&n==null&&a==null&&o==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:o,multipleOf:i}}function LIf(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[oQC,uQC]:[sQC,cQC];return e<r||e>n?void 0:e}function UIf({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=OQC(i)??e.schema,o=lno(i),c=AQC(i),s=wFs({context:r,fileContainingReference:t,declarationFile:B2i(o),type:a});return i.type==="nullable"&&(s=r.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),i.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function VIf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=`list<${x6(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{},type:c}}function WIf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=AFs(e.key),c=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),d=e.encoding!=null?OFs(e.encoding):void 0,s=`map<${x6(o)}, ${x6(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=d),e.availability!=null&&(u.availability=wJ(e.availability)),u}function HIf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){if(!n.respectNullableSchemas)return PFs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});let o=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=x6(o),d=fno(o),s=AXo(o),u=QIf(o),l=$Wy(c);if(n.wrapReferencesToNullableInOptional&&(l=wla(l)),e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let m=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(m.docs=e.description??d),s!=null&&(m.default=s),u!=null&&(m.validation=u),e.availability!=null&&(m.availability=wJ(e.availability)),m}function PFs({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=x6(o),d=fno(o),s=AXo(o),u=QIf(o),l=wla(c);if(e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let m=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(m.docs=e.description??d),s!=null&&(m.default=s),u!=null&&(m.validation=u),e.availability!=null&&(m.availability=wJ(e.availability)),m}function GIf(){return"unknown"}function JIf(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:tc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function bQC({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let a=PXo(e,i),o=e.nameOverride??e.generatedName;n.builder.addType(r,{name:o,schema:a.schema});let c=wFs({type:o,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=wJ(e.availability)),d}function gQC({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=KIf({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:o.schema});let d=wFs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function mQC({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=$If({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:o.schema});let d=wFs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function wFs({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 OQC(e){return Wj._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 AQC(e){return Wj._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 ase;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(ase||(ase={}));function HAi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:tc(e)}}function kWy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a;switch(e.type){case"primitive":a=jQC(e);break;case"array":a=PQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":a=wQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":a=EQC({schema:e,context:t,declarationFile:r,namespace:n});break;case"unknown":a=DQC(e.nameOverride,e.generatedName);break;case"optional":a=eHy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":a=SQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":a=PXo(e,i);break;case"literal":a=CQC(e,e.nameOverride,e.generatedName);break;case"object":a=KIf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"oneOf":a=$If({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;default:tc(e)}return a}function KIf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=t.isInState(ase.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},d=new Set;for(let A of e.properties){if(A.readonly&&(o=!0),a&&A.readonly)continue;if(Object.keys(A.conflict).length>0){if(Object.entries(A.conflict).every(([R,V])=>!V.differentSchema))continue;Object.entries(A.conflict).forEach(([R])=>{YIf({property:A.key,schemaId:R,context:t,namespace:n}).forEach($=>{d.add($)})})}let P=UD({schema:A.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}),C=A.audiences,I=A.nameOverride,T=wJ(A.availability),z=TQC(A);c[A.key]=BQC({typeReference:P,audiences:C,name:I,availability:T,propertyAccess:z})}let s=new Set;for(let A of e.allOfPropertyConflicts)A.allOfSchemaIds.forEach(P=>d.add(P)),A.conflictingTypeSignatures&&s.add(A.propertyKey);let u=[];for(let A of e.allOf){let P=tHy({schema:A.schema,context:t,namespace:n});if(P==null||d.has(A.schema)||d.has(P))continue;let C=UD({schema:Wj.reference(A),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});u.push(x6(C))}for(let A of d){let P=XIf(t,A,n);for(let C of P.properties)c[C.key]==null&&(s.has(C.key)&&(c[C.key]="unknown"),c[C.key]=UD({schema:C.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}));for(let C of P.allOf){if(d.has(C.schema))continue;let I=UD({schema:Wj.reference(C),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});u.push(x6(I))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([A,P])=>IQC(A)?[A,typeof P=="string"?{type:P,name:`_${A}`}:{...P,name:`_${A}`}]:[A,P]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=wJ(e.availability)),e.source!=null&&(l.source=HAi(e.source)),l.inline=ZIf(e,i);let m=e.nameOverride??e.generatedName;return{name:o&&t.respectReadonlySchemas&&!a?`${m}Read`:m,schema:l}}function YIf({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return YIf({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:o}=XIf(r,t,n),c=a.some(s=>s.key===e),d=[...o.flatMap(s=>YIf({property:e,context:r,schemaId:s.schema,namespace:n}))];if(c||d.length>0)return[t,...d]}return[]}function XIf(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return XIf(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function PQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:VIf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function wQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:WIf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function jQC(e){let t=AFs(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 ZWy(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function PXo(e,t){let r={enum:e.values.map(a=>{let o=a.nameOverride??a.generatedName,c=a.value;if(o===c&&a.description==null&&(a.casing==null||ZWy(a.casing)))return o;let d={value:a.value};if(o!==c&&(d.name=o),a.description!=null&&(d.docs=a.description),a.casing!=null&&!ZWy(a.casing)){let s={},u=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,u=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,u=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,u=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,u=!0),u&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=ZIf(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?HAi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;n.has(o.toLowerCase())||(i.enum.push(a),n.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function EQC({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:UIf({schema:e,context:t,fileContainingReference:r,namespace:n})}}function SQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:HIf({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:eHy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function eHy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:PFs({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function DQC(e,t){return{name:e??t,schema:GIf()}}function CQC(e,t,r){return{name:t??r,schema:JIf(e)}}function $If({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=e.encoding!=null?OFs(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=UD({schema:s.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1});let d={};for(let[s,u]of Object.entries(e.schemas))d[s]=UD({schema:u,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?wJ(e.availability):void 0,union:d,encoding:a,source:e.source!=null?HAi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(UD({schema:c,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?HAi(e.source):void 0,inline:ZIf(e,i)}}}var MQC=/^[0-9]/;function IQC(e){return MQC.test(e)}function tHy({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?tHy({context:t,schema:n.schema,namespace:r}):e}function BQC({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 ZIf(e,t){return e.inline===!0||t>0?!0:void 0}function TQC(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return zX.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return zX.ObjectPropertyAccess.WriteOnly}}function rHy(e){let t=e.replace(/^x-|^X-/,"");return EA(t)}var nHy="BasicAuthScheme",jFs="BearerAuthScheme";function iHy(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:nHy,schema:i}),t||(e.builder.setAuth(nHy),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:jFs,schema:i}),t||(e.builder.setAuth(jFs),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??rHy(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:jFs,schema:i}),t||(e.builder.setAuth(jFs),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(nw.of("__package__.yml"),{name:"OauthScope",schema:PXo(n.scopesEnum,0).schema})}}function uVr({header:e,context:t,fileContainingReference:r,namespace:n}){let i=UD({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),a=x6(i),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:EA(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=wJ(e.availability)),d}function EFs({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=UD({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return x6(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:x6(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=wJ(e.availability)),a}function DFs({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=kIf({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=x6(i.value),o=AXo(i.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),i.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=wJ(e.availability)),qQC(i.value)&&i.value.validation!==void 0&&(c.validation=i.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function kIf({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:UD({schema:Wj.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:nw.of(rF),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(i.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(sno.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:cno(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[c,d]=i.value.schemas;if(c!=null&&d!=null&&SFs({array:c,primitive:d}))return{value:UD({schema:Wj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&SFs({array:c,primitive:d}))return{value:UD({schema:Wj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(i.value.schemas))return kIf({schema:d,context:t,fileContainingReference:r,namespace:n})}else if(t.objectQueryParameters)return{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let i=e.type==="optional"?Wj.optional:Wj.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,n);if(a==null)return;if(a.type==="array")return{value:UD({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:UD({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 a=[],o=!1;for(let[c,d]of Object.entries(e.value.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(sno.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:cno(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,d]=e.value.value.schemas;if(c!=null&&d!=null&&SFs({array:c,primitive:d}))return{value:UD({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&SFs({array:d,primitive:c}))return{value:UD({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.objectQueryParameters)return{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[c,d]of Object.entries(e.value.value.schemas))return kIf({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.objectQueryParameters?{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:UD({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:UD({schema:Wj.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:UD({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function SFs({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function qQC(e){return e.type!=null}function aHy({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"]=RQC(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=NQC({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=T2i(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function RQC(e){let t={};return e.forEach(r=>{let n=T2i(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function NQC({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=T2i(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function T2i(e){switch(e.type){case"primitive":return oHy(e.value);case"object":return uHy(e.properties);case"array":return FQC(e.value);case"map":return xQC(e.value);case"oneOf":return zQC(e.value);case"enum":return e.value;case"literal":return QQC(e.value);case"unknown":return T2i(e.value);case"null":return null;default:tc(e)}}function oHy(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:tc(e)}}function uHy(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,T2i(r)]))}function FQC(e){return e.map(t=>T2i(t))}function xQC(e){return Object.fromEntries(e.map(t=>[oHy(t.key),T2i(t.value)]))}function zQC(e){return e.type==="discriminated"?uHy(e.value):T2i(e.value)}function QQC(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:tc(e)}}function GAi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function CFs(e,t){return t??(e?.groupName!=null?GAi(e.groupName):void 0)}function sHy({channel:e,context:t,declarationFile:r}){let n={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(n.audiences=e.audiences),e.summary!=null&&(n["display-name"]=e.summary),e.description!=null&&(n.docs=e.description);let i=GAi(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=EFs({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let o={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=DFs({queryParameter:d,context:t,fileContainingReference:r,namespace:i});s!=null&&(o[d.name]=s)}Object.keys(o).length>0&&(n["query-parameters"]=o);let c={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=uVr({header:d,context:t,fileContainingReference:r,namespace:i});c[d.name]=s}Object.keys(c).length>0&&(n.headers=c),t.builder.addChannel(r,{channel:n});for(let d of e.messages)t.builder.addChannelMessage(r,{messageId:d.name,message:{origin:d.origin,body:UD({schema:d.body,context:t,fileContainingReference:r,namespace:i,declarationDepth:0})}});for(let d of e.examples){let s=aHy({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}function cHy(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var JAi="Base",LQC="Default";function jla(e){return Object.entries(e).reduce((t,[r,n])=>(int(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function lHy(e){if(e.environmentOverrides!=null){for(let[T,z]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:T,schema:z});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(T=>cHy(T)),i=e.ir.servers;for(let T of i)if(cHy(T)){let z={urls:{}};for(let[U,R]of Object.entries(T.urls))z.urls[U]=R.url;T.name&&(t[T.name]=z)}else if("url"in T&&T.url){let z=T.audiences?{url:T.url,audiences:T.audiences}:T.url;if(T.name==null){r.push(z);continue}t[T.name]=z}let a={},o={},c=[];for(let T of e.ir.endpoints)for(let z of T.servers){if(z.url==null&&z.name!=null){a[z.name]||(a[z.name]=[]);continue}if(z.url==null)continue;let U=z.audiences?{url:z.url,audiences:z.audiences}:z.url;if(z.name==null){c.push(U);continue}a[z.name]||(a[z.name]=[]),a[z.name]?.push({url:z.url,audiences:z.audiences}),o[z.name]=U}let d={},s=[];for(let T of e.ir.websocketServers){let z=T.audiences?{url:T.url,audiences:T.audiences}:T.url;if(T.name==null){s.push(z);continue}d[T.name]=z}let u=Object.keys(t).length,l=u>0,m=Object.keys(o).length>0,A=Object.keys(a).some(T=>a[T]?.length===0),P=Object.keys(d).length>0;if(!l&&!m&&P&&e.ir.servers.length===0){for(let[T,z]of Object.entries(d))e.builder.addEnvironment({name:T,schema:z});e.builder.setDefaultEnvironment(Object.keys(d)[0]),e.builder.setDefaultUrl(JAi);return}if(c.length>0&&e.logger.error(`Skipping endpoint level servers ${c.map(T=>typeof T=="string"?T:T.url).join(", ")} because x-fern-server-name was not provided.`),!l){let T=e.ir.servers[0]?.url,z=e.ir.servers[0]?.audiences;if(T!=null){let U=z?{url:T,audiences:z}:T;t[LQC]=U}}let C=Object.values(t).map(T=>typeof T=="string"?T:int(T)?Object.values(T.urls)[0]:T.url),I=r.filter(T=>{let z=typeof T=="string"?T:T.url;return!C.includes(z)});if(I.length>0&&e.logger.error(`Skipping top level servers ${I.map(T=>typeof T=="string"?T:T.url).join(", ")} because x-fern-server-name was not provided.`),n){let T=!0;for(let[z,U]of Object.entries(t))if(e.builder.addEnvironment({name:z,schema:U}),T){if(e.builder.setDefaultEnvironment(z),int(U)){let R=Object.keys(U.urls)[0];R&&e.builder.setDefaultUrl(R)}T=!1}return}if(!m&&!A){let T=!0;for(let[z,U]of Object.entries(t))if(T){if(P){let R=typeof U=="string"?U:int(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:z,schema:{urls:{[JAi]:R??"",...jla(d)}}})}else e.builder.addEnvironment({name:z,schema:U});e.builder.setDefaultEnvironment(z),T=!1}else if(P){let R=typeof U=="string"?U:int(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:z,schema:{urls:{[JAi]:R??"",...jla(d)}}})}else e.builder.addEnvironment({name:z,schema:U});P&&e.builder.setDefaultUrl(JAi)}else if(u===1){let T=Object.keys(t)[0],z=Object.values(t)[0],U=typeof z=="string"?z:int(z)?Object.values(z.urls)[0]:z.url;e.builder.addEnvironment({name:T,schema:{urls:{[JAi]:U??"",...jla(o),...jla(d)}}}),e.builder.setDefaultEnvironment(T),e.builder.setDefaultUrl(JAi)}else{let T=new Map;for(let z of e.ir.endpoints)for(let U of z.servers)if(U.url!=null&&U.name!=null){T.has(U.name)||T.set(U.name,new Map);let R=U.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",V=T.get(U.name);V&&V.set(R,U.url)}if(T.size>0){let z=!0;for(let[U,R]of Object.entries(t)){let V=typeof R=="string"?R:int(R)?Object.values(R.urls)[0]:R.url;if(!V)continue;let $=V.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",re={[JAi]:V};for(let[Y,te]of T.entries()){let ne=te.get($)||te.get("production")||te.values().next().value;ne&&(re[Y]=ne)}P&&Object.assign(re,jla(d)),Object.keys(re).length>1?e.builder.addEnvironment({name:U,schema:{urls:re}}):e.builder.addEnvironment({name:U,schema:V}),z&&(e.builder.setDefaultEnvironment(U),z=!1)}T.size>0&&e.builder.setDefaultUrl(JAi)}else{let z=!0;for(let[U,R]of Object.entries(t)){if(P||Object.keys(o).length>0){let V=typeof R=="string"?R:int(R)?Object.values(R.urls)[0]:R.url;e.builder.addEnvironment({name:U,schema:{urls:{[JAi]:V??"",...jla(o),...jla(d)}}})}else e.builder.addEnvironment({name:U,schema:R});z&&(e.builder.setDefaultEnvironment(U),z=!1)}}}}var eBf=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},UQC=.75,VQC=new Set("authorization");function fHy(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 a=n.schema?lno(n.schema):void 0,o=a!=null?GAi(a):void 0,c=nw.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?x6(UD({schema:n.schema,context:e,fileContainingReference:o?TX(nw.of(EA(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(VQC.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],d=uVr({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:nw.of($k),context:e,namespace:void 0});o=new eBf(d),r[a.name]=o}o.increment()}let n=e.ir.endpoints.length*UQC;for(let[i,a]of Object.entries(r)){let o=t[i],c=a.count===e.ir.endpoints.length,d=a.count>=n;o==null&&(c?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:wla(a.schema)}))}}}function dHy(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?lno(t.schema):void 0,n=r!=null?GAi(r):void 0,i=uVr({header:{...t,schema:t.schema??Wj.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:lq.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:nw.of($k),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:wla(i)})}}function lwe(e){switch(e.type){case"primitive":return _Hy(e.value);case"object":return hHy(e.properties);case"array":return yHy(e.value);case"map":return HQC(e.value);case"oneOf":return GQC(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return JQC(e.value);case"unknown":return lwe(e.value);case"null":return null;default:tc(e)}}function pHy(e){switch(e.type){case"withStreaming":return e.sse?{stream:WQC(e.events)}:{stream:yHy(e.events)};case"withoutStreaming":return{body:lwe(e.value)};default:tc(e)}}function _Hy(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:tc(e)}}function hHy(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lwe(r)]))}function WQC(e){return e.map(t=>({event:"",data:lwe(t)}))}function yHy(e){return e.map(t=>lwe(t))}function HQC(e){return Object.fromEntries(e.map(t=>[_Hy(t.key),lwe(t.value)]))}function GQC(e){return e.type==="discriminated"?hHy(e.value):lwe(e.value)}function JQC(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:tc(e)}}function vHy({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"]=KQC(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=$QC(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),a=Object.keys(i).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(n||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(i))if(!o.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let u=cee({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Hc}});u!=null&&c.push({name:d,value:fS.literal(O2i.string(u))})}else c.push({name:d,value:fS.primitive(AO.string(d))});r.headers=YQC({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=lwe(e.request)),e.response!=null&&(r.response=pHy(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(Gw)),r}function KQC(e){let t={};return e.forEach(r=>{let n=lwe(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function $QC(e){let t={};return e.forEach(r=>{let n=lwe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function YQC({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=lwe(n.value);i!=null&&(r[n.name]=i)}),r}function bHy(e){return xde._visit(e,{get:()=>zX.HttpMethodSchema.Get,post:()=>zX.HttpMethodSchema.Post,put:()=>zX.HttpMethodSchema.Put,patch:()=>zX.HttpMethodSchema.Patch,delete:()=>zX.HttpMethodSchema.Delete,head:()=>zX.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 gHy(e){return e==="POST"||e==="PUT"||e==="PATCH"}function mHy({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,o=e.path,c=CFs(e.sdkName,e.namespace),d={};for(let I of e.pathParameters)I.parameterNameOverride&&(o=o.replace(I.name,I.parameterNameOverride)),d[I.parameterNameOverride??I.name]=EFs({pathParameter:I,context:r,fileContainingReference:t,namespace:c}),a.add(I.name);let s={};for(let I of e.queryParameters){let T=DFs({queryParameter:I,context:r,fileContainingReference:t,namespace:c});T!=null&&(s[I.name]=T,a.add(I.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:tc(e.pagination)}let l={path:o,method:bHy(e.method),auth:Object.keys(e.security).length>0?e.security:void 0,docs:e.description??void 0,pagination:u,source:e.source!=null?HAi(e.source):void 0};!eLC({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let m={},A=r.builder.getGlobalHeaderNames(),P=r.builder.getAuthHeaderName();P!=null&&A.add(P);let C=e.headers.filter(I=>!A.has(I.name));for(let I of C){let T=uVr({header:I,context:r,fileContainingReference:t,namespace:c});m[I.name]=T,a.add(typeof T=="string"?I.name:T.name??I.name)}if(e.request!=null){r.setInState(ase.Request);let I=kQC({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(m).length>0?m:void 0,usedNames:a,namespace:c});l.request=I.value,i=[...i,...I.schemaIdsToExclude??[]],r.unsetInState(ase.Request)}else{let I=r.inlinePathParameters&&Object.keys(d).length>0,T=Object.keys(s).length>0,z=Object.keys(m).length>0,U={};(I||T||z)&&(U.name=e.requestNameOverride??e.generatedRequestName),I&&(U["path-parameters"]=d),T&&(U["query-parameters"]=s),z&&(U.headers=m),Object.keys(U).length>0&&(l.request=U)}if(e.response!=null&&e.response._visit({json:I=>{let T=UD({schema:I.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:I.description??void 0,type:x6(T)},I.statusCode!=null&&(l.response["status-code"]=I.statusCode),I.responseProperty!=null&&(l.response.property=I.responseProperty)},streamingJson:I=>{let T=UD({schema:I.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:I.description??void 0,type:x6(T),format:"json"}},streamingSse:I=>{let T=UD({schema:I.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:I.description??void 0,type:x6(T),format:"sse"}},file:I=>{l.response={docs:I.description??void 0,type:"file","status-code":I.statusCode}},bytes:I=>{l.response={docs:I.description??void 0,type:"bytes","status-code":I.statusCode}},streamingText:I=>{l["response-stream"]={docs:I.description??void 0,type:"text"}},text:I=>{l.response={docs:I.description??void 0,type:"text","status-code":I.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let I=r.getDefaultServerName(),T=e.servers[0];T==null?I!=null&&(l.url=I):l.url=T.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=wJ(e.availability)),Object.entries(e.errors).forEach(([I,T])=>{let z=T.generatedName,U=nw.of(rF);r.builder.enableUniqueErrorsPerEndpoint&&(z=`${e.generatedRequestName}${T.generatedName}`,T.schema!=null&&(T.schema.type!=="reference"&&T.schema.type!=="oneOf"?T.schema.generatedName=`${e.generatedRequestName}${T.schema.generatedName}`:T.schema.type==="oneOf"&&(T.schema.value.generatedName=`${e.generatedRequestName}${T.schema.value.generatedName}`)));let R={"status-code":parseInt(I)},V=JWy({location:OHy,namespaceOverride:c});if(T.schema!=null){let Y=UD({schema:T.schema,context:r,fileContainingReference:V,declarationFile:V,namespace:c,declarationDepth:0});R.type=x6(Y),R.docs=T.description}r.builder.addError(V,{name:z,schema:r.isErrorUnknownSchema(parseInt(I))?{...R,type:"unknown"}:R}),l.errors==null&&(l.errors=[]);let $=r.builder.addImport({file:t,fileToImport:V});l.errors.push($!=null?`${$}.${z}`:z),R.type!=null&&T.examples?.forEach(Y=>{let te={value:lwe(Y.example),name:Y.name,docs:Y.description};r.builder.addErrorExample(V,{name:z,example:te})})}),e.examples.length>0&&(l.examples=XQC({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=ZQC({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[tBf,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function XQC({endpointExamples:e,context:t}){return e.map(r=>{try{return vHy({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function ZQC({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:tc(e)}}function kQC({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:u,namespace:l}){if(n.type==="json"||n.type==="formUrlEncoded"){let m=n.schema.type==="reference"?n.schema.schema:void 0,A=n.schema.type==="reference"?r.getSchema(n.schema.schema,l):n.schema;if(A?.type!=="object"||m!=null&&d.includes(m)){let z=UD({schema:n.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),U={schemaIdsToExclude:[],value:{body:z}},R=Object.keys(o??{}).length>0,V=Object.keys(c??{}).length>0,$=Object.keys(s??{}).length>0;return R&&(U.value["path-parameters"]=o),V&&(U.value["query-parameters"]=c),$&&(U.value.headers=s),(R||V||$)&&(U.value.name=i??a),n.contentType!=null&&(U.value["content-type"]=n.contentType),n.description!=null&&(U.value.docs=n.description),U}let P=Object.fromEntries(A.properties.filter(z=>z.readonly==null?!0:!(gHy(e.method)&&z.readonly)).map(z=>{let U=UD({schema:z.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),R=z.nameOverride??z.key,V=wJ(z.availability);if(!u.has(R)&&z.audiences.length<=0)return u.add(R),z.nameOverride!=null?[z.key,{type:x6(U),docs:fno(U),name:z.nameOverride,availability:V}]:[z.key,V?{...typeof U=="string"?{type:U}:U,availability:V}:U];let $={type:x6(U),docs:fno(U)};return u.has(R)&&($.name=z.generatedName),z.audiences.length>0&&($.audiences=z.audiences),V!=null&&($.availability=V),u.add(R),[z.key,$]})),C=A.allOf.map(z=>{let U=UD({schema:Wj.reference(z),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return x6(U)}).filter(z=>z!=="unknown"),I={properties:P};C.length>0&&(I.extends=C),n.additionalProperties&&(I["extra-properties"]=!0);let T={name:i??A.nameOverride??A.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:I};return n.contentType!=null&&(T["content-type"]=n.contentType),n.description!=null&&(T.docs=n.description),{schemaIdsToExclude:m!=null?[m]:[],value:T}}else if(n.type==="octetStream"){let m={body:"bytes","content-type":n.contentType??C7.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(m.name=i??a),n.description!=null&&(m.docs=n.description),{schemaIdsToExclude:[],value:m}}else if(n.type==="multipart"){let m=Object.fromEntries(n.properties.map(A=>{if(A.schema.type==="file"){let P=A.schema.isArray?"list<file>":"file";if(P=A.schema.isOptional?`optional<${P}>`:P,A.description!=null||A.contentType!=null){let C={type:P};if(A.description!=null&&(C.docs=A.description),A.contentType!=null){let I=A.contentType.split(",")[0];C["content-type"]=I}return[A.key,C]}return[A.key,P]}else{let P=UD({schema:A.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(A.contentType||A.exploded||A.encoding){let C=typeof P=="string"?{type:P}:P;A.contentType!=null&&(C["content-type"]=A.contentType),A.encoding==="form"?C.style="form":A.encoding==="json"?C.style="json":A.exploded&&(C.style="exploded"),P=C}return[A.key,P]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:m},"content-type":C7.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else tc(n)}function eLC({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:tc(t)}}function tLC({location:e,namespaceOverride:t}){return t!=null?{...e,file:TX(nw.of(t),e.file)}:e}function rLC(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:nw.of(`${EA(r)}.yml`),endpointId:e.summary!=null?EA(e.summary):EA(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:nw.of(rF),endpointId:EA(e.summary)}:{file:nw.of(rF),endpointId:EA(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:nw.of(rF),endpointId:n};let i=wXo(r),a=wXo(n);if(Due(i,a))return{file:nw.of("__package__.yml"),endpointId:r};let o=aLC({operationId:n,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let d=0;d<i.length;++d){let s=i[d];if(s!=null&&s===a[d])c.push(s);else{let u=EA(r);return{file:nw.of(`${u}.yml`),endpointId:n,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:nw.of(EA(c.join("_"))+".yml"),endpointId:EA(a.slice(c.length).join("_")),tag:r}}function jXo(e){let t=e.tags[0];if(e.sdkName!=null){let r=zIf({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:nw.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return tLC({namespaceOverride:e.namespace,location:rLC(e)})}function wXo(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=ept(t),t}var nLC=new RegExp("[^a-zA-Z0-9{}]+"),iLC=new RegExp("[{}]","g");function aLC({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(nLC).join("_").replaceAll(iLC,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:nw.of(EA(t)+".yml"),endpointId:EA(e.slice(0,-1*a.length)),tag:t}}function AHy(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:o,file:c,tag:d}=jXo(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let A=e.ir.groups;for(let P of a.sdkName.groupName){let C=typeof P=="string"?P:P.name,I=A[C];if(I==null)break;if(I.summary!=null||I.description!=null){u=A[C];break}}}let l=d==null?void 0:n.tagsById[d];e.setInState(ase.Endpoint),e.setEndpointMethod(a.method);let m=mHy({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(ase.Endpoint),i=[...i,...m.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:m.value,source:a.source!=null?HAi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function PHy(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?GAi(r.groupName):void 0,i=UD({schema:Wj.primitive(r),context:e,fileContainingReference:nw.of(rF),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:x6(i),docs:r.description??void 0}})}}function wHy(e){for(let t of e.ir.webhooks){let r=sLC({webhook:t,context:e});if(r==null)continue;let n=CFs(t.sdkName,t.namespace),i={};for(let o of t.headers)i[o.name]=uVr({header:o,context:e,fileContainingReference:r.file,namespace:n});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:UD({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:lwe(o.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function oLC({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:TX(nw.of(t),e.file)}:e}function uLC({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:nw.of(rF),endpointId:n};let i=wXo(r),a=wXo(n);if(Due(i,a))return{file:nw.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<i.length;++c){let d=i[c];if(d!=null&&d===a[c])o.push(d);else{let s=EA(r);return{file:nw.of(`${s}.yml`),endpointId:n,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:nw.of(EA(o.join("_"))+".yml"),endpointId:EA(a.slice(o.length).join("_")),tag:r}}function sLC({webhook:e,context:t}){return e.sdkName!=null?{file:GWy({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:oLC({namespaceOverride:e.namespace,location:uLC({webhook:e,context:t})})}var cLC=nw.of(rF);function EHy(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return jHy({namespace:e.namespace,groupName:e.groupName});case"oneOf":return jHy({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return cLC;default:tc(e)}}function jHy({namespace:e,groupName:t}){return e!=null&&t!=null?B2i([{type:"namespace",name:e},...t]):e!=null?B2i([{type:"namespace",name:e}]):B2i(t)}var tBf="external",OHy=nw.of(rF);function SHy({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let o=EHy(a),c=kWy({schema:a,context:n,declarationFile:o,namespace:r,declarationDepth:0});if(Ezi(c.schema)){let d=x6(c.schema);if(d===(c.name??i)||d===`optional<${c.name??i}>`||d===`nullable<${c.name??i}>`||d===`optional<nullable<${c.name??i}>>`)continue}n.builder.addType(o,{name:c.name??i,schema:c.schema})}}function DHy(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),lHy(e),fHy(e),dHy(e),iHy(e),PHy(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(tBf);let t=AHy(e),r=t.sdkGroups;e.setInState(ase.Webhook),wHy(e),e.unsetInState(ase.Webhook),e.setInState(ase.Channel);for(let i of Object.values(e.ir.channels)){let a=B2i(i.groupName);sHy({channel:i,context:e,declarationFile:a})}e.unsetInState(ase.Channel);let n=lLC({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});SHy({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))SHy({schemas:a,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function lLC({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(a=>Object.keys(a))]),i=new Set(t);for(let a of n)r.includes(a)||i.add(a);return Array.from(i)}var EXo=class{context;constructor(t){this.context=t}};var MFs=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[o,c]of Object.entries(n.files)){let d=i!=null?nw.of(`${i}${"/"}${o}`):nw.of(o);t[d]=c}let a=Object.keys(n.directories).sort();for(let o of a){let c=i!=null?`${i}${"/"}${o}`:o,d=n.directories[o];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[nw.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 Ela=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new MFs,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:a}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),n!=null&&(o.service["base-path"]=n),i!=null&&(o.service["display-name"]=i),a!=null&&(o.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return yLr(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"]))CHy(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(CHy(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??EA((_pt(r)+"/"+vaa(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===nw.of($k))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=fas(_pt(xGa.of(`/${t}`)),xGa.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=fas(_pt(xGa.of(`/${t}`)),xGa.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===nw.of($k))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 a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.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 a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>Due(c,n))??!1)||a.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=i),a.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=TX(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}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,a])=>[i,{...a,path:TX(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,o])=>[a,{...o,path:TX(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===rF?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 CHy(e){return e?.header!=null}var IFs=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=o,this.globalHeaderOverrides=a,this.detectGlobalHeaders=n?.detectGlobalHeaders??!0,this.objectQueryParameters=n?.objectQueryParameters??!1,this.respectReadonlySchemas=n?.respectReadonlySchemas??!1,this.respectNullableSchemas=n?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=n?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=n?.inlinePathParameters??!1,this.useBytesForBinaryResponse=n?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=n?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=n?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=n?.enableUniqueErrorsPerEndpoint??!1,this.wrapReferencesToNullableInOptional=n?.wrapReferencesToNullableInOptional??!0,this.coerceOptionalSchemasToNullable=n?.coerceOptionalSchemasToNullable??!0,this.builder=new Ela(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,u]of Object.entries(d.errors)){let l=parseInt(s),m=c[l];m==null&&u.schema!=null?c[l]=u.schema:m!=null&&u.schema!=null&&$xe(m,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(ase.Channel,ase.Endpoint,ase.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:tc(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:tc(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))}};function rBf(e){let t=new IFs(e);return DHy(t)}var BFs=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:n,absoluteFilePath:i}){let a=rBf({taskContext:t,ir:r,options:hXo({overrides:{...n,respectReadonlySchemas:n?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:n?.respectNullableSchemas??this.args.respectNullableSchemas,wrapReferencesToNullableInOptional:n?.wrapReferencesToNullableInOptional??this.args.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:n?.coerceOptionalSchemasToNullable??this.args.coerceOptionalSchemasToNullable,onlyIncludeReferencedSchemas:n?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:n?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:n?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:n?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:n?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:n?.auth!=null?{auth:n.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:i??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Lg.dump(a.rootApiFile)},namedDefinitionFiles:{...pg(a.definitionFiles,o=>({absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Lg.dump(o),contents:o})),[nw.of(rF)]:{absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Lg.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var SXo=class extends fqr{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;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.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.resolveAliases=t.resolveAliases,this.converter=new BFs(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:n},i){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:n},i);return this.converter.convert({context:t,ir:a,settings:i,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new Qnt({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var Rbe={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 dno={of(e){return e}};var MHy={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},nBf={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:MHy,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Ab={SOURCE:dno.of("source"),SDK_NAMESPACE:dno.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:dno.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:dno.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:dno.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated"};var EV={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,wrapReferencesToNullableInOptional:!0,coerceOptionalSchemasToNullable:!0};function iyt({options:e,overrides:t}){return{disableExamples:t?.disableExamples??EV.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??EV.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??EV.useTitlesAsName,audiences:t?.audiences??e?.audiences??EV.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??EV.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??EV.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??EV.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??EV.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??EV.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??EV.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??EV.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??EV.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??EV.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??EV.objectQueryParameters,filter:t?.filter??e?.filter??EV.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??EV.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??EV.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??EV.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??EV.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??EV.typeDatesAsStrings,preserveSingleSchemaOneOf:t?.preserveSingleSchemaOneOf??e?.preserveSingleSchemaOneOf??EV.preserveSingleSchemaOneOf,inlineAllOfSchemas:t?.inlineAllOfSchemas??e?.inlineAllOfSchemas??EV.inlineAllOfSchemas,resolveAliases:t?.resolveAliases??e?.resolveAliases??EV.resolveAliases,groupMultiApiEnvironments:t?.groupMultiApiEnvironments??e?.groupMultiApiEnvironments??EV.groupMultiApiEnvironments,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??EV.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??EV.coerceOptionalSchemasToNullable}}var IHy={naming:"v1"};function Hy(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function DXo(e,t,r,n,i=[]){try{let a=Hy(e,t);if(a!=null)return r.parse(a)}catch{let o=ept(i).join(" -> ");n.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function Sla(e){let t=Hy(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 BHy({schema:e,logger:t}){return Hy(e,Ab.ENCODING)??void 0}function THy(e){return Hy(e,Ab.FERN_ENUM)}function qHy({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let o=Hy(n,Ab.SDK_NAMESPACE),c=Hy(n,Ab.SDK_GROUP_NAME),d=Hy(n,Ab.TYPE_DEFINITION);if(d!=null)return CXo({fernType:d,nameOverride:e,generatedName:t,title:r,description:i,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function CXo({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c}){return cee({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.base64({example:void 0})});case"BOOLEAN":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.boolean({default:void 0,example:void 0})});case"DATE":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.date({example:void 0})});case"DATE_TIME":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.datetime({example:void 0})});case"FLOAT":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.float({example:void 0})});case"DOUBLE":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.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 mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.uint({default:void 0,example:void 0})});case"INTEGER":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.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 mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.uint64({default:void 0,example:void 0})});case"LONG":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:tc(d.v1)}},unknown:()=>mh.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,namespace:o,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?mh.map({nameOverride:t,generatedName:r,title:n,key:d,value:s,description:i,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?mh.array({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?mh.optional({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?mh.nullable({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:d=>d!=null?mh.array({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>mh.literal({nameOverride:t,generatedName:r,title:n,value:d._visit({string:s=>jV.string(s),boolean:s=>jV.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,namespace:o,groupName:c}),named:d=>mh.reference({schema:d,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,source:swe.openapi({file:"<memory>"})})}})}function RHy(e){let t=Hy(e,Ab.SOURCE);if(t!=null)return t.endsWith(".proto")?swe.protobuf({file:t}):swe.openapi({file:t})}function Dla(e){if(e!=null&&typeof e=="boolean")return e}function $g(e){return e?.$ref!=null}function NHy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:m,encoding:A,source:P}){return i===void 0&&(i=s.options.additionalPropertiesDefaultsTo),iBf({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:z0.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"||MXo(i,s.options)?mh.unknown({...fLC(i),generatedName:`${t}Value`}):FHy(pS(i,!1,s.options.optionalAdditionalProperties?d:!1,s,[...n,"Value"],P,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:m,encoding:A})}function FHy(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=FHy(e.value);break;case"oneOf":e.value.inline=!0;break;default:tc(e)}return e}function iBf({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:d,namespace:s,groupName:u,example:l,encoding:m}){let A=mh.map({nameOverride:e,generatedName:t,title:r,description:c,availability:d,key:n,value:i,namespace:s,groupName:u,encoding:m,example:l,inline:void 0});return o&&(A=mh.nullable({nameOverride:e,generatedName:t,title:r,value:A,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),a&&(A=mh.optional({nameOverride:e,generatedName:t,title:r,value:A,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),A}function MXo(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!($g(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null||"allOf"in e&&e.allOf!=null||"enum"in e&&e.enum!=null)}function fLC(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"||$g(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function xHy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:m,source:A}){let P=i==null?mh.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):pS(i,!1,!1,s,[...n,"Item"],A,u);return dLC({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:P,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,example:m})}function dLC({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,example:u}){let l=mh.array({nameOverride:e,generatedName:t,title:r,value:n,description:o,availability:c,namespace:d,groupName:s,example:u,inline:void 0});return a&&(l=mh.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(l=mh.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),l}function fwe(e){switch(Hy(e,Ab.AVAILABILITY)){case"deprecated":return Nde.Deprecated;case"beta":return Nde.Beta;case"generally-available":return Nde.GenerallyAvailable;default:break}if(!$g(e)&&e.deprecated)return Nde.Deprecated}function aBf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminator:u,context:l,namespace:m,groupName:A,encoding:P,source:C}){let I=u.propertyName,T=Object.fromEntries(Object.entries(u.mapping??{}).map(([U,R])=>{let V=KAi({$ref:R},!1,!1,l,[R],P,C,m);return l.markReferencedByDiscriminatedUnion({$ref:R},I,1),[U,V]})),z=Object.entries(i).filter(([U])=>U!==I).map(([U,R])=>{let V=c!=null&&c.includes(U),[$,re]=l.options.coerceOptionalSchemasToNullable?[!1,!V]:[!V,!1],Y=pS(R,$,re,l,[...n,U],C,m);return{key:U,schema:Y}});return zHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:z,description:a,availability:o,discriminant:I,subtypes:T,namespace:m,groupName:A,source:C})}function oBf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminant:u,variants:l,context:m,namespace:A,groupName:P,encoding:C,source:I}){let T=Object.fromEntries(Object.entries(l).map(([U,R])=>{if($g(R)){let V=KAi(R,!1,!1,m,[R.$ref],C,I,A);return m.markReferencedByDiscriminatedUnion(R,u,1),[U,V]}else{let V=pno(R,!1,!1,m,[...n,U],C,I,A,new Set([u]));return[U,V]}})),z=Object.entries(i).filter(([U])=>U!==u).map(([U,R])=>{let V=c!=null&&c.includes(U),[$,re]=m.options.coerceOptionalSchemasToNullable?[!1,!V]:[!V,!1],Y=pS(R,$,re,m,[...n,U],I,A);return{key:U,schema:Y}});return zHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:z,description:a,availability:o,discriminant:u,subtypes:T,namespace:A,groupName:P,source:I})}function zHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:a,description:o,availability:c,discriminant:d,subtypes:s,namespace:u,groupName:l,source:m}){let A=mh.oneOf(Unt.discriminated({description:o,availability:c,discriminantProperty:d,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:m,inline:void 0}));return i&&(A=mh.nullable({nameOverride:e,generatedName:t,title:r,value:A,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),n&&(A=mh.optional({nameOverride:e,generatedName:t,title:r,value:A,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),A}function QHy(e){if(e.proto!=null)return Iro.protobuf({typeName:e.proto.type})}function q2i({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:o,description:c,availability:d,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:m,context:A,source:P,inline:C}){let I=_LC(i??[]),T=new Set(a),z=Array.from(T).map((R,V)=>{let $=n?.[R],re=I[V],Y=sno.test(R),te=$?.name??re,ne=Y?R:cno(R);return te!=null&&!sno.test(te)&&(A?.logger.warn(`Enum name override ${te} is not a valid name. Falling back on ${ne}.`),te=void 0),{nameOverride:te,generatedName:ne,value:R,description:$?.description,availability:d,casing:{snake:$?.casing?.snake??void 0,pascal:$?.casing?.pascal??void 0,screamingSnake:$?.casing?.screamingSnake??void 0,camel:$?.casing?.camel??void 0}}}),U=o!=null?z.find(R=>R.value===o):void 0;return pLC({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:z,_default:U,description:c,availability:d,namespace:l,groupName:m,source:P,inline:C})}function pLC({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:n,title:i,values:a,_default:o,description:c,availability:d,namespace:s,groupName:u,source:l,inline:m}){let A=mh.enum({nameOverride:r,generatedName:n,title:i,values:a,description:c,availability:d,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:m});return t&&(A=mh.nullable({nameOverride:r,generatedName:n,title:i,value:A,description:c,availability:d,namespace:s,groupName:u,inline:m})),e&&(A=mh.optional({nameOverride:r,generatedName:n,title:i,value:A,description:c,availability:d,namespace:s,groupName:u,inline:m})),A}function _LC(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 LHy({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:m,wrapAsNullable:A,example:P,namespace:C,groupName:I}){return n==="int64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint32"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I})}function hLC(e){return typeof e=="string"?jV.string(e):typeof e=="boolean"?jV.boolean(e):jV.string(`${e}`)}function UHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,value:a,description:o,availability:c,namespace:d,groupName:s}){let u=mh.literal({nameOverride:e,generatedName:t,title:r,value:hLC(a),description:o,availability:c,namespace:d,groupName:s});return i&&(u=mh.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),n&&(u=mh.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),u}function uBf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:m,wrapAsNullable:A,example:P,namespace:C,groupName:I}){return n==null||n==="double"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.double({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="float"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="int32"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="int64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint32"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="time-delta"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):ose({nameOverride:e,generatedName:t,title:r,primitive:z0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I})}var yLC={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},vLC={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}}},bLC={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}}},gLC={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},mLC={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},OLC={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},ALC={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},PLC={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function IXo(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[yLC,vLC,bLC,gLC,mLC,OLC,ALC,PLC],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==i.join(""));return r}function Eie(e,t){let n=e.map(i=>/^[^a-zA-Z0-9]+$/.test(i)?i:GU(EA(i))).join("");return/^\d/.test(n)?OXo(n)??n:n}function VHy(e){let t=e.join("_");return EA(t)}function I4(e){switch(e.type){case"object":return Wj.object({allOf:e.allOf,properties:e.properties.map(t=>jLC(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return Wj.array({description:e.description,availability:e.availability,value:I4(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Wj.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 Wj.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 Wj.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:I4(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Wj.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:I4(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Wj.primitive({description:e.description,availability:e.availability,schema:WHy(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Wj.map({description:e.description,availability:e.availability,key:Wj.primitive({description:e.key.description,availability:e.key.availability,schema:WHy(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:I4(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return Wj.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 Wj.oneOf(wLC(e.value));case"unknown":return Wj.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:tc(e)}}function wLC(e){switch(e.type){case"discriminated":return rVr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:I4(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,I4(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return rVr.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>I4(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:tc(e)}}function WHy(e){switch(e.type){case"string":return lq.string(e);case"base64":return lq.base64();case"boolean":return lq.boolean(e);case"date":return lq.date();case"datetime":return lq.datetime();case"double":return lq.double(e);case"float":return lq.float();case"int":return lq.int(e);case"int64":return lq.int64(e);case"uint":return lq.uint();case"uint64":return lq.uint64();default:tc(e)}}function jLC(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:I4(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function TFs(e,t){return $xe(I4(e),I4(t))}function HHy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:o,wrapAsOptional:c,wrapAsNullable:d,allOf:s,context:u,propertiesToExclude:l,namespace:m,groupName:A,fullExamples:P,additionalProperties:C,availability:I,source:T}){let z=[...o??[]],U={...i},R=[],V=[];for(let ne of s)if(!u.options.inlineAllOfSchemas&&$g(ne)){let Oe=u.resolveSchemaReference(ne);if(Oe.discriminator!=null&&Oe.discriminator.mapping!=null)continue;if(Oe.oneOf!=null||Oe.anyOf!=null){let ve=Oe.oneOf??Oe.anyOf;if(ve!=null){for(let be of ve){let Ie=$g(be)?u.resolveSchemaReference(be):be,Be=pS(Ie,!1,!1,u.DUMMY,n,T,m);Be.type==="object"&&R.push(...Be.properties.map(Se=>Se.schema.type!=="optional"&&Se.schema.type!=="nullable"?{...Se,schema:mh.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Se.schema,description:void 0,availability:Se.availability,namespace:void 0,groupName:void 0,inline:void 0})}:Se))}continue}}let ge=R2i(ne);if(ge==null)continue;V.push({schemaId:ge,convertedSchema:sBf(ne,[ge],T,u.options.preserveSchemaIds),properties:GHy({schema:ne,context:u,breadcrumbs:n,source:T,namespace:m})}),u.markSchemaAsReferencedByNonRequest(ge)}else if($g(ne)){let Oe=u.resolveSchemaReference(ne),ge=pS(Oe,!1,!1,u,n,T,m);ge.type==="object"&&R.push(...ge.properties)}else{let Oe=ne.required??[];R=R.map(ve=>(ve.schema.type==="optional"||ve.schema.type==="nullable")&&Oe.includes(ve.key)?{...ve,schema:ve.schema.value}:ve);let ge=pS(ne,!1,!1,u,n,T,m);ge.type==="object"&&R.push(...ge.properties)}let $={};for(let ne of V)for(let[Oe,ge]of Object.entries(ne.properties)){let ve=$[Oe];ve!=null?(ve.schemaIds.push(ne.schemaId),ve.schemas.some(Ie=>TFs(Ie,ge))||ve.schemas.push(ge)):$[Oe]={schemaIds:[ne.schemaId],schemas:[ge]}}let re=[];for(let[ne,Oe]of Object.entries($))Oe.schemaIds.length>1&&re.push({propertyKey:ne,allOfSchemaIds:Oe.schemaIds,conflictingTypeSignatures:Oe.schemas.length>1});let Y=Object.fromEntries(Object.entries(U).filter(([ne,Oe])=>!(!$g(Oe)&&Oe.type==="null"))),te=Object.entries(Y).map(([ne,Oe])=>{let ge=Hy(Oe,Ab.AUDIENCES)??[],ve=fwe(Oe),be=$g(Oe)?!1:Oe.readOnly,Ie=$g(Oe)?!1:Oe.writeOnly,Se=!(z.includes(ne)&&!be),St=Hy(Oe,Ab.FERN_PROPERTY_NAME),yt=[...n,ne],Re=VHy(yt),De=pS(Oe,Se,!1,u,yt,T,m),Lt={};for(let Xe of V){let Yt=Xe.properties[ne];Yt!=null&&!TFs(De,Yt)?Lt[Xe.schemaId]={differentSchema:!0}:Yt!=null&&(Lt[Xe.schemaId]={differentSchema:!1})}return{key:ne,schema:De,nameOverride:St,audiences:ge,conflict:Lt,generatedName:Re,availability:ve,readonly:be,writeonly:Ie}});return te.push(...R.map(ne=>{let Oe=ne.conflict;for(let ge of V){let ve=ge.properties[ne.key];ve!=null&&!TFs(ne.schema,ve)?Oe[ge.schemaId]={differentSchema:!0}:ve!=null&&(Oe[ge.schemaId]={differentSchema:!1})}return{...ne,conflict:Oe}})),ELC({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,properties:te.filter(ne=>!l.has(ne.key)),description:a,allOf:V.map(ne=>ne.convertedSchema),allOfPropertyConflicts:re,namespace:m,groupName:A,fullExamples:P,additionalProperties:C,availability:I,source:T,context:u})}function ELC({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:a,description:o,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:m,availability:A,source:P,context:C}){let I=mh.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:MXo(m,C.options),availability:A,source:P,inline:void 0});return i&&(I=mh.nullable({nameOverride:e,generatedName:t,title:r,value:I,description:o,availability:A,namespace:s,groupName:u,inline:void 0})),n&&(I=mh.optional({nameOverride:e,generatedName:t,title:r,value:I,description:o,availability:A,namespace:s,groupName:u,inline:void 0})),I}function GHy({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[o,c]=$g(e)?[t.resolveSchemaReference(e),IXo(e.$ref)]:[e,r];for(let d of o.allOf??[])a={...a,...GHy({schema:d,context:t,breadcrumbs:c,source:n,namespace:i})};for(let[d,s]of Object.entries(o.properties??{})){let u=pS(s,!1,!1,t,[...c,d],n,i);a[d]=u}return a}function N2i({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:d,subtypes:s,namespace:u,groupName:l,encoding:m,source:A,subtypePrefixOverrides:P}){let C=CLC({schemas:s}),I=s.flatMap((z,U)=>{if(!$g(z)&&z.enum!=null&&d.options.coerceEnumsToLiterals&&z.type==="string")return z.enum.map(V=>mh.literal({nameOverride:void 0,generatedName:Eie([t,V],d.options.preserveSchemaIds),title:void 0,value:jV.string(String(V)),namespace:u,groupName:void 0,description:void 0,availability:V.availability}));let R=C[U];if(P!=null){let V=P[U];V!=null&&"name"in V&&(R=V.name)}return[pS(z,!1,!1,d,[...n,R??`${U}`],A,u)]}),T=SLC(I);return DLC({uniqueSubtypes:T,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:i,availability:a,namespace:u,groupName:l,context:d,encoding:m,source:A})}function SLC(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r],i=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(n!=null&&o!=null&&$xe(n,o)){i=!0;break}}n!=null&&!i&&t.push(n)}return t}function DLC({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,context:u,encoding:l,source:m}){if(Object.entries(e).every(([P,C])=>C.type==="literal")){let P={},C=[];return Object.entries(e).forEach(([I,T])=>{T.type==="literal"&&T.value.type==="string"&&(C.push(T.value.value),T.description!=null&&(P[T.value.value]={description:T.description}))}),q2i({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,fernEnum:P,enumVarNames:void 0,enumValues:C,_default:void 0,namespace:d,groupName:s,context:u,source:m,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let P=e[0];return a&&(P=mh.nullable({nameOverride:t,generatedName:r,title:n,value:P,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(P=mh.optional({nameOverride:t,generatedName:r,title:n,value:P,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),P}return JHy({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:d,groupName:s,encoding:l,source:m})}function cBf({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:d,groupName:s,discriminator:u,encoding:l,source:m}){let A=Object.entries(u.mapping??{}).map(([I,T],z)=>{let U={$ref:T},R=KAi(U,!1,!1,c,[T],l,m,d);return c.markSchemaWithDiscriminantValue(U,u.propertyName,I),R.type==="object"&&(R.properties={[u.propertyName]:mh.literal({nameOverride:void 0,generatedName:Eie([t,I],c.options.preserveSchemaIds),title:void 0,value:jV.string(I),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...R.properties.filter(V=>V.key!==u.propertyName)}),R}),P=[];for(let I=0;I<A.length;++I){let T=A[I],z=!1;for(let U=I+1;U<A.length;++U){let R=A[U];if(T!=null&&R!=null&&$xe(T,R)){z=!0;break}}T!=null&&!z&&P.push(T)}if(Object.entries(P).every(([I,T])=>T.type==="literal")){let I={},T=[];return Object.entries(P).forEach(([z,U])=>{U.type==="literal"&&U.value.type==="string"&&(T.push(U.value.value),U.description!=null&&(I[U.value.value]={description:U.description}))}),q2i({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:n,availability:i,fernEnum:I,enumVarNames:void 0,enumValues:T,_default:void 0,namespace:d,groupName:s,context:c,source:m,inline:void 0})}return P.length===1&&P[0]!=null&&!c.options.preserveSingleSchemaOneOf?P[0]:JHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:n,availability:i,subtypes:P,namespace:d,groupName:s,encoding:l,source:m})}function CLC({schemas:e}){let t={},r=0;for(let a of e){if(!$g(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let o=Object.keys(a.properties),c={},d=o;for(let[s,u]of Object.entries(t)){let l=nts(u,o);d=nts(d,u),c[s]=l}c[r]=d,t=c}}r++}let n=[],i=0;for(let a of e){let o=t[i];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null){n.push(c[0]),++i;continue}}$g(a)?n.push(I2i(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(I2i(i)??`${i}`),++i}return n}function JHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,description:a,availability:o,subtypes:c,namespace:d,groupName:s,encoding:u,source:l}){let m=mh.oneOf(Unt.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:d,groupName:s,encoding:u,source:l,inline:void 0}));return i&&(m=mh.nullable({nameOverride:e,generatedName:t,title:r,value:m,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),n&&(m=mh.optional({nameOverride:e,generatedName:t,title:r,value:m,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),m}function _no(e){if(e.default!=null&&typeof e.default=="string")return e.default}function qFs({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=Sla(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function KHy({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=Sla(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function sVr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=Sla(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function $Hy({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=Sla(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var Cla="#/components/schemas/";function ZHy(e,t){let r=$g(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"string":case"integer":return!0;case"array":return ZHy(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 MLC(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:ZHy(t,r):!1}function pS(e,t,r,n,i,a,o,c=!1,d=new Set,s){let u=RHy(e)??a,l=xLC({schema:e,logger:n.logger});if($g(e)){let m=R2i(e);return m!=null?MLC(m,e,n)?pno(n.resolveSchemaReference(e),t,r,n,IXo(e.$ref),l,u,o,d,c,s):(c?n.markSchemaAsReferencedByRequest(m):n.markSchemaAsReferencedByNonRequest(m),KAi(e,t,r,n,i,l,u,o)):pno(n.resolveSchemaReference(e),t,r,n,IXo(e.$ref),l,u,o,d,c,s)}return pno(e,t,r,n,i,l,u,o,d,c,s)}function KAi(e,t,r,n,i,a,o,c){let d=e.$ref.includes("properties")?pno(n.resolveSchemaReference(e),t,r,n,i,a,o,c,new Set):mh.reference(sBf(e,i,o,n.options.preserveSchemaIds));if(r===!1){let s=n.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(d=mh.nullable({title:void 0,nameOverride:void 0,generatedName:Eie(i,n.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(d=mh.optional({title:void 0,nameOverride:void 0,generatedName:Eie(i,n.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),d}function ILC(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function pno(e,t,r,n,i,a,o,c,d=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Hy(e,Ab.TYPE_NAME)??(n.options.useTitlesAsName?ILC(e.title):void 0),m=Hy(e,Ab.SDK_GROUP_NAME)??Hy(e,Rbe.TAGS)?.[0],A=(typeof m=="string"?[m]:m)??[];A=n.resolveGroupName(A);let P=Eie(i,n.options.preserveSchemaIds),C=e.title,I=e.description,T=fwe(e),z=[];e.example!=null&&z.push({name:void 0,value:e.example,description:void 0});let U=Hy(e,Rbe.EXAMPLES);U!=null&&Object.keys(U).length>0&&z.push(...Object.entries(U).map(([$,re])=>({name:re?.summary??$,value:re.value,description:re.description})));let R=Sla(e);R!=null&&Object.keys(R).length>0&&z.push(...R.map($=>({name:void 0,value:$,description:void 0})));let V=qHy({schema:e,description:I,title:C,nameOverride:l,generatedName:P,availability:T});if(V!=null){let $=V;return r&&($=mh.nullable({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:$})),t&&($=mh.optional({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:$})),$}try{if(Array.isArray(e.type)){let Y=e.type.indexOf("null"),te=Y!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&te)e.type.splice(Y,1),e.type=e.type[0],e.nullable=!0;else if(te&&(e.type.splice(Y,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let ne=new Set([...e.oneOf,...e.type]);e.oneOf=[...ne]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(te=>te!==null),!FFs(e.enum))return ose({nameOverride:l,generatedName:P,title:C,primitive:z0.string({default:_no(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:sVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A,wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T});let Y=THy(e);return e.enum.length===1&&e.enum[0]!=null&&Y==null?UHy({nameOverride:l,generatedName:P,title:C,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:I,availability:T,namespace:c,groupName:A}):q2i({nameOverride:l,generatedName:P,title:C,fernEnum:Y,enumVarNames:Hy(e,[Rbe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:A,context:n,source:o,inline:void 0})}if(FFs(e.type)&&e.type.length>1){let Y=e.type.includes("null"),te=e.type.filter(ne=>ne!=="null").map(ne=>({type:ne,nullable:Y}));return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:te,namespace:c,groupName:A,encoding:a,source:o})}if(e.type==="boolean"){let Y=Hy(e,Ab.BOOLEAN_LITERAL);return Y!=null?YHy({nameOverride:l,generatedName:P,title:C,literal:jV.boolean(Y),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A}):ose({nameOverride:l,generatedName:P,title:C,primitive:z0.boolean({default:BLC(e.default),example:KHy({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A})}if(e.type==="number")return uBf({nameOverride:l,generatedName:P,title:C,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Dla(e.exclusiveMinimum),exclusiveMaximum:Dla(e.exclusiveMaximum),multipleOf:e.multipleOf,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:qFs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="integer")return LHy({nameOverride:l,generatedName:P,title:C,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Dla(e.exclusiveMinimum),exclusiveMaximum:Dla(e.exclusiveMaximum),multipleOf:e.multipleOf,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:qFs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="float")return uBf({nameOverride:l,generatedName:P,title:C,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Dla(e.exclusiveMinimum),exclusiveMaximum:Dla(e.exclusiveMaximum),multipleOf:e.multipleOf,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:qFs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="string"){if(e.format==="date-time")return ose({nameOverride:l,generatedName:P,title:C,primitive:z0.datetime({example:sVr({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A});if(e.format==="date"&&n.options.typeDatesAsStrings===!1)return ose({nameOverride:l,generatedName:P,title:C,primitive:z0.date({example:sVr({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A});if(e.format==="json-string"){let te=mh.unknown({nameOverride:l,generatedName:P,title:C,description:I,availability:T,namespace:c,groupName:A,example:void 0});return r&&(te=mh.nullable({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:te})),t&&(te=mh.optional({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:te})),te}let Y=eGy(e,"const");return Y!=null?YHy({nameOverride:l,generatedName:P,title:C,literal:jV.string(Y),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A}):ose({nameOverride:l,generatedName:P,title:C,primitive:z0.string({default:_no(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:sVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A,wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T})}if(e.type==="array")return xHy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,item:e.items,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,example:$Hy({schema:e,logger:n.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&RFs(e))return NHy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,additionalProperties:e.additionalProperties,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Hy(e,Ab.IS_DISCRIMINATED)===!1)return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf,namespace:c,groupName:A,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return n.options.discriminatedUnionV2?cBf({nameOverride:l,generatedName:P,title:C,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,discriminator:e.discriminator,encoding:a,source:o}):aBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let Y=Hy(e,Ab.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return n.options.discriminatedUnionV2||Y?cBf({nameOverride:l,generatedName:P,title:C,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,discriminator:e.discriminator,encoding:a,source:o}):aBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(n.options.preserveSingleSchemaOneOf)return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf.filter(ne=>$g(ne)||ne.type!=="null"),encoding:a,namespace:c,groupName:A,source:o});let te=pS(e.oneOf[0],t,r,n,i,o,c,s);return hno(te,I,c,A)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let ge=e.oneOf[0],ve=e.oneOf[1];if(!$g(ge)&&ge.type==="null")return pS(ve,!1,!0,n,i,o,c);if(!$g(ve)&&ve.type==="null")return pS(ge,!1,!0,n,i,o,c)}let te=RLC({schemas:e.oneOf});if(te!=null)return q2i({nameOverride:l,generatedName:P,title:C,fernEnum:void 0,enumVarNames:void 0,enumValues:te,_default:e.default,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:A,context:n,source:o,inline:void 0});let ne=XHy({schemas:e.oneOf,context:n});if(ne!=null&&!n.options.discriminatedUnionV2&&!Y)return oBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},required:e.required,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,discriminant:ne.discriminant,variants:ne.schemas,context:n,namespace:c,groupName:A,encoding:a,source:o});let Oe=e.oneOf.filter(ge=>!$g(ge)&&ge.type==="null").length>0;return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r||Oe,context:n,subtypes:e.oneOf.filter(ge=>$g(ge)||ge.type!=="null"),encoding:a,namespace:c,groupName:A,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let ne=pS(e.anyOf[0],t,r,n,i,o,c,s);return hno(ne,I,c,A)}if(e.anyOf.length===2){let[ne,Oe]=e.anyOf;if(ne!=null&&Oe!=null){if(!$g(ne)&&ne.type==="null"){let ge=pS(Oe,!1,!0,n,i,o,c);return hno(ge,I,c,A)}else if(!$g(Oe)&&Oe.type==="null"){let ge=pS(ne,!1,!0,n,i,o,c);return hno(ge,I,c,A)}}}let Y=XHy({schemas:e.anyOf,context:n});if(Y!=null&&!n.options.discriminatedUnionV2)return oBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},required:e.required,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,discriminant:Y.discriminant,variants:Y.schemas,context:n,namespace:c,groupName:A,encoding:a,source:o});let te=e.anyOf.filter(ne=>!$g(ne)&&ne.type==="null").length>0;return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r||te,context:n,subtypes:e.anyOf.filter(ne=>$g(ne)||ne.type!=="null"),encoding:a,namespace:c,groupName:A,source:o})}if(e.allOf!=null||e.properties!=null){let Y=[];for(let ne of e.allOf??[])($g(ne)||Object.keys(ne).length>0)&&Y.push(ne);if((e.properties==null||RFs(e))&&Y.length===1&&Y[0]!=null){let ne=pS(Y[0],t,r,n,i,o,c,s);return hno(ne,I,c,A)}let te=Y.filter(ne=>{let Oe=NFs(ne);return Oe||n.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(ne)}`),Oe});if((e.properties==null||RFs(e))&&te.length===1&&te[0]!=null){let ne=pS(te[0],t,r,n,i,o,c,s);return hno(ne,I,c,A)}return HHy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},description:I,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:te,context:n,propertiesToExclude:d,namespace:c,groupName:A,fullExamples:z,additionalProperties:e.additionalProperties,availability:T,encoding:a,source:o})}if(e.type==="object"&&TLC(e)&&qLC(e)&&RFs(e))return iBf({nameOverride:l,generatedName:P,title:C,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${P}Key`,title:void 0,description:void 0,availability:void 0,schema:z0.string({default:_no(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:sVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A},valueSchema:mh.unknown({nameOverride:void 0,generatedName:`${P}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:A}),namespace:c,groupName:A,encoding:a,example:e.example});e.type!=null&&n.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${i.join("->")}. Coercing to unknown.`);let $=e.example??e.default,re=mh.unknown({nameOverride:l,generatedName:P,title:C,description:I,availability:T,namespace:c,groupName:A,example:$});return r&&(re=mh.nullable({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:re})),t&&(re=mh.optional({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:re})),re}catch($){return n.logger.debug(`Error converting schema: ${$.message}
2408
+ `)),{ok:!0,value:t}):n}}function bRs(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var Bro=class e extends Error{errors;constructor(t){super(t.map(bRs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Tro=class e extends Error{errors;constructor(t){super(t.map(bRs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function u5(e){return{optional:()=>IIf(e),transform:t=>BIf(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new Tro(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new Bro(n.errors)}}}function IIf(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:()=>fq.OPTIONAL};return{...t,...u5(t)}}function BIf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...u5(r)}}function dWy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:x2(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:x2(t,"bigint")}]},getType:()=>fq.BIGINT};return{...zde(e),...u5(e)}}var eQC=/^([+-]?\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 pWy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:x2(t,"string")}]}:eQC.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:x2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:x2(t,"Date object")}]},getType:()=>fq.DATE};return{...zde(e),...u5(e)}}function cwe(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...zde(r),...u5(r)}}}function gRs(e){let t=new Set(e);return cwe(fq.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:x2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:x2(n,"enum")}]}:{ok:!0,value:n})()}function _Wy(e){let t=TIf(e);return{...t,...u5(t)}}function TIf(e){return{parse:(t,r)=>qro(e).parse(t,r),json:(t,r)=>qro(e).json(t,r),getType:()=>qro(e).getType()}}function qro(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function vXo(e){return Object.entries(e)}function bXo(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function P2i(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function gXo(e){return Object.keys(e)}function hWy(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function _qr(e){return{withParsedProperties:t=>qIf(e,t)}}function qIf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(n,i)=>{if(!P2i(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:x2(n,"object")}]};let a=new Set(Object.keys(t)),o=bXo(n,Object.keys(n).filter(c=>!a.has(c)));return e.json(o,i)},getType:()=>e.getType()};return{...r,...u5(r),..._qr(r)}}function yWy(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function w2i(e){return e.isProperty}function mRs(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>w2i(n)?n.rawKey:r),_getParsedProperties:()=>gXo(e),parse:(r,n)=>{let i={},a=[];for(let[o,c]of vXo(e)){let d=w2i(c)?c.rawKey:o,s=w2i(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};i[d]=u,gWy(s)&&a.push(d)}return vWy({value:r,requiredKeys:a,getProperty:o=>{let c=i[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,o]of vXo(e)){let c=w2i(o)?o.valueSchema:o;gWy(c)&&i.push(a)}return vWy({value:r,requiredKeys:i,getProperty:a=>{let o=e[a];if(o!=null)return w2i(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>fq.OBJECT};return{...zde(t),...u5(t),..._qr(t),...Pla(t)}}function vWy({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!P2i(e))return{ok:!1,errors:[{path:a,message:x2(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let m=l.transform(u);m.ok?d[l.transformedKey]=m.value:(d[s]=u,c.push(...m.errors))}else switch(n){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||i?{ok:!0,value:d}:{ok:!1,errors:c}}function Pla(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>bWy({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>bWy({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>fq.OBJECT};return{...r,...u5(r),..._qr(r),...Pla(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,n)=>{let i=e.parse(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},json:(r,n)=>{let i=e.json(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},getType:()=>fq.OBJECT};return{...t,...u5(t),..._qr(t),...Pla(t)}}}}function bWy({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,o]=hWy(gXo(t),s=>i.has(s)),c=r(bXo(t,o)),d=n(bXo(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function gWy(e){return!tQC(e)}function tQC(e){switch(e.getType()){case fq.ANY:case fq.UNKNOWN:case fq.OPTIONAL:return!0;default:return!1}}function mWy(e){return mRs(e)}function OWy(e){let t={...TIf(e),_getRawProperties:()=>qro(e)._getRawProperties(),_getParsedProperties:()=>qro(e)._getParsedProperties()};return{...t,...u5(t),..._qr(t),...Pla(t)}}function ORs(e){let t={parse:(r,n)=>AWy(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>AWy(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>fq.LIST};return{...zde(t),...u5(t)}}function AWy(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:x2(e,"list"),path:[]}]}}function PWy(e){return cwe(fq.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:x2(r,`"${e}"`)}]})()}function wWy(e){return cwe(fq.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:x2(r,`${e.toString()}`)}]})()}var jWy=cwe(fq.ANY,e=>({ok:!0,value:e}));var EWy=cwe(fq.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:x2(e,"boolean")}]});var SWy=cwe(fq.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:x2(e,"number")}]});var DWy=cwe(fq.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:x2(e,"string")}]});var CWy=cwe(fq.UNKNOWN,e=>({ok:!0,value:e}));function IWy(e,t){let r={parse:(n,i)=>MWy({value:n,isKeyNumeric:e.getType()===fq.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>MWy({value:n,isKeyNumeric:e.getType()===fq.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>fq.RECORD};return{...zde(r),...u5(r)}}function MWy({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return P2i(e)?vXo(e).reduce((a,[o,c])=>{if(c==null)return a;let d=a,s=o;if(t){let A=o.length>0?Number(o):NaN;isNaN(A)||(s=A)}let u=r(s),l=n(c,s);if(d.ok&&u.ok&&l.ok)return{ok:!0,value:{...d.value,[u.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),u.ok||m.push(...u.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:x2(e,"object")}]}}function BWy(e){let t=ORs(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:x2(n,"Set")}]},getType:()=>fq.SET};return{...zde(r),...u5(r)}}function qWy(e){let t={parse:(r,n)=>TWy((i,a)=>i.parse(r,a),e,n),json:(r,n)=>TWy((i,a)=>i.json(r,a),e,n),getType:()=>fq.UNDISCRIMINATED_UNION};return{...zde(t),...u5(t)}}function TWy(e,t,r){let n=[];for(let[i,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)n.push({path:c.path,message:`[Variant ${i}] ${c.message}`})}return{ok:!1,errors:n}}function RWy(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function FWy(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=gRs(gXo(t)),a={parse:(o,c)=>NWy({value:o,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>NWy({value:o,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>fq.UNION};return{...zde(a),...u5(a),..._qr(a)}}function NWy({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!P2i(e))return{ok:!1,errors:[{path:c,message:x2(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=n(d);if(!u.ok)return{ok:!1,errors:u.errors};let l=i(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let m=o(s,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var fI=Gr.objectWithoutOptionalProperties({title:Gr.string().optional()});var ARs=Gr.objectWithoutOptionalProperties({file:Gr.string()});var PRs=Gr.objectWithoutOptionalProperties({file:Gr.string()});var wRs=Gr.union("type",{openapi:ARs,protobuf:PRs}).transform({transform:e=>{switch(e.type){case"openapi":return swe.openapi(e);case"protobuf":return swe.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var ZA=Gr.objectWithoutOptionalProperties({source:wRs.optional()});var jRs=Gr.objectWithoutOptionalProperties({typeName:Gr.string()});var ERs=Gr.union("type",{protobuf:jRs}).transform({transform:e=>{switch(e.type){case"protobuf":return Iro.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Kxe=Gr.objectWithoutOptionalProperties({encoding:ERs.optional()});var ky=Gr.objectWithoutOptionalProperties({description:Gr.string().optional()});var SRs=Gr.enum_(["GenerallyAvailable","Beta","Deprecated"]);var BP=Gr.objectWithoutOptionalProperties({availability:SRs.optional()});var nVr=Gr.number();var ryt=Gr.objectWithoutOptionalProperties({statusCode:nVr.optional()});var eD=Gr.objectWithoutOptionalProperties({nameOverride:Gr.string().optional(),generatedName:Gr.string()});var N6=Gr.objectWithoutOptionalProperties({inline:Gr.boolean().optional()});var kCe=Gr.string();var eMe=Gr.string();var DRs=Gr.objectWithoutOptionalProperties({id:eMe}).extend(ky);var Rro=Gr.string();var CRs=Gr.objectWithoutOptionalProperties({usernameVariableName:Gr.string().optional(),usernameEnvVar:Gr.string().optional(),passwordVariableName:Gr.string().optional(),passwordEnvVar:Gr.string().optional()});var MRs=Gr.objectWithoutOptionalProperties({tokenVariableName:Gr.string().optional(),tokenEnvVar:Gr.string().optional()});var IRs=Gr.objectWithoutOptionalProperties({headerName:Gr.string(),prefix:Gr.string().optional(),headerVariableName:Gr.string().optional(),headerEnvVar:Gr.string().optional()});var BRs=Gr.objectWithoutOptionalProperties({queryParameterName:Gr.string()});var TRs=Gr.objectWithoutOptionalProperties({snake:Gr.string().optional(),camel:Gr.string().optional(),screamingSnake:Gr.string().optional(),pascal:Gr.string().optional()});var j2i=Gr.objectWithoutOptionalProperties({nameOverride:Gr.string().optional(),generatedName:Gr.string(),value:Gr.string(),casing:TRs.optional()}).extend(ky).extend(BP);var qRs=Gr.objectWithoutOptionalProperties({type:Gr.stringLiteral("namespace"),name:Gr.string()});var RRs=Gr.undiscriminatedUnion([Gr.string(),qRs]);var E2i=Gr.list(RRs);var dI=Gr.objectWithoutOptionalProperties({groupName:E2i.optional()});var dS=Gr.objectWithoutOptionalProperties({namespace:Gr.string().optional()});var Nro=Gr.objectWithoutOptionalProperties({default:j2i.optional(),values:Gr.list(j2i)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var NRs=Gr.objectWithoutOptionalProperties({scopesEnum:Nro.optional()});var FRs=Gr.union("type",{basic:CRs,bearer:MRs,header:IRs,query:BRs,oauth:NRs}).transform({transform:e=>{switch(e.type){case"basic":return Rde.basic(e);case"bearer":return Rde.bearer(e);case"header":return Rde.header(e);case"query":return Rde.query(e);case"oauth":return Rde.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var mXo=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),url:Gr.string(),audiences:Gr.list(Gr.string()).optional()}).extend(ky);var xRs=Gr.string();var iVr=Gr.objectWithoutOptionalProperties({sdkMethodName:Gr.string().optional()});var NIf={};ff(NIf,{FullExample:()=>s5,FullObjectExample:()=>LRs,FullOneOfExample:()=>VRs,KeyValuePair:()=>URs,LiteralExample:()=>zRs,NullExample:()=>QRs,PrimitiveExample:()=>xro,PropertyKey:()=>Fro});var Fro=Gr.string();var xro=Gr.union("type",{int:Gr.object({value:Gr.number()}),int64:Gr.object({value:Gr.number()}),uint:Gr.object({value:Gr.number()}),uint64:Gr.object({value:Gr.number()}),float:Gr.object({value:Gr.number()}),double:Gr.object({value:Gr.number()}),string:Gr.object({value:Gr.string()}),datetime:Gr.object({value:Gr.string()}),date:Gr.object({value:Gr.string()}),base64:Gr.object({value:Gr.string()}),boolean:Gr.object({value:Gr.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return AO.int(e.value);case"int64":return AO.int64(e.value);case"uint":return AO.uint(e.value);case"uint64":return AO.uint64(e.value);case"float":return AO.float(e.value);case"double":return AO.double(e.value);case"string":return AO.string(e.value);case"datetime":return AO.datetime(e.value);case"date":return AO.date(e.value);case"base64":return AO.base64(e.value);case"boolean":return AO.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var zRs=Gr.union("type",{boolean:Gr.object({value:Gr.boolean()}),string:Gr.object({value:Gr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return O2i.boolean(e.value);case"string":return O2i.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QRs=Gr.objectWithoutOptionalProperties({});var s5=Gr.union("type",{primitive:Gr.object({value:xro}),object:Gr.lazyObject(()=>LRs),array:Gr.object({value:Gr.list(Gr.lazy(()=>s5))}),map:Gr.object({value:Gr.list(Gr.lazyObject(()=>URs))}),enum:Gr.object({value:Gr.string()}),literal:Gr.object({value:zRs}),oneOf:Gr.object({value:Gr.lazy(()=>VRs)}),null:QRs,unknown:Gr.object({value:Gr.lazy(()=>s5)})}).transform({transform:e=>{switch(e.type){case"primitive":return fS.primitive(e.value);case"object":return fS.object(e);case"array":return fS.array(e.value);case"map":return fS.map(e.value);case"enum":return fS.enum(e.value);case"literal":return fS.literal(e.value);case"oneOf":return fS.oneOf(e.value);case"null":return fS.null(e);case"unknown":return fS.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var LRs=Gr.objectWithoutOptionalProperties({properties:Gr.record(Fro,Gr.lazy(()=>s5))});var URs=Gr.objectWithoutOptionalProperties({key:xro,value:Gr.lazy(()=>s5)});var VRs=Gr.union("type",{discriminated:Gr.object({value:Gr.record(Fro,Gr.lazy(()=>s5))}),undiscriminated:Gr.object({value:Gr.lazy(()=>s5)})}).transform({transform:e=>{switch(e.type){case"discriminated":return A2i.discriminated(e.value);case"undiscriminated":return A2i.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var FIf={};ff(FIf,{AllOfPropertyConflict:()=>nno,ArraySchema:()=>qNs,Availability:()=>SRs,BooleanSchema:()=>DNs,BytesResponse:()=>Jro,CasingOverrides:()=>TRs,CommonProperty:()=>UNs,CursorPagination:()=>fNs,CustomCodeSample:()=>cNs,CustomCodeSampleLanguage:()=>oNs,CustomCodeSampleSdk:()=>sNs,CustomPagination:()=>pNs,DiscriminatedOneOfSchema:()=>QNs,DoubleSchema:()=>ENs,Endpoint:()=>_Ns,EndpointExample:()=>Xro,EndpointResponseExample:()=>aNs,EndpointSdkName:()=>aVr,EndpointSecurity:()=>zro,EnumSchema:()=>Nro,EnumValue:()=>j2i,ErrorExample:()=>eNs,FernExample:()=>rNs,FileResponse:()=>Hro,FileSchema:()=>GRs,FormUrlEncodedRequest:()=>XRs,FullEndpointExample:()=>lNs,GlobalHeader:()=>MNs,Header:()=>S2i,HeaderExample:()=>Yro,HttpEndpointServer:()=>Kro,HttpError:()=>tNs,HttpMethod:()=>Qro,IdempotencyHeader:()=>INs,IntSchema:()=>wNs,JsonRequest:()=>YRs,JsonResponse:()=>Gro,LiteralSchema:()=>rno,LiteralSchemaValue:()=>BNs,LongSchema:()=>jNs,MapSchema:()=>RNs,MultipartRequest:()=>Wro,MultipartRequestProperty:()=>$Rs,MultipartRequestPropertyEncoding:()=>KRs,MultipartSchema:()=>JRs,NullableSchema:()=>FNs,ObjectProperty:()=>zNs,ObjectPropertyConflictInfo:()=>ino,ObjectSchema:()=>TNs,OctetStreamRequest:()=>Vro,OffsetPagination:()=>dNs,OneOfSchema:()=>xNs,OpenApiIntermediateRepresentation:()=>xWy,OptionalSchema:()=>NNs,Pagination:()=>Zro,PathParameter:()=>Lro,PathParameterExample:()=>nNs,PrimitiveSchema:()=>C2i,PrimitiveSchemaValue:()=>CNs,QueryParameter:()=>Uro,QueryParameterExample:()=>$ro,ReferencedSchema:()=>oVr,Request:()=>ZRs,Response:()=>kRs,RetriesConfiguration:()=>kro,Schema:()=>hM,Schemas:()=>PNs,SdkGroupInfo:()=>WRs,StreamingResponseExample:()=>iNs,StringSchema:()=>SNs,SupportedSdkLanguage:()=>uNs,Tags:()=>HRs,TextResponse:()=>D2i,UnDiscriminatedOneOfSchema:()=>LNs,Webhook:()=>hNs,WebhookExampleCall:()=>tno,WebhookHttpMethod:()=>eno,WebsocketChannel:()=>ANs,WebsocketHandshake:()=>yNs,WebsocketMessageExample:()=>mNs,WebsocketMessageOrigin:()=>vNs,WebsocketMessageSchema:()=>bNs,WebsocketServer:()=>gNs,WebsocketSessionExample:()=>ONs});var WRs=Gr.objectWithoutOptionalProperties({summary:Gr.string().optional(),description:Gr.string().optional()});var HRs=Gr.objectWithoutOptionalProperties({tagsById:Gr.record(eMe,DRs),orderedTagIds:Gr.list(eMe).optional()});var zro=Gr.list(Gr.record(Rro,Gr.list(Gr.string())));var Qro=Gr.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var Lro=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>hM),variableReference:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var Uro=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>hM),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var S2i=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>hM),env:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var aVr=Gr.objectWithoutOptionalProperties({groupName:E2i,methodName:Gr.string()});var Vro=Gr.objectWithoutOptionalProperties({contentType:Gr.string().optional()}).extend(ky).extend(ZA);var GRs=Gr.objectWithoutOptionalProperties({isOptional:Gr.boolean(),isArray:Gr.boolean()}).extend(ky);var JRs=Gr.union("type",{file:GRs,json:Gr.object({value:Gr.lazy(()=>hM)})}).transform({transform:e=>{switch(e.type){case"file":return tVr.file(e);case"json":return tVr.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var KRs=Gr.enum_(["json","form"]);var $Rs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:JRs,contentType:Gr.string().optional(),exploded:Gr.boolean().optional(),encoding:KRs.optional()}).extend(ky);var Wro=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),properties:Gr.list($Rs)}).extend(ky).extend(ZA);var YRs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM),contentType:Gr.string().optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA);var XRs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM),contentType:Gr.string().optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA);var ZRs=Gr.union("type",{octetStream:Vro,multipart:Wro,json:YRs,formUrlEncoded:XRs}).transform({transform:e=>{switch(e.type){case"octetStream":return pqr.octetStream(e);case"multipart":return pqr.multipart(e);case"json":return pqr.json(e);case"formUrlEncoded":return pqr.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var Hro=Gr.objectWithoutOptionalProperties({}).extend(ky).extend(ZA).extend(ryt);var Gro=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM),responseProperty:Gr.string().optional()}).extend(ky).extend(ZA).extend(ryt);var D2i=Gr.objectWithoutOptionalProperties({}).extend(ky).extend(ZA).extend(ryt);var Jro=Gr.objectWithoutOptionalProperties({}).extend(ky).extend(ZA).extend(ryt);var kRs=Gr.union("type",{file:Hro,json:Gro,text:D2i,bytes:Jro,streamingSse:Gro,streamingText:D2i,streamingJson:Gro}).transform({transform:e=>{switch(e.type){case"file":return qbe.file(e);case"json":return qbe.json(e);case"text":return qbe.text(e);case"bytes":return qbe.bytes(e);case"streamingSse":return qbe.streamingSse(e);case"streamingText":return qbe.streamingText(e);case"streamingJson":return qbe.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var eNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),description:Gr.string().optional(),example:Gr.lazy(()=>s5)});var tNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>hM).optional(),examples:Gr.list(eNs).optional()}).extend(ky).extend(eD).extend(ZA);var Kro=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),url:Gr.string().optional(),audiences:Gr.list(Gr.string()).optional()});var rNs=Gr.unknown();var nNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),parameterNameOverride:Gr.string().optional(),value:Gr.lazy(()=>s5)});var $ro=Gr.objectWithoutOptionalProperties({name:Gr.string(),value:Gr.lazy(()=>s5)});var Yro=Gr.objectWithoutOptionalProperties({name:Gr.string(),value:Gr.lazy(()=>s5)});var iNs=Gr.objectWithoutOptionalProperties({sse:Gr.boolean(),events:Gr.list(Gr.lazy(()=>s5))});var aNs=Gr.union("type",{withStreaming:iNs,withoutStreaming:Gr.object({value:Gr.lazy(()=>s5)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return tyt.withStreaming(e);case"withoutStreaming":return tyt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var oNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),language:Gr.string(),code:Gr.string(),install:Gr.string().optional()}).extend(ky);var uNs=Gr.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var sNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),sdk:uNs,code:Gr.string()}).extend(ky);var cNs=Gr.union("type",{language:oNs,sdk:sNs}).transform({transform:e=>{switch(e.type){case"language":return eVr.language(e);case"sdk":return eVr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var lNs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),pathParameters:Gr.list(nNs).optional(),queryParameters:Gr.list($ro).optional(),headers:Gr.list(Yro).optional(),request:Gr.lazy(()=>s5).optional(),response:aNs.optional(),codeSamples:Gr.list(cNs)}).extend(ky);var Xro=Gr.union("type",{unknown:Gr.object({value:rNs}),full:lNs}).transform({transform:e=>{switch(e.type){case"unknown":return eyt.unknown(e.value);case"full":return eyt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var fNs=Gr.objectWithoutOptionalProperties({cursor:Gr.string(),nextCursor:Gr.property("next_cursor",Gr.string()),results:Gr.string()});var dNs=Gr.objectWithoutOptionalProperties({offset:Gr.string(),results:Gr.string(),step:Gr.string().optional(),hasNextPage:Gr.string().optional()});var pNs=Gr.objectWithoutOptionalProperties({results:Gr.string()});var Zro=Gr.union("type",{cursor:fNs,offset:dNs,custom:pNs}).transform({transform:e=>{switch(e.type){case"cursor":return Lnt.cursor(e);case"offset":return Lnt.offset(e);case"custom":return Lnt.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var kro=Gr.union("type",{disabled:Gr.object({value:Gr.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return yXo.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var _Ns=Gr.objectWithoutOptionalProperties({authed:Gr.boolean(),security:zro,internal:Gr.boolean().optional(),idempotent:Gr.boolean().optional(),method:Qro,audiences:Gr.list(Gr.string()),path:Gr.string(),summary:Gr.string().optional(),operationId:Gr.string().optional(),tags:Gr.list(eMe),pathParameters:Gr.list(Lro),queryParameters:Gr.list(Uro),headers:Gr.list(S2i),sdkName:aVr.optional(),generatedRequestName:Gr.string(),requestNameOverride:Gr.string().optional(),request:ZRs.optional(),response:kRs.optional(),errors:Gr.record(nVr,tNs),servers:Gr.list(Kro),examples:Gr.list(Xro),pagination:Zro.optional(),retries:kro.optional()}).extend(ky).extend(BP).extend(ZA).extend(dS);var eno=Gr.enum_(["GET","POST"]);var tno=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),payload:Gr.lazy(()=>s5)}).extend(ky);var hNs=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),sdkName:aVr.optional(),method:eno,summary:Gr.string().optional(),operationId:Gr.string(),tags:Gr.list(eMe),headers:Gr.list(S2i),generatedPayloadName:Gr.string(),payload:Gr.lazy(()=>hM),examples:Gr.list(tno)}).extend(ky).extend(ZA).extend(dS);var yNs=Gr.objectWithoutOptionalProperties({queryParameters:Gr.list(Uro),headers:Gr.list(S2i),pathParameters:Gr.list(Lro)});var vNs=Gr.enum_(["client","server"]);var bNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),origin:vNs,body:Gr.lazy(()=>hM)});var gNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),url:Gr.string()});var mNs=Gr.objectWithoutOptionalProperties({messageType:Gr.string(),payload:Gr.lazy(()=>s5)}).extend(ky);var ONs=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),queryParameters:Gr.list($ro).optional(),headers:Gr.list(Yro).optional(),messages:Gr.list(mNs)}).extend(ky);var ANs=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),path:Gr.string(),groupName:E2i,summary:Gr.string().optional(),handshake:yNs,messages:Gr.list(bNs),servers:Gr.list(gNs),examples:Gr.list(ONs)}).extend(ky).extend(ZA);var PNs=Gr.objectWithoutOptionalProperties({rootSchemas:Gr.record(kCe,Gr.lazy(()=>hM)),namespacedSchemas:Gr.record(xRs,Gr.record(kCe,Gr.lazy(()=>hM)))});var wNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional()});var jNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional()});var ENs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional()});var SNs=Gr.objectWithoutOptionalProperties({default:Gr.string().optional(),pattern:Gr.string().optional(),format:Gr.string().optional(),minLength:Gr.number().optional(),maxLength:Gr.number().optional()});var DNs=Gr.objectWithoutOptionalProperties({default:Gr.boolean().optional()});var CNs=Gr.union("type",{int:wNs,int64:jNs,uint:Gr.object({}),uint64:Gr.object({}),float:Gr.object({}),double:ENs,string:SNs,datetime:Gr.object({}),date:Gr.object({}),base64:Gr.object({}),boolean:DNs}).transform({transform:e=>{switch(e.type){case"int":return lq.int(e);case"int64":return lq.int64(e);case"uint":return lq.uint();case"uint64":return lq.uint64();case"float":return lq.float();case"double":return lq.double(e);case"string":return lq.string(e);case"datetime":return lq.datetime();case"date":return lq.date();case"base64":return lq.base64();case"boolean":return lq.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var C2i=Gr.objectWithoutOptionalProperties({schema:CNs}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var MNs=Gr.objectWithoutOptionalProperties({header:Gr.string(),name:Gr.string().optional(),optional:Gr.boolean().optional(),env:Gr.string().optional(),schema:Gr.lazy(()=>hM).optional()});var INs=Gr.objectWithoutOptionalProperties({header:Gr.string(),name:Gr.string().optional(),env:Gr.string().optional(),schema:Gr.lazy(()=>hM).optional()});var xWy=Gr.objectWithoutOptionalProperties({apiVersion:Gr.unknown().optional(),title:Gr.string().optional(),description:Gr.string().optional(),basePath:Gr.string().optional(),servers:Gr.list(mXo),websocketServers:Gr.list(mXo),groups:Gr.record(Gr.string(),WRs),tags:HRs,hasEndpointsMarkedInternal:Gr.boolean(),endpoints:Gr.list(_Ns),webhooks:Gr.list(hNs),channels:Gr.record(Gr.string(),ANs),groupedSchemas:PNs,variables:Gr.record(Gr.string(),C2i),nonRequestReferencedSchemas:Gr.set(kCe),securitySchemes:Gr.record(Rro,FRs),globalHeaders:Gr.list(MNs).optional(),idempotencyHeaders:Gr.list(INs).optional()});var oVr=Gr.objectWithoutOptionalProperties({schema:kCe}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI);var BNs=Gr.union("type",{boolean:Gr.object({value:Gr.boolean()}),string:Gr.object({value:Gr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return jV.boolean(e.value);case"string":return jV.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var rno=Gr.objectWithoutOptionalProperties({value:BNs}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var hM=Gr.union("type",{primitive:C2i,object:Gr.lazyObject(()=>TNs),array:Gr.lazyObject(()=>qNs),map:Gr.lazyObject(()=>RNs),optional:Gr.lazyObject(()=>NNs),enum:Nro,reference:oVr,literal:rno,oneOf:Gr.object({value:Gr.lazy(()=>xNs)}),nullable:Gr.lazyObject(()=>FNs),unknown:eD}).transform({transform:e=>{switch(e.type){case"primitive":return Wj.primitive(e);case"object":return Wj.object(e);case"array":return Wj.array(e);case"map":return Wj.map(e);case"optional":return Wj.optional(e);case"enum":return Wj.enum(e);case"reference":return Wj.reference(e);case"literal":return Wj.literal(e);case"oneOf":return Wj.oneOf(e.value);case"nullable":return Wj.nullable(e);case"unknown":return Wj.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var nno=Gr.objectWithoutOptionalProperties({propertyKey:Gr.string(),allOfSchemaIds:Gr.list(kCe),conflictingTypeSignatures:Gr.boolean()});var TNs=Gr.objectWithoutOptionalProperties({allOf:Gr.list(oVr),properties:Gr.list(Gr.lazyObject(()=>zNs)),allOfPropertyConflicts:Gr.list(nno),additionalProperties:Gr.boolean()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var ino=Gr.objectWithoutOptionalProperties({differentSchema:Gr.boolean()});var zNs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>hM),readonly:Gr.boolean().optional(),writeonly:Gr.boolean().optional(),conflict:Gr.record(kCe,ino),generatedName:Gr.string(),nameOverride:Gr.string().optional(),audiences:Gr.list(Gr.string())}).extend(BP);var qNs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var RNs=Gr.objectWithoutOptionalProperties({key:C2i,value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(fI).extend(N6);var NNs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var FNs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>hM)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var xNs=Gr.union("type",{discriminated:Gr.lazyObject(()=>QNs),undiscriminated:Gr.lazyObject(()=>LNs)}).transform({transform:e=>{switch(e.type){case"discriminated":return rVr.discriminated(e);case"undiscriminated":return rVr.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var QNs=Gr.objectWithoutOptionalProperties({discriminantProperty:Gr.string(),commonProperties:Gr.list(Gr.lazyObject(()=>UNs)),schemas:Gr.record(Gr.string(),Gr.lazy(()=>hM))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var UNs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>hM)});var LNs=Gr.objectWithoutOptionalProperties({schemas:Gr.list(Gr.lazy(()=>hM))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var xIf={};ff(xIf,{ArraySchemaWithExample:()=>fFs,Base64WithExample:()=>oFs,BooleanWithExample:()=>uFs,CommonPropertyWithExample:()=>mFs,DateWithExample:()=>aFs,DatetimeWithExample:()=>iFs,DiscriminatedOneOfSchemaWithExample:()=>bFs,DoubleWithExample:()=>rFs,EndpointWithExample:()=>QWy,EnumSchemaWithExample:()=>cFs,FloatWithExample:()=>tFs,HeaderWithExample:()=>M2i,HttpErrorWithExample:()=>YNs,Int64WithExample:()=>ZNs,IntWithExample:()=>XNs,JsonRequestWithExample:()=>GNs,JsonResponseWithExample:()=>ono,MapSchemaWithExample:()=>dFs,NamedFullExample:()=>nyt,NullableSchemaWithExample:()=>_Fs,ObjectPropertyWithExample:()=>vFs,ObjectSchemaWithExample:()=>hFs,OneOfSchemaWithExample:()=>yFs,OptionalSchemaWithExample:()=>pFs,ParseFormUrlEncodedRequest:()=>JNs,ParseMultipartRequest:()=>HNs,ParseOctetStreamRequest:()=>WNs,PathParameterWithExample:()=>VNs,PrimitiveSchemaValueWithExample:()=>sFs,PrimitiveSchemaWithExample:()=>uno,QueryParameterWithExample:()=>ano,RequestWithExample:()=>KNs,ResponseWithExample:()=>$Ns,SchemaWithExample:()=>F6,StringSchemaWithExample:()=>nFs,Uint64WithExample:()=>eFs,UintWithExample:()=>kNs,UnDiscriminatedOneOfSchemaWithExample:()=>gFs,UnknownSchemaWithExample:()=>lFs,WebhookWithExample:()=>LWy,WebsocketHandshakeWithExample:()=>zWy});var nyt=Gr.objectWithoutOptionalProperties({name:Gr.string().optional(),value:Gr.unknown()}).extend(ky);var ano=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>F6),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var M2i=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>F6),env:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var zWy=Gr.objectWithoutOptionalProperties({queryParameters:Gr.list(ano),headers:Gr.list(M2i)});var VNs=Gr.objectWithoutOptionalProperties({name:Gr.string(),schema:Gr.lazy(()=>F6),variableReference:Gr.string().optional(),parameterNameOverride:Gr.string().optional()}).extend(ky).extend(BP).extend(ZA);var WNs=Gr.objectWithoutOptionalProperties({}).extend(Vro).extend(iVr);var HNs=Gr.objectWithoutOptionalProperties({}).extend(Wro).extend(iVr);var GNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>F6),contentType:Gr.string().optional(),fullExamples:Gr.list(nyt).optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA).extend(iVr);var JNs=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>F6),contentType:Gr.string().optional(),fullExamples:Gr.list(nyt).optional(),additionalProperties:Gr.boolean()}).extend(ky).extend(ZA).extend(iVr);var KNs=Gr.union("type",{octetStream:WNs,multipart:HNs,json:GNs,formUrlEncoded:JNs}).transform({transform:e=>{switch(e.type){case"octetStream":return ZCe.octetStream(e);case"multipart":return ZCe.multipart(e);case"json":return ZCe.json(e);case"formUrlEncoded":return ZCe.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var ono=Gr.objectWithoutOptionalProperties({schema:Gr.lazy(()=>F6),responseProperty:Gr.string().optional(),fullExamples:Gr.list(nyt).optional()}).extend(ky).extend(ZA).extend(ryt);var $Ns=Gr.union("type",{file:Hro,json:ono,text:D2i,bytes:Jro,streamingSse:ono,streamingText:D2i,streamingJson:ono}).transform({transform:e=>{switch(e.type){case"file":return QL.file(e);case"json":return QL.json(e);case"text":return QL.text(e);case"bytes":return QL.bytes(e);case"streamingSse":return QL.streamingSse(e);case"streamingText":return QL.streamingText(e);case"streamingJson":return QL.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var YNs=Gr.objectWithoutOptionalProperties({statusCode:nVr,schema:Gr.lazy(()=>F6),fullExamples:Gr.list(nyt).optional()}).extend(ky).extend(eD).extend(ZA);var QWy=Gr.objectWithoutOptionalProperties({authed:Gr.boolean(),security:zro,internal:Gr.boolean().optional(),idempotent:Gr.boolean().optional(),method:Qro,audiences:Gr.list(Gr.string()),path:Gr.string(),summary:Gr.string().optional(),operationId:Gr.string().optional(),tags:Gr.list(eMe),pathParameters:Gr.list(VNs),queryParameters:Gr.list(ano),headers:Gr.list(M2i),sdkName:aVr.optional(),generatedRequestName:Gr.string(),requestNameOverride:Gr.string().optional(),request:KNs.optional(),response:$Ns.optional(),errors:Gr.record(nVr,YNs),servers:Gr.list(Kro),examples:Gr.list(Xro),pagination:Zro.optional(),retries:kro.optional()}).extend(ky).extend(BP).extend(ZA).extend(dS);var LWy=Gr.objectWithoutOptionalProperties({audiences:Gr.list(Gr.string()),sdkName:aVr.optional(),method:eno,summary:Gr.string().optional(),operationId:Gr.string(),tags:Gr.list(eMe),headers:Gr.list(M2i),generatedPayloadName:Gr.string(),payload:Gr.lazy(()=>F6),examples:Gr.list(tno)}).extend(ky).extend(ZA).extend(dS);var XNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional(),example:Gr.number().optional()});var ZNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var kNs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var eFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),example:Gr.number().optional()});var tFs=Gr.objectWithoutOptionalProperties({example:Gr.number().optional()});var rFs=Gr.objectWithoutOptionalProperties({default:Gr.number().optional(),minimum:Gr.number().optional(),maximum:Gr.number().optional(),exclusiveMinimum:Gr.boolean().optional(),exclusiveMaximum:Gr.boolean().optional(),multipleOf:Gr.number().optional(),example:Gr.number().optional()});var nFs=Gr.objectWithoutOptionalProperties({default:Gr.string().optional(),pattern:Gr.string().optional(),format:Gr.string().optional(),minLength:Gr.number().optional(),maxLength:Gr.number().optional(),example:Gr.string().optional()});var iFs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var aFs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var oFs=Gr.objectWithoutOptionalProperties({example:Gr.string().optional()});var uFs=Gr.objectWithoutOptionalProperties({default:Gr.boolean().optional(),example:Gr.boolean().optional()});var sFs=Gr.union("type",{int:XNs,int64:ZNs,uint:kNs,uint64:eFs,float:tFs,double:rFs,string:nFs,datetime:iFs,date:aFs,base64:oFs,boolean:uFs}).transform({transform:e=>{switch(e.type){case"int":return z0.int(e);case"int64":return z0.int64(e);case"uint":return z0.uint(e);case"uint64":return z0.uint64(e);case"float":return z0.float(e);case"double":return z0.double(e);case"string":return z0.string(e);case"datetime":return z0.datetime(e);case"date":return z0.date(e);case"base64":return z0.base64(e);case"boolean":return z0.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var uno=Gr.objectWithoutOptionalProperties({schema:sFs}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var cFs=Gr.objectWithoutOptionalProperties({default:j2i.optional(),values:Gr.list(j2i),example:Gr.string().optional()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var lFs=Gr.objectWithoutOptionalProperties({example:Gr.unknown()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI);var F6=Gr.union("type",{primitive:uno,object:Gr.lazyObject(()=>hFs),array:Gr.lazyObject(()=>fFs),map:Gr.lazyObject(()=>dFs),optional:Gr.lazyObject(()=>pFs),enum:cFs,reference:oVr,literal:rno,oneOf:Gr.object({value:Gr.lazy(()=>yFs)}),nullable:Gr.lazyObject(()=>_Fs),unknown:lFs}).transform({transform:e=>{switch(e.type){case"primitive":return mh.primitive(e);case"object":return mh.object(e);case"array":return mh.array(e);case"map":return mh.map(e);case"optional":return mh.optional(e);case"enum":return mh.enum(e);case"reference":return mh.reference(e);case"literal":return mh.literal(e);case"oneOf":return mh.oneOf(e.value);case"nullable":return mh.nullable(e);case"unknown":return mh.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var fFs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>F6),example:Gr.list(Gr.unknown()).optional()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var dFs=Gr.objectWithoutOptionalProperties({key:uno,value:Gr.lazy(()=>F6),example:Gr.unknown().optional()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(fI).extend(N6);var pFs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>F6)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var _Fs=Gr.objectWithoutOptionalProperties({value:Gr.lazy(()=>F6)}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(fI).extend(N6);var hFs=Gr.objectWithoutOptionalProperties({allOf:Gr.list(oVr),properties:Gr.list(Gr.lazyObject(()=>vFs)),allOfPropertyConflicts:Gr.list(nno),fullExamples:Gr.list(nyt).optional(),additionalProperties:Gr.boolean()}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(ZA).extend(fI).extend(N6);var vFs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>F6),readonly:Gr.boolean().optional(),writeonly:Gr.boolean().optional(),audiences:Gr.list(Gr.string()),conflict:Gr.record(kCe,ino),nameOverride:Gr.string().optional(),generatedName:Gr.string()}).extend(BP);var yFs=Gr.union("type",{discriminated:Gr.lazyObject(()=>bFs),undiscriminated:Gr.lazyObject(()=>gFs)}).transform({transform:e=>{switch(e.type){case"discriminated":return Unt.discriminated(e);case"undiscriminated":return Unt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var bFs=Gr.objectWithoutOptionalProperties({discriminantProperty:Gr.string(),commonProperties:Gr.list(Gr.lazyObject(()=>mFs)),schemas:Gr.record(Gr.string(),Gr.lazy(()=>F6))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var mFs=Gr.objectWithoutOptionalProperties({key:Gr.string(),schema:Gr.lazy(()=>F6)});var gFs=Gr.objectWithoutOptionalProperties({schemas:Gr.list(Gr.lazy(()=>F6))}).extend(dI).extend(dS).extend(eD).extend(ky).extend(BP).extend(Kxe).extend(ZA).extend(fI).extend(N6);var UWy=/^(\d+)/,sno=/^[a-zA-Z][a-zA-Z0-9_]*$/,VWy={"<":"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 I2i(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 o=Math.floor(e/10),c=e%10;return c===0?n[o]:`${n[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${I2i(c)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${I2i(a)}`}function OXo(e){let t=e.match(UWy);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=I2i(i);return n.length>0?`${a}_${n}`:a}}}function cno(e){let t=OXo(e),r=VWy[e];return t!=null?GU(EA(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":GU(EA(e)))}function $xe(e,t){return e.type==="primitive"&&t.type==="primitive"?WWy(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?rQC(e.values,t.values):e.type==="array"&&t.type==="array"?$xe(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"?$xe(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?nQC(e.value,t.value):e.type==="object"&&t.type==="object"?iQC(e,t):e.type==="map"&&t.type==="map"?WWy(e.key.schema,t.key.schema)&&$xe(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function WWy(e,t){return e.type===t.type}function rQC(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return Due(r,n)}function nQC(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:$xe(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:$xe(r,i)}):!1}function iQC(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 a=r[n];return a==null?!1:$xe(a,i.schema)})}function wJ(e){switch(e){case Nde.Deprecated:return"deprecated";case Nde.Beta:return"pre-release";case Nde.GenerallyAvailable:return"generally-available";default:return}}function aQC(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 HWy(e){let t=e?aQC(e):void 0;if(t==null||t.length===0)return Yia;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(EA(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(EA(i.name)):r.push(i.name,Yia);break}default:tc(i.type)}else tc(i);return r.join("/")}function B2i(e){return nw.of(`${HWy(e)}.yml`)}function zIf({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Yia:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,HWy(r))}function GWy({sdkName:e,namespaceOverride:t}){return nw.of(`${zIf({sdkName:e,namespaceOverride:t})}.yml`)}function JWy({location:e,namespaceOverride:t}){return t!=null?TX(nw.of(t),e):e}function OFs(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:tc(e.type)}}function lno(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:tc(e)}}function x6(e){return typeof e=="string"?e:e.type}function fno(e){if(typeof e!="string")return e.docs}function AXo(e){if(typeof e!="string")return e.default}function QIf(e){if(typeof e!="string")return e.validation}function $Wy(e){let t=x6(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?KWy(e):{...e,type:KWy(e.type)}}function KWy(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function wla(e){return x6(e).startsWith("optional<")?e:typeof e=="string"?YWy(e):{...e,type:YWy(e.type)}}function YWy(e){return e.startsWith("optional<")?e:`optional<${e}>`}var oQC=-2147483648,uQC=2147483647,sQC=-17976931348623157e292,cQC=17976931348623157e292;function UD({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:a}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return AFs(e);case"array":return VIf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"map":return WIf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"reference":return UIf({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return GIf();case"optional":return PFs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"nullable":return HIf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"enum":return bQC({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:a});case"literal":return e.value,JIf(e);case"object":return gQC({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"oneOf":return mQC({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});default:tc(e)}}function AFs(e){switch(e.schema.type){case"string":return dQC({description:e.description,schema:e.schema});case"int":return pQC({description:e.description,schema:e.schema});case"float":return _QC({description:e.description,schema:e.schema});case"double":return hQC({description:e.description,schema:e.schema});case"boolean":return lQC({description:e.description,schema:e.schema});case"int64":return fQC({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function lQC({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 fQC({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 dQC({description:e,schema:t}){let r="string",n=yQC(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 pQC({description:e,schema:t}){let r="integer",n=XWy(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 _QC({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function hQC({description:e,schema:t}){let r="double",n=XWy(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 yQC(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=vQC(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function vQC(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 XWy(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=LIf(r,t),n=LIf(n,t),i=LIf(i,t),!(r==null&&n==null&&a==null&&o==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:o,multipleOf:i}}function LIf(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[oQC,uQC]:[sQC,cQC];return e<r||e>n?void 0:e}function UIf({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=OQC(i)??e.schema,o=lno(i),c=AQC(i),s=wFs({context:r,fileContainingReference:t,declarationFile:B2i(o),type:a});return i.type==="nullable"&&(s=r.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),i.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function VIf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=`list<${x6(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{},type:c}}function WIf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=AFs(e.key),c=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),d=e.encoding!=null?OFs(e.encoding):void 0,s=`map<${x6(o)}, ${x6(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=d),e.availability!=null&&(u.availability=wJ(e.availability)),u}function HIf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){if(!n.respectNullableSchemas)return PFs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});let o=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=x6(o),d=fno(o),s=AXo(o),u=QIf(o),l=$Wy(c);if(n.wrapReferencesToNullableInOptional&&(l=wla(l)),e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let m=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(m.docs=e.description??d),s!=null&&(m.default=s),u!=null&&(m.validation=u),e.availability!=null&&(m.availability=wJ(e.availability)),m}function PFs({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=UD({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=x6(o),d=fno(o),s=AXo(o),u=QIf(o),l=wla(c);if(e.availability==null&&e.description==null&&d==null&&s==null&&u==null&&e.title==null)return l;let m=typeof l=="string"?{type:l}:l;return(e.description!=null||d!=null)&&(m.docs=e.description??d),s!=null&&(m.default=s),u!=null&&(m.validation=u),e.availability!=null&&(m.availability=wJ(e.availability)),m}function GIf(){return"unknown"}function JIf(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:tc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function bQC({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let a=PXo(e,i),o=e.nameOverride??e.generatedName;n.builder.addType(r,{name:o,schema:a.schema});let c=wFs({type:o,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=wJ(e.availability)),d}function gQC({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=KIf({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:o.schema});let d=wFs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function mQC({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let o=$If({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:o.schema});let d=wFs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:wJ(e.availability)}:{}}}function wFs({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 OQC(e){return Wj._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 AQC(e){return Wj._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 ase;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(ase||(ase={}));function HAi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:tc(e)}}function kWy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a;switch(e.type){case"primitive":a=jQC(e);break;case"array":a=PQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":a=wQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":a=EQC({schema:e,context:t,declarationFile:r,namespace:n});break;case"unknown":a=DQC(e.nameOverride,e.generatedName);break;case"optional":a=eHy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":a=SQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":a=PXo(e,i);break;case"literal":a=CQC(e,e.nameOverride,e.generatedName);break;case"object":a=KIf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"oneOf":a=$If({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;default:tc(e)}return a}function KIf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=t.isInState(ase.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},d=new Set;for(let A of e.properties){if(A.readonly&&(o=!0),a&&A.readonly)continue;if(Object.keys(A.conflict).length>0){if(Object.entries(A.conflict).every(([R,V])=>!V.differentSchema))continue;Object.entries(A.conflict).forEach(([R])=>{YIf({property:A.key,schemaId:R,context:t,namespace:n}).forEach($=>{d.add($)})})}let P=UD({schema:A.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}),C=A.audiences,I=A.nameOverride,T=wJ(A.availability),z=TQC(A);c[A.key]=BQC({typeReference:P,audiences:C,name:I,availability:T,propertyAccess:z})}let s=new Set;for(let A of e.allOfPropertyConflicts)A.allOfSchemaIds.forEach(P=>d.add(P)),A.conflictingTypeSignatures&&s.add(A.propertyKey);let u=[];for(let A of e.allOf){let P=tHy({schema:A.schema,context:t,namespace:n});if(P==null||d.has(A.schema)||d.has(P))continue;let C=UD({schema:Wj.reference(A),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});u.push(x6(C))}for(let A of d){let P=XIf(t,A,n);for(let C of P.properties)c[C.key]==null&&(s.has(C.key)&&(c[C.key]="unknown"),c[C.key]=UD({schema:C.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}));for(let C of P.allOf){if(d.has(C.schema))continue;let I=UD({schema:Wj.reference(C),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});u.push(x6(I))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([A,P])=>IQC(A)?[A,typeof P=="string"?{type:P,name:`_${A}`}:{...P,name:`_${A}`}]:[A,P]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=wJ(e.availability)),e.source!=null&&(l.source=HAi(e.source)),l.inline=ZIf(e,i);let m=e.nameOverride??e.generatedName;return{name:o&&t.respectReadonlySchemas&&!a?`${m}Read`:m,schema:l}}function YIf({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return YIf({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:o}=XIf(r,t,n),c=a.some(s=>s.key===e),d=[...o.flatMap(s=>YIf({property:e,context:r,schemaId:s.schema,namespace:n}))];if(c||d.length>0)return[t,...d]}return[]}function XIf(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return XIf(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function PQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:VIf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function wQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:WIf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function jQC(e){let t=AFs(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 ZWy(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function PXo(e,t){let r={enum:e.values.map(a=>{let o=a.nameOverride??a.generatedName,c=a.value;if(o===c&&a.description==null&&(a.casing==null||ZWy(a.casing)))return o;let d={value:a.value};if(o!==c&&(d.name=o),a.description!=null&&(d.docs=a.description),a.casing!=null&&!ZWy(a.casing)){let s={},u=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,u=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,u=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,u=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,u=!0),u&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=ZIf(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?HAi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;n.has(o.toLowerCase())||(i.enum.push(a),n.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function EQC({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:UIf({schema:e,context:t,fileContainingReference:r,namespace:n})}}function SQC({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:HIf({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:eHy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function eHy({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:PFs({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function DQC(e,t){return{name:e??t,schema:GIf()}}function CQC(e,t,r){return{name:t??r,schema:JIf(e)}}function $If({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=e.encoding!=null?OFs(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=UD({schema:s.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1});let d={};for(let[s,u]of Object.entries(e.schemas))d[s]=UD({schema:u,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?wJ(e.availability):void 0,union:d,encoding:a,source:e.source!=null?HAi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(UD({schema:c,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?HAi(e.source):void 0,inline:ZIf(e,i)}}}var MQC=/^[0-9]/;function IQC(e){return MQC.test(e)}function tHy({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?tHy({context:t,schema:n.schema,namespace:r}):e}function BQC({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 ZIf(e,t){return e.inline===!0||t>0?!0:void 0}function TQC(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return zX.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return zX.ObjectPropertyAccess.WriteOnly}}function rHy(e){let t=e.replace(/^x-|^X-/,"");return EA(t)}var nHy="BasicAuthScheme",jFs="BearerAuthScheme";function iHy(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:nHy,schema:i}),t||(e.builder.setAuth(nHy),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:jFs,schema:i}),t||(e.builder.setAuth(jFs),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??rHy(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:jFs,schema:i}),t||(e.builder.setAuth(jFs),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(nw.of("__package__.yml"),{name:"OauthScope",schema:PXo(n.scopesEnum,0).schema})}}function uVr({header:e,context:t,fileContainingReference:r,namespace:n}){let i=UD({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),a=x6(i),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:EA(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=wJ(e.availability)),d}function EFs({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=UD({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return x6(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:x6(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=wJ(e.availability)),a}function DFs({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=kIf({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=x6(i.value),o=AXo(i.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),i.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=wJ(e.availability)),qQC(i.value)&&i.value.validation!==void 0&&(c.validation=i.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function kIf({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:UD({schema:Wj.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:nw.of(rF),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,d]of Object.entries(i.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(sno.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:cno(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[c,d]=i.value.schemas;if(c!=null&&d!=null&&SFs({array:c,primitive:d}))return{value:UD({schema:Wj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&SFs({array:c,primitive:d}))return{value:UD({schema:Wj.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(i.value.schemas))return kIf({schema:d,context:t,fileContainingReference:r,namespace:n})}else if(t.objectQueryParameters)return{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let i=e.type==="optional"?Wj.optional:Wj.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,n);if(a==null)return;if(a.type==="array")return{value:UD({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:UD({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 a=[],o=!1;for(let[c,d]of Object.entries(e.value.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(o=!0),d.type==="literal"&&d.value.type==="string"&&(sno.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:cno(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,d]=e.value.value.schemas;if(c!=null&&d!=null&&SFs({array:c,primitive:d}))return{value:UD({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&SFs({array:d,primitive:c}))return{value:UD({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.objectQueryParameters)return{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[c,d]of Object.entries(e.value.value.schemas))return kIf({schema:i({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.objectQueryParameters?{value:UD({schema:e,context:t,fileContainingReference:r,declarationFile:nw.of(rF),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:UD({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:UD({schema:Wj.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:UD({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function SFs({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function qQC(e){return e.type!=null}function aHy({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"]=RQC(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=NQC({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=T2i(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function RQC(e){let t={};return e.forEach(r=>{let n=T2i(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function NQC({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=T2i(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function T2i(e){switch(e.type){case"primitive":return oHy(e.value);case"object":return uHy(e.properties);case"array":return FQC(e.value);case"map":return xQC(e.value);case"oneOf":return zQC(e.value);case"enum":return e.value;case"literal":return QQC(e.value);case"unknown":return T2i(e.value);case"null":return null;default:tc(e)}}function oHy(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:tc(e)}}function uHy(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,T2i(r)]))}function FQC(e){return e.map(t=>T2i(t))}function xQC(e){return Object.fromEntries(e.map(t=>[oHy(t.key),T2i(t.value)]))}function zQC(e){return e.type==="discriminated"?uHy(e.value):T2i(e.value)}function QQC(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:tc(e)}}function GAi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function CFs(e,t){return t??(e?.groupName!=null?GAi(e.groupName):void 0)}function sHy({channel:e,context:t,declarationFile:r}){let n={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(n.audiences=e.audiences),e.summary!=null&&(n["display-name"]=e.summary),e.description!=null&&(n.docs=e.description);let i=GAi(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=EFs({pathParameter:d,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let o={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=DFs({queryParameter:d,context:t,fileContainingReference:r,namespace:i});s!=null&&(o[d.name]=s)}Object.keys(o).length>0&&(n["query-parameters"]=o);let c={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=uVr({header:d,context:t,fileContainingReference:r,namespace:i});c[d.name]=s}Object.keys(c).length>0&&(n.headers=c),t.builder.addChannel(r,{channel:n});for(let d of e.messages)t.builder.addChannelMessage(r,{messageId:d.name,message:{origin:d.origin,body:UD({schema:d.body,context:t,fileContainingReference:r,namespace:i,declarationDepth:0})}});for(let d of e.examples){let s=aHy({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}function cHy(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var JAi="Base",LQC="Default";function jla(e){return Object.entries(e).reduce((t,[r,n])=>(int(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function lHy(e){if(e.environmentOverrides!=null){for(let[T,z]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:T,schema:z});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(T=>cHy(T)),i=e.ir.servers;for(let T of i)if(cHy(T)){let z={urls:{}};for(let[U,R]of Object.entries(T.urls))z.urls[U]=R.url;T.name&&(t[T.name]=z)}else if("url"in T&&T.url){let z=T.audiences?{url:T.url,audiences:T.audiences}:T.url;if(T.name==null){r.push(z);continue}t[T.name]=z}let a={},o={},c=[];for(let T of e.ir.endpoints)for(let z of T.servers){if(z.url==null&&z.name!=null){a[z.name]||(a[z.name]=[]);continue}if(z.url==null)continue;let U=z.audiences?{url:z.url,audiences:z.audiences}:z.url;if(z.name==null){c.push(U);continue}a[z.name]||(a[z.name]=[]),a[z.name]?.push({url:z.url,audiences:z.audiences}),o[z.name]=U}let d={},s=[];for(let T of e.ir.websocketServers){let z=T.audiences?{url:T.url,audiences:T.audiences}:T.url;if(T.name==null){s.push(z);continue}d[T.name]=z}let u=Object.keys(t).length,l=u>0,m=Object.keys(o).length>0,A=Object.keys(a).some(T=>a[T]?.length===0),P=Object.keys(d).length>0;if(!l&&!m&&P&&e.ir.servers.length===0){for(let[T,z]of Object.entries(d))e.builder.addEnvironment({name:T,schema:z});e.builder.setDefaultEnvironment(Object.keys(d)[0]),e.builder.setDefaultUrl(JAi);return}if(c.length>0&&e.logger.error(`Skipping endpoint level servers ${c.map(T=>typeof T=="string"?T:T.url).join(", ")} because x-fern-server-name was not provided.`),!l){let T=e.ir.servers[0]?.url,z=e.ir.servers[0]?.audiences;if(T!=null){let U=z?{url:T,audiences:z}:T;t[LQC]=U}}let C=Object.values(t).map(T=>typeof T=="string"?T:int(T)?Object.values(T.urls)[0]:T.url),I=r.filter(T=>{let z=typeof T=="string"?T:T.url;return!C.includes(z)});if(I.length>0&&e.logger.error(`Skipping top level servers ${I.map(T=>typeof T=="string"?T:T.url).join(", ")} because x-fern-server-name was not provided.`),n){let T=!0;for(let[z,U]of Object.entries(t))if(e.builder.addEnvironment({name:z,schema:U}),T){if(e.builder.setDefaultEnvironment(z),int(U)){let R=Object.keys(U.urls)[0];R&&e.builder.setDefaultUrl(R)}T=!1}return}if(!m&&!A){let T=!0;for(let[z,U]of Object.entries(t))if(T){if(P){let R=typeof U=="string"?U:int(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:z,schema:{urls:{[JAi]:R??"",...jla(d)}}})}else e.builder.addEnvironment({name:z,schema:U});e.builder.setDefaultEnvironment(z),T=!1}else if(P){let R=typeof U=="string"?U:int(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:z,schema:{urls:{[JAi]:R??"",...jla(d)}}})}else e.builder.addEnvironment({name:z,schema:U});P&&e.builder.setDefaultUrl(JAi)}else if(u===1){let T=Object.keys(t)[0],z=Object.values(t)[0],U=typeof z=="string"?z:int(z)?Object.values(z.urls)[0]:z.url;e.builder.addEnvironment({name:T,schema:{urls:{[JAi]:U??"",...jla(o),...jla(d)}}}),e.builder.setDefaultEnvironment(T),e.builder.setDefaultUrl(JAi)}else{let T=new Map;for(let z of e.ir.endpoints)for(let U of z.servers)if(U.url!=null&&U.name!=null){T.has(U.name)||T.set(U.name,new Map);let R=U.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",V=T.get(U.name);V&&V.set(R,U.url)}if(T.size>0){let z=!0;for(let[U,R]of Object.entries(t)){let V=typeof R=="string"?R:int(R)?Object.values(R.urls)[0]:R.url;if(!V)continue;let $=V.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",re={[JAi]:V};for(let[Y,te]of T.entries()){let ne=te.get($)||te.get("production")||te.values().next().value;ne&&(re[Y]=ne)}P&&Object.assign(re,jla(d)),Object.keys(re).length>1?e.builder.addEnvironment({name:U,schema:{urls:re}}):e.builder.addEnvironment({name:U,schema:V}),z&&(e.builder.setDefaultEnvironment(U),z=!1)}T.size>0&&e.builder.setDefaultUrl(JAi)}else{let z=!0;for(let[U,R]of Object.entries(t)){if(P||Object.keys(o).length>0){let V=typeof R=="string"?R:int(R)?Object.values(R.urls)[0]:R.url;e.builder.addEnvironment({name:U,schema:{urls:{[JAi]:V??"",...jla(o),...jla(d)}}})}else e.builder.addEnvironment({name:U,schema:R});z&&(e.builder.setDefaultEnvironment(U),z=!1)}}}}var eBf=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},UQC=.75,VQC=new Set("authorization");function fHy(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 a=n.schema?lno(n.schema):void 0,o=a!=null?GAi(a):void 0,c=nw.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?x6(UD({schema:n.schema,context:e,fileContainingReference:o?TX(nw.of(EA(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(VQC.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],d=uVr({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:nw.of($k),context:e,namespace:void 0});o=new eBf(d),r[a.name]=o}o.increment()}let n=e.ir.endpoints.length*UQC;for(let[i,a]of Object.entries(r)){let o=t[i],c=a.count===e.ir.endpoints.length,d=a.count>=n;o==null&&(c?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:wla(a.schema)}))}}}function dHy(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?lno(t.schema):void 0,n=r!=null?GAi(r):void 0,i=uVr({header:{...t,schema:t.schema??Wj.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:lq.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:nw.of($k),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:wla(i)})}}function lwe(e){switch(e.type){case"primitive":return _Hy(e.value);case"object":return hHy(e.properties);case"array":return yHy(e.value);case"map":return HQC(e.value);case"oneOf":return GQC(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return JQC(e.value);case"unknown":return lwe(e.value);case"null":return null;default:tc(e)}}function pHy(e){switch(e.type){case"withStreaming":return e.sse?{stream:WQC(e.events)}:{stream:yHy(e.events)};case"withoutStreaming":return{body:lwe(e.value)};default:tc(e)}}function _Hy(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:tc(e)}}function hHy(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,lwe(r)]))}function WQC(e){return e.map(t=>({event:"",data:lwe(t)}))}function yHy(e){return e.map(t=>lwe(t))}function HQC(e){return Object.fromEntries(e.map(t=>[_Hy(t.key),lwe(t.value)]))}function GQC(e){return e.type==="discriminated"?hHy(e.value):lwe(e.value)}function JQC(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:tc(e)}}function vHy({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"]=KQC(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=$QC(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),a=Object.keys(i).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(n||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(i))if(!o.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let u=cee({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Hc}});u!=null&&c.push({name:d,value:fS.literal(O2i.string(u))})}else c.push({name:d,value:fS.primitive(AO.string(d))});r.headers=YQC({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=lwe(e.request)),e.response!=null&&(r.response=pHy(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(Gw)),r}function KQC(e){let t={};return e.forEach(r=>{let n=lwe(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function $QC(e){let t={};return e.forEach(r=>{let n=lwe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function YQC({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=lwe(n.value);i!=null&&(r[n.name]=i)}),r}function bHy(e){return xde._visit(e,{get:()=>zX.HttpMethodSchema.Get,post:()=>zX.HttpMethodSchema.Post,put:()=>zX.HttpMethodSchema.Put,patch:()=>zX.HttpMethodSchema.Patch,delete:()=>zX.HttpMethodSchema.Delete,head:()=>zX.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 gHy(e){return e==="POST"||e==="PUT"||e==="PATCH"}function mHy({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,o=e.path,c=CFs(e.sdkName,e.namespace),d={};for(let I of e.pathParameters)I.parameterNameOverride&&(o=o.replace(I.name,I.parameterNameOverride)),d[I.parameterNameOverride??I.name]=EFs({pathParameter:I,context:r,fileContainingReference:t,namespace:c}),a.add(I.name);let s={};for(let I of e.queryParameters){let T=DFs({queryParameter:I,context:r,fileContainingReference:t,namespace:c});T!=null&&(s[I.name]=T,a.add(I.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:tc(e.pagination)}let l={path:o,method:bHy(e.method),auth:Object.keys(e.security).length>0?e.security:void 0,docs:e.description??void 0,pagination:u,source:e.source!=null?HAi(e.source):void 0};!eLC({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let m={},A=r.builder.getGlobalHeaderNames(),P=r.builder.getAuthHeaderName();P!=null&&A.add(P);let C=e.headers.filter(I=>!A.has(I.name));for(let I of C){let T=uVr({header:I,context:r,fileContainingReference:t,namespace:c});m[I.name]=T,a.add(typeof T=="string"?I.name:T.name??I.name)}if(e.request!=null){r.setInState(ase.Request);let I=kQC({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(m).length>0?m:void 0,usedNames:a,namespace:c});l.request=I.value,i=[...i,...I.schemaIdsToExclude??[]],r.unsetInState(ase.Request)}else{let I=r.inlinePathParameters&&Object.keys(d).length>0,T=Object.keys(s).length>0,z=Object.keys(m).length>0,U={};(I||T||z)&&(U.name=e.requestNameOverride??e.generatedRequestName),I&&(U["path-parameters"]=d),T&&(U["query-parameters"]=s),z&&(U.headers=m),Object.keys(U).length>0&&(l.request=U)}if(e.response!=null&&e.response._visit({json:I=>{let T=UD({schema:I.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:I.description??void 0,type:x6(T)},I.statusCode!=null&&(l.response["status-code"]=I.statusCode),I.responseProperty!=null&&(l.response.property=I.responseProperty)},streamingJson:I=>{let T=UD({schema:I.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:I.description??void 0,type:x6(T),format:"json"}},streamingSse:I=>{let T=UD({schema:I.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:I.description??void 0,type:x6(T),format:"sse"}},file:I=>{l.response={docs:I.description??void 0,type:"file","status-code":I.statusCode}},bytes:I=>{l.response={docs:I.description??void 0,type:"bytes","status-code":I.statusCode}},streamingText:I=>{l["response-stream"]={docs:I.description??void 0,type:"text"}},text:I=>{l.response={docs:I.description??void 0,type:"text","status-code":I.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let I=r.getDefaultServerName(),T=e.servers[0];T==null?I!=null&&(l.url=I):l.url=T.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=wJ(e.availability)),Object.entries(e.errors).forEach(([I,T])=>{let z=T.generatedName,U=nw.of(rF);r.builder.enableUniqueErrorsPerEndpoint&&(z=`${e.generatedRequestName}${T.generatedName}`,T.schema!=null&&(T.schema.type!=="reference"&&T.schema.type!=="oneOf"?T.schema.generatedName=`${e.generatedRequestName}${T.schema.generatedName}`:T.schema.type==="oneOf"&&(T.schema.value.generatedName=`${e.generatedRequestName}${T.schema.value.generatedName}`)));let R={"status-code":parseInt(I)},V=JWy({location:OHy,namespaceOverride:c});if(T.schema!=null){let Y=UD({schema:T.schema,context:r,fileContainingReference:V,declarationFile:V,namespace:c,declarationDepth:0});R.type=x6(Y),R.docs=T.description}r.builder.addError(V,{name:z,schema:r.isErrorUnknownSchema(parseInt(I))?{...R,type:"unknown"}:R}),l.errors==null&&(l.errors=[]);let $=r.builder.addImport({file:t,fileToImport:V});l.errors.push($!=null?`${$}.${z}`:z),R.type!=null&&T.examples?.forEach(Y=>{let te={value:lwe(Y.example),name:Y.name,docs:Y.description};r.builder.addErrorExample(V,{name:z,example:te})})}),e.examples.length>0&&(l.examples=XQC({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=ZQC({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[tBf,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function XQC({endpointExamples:e,context:t}){return e.map(r=>{try{return vHy({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function ZQC({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:tc(e)}}function kQC({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:u,namespace:l}){if(n.type==="json"||n.type==="formUrlEncoded"){let m=n.schema.type==="reference"?n.schema.schema:void 0,A=n.schema.type==="reference"?r.getSchema(n.schema.schema,l):n.schema;if(A?.type!=="object"||m!=null){let z=UD({schema:n.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),U={schemaIdsToExclude:[],value:{body:z}},R=Object.keys(o??{}).length>0,V=Object.keys(c??{}).length>0,$=Object.keys(s??{}).length>0;return R&&(U.value["path-parameters"]=o),V&&(U.value["query-parameters"]=c),$&&(U.value.headers=s),(R||V||$)&&(U.value.name=i??a),n.contentType!=null&&(U.value["content-type"]=n.contentType),n.description!=null&&(U.value.docs=n.description),U}let P=Object.fromEntries(A.properties.filter(z=>z.readonly==null?!0:!(gHy(e.method)&&z.readonly)).map(z=>{let U=UD({schema:z.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),R=z.nameOverride??z.key,V=wJ(z.availability);if(!u.has(R)&&z.audiences.length<=0)return u.add(R),z.nameOverride!=null?[z.key,{type:x6(U),docs:fno(U),name:z.nameOverride,availability:V}]:[z.key,V?{...typeof U=="string"?{type:U}:U,availability:V}:U];let $={type:x6(U),docs:fno(U)};return u.has(R)&&($.name=z.generatedName),z.audiences.length>0&&($.audiences=z.audiences),V!=null&&($.availability=V),u.add(R),[z.key,$]})),C=A.allOf.map(z=>{let U=UD({schema:Wj.reference(z),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return x6(U)}).filter(z=>z!=="unknown"),I={properties:P};C.length>0&&(I.extends=C),n.additionalProperties&&(I["extra-properties"]=!0);let T={name:i??A.nameOverride??A.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:I};return n.contentType!=null&&(T["content-type"]=n.contentType),n.description!=null&&(T.docs=n.description),{schemaIdsToExclude:m!=null?[m]:[],value:T}}else if(n.type==="octetStream"){let m={body:"bytes","content-type":n.contentType??C7.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(m.name=i??a),n.description!=null&&(m.docs=n.description),{schemaIdsToExclude:[],value:m}}else if(n.type==="multipart"){let m=Object.fromEntries(n.properties.map(A=>{if(A.schema.type==="file"){let P=A.schema.isArray?"list<file>":"file";if(P=A.schema.isOptional?`optional<${P}>`:P,A.description!=null||A.contentType!=null){let C={type:P};if(A.description!=null&&(C.docs=A.description),A.contentType!=null){let I=A.contentType.split(",")[0];C["content-type"]=I}return[A.key,C]}return[A.key,P]}else{let P=UD({schema:A.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(A.contentType||A.exploded||A.encoding){let C=typeof P=="string"?{type:P}:P;A.contentType!=null&&(C["content-type"]=A.contentType),A.encoding==="form"?C.style="form":A.encoding==="json"?C.style="json":A.exploded&&(C.style="exploded"),P=C}return[A.key,P]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:m},"content-type":C7.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else tc(n)}function eLC({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:tc(t)}}function tLC({location:e,namespaceOverride:t}){return t!=null?{...e,file:TX(nw.of(t),e.file)}:e}function rLC(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:nw.of(`${EA(r)}.yml`),endpointId:e.summary!=null?EA(e.summary):EA(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:nw.of(rF),endpointId:EA(e.summary)}:{file:nw.of(rF),endpointId:EA(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:nw.of(rF),endpointId:n};let i=wXo(r),a=wXo(n);if(Due(i,a))return{file:nw.of("__package__.yml"),endpointId:r};let o=aLC({operationId:n,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let d=0;d<i.length;++d){let s=i[d];if(s!=null&&s===a[d])c.push(s);else{let u=EA(r);return{file:nw.of(`${u}.yml`),endpointId:n,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:nw.of(EA(c.join("_"))+".yml"),endpointId:EA(a.slice(c.length).join("_")),tag:r}}function jXo(e){let t=e.tags[0];if(e.sdkName!=null){let r=zIf({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:nw.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return tLC({namespaceOverride:e.namespace,location:rLC(e)})}function wXo(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=ept(t),t}var nLC=new RegExp("[^a-zA-Z0-9{}]+"),iLC=new RegExp("[{}]","g");function aLC({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(nLC).join("_").replaceAll(iLC,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:nw.of(EA(t)+".yml"),endpointId:EA(e.slice(0,-1*a.length)),tag:t}}function AHy(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:o,file:c,tag:d}=jXo(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let A=e.ir.groups;for(let P of a.sdkName.groupName){let C=typeof P=="string"?P:P.name,I=A[C];if(I==null)break;if(I.summary!=null||I.description!=null){u=A[C];break}}}let l=d==null?void 0:n.tagsById[d];e.setInState(ase.Endpoint),e.setEndpointMethod(a.method);let m=mHy({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(ase.Endpoint),i=[...i,...m.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:m.value,source:a.source!=null?HAi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function PHy(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?GAi(r.groupName):void 0,i=UD({schema:Wj.primitive(r),context:e,fileContainingReference:nw.of(rF),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:x6(i),docs:r.description??void 0}})}}function wHy(e){for(let t of e.ir.webhooks){let r=sLC({webhook:t,context:e});if(r==null)continue;let n=CFs(t.sdkName,t.namespace),i={};for(let o of t.headers)i[o.name]=uVr({header:o,context:e,fileContainingReference:r.file,namespace:n});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:UD({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:lwe(o.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function oLC({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:TX(nw.of(t),e.file)}:e}function uLC({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:nw.of(rF),endpointId:n};let i=wXo(r),a=wXo(n);if(Due(i,a))return{file:nw.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<i.length;++c){let d=i[c];if(d!=null&&d===a[c])o.push(d);else{let s=EA(r);return{file:nw.of(`${s}.yml`),endpointId:n,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:nw.of(EA(o.join("_"))+".yml"),endpointId:EA(a.slice(o.length).join("_")),tag:r}}function sLC({webhook:e,context:t}){return e.sdkName!=null?{file:GWy({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:oLC({namespaceOverride:e.namespace,location:uLC({webhook:e,context:t})})}var cLC=nw.of(rF);function EHy(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return jHy({namespace:e.namespace,groupName:e.groupName});case"oneOf":return jHy({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return cLC;default:tc(e)}}function jHy({namespace:e,groupName:t}){return e!=null&&t!=null?B2i([{type:"namespace",name:e},...t]):e!=null?B2i([{type:"namespace",name:e}]):B2i(t)}var tBf="external",OHy=nw.of(rF);function SHy({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let o=EHy(a),c=kWy({schema:a,context:n,declarationFile:o,namespace:r,declarationDepth:0});if(Ezi(c.schema)){let d=x6(c.schema);if(d===(c.name??i)||d===`optional<${c.name??i}>`||d===`nullable<${c.name??i}>`||d===`optional<nullable<${c.name??i}>>`)continue}n.builder.addType(o,{name:c.name??i,schema:c.schema})}}function DHy(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),lHy(e),fHy(e),dHy(e),iHy(e),PHy(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(tBf);let t=AHy(e),r=t.sdkGroups;e.setInState(ase.Webhook),wHy(e),e.unsetInState(ase.Webhook),e.setInState(ase.Channel);for(let i of Object.values(e.ir.channels)){let a=B2i(i.groupName);sHy({channel:i,context:e,declarationFile:a})}e.unsetInState(ase.Channel);let n=lLC({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});SHy({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))SHy({schemas:a,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function lLC({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(a=>Object.keys(a))]),i=new Set(t);for(let a of n)r.includes(a)||i.add(a);return Array.from(i)}var EXo=class{context;constructor(t){this.context=t}};var MFs=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[o,c]of Object.entries(n.files)){let d=i!=null?nw.of(`${i}${"/"}${o}`):nw.of(o);t[d]=c}let a=Object.keys(n.directories).sort();for(let o of a){let c=i!=null?`${i}${"/"}${o}`:o,d=n.directories[o];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[nw.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 Ela=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new MFs,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:a}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),n!=null&&(o.service["base-path"]=n),i!=null&&(o.service["display-name"]=i),a!=null&&(o.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return yLr(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"]))CHy(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(CHy(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??EA((_pt(r)+"/"+vaa(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===nw.of($k))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=fas(_pt(xGa.of(`/${t}`)),xGa.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=fas(_pt(xGa.of(`/${t}`)),xGa.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===nw.of($k))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 a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.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 a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>Due(c,n))??!1)||a.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=i),a.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=TX(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}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,a])=>[i,{...a,path:TX(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,o])=>[a,{...o,path:TX(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===rF?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 CHy(e){return e?.header!=null}var IFs=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=o,this.globalHeaderOverrides=a,this.detectGlobalHeaders=n?.detectGlobalHeaders??!0,this.objectQueryParameters=n?.objectQueryParameters??!1,this.respectReadonlySchemas=n?.respectReadonlySchemas??!1,this.respectNullableSchemas=n?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=n?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=n?.inlinePathParameters??!1,this.useBytesForBinaryResponse=n?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=n?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=n?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=n?.enableUniqueErrorsPerEndpoint??!1,this.wrapReferencesToNullableInOptional=n?.wrapReferencesToNullableInOptional??!0,this.coerceOptionalSchemasToNullable=n?.coerceOptionalSchemasToNullable??!0,this.builder=new Ela(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,u]of Object.entries(d.errors)){let l=parseInt(s),m=c[l];m==null&&u.schema!=null?c[l]=u.schema:m!=null&&u.schema!=null&&$xe(m,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(ase.Channel,ase.Endpoint,ase.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:tc(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:tc(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))}};function rBf(e){let t=new IFs(e);return DHy(t)}var BFs=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:n,absoluteFilePath:i}){let a=rBf({taskContext:t,ir:r,options:hXo({overrides:{...n,respectReadonlySchemas:n?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:n?.respectNullableSchemas??this.args.respectNullableSchemas,wrapReferencesToNullableInOptional:n?.wrapReferencesToNullableInOptional??this.args.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:n?.coerceOptionalSchemasToNullable??this.args.coerceOptionalSchemasToNullable,onlyIncludeReferencedSchemas:n?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:n?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:n?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:n?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:n?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:n?.auth!=null?{auth:n.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:i??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Lg.dump(a.rootApiFile)},namedDefinitionFiles:{...pg(a.definitionFiles,o=>({absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Lg.dump(o),contents:o})),[nw.of(rF)]:{absoluteFilepath:i??this.args.absoluteFilePath,rawContents:Lg.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var SXo=class extends fqr{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;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.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.resolveAliases=t.resolveAliases,this.converter=new BFs(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:n},i){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:n},i);return this.converter.convert({context:t,ir:a,settings:i,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new Qnt({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var Rbe={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 dno={of(e){return e}};var MHy={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},nBf={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:MHy,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Ab={SOURCE:dno.of("source"),SDK_NAMESPACE:dno.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:dno.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:dno.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:dno.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated"};var EV={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,wrapReferencesToNullableInOptional:!0,coerceOptionalSchemasToNullable:!0};function iyt({options:e,overrides:t}){return{disableExamples:t?.disableExamples??EV.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??EV.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??EV.useTitlesAsName,audiences:t?.audiences??e?.audiences??EV.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??EV.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??EV.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??EV.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??EV.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??EV.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??EV.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??EV.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??EV.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??EV.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??EV.objectQueryParameters,filter:t?.filter??e?.filter??EV.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??EV.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??EV.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??EV.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??EV.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??EV.typeDatesAsStrings,preserveSingleSchemaOneOf:t?.preserveSingleSchemaOneOf??e?.preserveSingleSchemaOneOf??EV.preserveSingleSchemaOneOf,inlineAllOfSchemas:t?.inlineAllOfSchemas??e?.inlineAllOfSchemas??EV.inlineAllOfSchemas,resolveAliases:t?.resolveAliases??e?.resolveAliases??EV.resolveAliases,groupMultiApiEnvironments:t?.groupMultiApiEnvironments??e?.groupMultiApiEnvironments??EV.groupMultiApiEnvironments,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??EV.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??EV.coerceOptionalSchemasToNullable}}var IHy={naming:"v1"};function Hy(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function DXo(e,t,r,n,i=[]){try{let a=Hy(e,t);if(a!=null)return r.parse(a)}catch{let o=ept(i).join(" -> ");n.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function Sla(e){let t=Hy(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 BHy({schema:e,logger:t}){return Hy(e,Ab.ENCODING)??void 0}function THy(e){return Hy(e,Ab.FERN_ENUM)}function qHy({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let o=Hy(n,Ab.SDK_NAMESPACE),c=Hy(n,Ab.SDK_GROUP_NAME),d=Hy(n,Ab.TYPE_DEFINITION);if(d!=null)return CXo({fernType:d,nameOverride:e,generatedName:t,title:r,description:i,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function CXo({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c}){return cee({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.base64({example:void 0})});case"BOOLEAN":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.boolean({default:void 0,example:void 0})});case"DATE":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.date({example:void 0})});case"DATE_TIME":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.datetime({example:void 0})});case"FLOAT":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.float({example:void 0})});case"DOUBLE":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.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 mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.uint({default:void 0,example:void 0})});case"INTEGER":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.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 mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.uint64({default:void 0,example:void 0})});case"LONG":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return mh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,schema:z0.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:tc(d.v1)}},unknown:()=>mh.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,namespace:o,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?mh.map({nameOverride:t,generatedName:r,title:n,key:d,value:s,description:i,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?mh.array({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?mh.optional({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?mh.nullable({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:d=>d!=null?mh.array({nameOverride:t,generatedName:r,title:n,value:d,description:i,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>mh.literal({nameOverride:t,generatedName:r,title:n,value:d._visit({string:s=>jV.string(s),boolean:s=>jV.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,namespace:o,groupName:c}),named:d=>mh.reference({schema:d,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:o,groupName:c,source:swe.openapi({file:"<memory>"})})}})}function RHy(e){let t=Hy(e,Ab.SOURCE);if(t!=null)return t.endsWith(".proto")?swe.protobuf({file:t}):swe.openapi({file:t})}function Dla(e){if(e!=null&&typeof e=="boolean")return e}function $g(e){return e?.$ref!=null}function NHy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:m,encoding:A,source:P}){return i===void 0&&(i=s.options.additionalPropertiesDefaultsTo),iBf({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:z0.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"||MXo(i,s.options)?mh.unknown({...fLC(i),generatedName:`${t}Value`}):FHy(pS(i,!1,s.options.optionalAdditionalProperties?d:!1,s,[...n,"Value"],P,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:m,encoding:A})}function FHy(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=FHy(e.value);break;case"oneOf":e.value.inline=!0;break;default:tc(e)}return e}function iBf({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:d,namespace:s,groupName:u,example:l,encoding:m}){let A=mh.map({nameOverride:e,generatedName:t,title:r,description:c,availability:d,key:n,value:i,namespace:s,groupName:u,encoding:m,example:l,inline:void 0});return o&&(A=mh.nullable({nameOverride:e,generatedName:t,title:r,value:A,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),a&&(A=mh.optional({nameOverride:e,generatedName:t,title:r,value:A,description:c,availability:d,namespace:s,groupName:u,inline:void 0})),A}function MXo(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!($g(e)||"type"in e&&e.type!=null||"oneOf"in e&&e.oneOf!=null||"anyOf"in e&&e.anyOf!=null||"allOf"in e&&e.allOf!=null||"enum"in e&&e.enum!=null)}function fLC(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"||$g(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function xHy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:d,context:s,namespace:u,groupName:l,example:m,source:A}){let P=i==null?mh.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):pS(i,!1,!1,s,[...n,"Item"],A,u);return dLC({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:P,wrapAsOptional:c,wrapAsNullable:d,description:a,availability:o,example:m})}function dLC({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,example:u}){let l=mh.array({nameOverride:e,generatedName:t,title:r,value:n,description:o,availability:c,namespace:d,groupName:s,example:u,inline:void 0});return a&&(l=mh.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(l=mh.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),l}function fwe(e){switch(Hy(e,Ab.AVAILABILITY)){case"deprecated":return Nde.Deprecated;case"beta":return Nde.Beta;case"generally-available":return Nde.GenerallyAvailable;default:break}if(!$g(e)&&e.deprecated)return Nde.Deprecated}function aBf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminator:u,context:l,namespace:m,groupName:A,encoding:P,source:C}){let I=u.propertyName,T=Object.fromEntries(Object.entries(u.mapping??{}).map(([U,R])=>{let V=KAi({$ref:R},!1,!1,l,[R],P,C,m);return l.markReferencedByDiscriminatedUnion({$ref:R},I,1),[U,V]})),z=Object.entries(i).filter(([U])=>U!==I).map(([U,R])=>{let V=c!=null&&c.includes(U),[$,re]=l.options.coerceOptionalSchemasToNullable?[!1,!V]:[!V,!1],Y=pS(R,$,re,l,[...n,U],C,m);return{key:U,schema:Y}});return zHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:z,description:a,availability:o,discriminant:I,subtypes:T,namespace:m,groupName:A,source:C})}function oBf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:o,required:c,wrapAsOptional:d,wrapAsNullable:s,discriminant:u,variants:l,context:m,namespace:A,groupName:P,encoding:C,source:I}){let T=Object.fromEntries(Object.entries(l).map(([U,R])=>{if($g(R)){let V=KAi(R,!1,!1,m,[R.$ref],C,I,A);return m.markReferencedByDiscriminatedUnion(R,u,1),[U,V]}else{let V=pno(R,!1,!1,m,[...n,U],C,I,A,new Set([u]));return[U,V]}})),z=Object.entries(i).filter(([U])=>U!==u).map(([U,R])=>{let V=c!=null&&c.includes(U),[$,re]=m.options.coerceOptionalSchemasToNullable?[!1,!V]:[!V,!1],Y=pS(R,$,re,m,[...n,U],I,A);return{key:U,schema:Y}});return zHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:d,wrapAsNullable:s,properties:z,description:a,availability:o,discriminant:u,subtypes:T,namespace:A,groupName:P,source:I})}function zHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:a,description:o,availability:c,discriminant:d,subtypes:s,namespace:u,groupName:l,source:m}){let A=mh.oneOf(Unt.discriminated({description:o,availability:c,discriminantProperty:d,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:m,inline:void 0}));return i&&(A=mh.nullable({nameOverride:e,generatedName:t,title:r,value:A,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),n&&(A=mh.optional({nameOverride:e,generatedName:t,title:r,value:A,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),A}function QHy(e){if(e.proto!=null)return Iro.protobuf({typeName:e.proto.type})}function q2i({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:o,description:c,availability:d,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:m,context:A,source:P,inline:C}){let I=_LC(i??[]),T=new Set(a),z=Array.from(T).map((R,V)=>{let $=n?.[R],re=I[V],Y=sno.test(R),te=$?.name??re,ne=Y?R:cno(R);return te!=null&&!sno.test(te)&&(A?.logger.warn(`Enum name override ${te} is not a valid name. Falling back on ${ne}.`),te=void 0),{nameOverride:te,generatedName:ne,value:R,description:$?.description,availability:d,casing:{snake:$?.casing?.snake??void 0,pascal:$?.casing?.pascal??void 0,screamingSnake:$?.casing?.screamingSnake??void 0,camel:$?.casing?.camel??void 0}}}),U=o!=null?z.find(R=>R.value===o):void 0;return pLC({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:z,_default:U,description:c,availability:d,namespace:l,groupName:m,source:P,inline:C})}function pLC({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:n,title:i,values:a,_default:o,description:c,availability:d,namespace:s,groupName:u,source:l,inline:m}){let A=mh.enum({nameOverride:r,generatedName:n,title:i,values:a,description:c,availability:d,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:m});return t&&(A=mh.nullable({nameOverride:r,generatedName:n,title:i,value:A,description:c,availability:d,namespace:s,groupName:u,inline:m})),e&&(A=mh.optional({nameOverride:r,generatedName:n,title:i,value:A,description:c,availability:d,namespace:s,groupName:u,inline:m})),A}function _LC(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 LHy({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:m,wrapAsNullable:A,example:P,namespace:C,groupName:I}){return n==="int64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint32"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I})}function hLC(e){return typeof e=="string"?jV.string(e):typeof e=="boolean"?jV.boolean(e):jV.string(`${e}`)}function UHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,value:a,description:o,availability:c,namespace:d,groupName:s}){let u=mh.literal({nameOverride:e,generatedName:t,title:r,value:hLC(a),description:o,availability:c,namespace:d,groupName:s});return i&&(u=mh.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),n&&(u=mh.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),u}function uBf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:u,availability:l,wrapAsOptional:m,wrapAsNullable:A,example:P,namespace:C,groupName:I}){return n==null||n==="double"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.double({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="float"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="int32"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int({default:i,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="int64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.int64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint32"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="uint64"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.uint64({default:i,example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):n==="time-delta"?ose({nameOverride:e,generatedName:t,title:r,primitive:z0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I}):ose({nameOverride:e,generatedName:t,title:r,primitive:z0.float({example:P}),wrapAsOptional:m,wrapAsNullable:A,description:u,availability:l,namespace:C,groupName:I})}var yLC={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},vLC={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}}},bLC={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}}},gLC={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},mLC={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},OLC={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},ALC={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},PLC={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function IXo(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[yLC,vLC,bLC,gLC,mLC,OLC,ALC,PLC],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==i.join(""));return r}function Eie(e,t){let n=e.map(i=>/^[^a-zA-Z0-9]+$/.test(i)?i:GU(EA(i))).join("");return/^\d/.test(n)?OXo(n)??n:n}function VHy(e){let t=e.join("_");return EA(t)}function I4(e){switch(e.type){case"object":return Wj.object({allOf:e.allOf,properties:e.properties.map(t=>jLC(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return Wj.array({description:e.description,availability:e.availability,value:I4(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Wj.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 Wj.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 Wj.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:I4(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Wj.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:I4(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Wj.primitive({description:e.description,availability:e.availability,schema:WHy(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Wj.map({description:e.description,availability:e.availability,key:Wj.primitive({description:e.key.description,availability:e.key.availability,schema:WHy(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:I4(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return Wj.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 Wj.oneOf(wLC(e.value));case"unknown":return Wj.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:tc(e)}}function wLC(e){switch(e.type){case"discriminated":return rVr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:I4(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,I4(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return rVr.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>I4(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:tc(e)}}function WHy(e){switch(e.type){case"string":return lq.string(e);case"base64":return lq.base64();case"boolean":return lq.boolean(e);case"date":return lq.date();case"datetime":return lq.datetime();case"double":return lq.double(e);case"float":return lq.float();case"int":return lq.int(e);case"int64":return lq.int64(e);case"uint":return lq.uint();case"uint64":return lq.uint64();default:tc(e)}}function jLC(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:I4(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function TFs(e,t){return $xe(I4(e),I4(t))}function HHy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:o,wrapAsOptional:c,wrapAsNullable:d,allOf:s,context:u,propertiesToExclude:l,namespace:m,groupName:A,fullExamples:P,additionalProperties:C,availability:I,source:T}){let z=[...o??[]],U={...i},R=[],V=[];for(let ne of s)if(!u.options.inlineAllOfSchemas&&$g(ne)){let Oe=u.resolveSchemaReference(ne);if(Oe.discriminator!=null&&Oe.discriminator.mapping!=null)continue;if(Oe.oneOf!=null||Oe.anyOf!=null){let ve=Oe.oneOf??Oe.anyOf;if(ve!=null){for(let be of ve){let Ie=$g(be)?u.resolveSchemaReference(be):be,Be=pS(Ie,!1,!1,u.DUMMY,n,T,m);Be.type==="object"&&R.push(...Be.properties.map(Se=>Se.schema.type!=="optional"&&Se.schema.type!=="nullable"?{...Se,schema:mh.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Se.schema,description:void 0,availability:Se.availability,namespace:void 0,groupName:void 0,inline:void 0})}:Se))}continue}}let ge=R2i(ne);if(ge==null)continue;V.push({schemaId:ge,convertedSchema:sBf(ne,[ge],T,u.options.preserveSchemaIds),properties:GHy({schema:ne,context:u,breadcrumbs:n,source:T,namespace:m})}),u.markSchemaAsReferencedByNonRequest(ge)}else if($g(ne)){let Oe=u.resolveSchemaReference(ne),ge=pS(Oe,!1,!1,u,n,T,m);ge.type==="object"&&R.push(...ge.properties)}else{let Oe=ne.required??[];R=R.map(ve=>(ve.schema.type==="optional"||ve.schema.type==="nullable")&&Oe.includes(ve.key)?{...ve,schema:ve.schema.value}:ve);let ge=pS(ne,!1,!1,u,n,T,m);ge.type==="object"&&R.push(...ge.properties)}let $={};for(let ne of V)for(let[Oe,ge]of Object.entries(ne.properties)){let ve=$[Oe];ve!=null?(ve.schemaIds.push(ne.schemaId),ve.schemas.some(Ie=>TFs(Ie,ge))||ve.schemas.push(ge)):$[Oe]={schemaIds:[ne.schemaId],schemas:[ge]}}let re=[];for(let[ne,Oe]of Object.entries($))Oe.schemaIds.length>1&&re.push({propertyKey:ne,allOfSchemaIds:Oe.schemaIds,conflictingTypeSignatures:Oe.schemas.length>1});let Y=Object.fromEntries(Object.entries(U).filter(([ne,Oe])=>!(!$g(Oe)&&Oe.type==="null"))),te=Object.entries(Y).map(([ne,Oe])=>{let ge=Hy(Oe,Ab.AUDIENCES)??[],ve=fwe(Oe),be=$g(Oe)?!1:Oe.readOnly,Ie=$g(Oe)?!1:Oe.writeOnly,Se=!(z.includes(ne)&&!be),St=Hy(Oe,Ab.FERN_PROPERTY_NAME),yt=[...n,ne],Re=VHy(yt),De=pS(Oe,Se,!1,u,yt,T,m),Lt={};for(let Xe of V){let Yt=Xe.properties[ne];Yt!=null&&!TFs(De,Yt)?Lt[Xe.schemaId]={differentSchema:!0}:Yt!=null&&(Lt[Xe.schemaId]={differentSchema:!1})}return{key:ne,schema:De,nameOverride:St,audiences:ge,conflict:Lt,generatedName:Re,availability:ve,readonly:be,writeonly:Ie}});return te.push(...R.map(ne=>{let Oe=ne.conflict;for(let ge of V){let ve=ge.properties[ne.key];ve!=null&&!TFs(ne.schema,ve)?Oe[ge.schemaId]={differentSchema:!0}:ve!=null&&(Oe[ge.schemaId]={differentSchema:!1})}return{...ne,conflict:Oe}})),ELC({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:d,properties:te.filter(ne=>!l.has(ne.key)),description:a,allOf:V.map(ne=>ne.convertedSchema),allOfPropertyConflicts:re,namespace:m,groupName:A,fullExamples:P,additionalProperties:C,availability:I,source:T,context:u})}function ELC({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,properties:a,description:o,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:m,availability:A,source:P,context:C}){let I=mh.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:d,namespace:s,groupName:u,fullExamples:l,additionalProperties:MXo(m,C.options),availability:A,source:P,inline:void 0});return i&&(I=mh.nullable({nameOverride:e,generatedName:t,title:r,value:I,description:o,availability:A,namespace:s,groupName:u,inline:void 0})),n&&(I=mh.optional({nameOverride:e,generatedName:t,title:r,value:I,description:o,availability:A,namespace:s,groupName:u,inline:void 0})),I}function GHy({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[o,c]=$g(e)?[t.resolveSchemaReference(e),IXo(e.$ref)]:[e,r];for(let d of o.allOf??[])a={...a,...GHy({schema:d,context:t,breadcrumbs:c,source:n,namespace:i})};for(let[d,s]of Object.entries(o.properties??{})){let u=pS(s,!1,!1,t,[...c,d],n,i);a[d]=u}return a}function N2i({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:d,subtypes:s,namespace:u,groupName:l,encoding:m,source:A,subtypePrefixOverrides:P}){let C=CLC({schemas:s}),I=s.flatMap((z,U)=>{if(!$g(z)&&z.enum!=null&&d.options.coerceEnumsToLiterals&&z.type==="string")return z.enum.map(V=>mh.literal({nameOverride:void 0,generatedName:Eie([t,V],d.options.preserveSchemaIds),title:void 0,value:jV.string(String(V)),namespace:u,groupName:void 0,description:void 0,availability:V.availability}));let R=C[U];if(P!=null){let V=P[U];V!=null&&"name"in V&&(R=V.name)}return[pS(z,!1,!1,d,[...n,R??`${U}`],A,u)]}),T=SLC(I);return DLC({uniqueSubtypes:T,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:i,availability:a,namespace:u,groupName:l,context:d,encoding:m,source:A})}function SLC(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r],i=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(n!=null&&o!=null&&$xe(n,o)){i=!0;break}}n!=null&&!i&&t.push(n)}return t}function DLC({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,namespace:d,groupName:s,context:u,encoding:l,source:m}){if(Object.entries(e).every(([P,C])=>C.type==="literal")){let P={},C=[];return Object.entries(e).forEach(([I,T])=>{T.type==="literal"&&T.value.type==="string"&&(C.push(T.value.value),T.description!=null&&(P[T.value.value]={description:T.description}))}),q2i({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,fernEnum:P,enumVarNames:void 0,enumValues:C,_default:void 0,namespace:d,groupName:s,context:u,source:m,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let P=e[0];return a&&(P=mh.nullable({nameOverride:t,generatedName:r,title:n,value:P,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),i&&(P=mh.optional({nameOverride:t,generatedName:r,title:n,value:P,description:o,availability:c,namespace:d,groupName:s,inline:void 0})),P}return JHy({nameOverride:t,generatedName:r,title:n,wrapAsOptional:i,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:d,groupName:s,encoding:l,source:m})}function cBf({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:d,groupName:s,discriminator:u,encoding:l,source:m}){let A=Object.entries(u.mapping??{}).map(([I,T],z)=>{let U={$ref:T},R=KAi(U,!1,!1,c,[T],l,m,d);return c.markSchemaWithDiscriminantValue(U,u.propertyName,I),R.type==="object"&&(R.properties={[u.propertyName]:mh.literal({nameOverride:void 0,generatedName:Eie([t,I],c.options.preserveSchemaIds),title:void 0,value:jV.string(I),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...R.properties.filter(V=>V.key!==u.propertyName)}),R}),P=[];for(let I=0;I<A.length;++I){let T=A[I],z=!1;for(let U=I+1;U<A.length;++U){let R=A[U];if(T!=null&&R!=null&&$xe(T,R)){z=!0;break}}T!=null&&!z&&P.push(T)}if(Object.entries(P).every(([I,T])=>T.type==="literal")){let I={},T=[];return Object.entries(P).forEach(([z,U])=>{U.type==="literal"&&U.value.type==="string"&&(T.push(U.value.value),U.description!=null&&(I[U.value.value]={description:U.description}))}),q2i({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:n,availability:i,fernEnum:I,enumVarNames:void 0,enumValues:T,_default:void 0,namespace:d,groupName:s,context:c,source:m,inline:void 0})}return P.length===1&&P[0]!=null&&!c.options.preserveSingleSchemaOneOf?P[0]:JHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:n,availability:i,subtypes:P,namespace:d,groupName:s,encoding:l,source:m})}function CLC({schemas:e}){let t={},r=0;for(let a of e){if(!$g(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let o=Object.keys(a.properties),c={},d=o;for(let[s,u]of Object.entries(t)){let l=nts(u,o);d=nts(d,u),c[s]=l}c[r]=d,t=c}}r++}let n=[],i=0;for(let a of e){let o=t[i];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null){n.push(c[0]),++i;continue}}$g(a)?n.push(I2i(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(I2i(i)??`${i}`),++i}return n}function JHy({nameOverride:e,generatedName:t,title:r,wrapAsOptional:n,wrapAsNullable:i,description:a,availability:o,subtypes:c,namespace:d,groupName:s,encoding:u,source:l}){let m=mh.oneOf(Unt.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:d,groupName:s,encoding:u,source:l,inline:void 0}));return i&&(m=mh.nullable({nameOverride:e,generatedName:t,title:r,value:m,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),n&&(m=mh.optional({nameOverride:e,generatedName:t,title:r,value:m,description:a,availability:o,namespace:d,groupName:s,inline:void 0})),m}function _no(e){if(e.default!=null&&typeof e.default=="string")return e.default}function qFs({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=Sla(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function KHy({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=Sla(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function sVr({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=Sla(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function $Hy({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=Sla(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var Cla="#/components/schemas/";function ZHy(e,t){let r=$g(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"string":case"integer":return!0;case"array":return ZHy(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 MLC(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:ZHy(t,r):!1}function pS(e,t,r,n,i,a,o,c=!1,d=new Set,s){let u=RHy(e)??a,l=xLC({schema:e,logger:n.logger});if($g(e)){let m=R2i(e);return m!=null?MLC(m,e,n)?pno(n.resolveSchemaReference(e),t,r,n,IXo(e.$ref),l,u,o,d,c,s):(c?n.markSchemaAsReferencedByRequest(m):n.markSchemaAsReferencedByNonRequest(m),KAi(e,t,r,n,i,l,u,o)):pno(n.resolveSchemaReference(e),t,r,n,IXo(e.$ref),l,u,o,d,c,s)}return pno(e,t,r,n,i,l,u,o,d,c,s)}function KAi(e,t,r,n,i,a,o,c){let d=e.$ref.includes("properties")?pno(n.resolveSchemaReference(e),t,r,n,i,a,o,c,new Set):mh.reference(sBf(e,i,o,n.options.preserveSchemaIds));if(r===!1){let s=n.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(d=mh.nullable({title:void 0,nameOverride:void 0,generatedName:Eie(i,n.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(d=mh.optional({title:void 0,nameOverride:void 0,generatedName:Eie(i,n.options.preserveSchemaIds),value:d,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),d}function ILC(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function pno(e,t,r,n,i,a,o,c,d=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Hy(e,Ab.TYPE_NAME)??(n.options.useTitlesAsName?ILC(e.title):void 0),m=Hy(e,Ab.SDK_GROUP_NAME)??Hy(e,Rbe.TAGS)?.[0],A=(typeof m=="string"?[m]:m)??[];A=n.resolveGroupName(A);let P=Eie(i,n.options.preserveSchemaIds),C=e.title,I=e.description,T=fwe(e),z=[];e.example!=null&&z.push({name:void 0,value:e.example,description:void 0});let U=Hy(e,Rbe.EXAMPLES);U!=null&&Object.keys(U).length>0&&z.push(...Object.entries(U).map(([$,re])=>({name:re?.summary??$,value:re.value,description:re.description})));let R=Sla(e);R!=null&&Object.keys(R).length>0&&z.push(...R.map($=>({name:void 0,value:$,description:void 0})));let V=qHy({schema:e,description:I,title:C,nameOverride:l,generatedName:P,availability:T});if(V!=null){let $=V;return r&&($=mh.nullable({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:$})),t&&($=mh.optional({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:$})),$}try{if(Array.isArray(e.type)){let Y=e.type.indexOf("null"),te=Y!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&te)e.type.splice(Y,1),e.type=e.type[0],e.nullable=!0;else if(te&&(e.type.splice(Y,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let ne=new Set([...e.oneOf,...e.type]);e.oneOf=[...ne]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(te=>te!==null),!FFs(e.enum))return ose({nameOverride:l,generatedName:P,title:C,primitive:z0.string({default:_no(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:sVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A,wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T});let Y=THy(e);return e.enum.length===1&&e.enum[0]!=null&&Y==null?UHy({nameOverride:l,generatedName:P,title:C,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:I,availability:T,namespace:c,groupName:A}):q2i({nameOverride:l,generatedName:P,title:C,fernEnum:Y,enumVarNames:Hy(e,[Rbe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:A,context:n,source:o,inline:void 0})}if(FFs(e.type)&&e.type.length>1){let Y=e.type.includes("null"),te=e.type.filter(ne=>ne!=="null").map(ne=>({type:ne,nullable:Y}));return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:te,namespace:c,groupName:A,encoding:a,source:o})}if(e.type==="boolean"){let Y=Hy(e,Ab.BOOLEAN_LITERAL);return Y!=null?YHy({nameOverride:l,generatedName:P,title:C,literal:jV.boolean(Y),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A}):ose({nameOverride:l,generatedName:P,title:C,primitive:z0.boolean({default:BLC(e.default),example:KHy({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A})}if(e.type==="number")return uBf({nameOverride:l,generatedName:P,title:C,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Dla(e.exclusiveMinimum),exclusiveMaximum:Dla(e.exclusiveMaximum),multipleOf:e.multipleOf,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:qFs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="integer")return LHy({nameOverride:l,generatedName:P,title:C,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Dla(e.exclusiveMinimum),exclusiveMaximum:Dla(e.exclusiveMaximum),multipleOf:e.multipleOf,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:qFs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="float")return uBf({nameOverride:l,generatedName:P,title:C,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Dla(e.exclusiveMinimum),exclusiveMaximum:Dla(e.exclusiveMaximum),multipleOf:e.multipleOf,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,example:qFs({schema:e,logger:n.logger,fallback:u}),namespace:c,groupName:A});if(e.type==="string"){if(e.format==="date-time")return ose({nameOverride:l,generatedName:P,title:C,primitive:z0.datetime({example:sVr({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A});if(e.format==="date"&&n.options.typeDatesAsStrings===!1)return ose({nameOverride:l,generatedName:P,title:C,primitive:z0.date({example:sVr({schema:e,logger:n.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A});if(e.format==="json-string"){let te=mh.unknown({nameOverride:l,generatedName:P,title:C,description:I,availability:T,namespace:c,groupName:A,example:void 0});return r&&(te=mh.nullable({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:te})),t&&(te=mh.optional({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:te})),te}let Y=eGy(e,"const");return Y!=null?YHy({nameOverride:l,generatedName:P,title:C,literal:jV.string(Y),wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T,namespace:c,groupName:A}):ose({nameOverride:l,generatedName:P,title:C,primitive:z0.string({default:_no(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:sVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A,wrapAsOptional:t,wrapAsNullable:r,description:I,availability:T})}if(e.type==="array")return xHy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,item:e.items,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,example:$Hy({schema:e,logger:n.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&RFs(e))return NHy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,additionalProperties:e.additionalProperties,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Hy(e,Ab.IS_DISCRIMINATED)===!1)return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf,namespace:c,groupName:A,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return n.options.discriminatedUnionV2?cBf({nameOverride:l,generatedName:P,title:C,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,discriminator:e.discriminator,encoding:a,source:o}):aBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let Y=Hy(e,Ab.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return n.options.discriminatedUnionV2||Y?cBf({nameOverride:l,generatedName:P,title:C,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,discriminator:e.discriminator,encoding:a,source:o}):aBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:n,namespace:c,groupName:A,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(n.options.preserveSingleSchemaOneOf)return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,context:n,subtypes:e.oneOf.filter(ne=>$g(ne)||ne.type!=="null"),encoding:a,namespace:c,groupName:A,source:o});let te=pS(e.oneOf[0],t,r,n,i,o,c,s);return hno(te,I,c,A)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let ge=e.oneOf[0],ve=e.oneOf[1];if(!$g(ge)&&ge.type==="null")return pS(ve,!1,!0,n,i,o,c);if(!$g(ve)&&ve.type==="null")return pS(ge,!1,!0,n,i,o,c)}let te=RLC({schemas:e.oneOf});if(te!=null)return q2i({nameOverride:l,generatedName:P,title:C,fernEnum:void 0,enumVarNames:void 0,enumValues:te,_default:e.default,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:A,context:n,source:o,inline:void 0});let ne=XHy({schemas:e.oneOf,context:n});if(ne!=null&&!n.options.discriminatedUnionV2&&!Y)return oBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},required:e.required,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,discriminant:ne.discriminant,variants:ne.schemas,context:n,namespace:c,groupName:A,encoding:a,source:o});let Oe=e.oneOf.filter(ge=>!$g(ge)&&ge.type==="null").length>0;return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r||Oe,context:n,subtypes:e.oneOf.filter(ge=>$g(ge)||ge.type!=="null"),encoding:a,namespace:c,groupName:A,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let ne=pS(e.anyOf[0],t,r,n,i,o,c,s);return hno(ne,I,c,A)}if(e.anyOf.length===2){let[ne,Oe]=e.anyOf;if(ne!=null&&Oe!=null){if(!$g(ne)&&ne.type==="null"){let ge=pS(Oe,!1,!0,n,i,o,c);return hno(ge,I,c,A)}else if(!$g(Oe)&&Oe.type==="null"){let ge=pS(ne,!1,!0,n,i,o,c);return hno(ge,I,c,A)}}}let Y=XHy({schemas:e.anyOf,context:n});if(Y!=null&&!n.options.discriminatedUnionV2)return oBf({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},required:e.required,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,discriminant:Y.discriminant,variants:Y.schemas,context:n,namespace:c,groupName:A,encoding:a,source:o});let te=e.anyOf.filter(ne=>!$g(ne)&&ne.type==="null").length>0;return N2i({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r||te,context:n,subtypes:e.anyOf.filter(ne=>$g(ne)||ne.type!=="null"),encoding:a,namespace:c,groupName:A,source:o})}if(e.allOf!=null||e.properties!=null){let Y=[];for(let ne of e.allOf??[])($g(ne)||Object.keys(ne).length>0)&&Y.push(ne);if((e.properties==null||RFs(e))&&Y.length===1&&Y[0]!=null){let ne=pS(Y[0],t,r,n,i,o,c,s);return hno(ne,I,c,A)}let te=Y.filter(ne=>{let Oe=NFs(ne);return Oe||n.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(ne)}`),Oe});if((e.properties==null||RFs(e))&&te.length===1&&te[0]!=null){let ne=pS(te[0],t,r,n,i,o,c,s);return hno(ne,I,c,A)}return HHy({nameOverride:l,generatedName:P,title:C,breadcrumbs:i,properties:e.properties??{},description:I,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:te,context:n,propertiesToExclude:d,namespace:c,groupName:A,fullExamples:z,additionalProperties:e.additionalProperties,availability:T,encoding:a,source:o})}if(e.type==="object"&&TLC(e)&&qLC(e)&&RFs(e))return iBf({nameOverride:l,generatedName:P,title:C,description:I,availability:T,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${P}Key`,title:void 0,description:void 0,availability:void 0,schema:z0.string({default:_no(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:sVr({schema:e,logger:n.logger,fallback:u})}),namespace:c,groupName:A},valueSchema:mh.unknown({nameOverride:void 0,generatedName:`${P}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:A}),namespace:c,groupName:A,encoding:a,example:e.example});e.type!=null&&n.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${i.join("->")}. Coercing to unknown.`);let $=e.example??e.default,re=mh.unknown({nameOverride:l,generatedName:P,title:C,description:I,availability:T,namespace:c,groupName:A,example:$});return r&&(re=mh.nullable({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:re})),t&&(re=mh.optional({availability:T,namespace:c,groupName:A,description:I,generatedName:P,inline:void 0,nameOverride:l,title:C,value:re})),re}catch($){return n.logger.debug(`Error converting schema: ${$.message}
2409
2409
  Location: ${i.join("-> ")}`),mh.unknown({nameOverride:l,generatedName:P,title:C,description:I,availability:T,namespace:c,groupName:A,example:void 0})}}function BLC(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 R2i(e){if(e.$ref.startsWith(Cla))return e.$ref.replace(Cla,"")}function sBf(e,t,r,n){let i=Hy(e,Ab.TYPE_NAME),a=Eie(t,n),o=e.description,c=fwe(e),d=R2i(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return Wj.reference({generatedName:a,nameOverride:i,title:void 0,schema:d,description:o??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function TLC(e){return e.oneOf==null||e.oneOf.length===0}function qLC(e){return e.allOf==null||e.allOf.length===0}function RFs(e){return e.properties==null||M7(e.properties)===0}function FFs(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function hno(e,t,r,n){return e.type==="reference"?mh.reference({...e,description:t,availability:e.availability,namespace:r,groupName:n}):e.type==="optional"?mh.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0}):e.type==="nullable"?mh.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:n,inline:void 0}):e}function NFs(e){return $g(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>NFs(t)):e.oneOf!=null?e.oneOf.every(t=>NFs(t)):e.anyOf!=null?e.anyOf.every(t=>NFs(t)):!1}function YHy({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:a,availability:o,nameOverride:c,generatedName:d,title:s}){let u=mh.literal({nameOverride:c,generatedName:d,title:s,value:e,namespace:n,groupName:i,description:a,availability:o});return r&&(u=mh.nullable({nameOverride:c,generatedName:d,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),t&&(u=mh.optional({nameOverride:c,generatedName:d,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),u}function ose({primitive:e,wrapAsOptional:t,wrapAsNullable:r,namespace:n,groupName:i,description:a,availability:o,generatedName:c,nameOverride:d,title:s}){i=typeof i=="string"?[i]:i;let u=mh.primitive({nameOverride:d,generatedName:c,title:s,schema:e,description:a,availability:o,namespace:n,groupName:i});return r&&(u=mh.nullable({nameOverride:d,generatedName:c,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),t&&(u=mh.optional({nameOverride:d,generatedName:c,title:s,value:u,namespace:n,groupName:i,description:a,availability:o,inline:void 0})),u}function RLC({schemas:e}){let t=new Set;for(let r of e){if($g(r))return;if(r.enum!=null&&FFs(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function XHy({schemas:e,context:t}){let r={};for(let n of e){let i=kHy({schema:n,context:t});for(let[a,o]of Object.entries(i)){let c=r[a];c!=null?c[o]=n:r[a]={[o]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function kHy({schema:e,context:t}){let r=$g(e)?t.resolveSchemaReference(e):e;return NLC({schema:r,context:t})}function NLC({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=kHy({schema:n,context:t});for(let[a,o]of Object.entries(i??{}))r[a]=o}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=$g(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&FFs(a.enum)&&FLC(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let o=eGy(a,"const");a.type==="string"&&o!=null&&(r[n]=o),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function FLC(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 eGy(e,t){let r=e[t];if(r!=null)return r}function xLC({schema:e,logger:t}){let r=BHy({schema:e,logger:t});if(r!=null)return QHy(r)}var yno=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(Cla))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let n=t.$ref.substring(Cla.length).split("/"),i=this.document.components;if(i==null||i.schemas==null)throw new Error("Document does not have components.schemas.");let[a,o,c]=n;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=i.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if($g(d)&&(d=this.resolveSchemaReference(d)),o==="properties"&&c!=null){let s=d.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);$g(s)?d=this.resolveSchemaReference(s):d=s}return d}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){}};var xFs=class extends yno{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),a=n.messages[i];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function vno(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let n={};for(let[i,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[i]=a;continue}let o=a.namespace;n[o]??={},n[o][i]=a;continue}case"oneOf":case"unknown":r[i]=a;continue;default:tc(a)}return{rootSchemas:r,namespacedSchemas:n}}function F2i(e){if(typeof e=="string")return fS.primitive(AO.string(e));if(typeof e=="number")return Number.isInteger(e)?fS.primitive(AO.int(e)):fS.primitive(AO.double(e));if(typeof e=="boolean")return fS.primitive(AO.boolean(e));if(Array.isArray(e)){let t=e.map(r=>F2i(r));return t.length===0?void 0:fS.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=F2i(n);i!=null&&t.push({key:AO.string(r),value:i})}return fS.map(t)}}function BXo(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function tGy(e){if(e!=null&&Array.isArray(e))return e}var x2i=class{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:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:o,skipReadonly:c}){switch(n.type){case"enum":return typeof r=="string"&&rGy({schema:n,value:r})?fS.enum(r):n.values[0]!=null?fS.enum(n.values[0]?.value):void 0;case"literal":return fS.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,o)&&this.exceedsMaxDepth(i,o))return fS.null({});let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:o,skipReadonly:c});return d??fS.null({})}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,o)&&(o.ignoreOptionals||this.exceedsMaxDepth(i,o))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:o,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:o});return fS.primitive(d)}case"reference":{let d=this.schemas[n.schema];if(d!=null&&!a.has(n.schema)){a.add(n.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(n.schema),u=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:i,options:o,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(n.schema),u}return}case"oneOf":switch(n.value.type){case"discriminated":{let d={},s={},u={},l=BXo(r),m=l?.[n.value.discriminantProperty],A=n.value.schemas[m],P=[],C=this.getDiscriminatedUnionVariantSchema(n.value,l);C!=null&&P.push(C),P.push(...Object.entries(n.value.schemas));for(let I of P)if(m!=null&&A!=null&&A.type==="object"){s=this.getAllProperties(A),u=this.getAllRequiredProperties(A),d[n.value.discriminantProperty]=fS.primitive(AO.string(m));break}else{let T=this.buildExampleHelper({exampleId:t,schema:I[1],example:void 0,visitedSchemaIds:a,depth:i,options:o,skipReadonly:c});if(T!=null){this.mergeExampleWith(T,d),d[n.value.discriminantProperty]=fS.primitive(AO.string(I[0]));break}}for(let I of n.value.commonProperties){s[I.key]={schema:I.schema,readonly:!1};let T=this.getResolvedSchema(I.schema);T.type!=="optional"&&T.type!=="nullable"&&(u[I.key]=I.schema)}for(let[I,T]of Object.entries(s)){let z=I in u;if(z&&l?.[I]!=null){let U=this.buildExampleHelper({schema:T.schema,exampleId:t,example:l[I],visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});if(U!=null)d[I]=U;else return}else{let U=this.buildExampleHelper({exampleId:t,schema:T.schema,example:l?.[I],visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});if(U!=null)d[I]=U;else if(z)return}}return fS.oneOf(A2i.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:i,options:o,skipReadonly:c});break}}return;case"unknown":if(r!=null){let d=F2i(r);if(d!=null)return fS.unknown(d)}return o.ignoreOptionals||this.exceedsMaxDepth(i,o)?void 0:o.isParameter?fS.primitive(AO.string(o.name??"string")):fS.map([{key:AO.string("key"),value:fS.primitive(AO.string("value"))}]);case"array":{let d=tGy(r),s=[];if(d!=null&&d.length>0)for(let u of d){let l=this.buildExampleHelper({exampleId:t,example:u,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else if(n.example!=null&&n.example.length>0)for(let u of n.example){let l=this.buildExampleHelper({exampleId:t,example:u,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else{let u=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:o,skipReadonly:c});u!=null&&s.push(u)}return fS.array(s)}case"map":{let d=BXo(r??n.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[m,A]of Object.entries(d)){let P=this.buildExampleFromPrimitive({schema:n.key.schema,example:m,options:o}),C=this.buildExampleHelper({exampleId:t,example:A,schema:n.value,visitedSchemaIds:a,depth:i+1,options:o,skipReadonly:c});C!=null&&l.push({key:P,value:C})}return fS.map(l)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return fS.map([{key:AO.string("key"),value:fS.unknown(fS.primitive(AO.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...o,name:"key"}}),u=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...o,name:"value"},skipReadonly:c});return u!=null&&u.type!=="null"?fS.map([{key:s,value:u}]):fS.map([])}case"object":{let d={},s=n.fullExamples?.find(A=>A.name===t)??n.fullExamples?.find(A=>A.name==null)??n.fullExamples?.[0],u=BXo(r)??(s!=null?BXo(s.value):{})??{},l=this.getAllProperties(n),m=this.getAllRequiredProperties(n);for(let[A,P]of Object.entries(l)){if(c&&P.readonly||P.schema._visit({optional:z=>typeof z.availability=="string"&&z.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 C=A in m,I=Object.keys(u).includes(A),T=this.buildExampleHelper({schema:P.schema,exampleId:t,example:u[A],visitedSchemaIds:a,depth:i+1,options:{...o,name:A},skipReadonly:c});if(C&&T!=null)d[A]=T;else{if(C)return;(I&&T!=null||!o.ignoreOptionals&&T!=null)&&(d[A]=T)}}if(n.additionalProperties){for(let[A,P]of Object.entries(u))if(!(A in d)){let C=this.buildExampleHelper({schema:mh.unknown({example:P,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:P,visitedSchemaIds:a,depth:i+1,options:{...o,name:A},skipReadonly:c});C!=null&&(d[A]=C)}}return fS.object({properties:d})}default:tc(n)}}mergeExampleWith(t,r){t._visit({array:Hc,enum:Hc,literal:Hc,map:n=>{for(let i of n){let a=i.key;a.type==="string"&&(r[a.value]=i.value)}},object:n=>{for(let[i,a]of Object.entries(n.properties))r[i]=a},oneOf:n=>{if(n.type==="discriminated")for(let[i,a]of Object.entries(n.value))r[i]=a;else this.mergeExampleWith(n.value,r)},primitive:Hc,unknown:Hc,null:Hc,_other:Hc})}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){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,o)=>o.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return rGy({schema:t,value:r})?5:0;case"object":{if(!Lq(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,o]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(o.schema,r[a])):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(!Lq(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,a)=>a-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",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 o of t.properties)if(this.hasExample(o.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let o=this.hasExample(a,r,n,i);return n.delete(t.schema),o}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));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 a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...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 a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?AO.string(t):r.example!=null?AO.string(r.example):AO.string(n.name??_P.STRING);case"base64":return t!=null&&typeof t=="string"?AO.base64(t):r.example!=null?AO.base64(r.example):AO.base64(_P.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?AO.boolean(t):r.example!=null?AO.boolean(r.example):AO.boolean(_P.BOOLEAN);case"date":return t!=null&&typeof t=="string"?AO.date(t):r.example!=null?AO.date(r.example):AO.date(_P.DATE);case"datetime":return t!=null&&typeof t=="string"?AO.datetime(t):r.example!=null?AO.datetime(r.example):AO.datetime(_P.DATE_TIME);case"double":return t!=null&&typeof t=="number"?AO.double(t):r.example!=null?AO.double(r.example):AO.double(_P.DOUBLE);case"float":return t!=null&&typeof t=="number"?AO.float(t):r.example!=null?AO.float(r.example):AO.float(_P.FLOAT);case"int":return t!=null&&typeof t=="number"?AO.int(t):r.example!=null?AO.int(r.example):AO.int(_P.INT);case"int64":return t!=null&&typeof t=="number"?AO.int64(t):r.example!=null?AO.int64(r.example):AO.int64(_P.INT64);case"uint":return t!=null&&typeof t=="number"?AO.uint(t):r.example!=null?AO.uint(r.example):AO.uint(_P.UINT);case"uint64":return t!=null&&typeof t=="number"?AO.uint64(t):r.example!=null?AO.uint64(r.example):AO.uint64(_P.UINT64);default:tc(r)}}};function rGy({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function hqr(e){switch(e.type){case"object":return mh.object({allOf:e.allOf,properties:e.properties.map(t=>QLC(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return mh.array({description:e.description,availability:e.availability,value:hqr(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return mh.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 mh.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 mh.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:hqr(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return mh.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:hqr(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return mh.primitive({description:e.description,availability:e.availability,schema:nGy(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return mh.map({description:e.description,availability:e.availability,key:mh.primitive({description:e.key.description,availability:e.key.availability,schema:nGy(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:hqr(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return mh.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 mh.oneOf(zLC(e.value));case"unknown":return mh.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:tc(e)}}function zLC(e){switch(e.type){case"discriminated":return Unt.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:hqr(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,hqr(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return Unt.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>hqr(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:tc(e)}}function nGy(e){switch(e.type){case"string":return z0.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return z0.base64({example:void 0});case"boolean":return z0.boolean({default:e.default,example:void 0});case"date":return z0.date({example:void 0});case"datetime":return z0.datetime({example:void 0});case"double":return z0.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 z0.float({example:void 0});case"int":return z0.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 z0.int64({default:e.default,example:void 0});case"uint":return z0.uint({default:void 0,example:void 0});case"uint64":return z0.uint64({default:void 0,example:void 0});default:tc(e)}}function QLC(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:hqr(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function zFs(e){return e.type!=="optional"&&e.type!=="nullable"}function lBf(e){return e==="POST"||e==="PUT"||e==="PATCH"}function TXo(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 QFs=class{schemas;context;globalHeaders;exampleTypeFactory;logger;constructor(t,r,n){this.schemas=t,this.context=r,this.globalHeaders=n,this.schemas=t,this.exampleTypeFactory=new x2i(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=ULC(t.request),n=VLC(t.response);if(r?.type==="unsupported"||n?.type==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:lBf(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&i.push([void 0,m])}else for(let{name:m,value:A}of r.examples){let P=this.exampleTypeFactory.buildExample({skipReadonly:lBf(t.method),schema:r.schema,exampleId:m,example:A,options:{isParameter:!1,ignoreOptionals:!0}});P!=null&&i.push([m,P])}if(l&&i.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let m=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});m!=null&&(t.response?.type==="json"?a.push([void 0,tyt.withoutStreaming(m)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,tyt.withStreaming({sse:t.response?.type==="streamingSse",events:[m]})]))}else for(let{name:m,value:A}of n.examples){let P=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:m,example:A,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});P!=null&&(t.response?.type==="json"?a.push([m,tyt.withoutStreaming(P)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,tyt.withStreaming({sse:t.response?.type==="streamingSse",events:[P]})]))}if(l&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let o=[];for(let l of t.pathParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!yqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&o.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:A})}let c=[];for(let l of t.queryParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!yqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&c.push({name:l.name,value:A})}let d=[];for(let l of t.headers){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!yqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),m&&A==null)return[];A!=null&&d.push({name:l.name,value:A})}for(let l of this.globalHeaders){let m=l.schema!=null?hqr(l.schema):mh.primitive({nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,schema:z0.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})}),A=this.exampleTypeFactory.buildExample({schema:m,exampleId:void 0,example:void 0,options:{name:l.header,isParameter:!0,ignoreOptionals:!0}});if(A!=null&&!yqr(A)&&(this.logger.warn(`Expected a primitive example but got ${A.type} for global header ${l.header} for ${t.method.toUpperCase()} ${t.path}`),A=void 0),A==null)return[];A!=null&&d.push({name:l.header,value:A})}let s=[];t.request!=null&&t.response!=null?s=LLC(i,a):t.request!=null?s=i.map(([l,m])=>({id:l,request:m,response:void 0})):t.response!=null&&(s=a.map(([l,m])=>({id:l,request:void 0,response:m})));let u=t.examples.filter(l=>TXo(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let m=l.value["code-samples"];if(m!=null)return this.convertCodeSamples(m)}return}else return l.codeSamples}).filter(l=>Gw(l));return s.length===0?[eyt.full({name:void 0,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:void 0,response:void 0,codeSamples:u})]:s.map(({id:l,request:m,response:A})=>eyt.full({name:l,description:void 0,pathParameters:o,queryParameters:c,headers:d,request:m,response:A,codeSamples:u}))}convertCodeSamples(t){return t.map(r=>"language"in r?eVr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):eVr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?Fde.Csharp:r.sdk,code:r.code})).filter(Gw)}isSchemaRequired(t){return zFs(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function LLC(e,t){let r=[];if(e.length<=1){let[i,a]=e[0]??[];if(t.length===0)return r.push({id:i,request:a,response:void 0}),r;for(let[o,c]of t)r.push({id:o??i,request:a,response:c});return r}if(t.length<=1){let[i,a]=t[0]??[];if(t.length===0)return r.push({id:i,request:void 0,response:a}),r;for(let[o,c]of e)r.push({id:o??i,request:c,response:a});return r}let n=new Set;for(let[i,a]of e){let o=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(i==null){if(o==null)continue;r.push({id:void 0,request:a,response:o});continue}let c=!1;for(let d=0;d<t.length;d++){let[s,u]=t[d];s==null||n.has(d)||i===s&&(r.push({id:i,request:a,response:u}),s!=null&&n.add(d),c=!0)}!c&&o!=null&&r.push({id:i,request:a,response:o})}for(let i=0;i<t.length;i++){if(n.has(i))continue;let[a,o]=t[i],c=e.find(([d])=>d==null)?.[1]??e[0]?.[1];c!=null&&r.push({id:a,request:c,response:o})}return r}function ULC(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:WLC(e),examples:[]}:e.type==="json"||e.type==="formUrlEncoded"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function VLC(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function yqr(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return yqr(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return yqr(e.value.value);default:return!1}case"null":return!0;default:tc(e)}}function WLC(e){return mh.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:hqr(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(Gw),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var bno=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new x2i(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:n,source:i,namespace:a}){let o=[];for(let c of r){let d=[];for(let l of n.queryParameters){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.queryParameters?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!yqr(A)&&(A=void 0),!(m&&A==null)&&A!=null&&d.push({name:l.name,value:A})}let s=[];for(let l of n.headers){let m=this.isSchemaRequired(l.schema),A=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.headers?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});A!=null&&!yqr(A)&&(A=void 0),!(m&&A==null)&&A!=null&&s.push({name:l.name,value:A})}let u=[];for(let l of c.messages){let m=t.getExampleMessageReference(l),A=t.resolveMessageReference({$ref:m}),P=$g(A.payload)?t.resolveSchemaReference(A.payload):A.payload,C=this.exampleTypeFactory.buildExample({schema:pS(P,!1,!1,t,[l.messageId],i,a),exampleId:void 0,example:l.value,options:{isParameter:!1,ignoreOptionals:!0}});C!=null&&u.push({messageType:l.type,payload:C,description:void 0})}o.push({name:c.summary,queryParameters:d,headers:s,description:c.description,messages:u})}return o}buildWebsocketSessionExample({handshake:t,messages:r}){let n={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},i=[];for(let o of t.queryParameters){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!yqr(d)&&(d=void 0),c&&d==null)return;d!=null&&i.push({name:o.name,value:d})}let a=[];for(let o of t.headers){let c=this.isSchemaRequired(o.schema),d=this.exampleTypeFactory.buildExample({schema:o.schema,exampleId:void 0,example:void 0,options:{name:o.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!yqr(d)&&(d=void 0),c&&d==null)return;d!=null&&a.push({name:o.name,value:d})}for(let o of r){let c=this.exampleTypeFactory.buildExample({schema:o.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});c!=null&&n.messages.push({messageType:o.type,payload:c,description:void 0})}return n}isSchemaRequired(t){return zFs(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var tMe={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function LFs(e){return Hy(e,tMe.FERN_EXAMPLES)??[]}function UFs(e,t){return t.includes("://")?t:`${e}://${t}`}function VFs(e){return e.startsWith("/")?e:"/"+e}function oGy({context:e,breadcrumbs:t,source:r,asyncApiOptions:n,document:i}){let a={},o={};for(let[s,u]of Object.entries(i.components?.schemas??{})){let l=pS(u,!1,!1,e,[s],r,e.namespace);a[s]=l}let c=new bno(a,e),d={};for(let[s,u]of Object.entries(i.servers??{}))d[s]={name:s,url:UFs(u.protocol,u.url)};for(let[s,u]of Object.entries(i.channels??{})){let l=Hy(u,tMe.IGNORE);if(l!=null&&l){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let m=[];if(u.parameters!=null)for(let[T,z]of Object.entries(u.parameters??{}))m.push({name:T,description:z.description,parameterNameOverride:void 0,schema:z.schema!=null?pS(z.schema,!1,!1,e,t,r,e.namespace):mh.primitive({schema:z0.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:fwe(z),source:r});let A=[],P=[];if(u.bindings?.ws!=null){if(u.bindings.ws.headers!=null){let T=u.bindings.ws.headers.required??[];for(let[z,U]of Object.entries(u.bindings.ws.headers.properties??{})){if($g(U)){let re=e.resolveSchemaReference(U);A.push({name:z,schema:KAi(U,!1,!1,e,t,void 0,r,e.namespace),description:re.description,parameterNameOverride:void 0,env:void 0,availability:fwe(re),source:r});continue}let R=T.includes(z),[V,$]=e.options.coerceOptionalSchemasToNullable?[!1,!R]:[!R,!1];A.push({name:z,schema:pS(U,V,$,e,[...t,z],r,e.namespace),description:U.description,parameterNameOverride:void 0,env:void 0,availability:fwe(U),source:r})}}if(u.bindings.ws.query!=null){let T=u.bindings.ws.query.required??[];for(let[z,U]of Object.entries(u.bindings.ws.query.properties??{})){if($g(U)){let re=e.resolveSchemaReference(U);P.push({name:z,schema:KAi(U,!1,!1,e,t,void 0,r,e.namespace),description:re.description,parameterNameOverride:void 0,availability:fwe(re),source:r});continue}let R=T.includes(z),[V,$]=e.options.coerceOptionalSchemasToNullable?[!1,!R]:[!R,!1];P.push({name:z,schema:pS(U,V,$,e,[...t,z],r,e.namespace),description:U.description,parameterNameOverride:void 0,availability:fwe(U),source:r})}}}let C;u.publish!=null&&("oneOf"in u.publish.message?C=iGy({generatedName:u.publish.operationId??"PublishEvent",event:u.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:n}):C=aGy({action:"Publish",channelPath:s,message:u.publish.message,context:e,source:r}));let I;if(u.subscribe!=null&&("oneOf"in u.subscribe.message?I=iGy({generatedName:u.subscribe.operationId??"SubscribeEvent",event:u.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:n}):I=aGy({action:"Subscribe",channelPath:s,message:u.subscribe.message,context:e,source:r})),A.length>0||P.length>0||C!=null||I!=null){let T=LFs(u),z=[];if(T.length>0)z=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:T,handshake:{headers:A,queryParameters:P},source:r,namespace:e.namespace});else{let $=[];C!=null&&$.push({type:"publish",payload:C}),I!=null&&$.push({type:"subscribe",payload:I});let re=c.buildWebsocketSessionExample({handshake:{headers:A,queryParameters:P},messages:$});re!=null&&z.push(re)}let U=Hy(u,tMe.FERN_CHANNEL_ADDRESS),R=U??VFs(s),V=[];C!=null&&V.push({origin:"client",name:"publish",body:I4(C)}),I!=null&&V.push({origin:"server",name:"subscribe",body:I4(I)}),o[s]={audiences:Hy(u,Ab.AUDIENCES)??[],handshake:{headers:A.map($=>({...$,schema:I4($.schema),env:$.env})),queryParameters:P.map($=>({...$,schema:I4($.schema)})),pathParameters:m.map($=>({...$,parameterNameOverride:void 0,schema:I4($.schema)}))},groupName:e.resolveGroupName([Hy(u,tMe.FERN_SDK_GROUP_NAME)??s]),messages:V,servers:(u.servers?.map($=>d[$])??Object.values(d)).filter($=>$!=null&&$.name!=null).map($=>({...$,name:$.name})),summary:Hy(u,tMe.FERN_DISPLAY_NAME),path:R,description:u.description,examples:z,source:r}}}return{groupedSchemas:vno(e.namespace,a),channels:o??void 0,servers:Object.values(d).map(s=>({...s,name:s.name})),basePath:Hy(i,tMe.BASE_PATH)}}function iGy({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:o}){if("oneOf"in t.message&&t.message.oneOf!=null){let c=[],d=[];for(let s of t.message.oneOf){let u,l={type:"notFound"};if($g(s)){let m=r.resolveMessageReference(s);!$g(m.payload)&&o.naming==="v2"?(l=m.name?{type:"name",name:m.name}:l,u={...m.payload,title:m.name??m.payload.title,description:m.name??m.payload.description}):u=m.payload}else u=s;d.push(l),c.push(u)}return N2i({description:t.description??t.message.description,availability:fwe(t.message),subtypes:c,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsOptional:!1,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:o.naming==="v2"?d:[]})}}function aGy({action:e,channelPath:t,message:r,context:n,source:i}){if(r.payload!=null){let a=r.payload;return $g(r.payload)&&(a=n.resolveSchemaReference(r.payload)),pS(a,!1,!1,n,[t,e],i,n.namespace)}}var WFs=class extends yno{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveParameterReference(t){let r="#/components/parameters/";if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(r.length),i=this.document.components.parameters[n];if(i==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in i?this.resolveParameterReference(i):i}resolveMessageReference(t){let r="#/channels/",n="#/components/messages/";if(t.$ref.startsWith(r)){let c=t.$ref.split("/"),d=c[2],s=c[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let l=this.document.channels[d].messages?.[s];if(l==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in l?this.resolveMessageReference(l):{name:s,...l}}let i=this.document.components;if(!t.$ref.startsWith(n)||!i?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(n.length),o=i.messages[a];if(o==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...o}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var uGy="#/channels/",sGy="#/servers/",fBf="$message.";function lGy({context:e,breadcrumbs:t,source:r,asyncApiOptions:n,document:i}){let a={},o={},c={},d=[],s={};for(let[P,C]of Object.entries(i.components?.schemas??{}))a[P]=pS(C,!1,!1,e,[P],r,e.namespace);for(let[P,C]of Object.entries(i.channels??{}))if(o[P]||(o[P]={}),C.messages){for(let[I,T]of Object.entries(C.messages))if(e.isReferenceObject(T)||e.isMessageWithPayload(T))if(c[I]||(c[I]=[]),e.isReferenceObject(T)){let z=e.resolveMessageReference(T);c[I].push({channelId:P,payload:z.payload})}else c[I].push({channelId:P,payload:T.payload})}for(let[P,C]of Object.entries(c))if(C.length===1){let I=C[0],T=I.channelId;o[T]=o[T]||{},o[T][P]=pS(I.payload,!1,!1,e,[P],r,e.namespace)}else{d.push(P);for(let{channelId:I,payload:T}of C){let z=`${I}_${P}`;o[I]||(o[I]={}),o[I][z]=pS(T,!1,!1,e,[z],r,e.namespace)}}let u=Object.values(o).reduce((P,C)=>({...P,...C}),{}),l=new bno(u,e),m={};for(let[P,C]of Object.entries(i.servers??{}))m[P]={name:P,url:UFs(C.protocol,C.host)};let A={};for(let[P,C]of Object.entries(i.operations??{})){if(Hy(C,tMe.IGNORE))continue;let I=HLC(C);if(A[I]||(A[I]={subscribe:[],publish:[],__parsedMessages:[]}),C.action==="receive")A[I].subscribe.push(...C.messages);else if(C.action==="send")A[I].publish.push(...C.messages);else throw new Error(`Operation ${P} has an invalid action: ${C.action}`)}for(let[P,C]of Object.entries(A)){let I=[];I.push(...cGy({messages:C.subscribe,channelPath:P,origin:"server",messageSchemas:o[P]??{},duplicatedMessageIds:d,context:e})),I.push(...cGy({messages:C.publish,channelPath:P,origin:"client",messageSchemas:o[P]??{},duplicatedMessageIds:d,context:e})),A[P]!=null&&(A[P].__parsedMessages=I)}for(let[P,C]of Object.entries(i.channels??{})){if(Hy(C,tMe.IGNORE))continue;let I=[],T=[],z=[];if(C.parameters!=null)for(let[U,R]of Object.entries(C.parameters)){let V=e.isReferenceObject(R)?e.resolveParameterReference(R):R,{type:$,parameterKey:re}=V.location!=null?GLC(V.location):{type:C.address?.includes(`={${U}}`)?"query":"path",parameterKey:U},Y=Hy(V,tMe.FERN_PARAMETER_OPTIONAL),te=GU(EA(P))+GU(EA(U)),ne={...V,type:"string",title:te,example:V.examples?.[0],default:V.default,enum:V.enum,required:void 0},Oe=pS(ne,!1,!1,e,[re],r,e.namespace);Y&&(Oe=mh.optional({value:Oe,description:void 0,availability:void 0,generatedName:"",title:te,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let ge={name:re,description:V.description,parameterNameOverride:void 0,schema:Oe,variableReference:void 0,availability:fwe(R),source:r};$==="header"?I.push({...ge,env:void 0}):$==="path"?T.push(ge):($==="payload"||$==="query")&&z.push(ge)}if(I.length>0||z.length>0||A[P]!=null&&(A[P].publish!=null||A[P].subscribe!=null)){let U=LFs(C),R=A[P]?.__parsedMessages??[],V=[];if(U.length>0)V=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:U,handshake:{headers:I,queryParameters:z},source:r,namespace:e.namespace});else{let re=[],{examplePublishMessage:Y,exampleSubscribeMessage:te}=KLC({messages:R,messageSchemas:o[P]??{}});Y!=null&&re.push(Y),te!=null&&re.push(te);let ne=l.buildWebsocketSessionExample({handshake:{headers:I,queryParameters:z},messages:re});ne!=null&&V.push(ne)}let $=Hy(C,tMe.FERN_SDK_GROUP_NAME);s[P]={audiences:Hy(C,Ab.AUDIENCES)??[],handshake:{headers:I.map(re=>({...re,schema:I4(re.schema),env:re.env})),queryParameters:z.map(re=>({...re,schema:I4(re.schema)})),pathParameters:T.map(re=>({...re,parameterNameOverride:void 0,schema:I4(re.schema)}))},groupName:e.resolveGroupName(typeof $=="string"?[$]:$??[P]),messages:R,summary:Hy(C,tMe.FERN_DISPLAY_NAME),servers:(C.servers?.map(re=>JLC(m,re))??Object.values(m)).map(re=>({...re,name:re.name})),path:C.address?.split("?")[0]??VFs(P),description:C.description,examples:V,source:r}}}return{groupedSchemas:vno(e.namespace,a),channels:s,servers:Object.values(m).map(P=>({...P,name:P.name})),basePath:Hy(i,tMe.BASE_PATH)}}function HLC(e){if(!e.channel.$ref.startsWith(uGy))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(uGy.length)}function GLC(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(fBf))throw new Error(`Invalid location format: ${e}; expected ${fBf} prefix`);let n=t.substring(fBf.length);if(n!=="header"&&n!=="path"&&n!=="payload")throw new Error(`Invalid message type: ${n}. Must be one of: header, path, payload`);return{type:n,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function JLC(e,t){if(!t.$ref.startsWith(sGy))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(sGy.length),n=e[r];if(n==null)throw new Error(`Failed to find server with name ${r}`);return n}function cGy({messages:e,channelPath:t,origin:r,messageSchemas:n,duplicatedMessageIds:i,context:a}){let o=[];return e.forEach((c,d)=>{let u=a.resolveMessageReference(c).name;i.includes(u)&&(u=`${t}_${u}`);let l=n[u];l!=null&&o.push({origin:r,name:u??`${r}Message${d+1}`,body:I4(l)})}),o}function KLC({messages:e,messageSchemas:t}){let r=e.find(o=>o.origin==="client")?.name,n=e.find(o=>o.origin==="server")?.name,i=r!=null?t[r]:void 0,a=n!=null?t[n]:void 0;return{examplePublishMessage:i!=null&&r!=null?{type:r,payload:i}:void 0,exampleSubscribeMessage:a!=null&&n!=null?{type:n,payload:a}:void 0}}function fGy({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){let o=[];if(a!=null&&o.push(a),parseFloat(e.asyncapi)<3){let c=e;c.tags?.[0]!=null?o.push(c.tags[0].name):i.naming!=="v2"&&o.push("websocket");let d=new xFs({document:c,taskContext:t,options:r,namespace:a});return oGy({context:d,breadcrumbs:o,source:n,asyncApiOptions:i,document:c})}else{let c=e,d=new WFs({document:c,taskContext:t,options:r,namespace:a});return lGy({context:d,breadcrumbs:o,source:n,asyncApiOptions:i,document:c})}}function dGy(e){return Hy(e,Ab.ASYNC_CONFIG)}var pGy="$request.";function _Gy(e){let t=Hy(e,Ab.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:$LC(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function $LC(e){return e.startsWith(pGy)?e.slice(pGy.length):e}function hGy(e){let t=e;if(t.cursor!=null)return Lnt.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return Lnt.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return Lnt.custom({results:r.results})}throw new Error("Invalid pagination extension")}function yGy(e,t){let r=Hy(t,Ab.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=Hy(e,Ab.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:hGy(n)}return hGy(r)}}function vGy(e){let t=YLC(e),r={};return dBf({obj:t,occurrences:r,breadcrumbs:[]}),r}function dBf({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)dBf({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)dBf({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function YLC(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?qXo(r.get):void 0,put:r?.put!=null?qXo(r.put):void 0,post:r?.post!=null?qXo(r.post):void 0,patch:r?.patch!=null?qXo(r.patch):void 0,delete:r?.delete!=null?qXo(r.delete):void 0}]))}}function qXo(e){return{...e,requestBody:e.requestBody!=null?$g(e.requestBody)?e.requestBody:XLC(e.requestBody):void 0}}function XLC(e){let t,r;for(let n in e.content){let i=C7.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[C7.MULTIPART_FORM_DATA]:r}}:e}var HFs=class{endpoints;parser=new Roa;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let n=[];for(let i of r){let a=this.parser.tryParse(i);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${i}"; expected format "POST /users/get"`);continue}n.push(`${a.method} ${a.path}`)}return n}};var bGy="#/components/parameters/",gGy="#/components/responses/",mGy="#/components/examples/",OGy="#/components/requestBodies/",gno=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=vGy(t),this.options=i,this.source=a,this.filter=new HFs({context:r,options:i}),this.DUMMY=this.getDummy(),this.namespace=o}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown"};if(Array.isArray(n)){let a=parseInt(i,10);if(isNaN(a)||a<0||a>=n.length)return{"x-fern-type":"unknown"};n=n[a]}else n=n[i]}return n==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):($g(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(bGy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(bGy.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return $g(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(OGy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(OGy.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return $g(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(gGy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(gGy.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return $g(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(mGy))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(mGy.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return $g(n)?this.resolveExampleReference(n):n}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}};var Mla=class extends gno{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var ZLC=rl.object({lang:rl.string(),label:rl.optional(rl.string()),source:rl.string()}),pBf=rl.array(ZLC);var AGy={README_EXT:"x-readme"};function kLC(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Lq(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function PGy(e){let t=Hy(e,AGy.README_EXT);if(!Lq(t))return[];let r=t["code-samples"];if(!kLC(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function wGy(e,t,r){let i=(Hy(t,Ab.EXAMPLES)??[]).filter(s=>{let u=zX.serialization.ExampleEndpointCallSchema.parse(s);return u.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),u.ok}),a=DXo(t,Rbe.REDOCLY_CODE_SAMPLES_KEBAB,pBf,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],c=[...DXo(t,Rbe.REDOCLY_CODE_SAMPLES_CAMEL,pBf,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];c.length>0&&i.push({"code-samples":c.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=PGy(t);return d.length>0&&i.push({"code-samples":d}),i.map(eyt.unknown)}function jGy(e){let t=Hy(e,Ab.AVAILABILITY);if(t==="ga"||t==="generally-available")return Nde.GenerallyAvailable;if(t==="beta"||t==="pre-release")return Nde.Beta;if(t==="deprecated")return Nde.Deprecated;if(e.deprecated)return Nde.Deprecated}function EGy(e){let t=Hy(e,Ab.RETRIES);if(t!=null&&t.disabled===!0)return vRs.RetriesConfiguration.disabled(t.disabled)}function GFs(e,t){return{url:eUC({url:e.url,variables:e.variables??{}}),description:e.description,name:tUC(e,t),audiences:Hy(e,Ab.AUDIENCES)}}function eUC({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,encodeURIComponent(i));return e}function tUC(e,t){let r=Hy(e,[Ab.SERVER_NAME_V1,Ab.SERVER_NAME_V2]);if(r!=null)return r;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox";if(t?.groupMultiApiEnvironments&&e.description!=null&&e.description.trim()!==""){let n=e.description.toLowerCase();return n==="prd"?"Production":n==="sbx"?"Sandbox":n==="staging"||n==="stg"?"Staging":n==="development"||n==="dev"?"Development":e.description}}function SGy(e){return Hy(e,Ab.PARAMETER_NAME)}function DGy(e){return Hy(e,Ab.SDK_VARIABLE)}function JFs({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){let o={pathParameters:[],queryParameters:[],headers:[]};for(let c of r){let d=Hy(c,Ab.IGNORE);if(d!=null&&d){n.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=$g(c)?n.resolveParameterReference(c):c,u=s.required??!1,l=fwe(s),m=[...i,s.name],A=Eie(m,n.options.preserveSchemaIds),[P,C]=n.options.coerceOptionalSchemasToNullable?[!1,!u]:[!u,!1],I=s.schema!=null?pS(s.schema,P,C,n,m,a,n.namespace,!1,new Set,sVr({schema:s,logger:n.logger})):u?mh.primitive({nameOverride:void 0,generatedName:A,title:void 0,schema:z0.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:sVr({schema:s,logger:n.logger})}),description:void 0,availability:l,namespace:void 0,groupName:void 0}):mh.optional({nameOverride:void 0,generatedName:A,title:void 0,value:mh.primitive({nameOverride:void 0,generatedName:A,title:void 0,schema:z0.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:sVr({schema:s,logger:n.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:l,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!$g(s.schema)&&s.schema.default!=null){let z=s.schema.default;typeof z=="string"&&z.length>0&&(I=mh.literal({nameOverride:void 0,generatedName:A,title:void 0,value:jV.string(z),description:void 0,availability:l,namespace:void 0,groupName:void 0}))}let T={name:s.name,schema:I,description:s.description,parameterNameOverride:SGy(s),availability:l,source:a};s.in==="query"?o.queryParameters.push(T):s.in==="path"?o.pathParameters.push({...T,variableReference:DGy(s)}):s.in==="header"?!rUC.has(s.name.toLowerCase())&&!n.authHeaders.has(s.name)?o.headers.push({...T,env:void 0}):n.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return o}var rUC=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function CGy(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r,schema:i??{},examples:RXo(n,t)}}}function nUC(e){return e.includes("json")||e==="*/*"}function _Bf({content:e,context:t}){for(let[r,n]of Object.entries(e))if(KFs({mediaType:r,mediaTypeObject:n,context:t})!=null)return[r,n]}function KFs({mediaType:e,mediaTypeObject:t,context:r}){if(!nUC(e))return;let n=t.schema;return{contentType:e.includes("*")?void 0:e,schema:n??{},examples:RXo(t,r)}}function $Fs({content:e,context:t}){let r=_Bf({content:e,context:t});if(!r)return;let[n,i]=r;return KFs({mediaType:n,mediaTypeObject:i,context:t})}function MGy(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:RXo(n,t)}}}function RXo(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Hy(e,Rbe.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let o=$g(a)?t.resolveExampleReference(a):a;return{name:o.summary??i,value:o.value,description:o.description}})),r}function iUC({content:e,context:t}){for(let[r,n]of Object.entries(e))if(BGy({mediaType:r,mediaTypeObject:n,context:t}))return[r,n]}function BGy({mediaType:e,mediaTypeObject:t,context:r}){if(C7.parse(e)?.isURLEncoded())return{schema:t.schema,contentType:e,examples:RXo(t,r)}}function aUC({content:e}){for(let[t,r]of Object.entries(e))if(TGy({mediaType:t,mediaTypeObject:r}))return[t,r]}function TGy({mediaType:e,mediaTypeObject:t}){if(C7.parse(e)?.isMultipart())return{schema:t.schema,encoding:t.encoding}}function qGy({mediaType:e}){return C7.parse(e)?.isBinary()??!1}function oUC({content:e}){for(let[t,r]of Object.entries(e))if(qGy({mediaType:t}))return[t,r]}function uUC(e,t){let r=$g(e)?hBf(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!$g(i)&&i.type==="string"&&i.format==="binary")!=null}function XFs({content:e,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}){let c=oUC({content:e});if(c){let[m,A]=c;return cVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o})}let d=aUC({content:e}),s=_Bf({content:e,context:n}),u=sUC({json:s,multipart:d,document:r,visitor:{json:([m,A])=>cVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}),multipart:([m,A])=>cVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o}),neither:()=>{}}});if(u)return u;let l=iUC({content:e,context:n});if(l){let[m,A]=l;return cVr({mediaType:m,mediaTypeObject:A,description:t,document:r,context:n,requestBreadcrumbs:i,source:a,namespace:o})}}function sUC({json:e,multipart:t,document:r,visitor:n}){if(!e&&!t)return n.neither();let[,i]=e??[void 0,void 0],[,a]=t??[void 0,void 0];return!i?.schema&&!a?.schema?n.neither():i?.schema&&a?.schema?i.schema&&uUC(i.schema,r)?n.multipart(t):n.json(e):i?.schema?n.json(e):a?.schema?n.multipart(t):n.neither()}function cVr({mediaType:e,mediaTypeObject:t,description:r,document:n,context:i,requestBreadcrumbs:a,source:o,namespace:c}){let d=cUC({mediaTypeObject:t});if(qGy({mediaType:e}))return ZCe.octetStream({description:r,source:o,sdkMethodName:d,contentType:e});let s=TGy({mediaType:e,mediaTypeObject:t}),u=s?.schema,l=s?.encoding;if(u){let P=$g(u)?hBf(u,n):{id:void 0,schema:u},C=pS(P.schema,!1,!1,i,a,o,c,!1),I=[];if(C.type==="object")for(let T of C.properties){let{isFile:z,isOptional:U,isArray:R,description:V}=YFs({schema:T.schema});if(z){let $=IGy(T.key,l);I.push({key:T.key,schema:tVr.file({isOptional:U,isArray:R,description:V}),description:V,contentType:$,exploded:!1,encoding:$==null?i.options.defaultFormParameterEncoding:void 0})}else{let $=IGy(T.key,l);I.push({key:T.key,schema:tVr.json(T.schema),description:void 0,contentType:$,exploded:l?.[T.key]?.explode,encoding:$==null?i.options.defaultFormParameterEncoding:fUC($)})}}return ZCe.multipart({name:$g(u)&&i.getNumberOfOccurrencesForRef(u)===1?P.id:void 0,description:P.schema.description,properties:I,source:o,sdkMethodName:d})}let m=KFs({mediaType:e,mediaTypeObject:t,context:i});if(m){let P=pS(m.schema,!1,!1,i,a,o,c,!0);return ZCe.json({description:void 0,schema:P,contentType:m.contentType,fullExamples:m.examples,additionalProperties:!$g(m.schema)&&MXo(m.schema.additionalProperties,i.options),source:o,sdkMethodName:d})}let A=BGy({mediaType:e,mediaTypeObject:t,context:i});if(A!=null&&A.schema!=null){let P=pS(A.schema,!1,!1,i,a,o,c,!1);return ZCe.formUrlEncoded({schema:P,description:r,contentType:A.contentType,source:o,fullExamples:A.examples,additionalProperties:!1,sdkMethodName:d})}}function cUC({mediaTypeObject:e}){return Hy(e,Ab.SDK_METHOD_NAME)}var lUC={"application/json":"json"};function fUC(e){return e?lUC[e]:void 0}function hBf(e,t){if(!e.$ref.startsWith(Cla))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=R2i(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=t.components?.schemas?.[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return $g(n)?hBf(n,t):{id:r,schema:n}}function YFs({schema:e,isOptional:t,isArray:r,description:n}){return pUC(e)?YFs({schema:e.value,isOptional:!0,isArray:r,description:e.description}):_UC(e)?YFs({schema:e.value,isOptional:t,isArray:r,description:e.description}):hUC(e)?YFs({schema:e.value,isOptional:t,isArray:!0,description:e.description}):dUC(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:n??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function dUC(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function pUC(e){return e.type==="optional"}function _UC(e){return e.type==="nullable"}function hUC(e){return e.type==="array"}function IGy(e,t){return t?.[e]?.contentType}var yBf={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},RGy=new Set(Object.values(yBf));var yUC=["200","201","202","204"];function FGy({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:o}){if(t==null)return{value:void 0,errors:{}};let c=vUC({responses:t,context:r,source:o,namespace:r.namespace}),d=!1,s;for(let u of i!=null?[i]:yUC){let l=t[u];l!=null&&(d=!0,s==null&&(s=NGy({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:o,namespace:r.namespace,statusCode:typeof u=="string"?parseInt(u):u})))}if(s==null&&!d&&t.default!=null&&(s=NGy({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:o,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:c};case"streamingJson":case"streamingSse":return{value:s,errors:c};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:c};default:tc(s)}return{value:void 0,errors:c}}function NGy({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:o,statusCode:c}){let d=$g(r)?n.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([m,A])=>{if(A.schema==null)return!1;let P=$g(A.schema)?n.resolveSchemaReference(A.schema):A.schema;return P.type==="string"&&P.format==="binary"}))return n.options.useBytesForBinaryResponse&&t==null?QL.bytes({description:d.description,source:a,statusCode:c}):QL.file({description:d.description,source:a,statusCode:c});let s=CGy(d.content??{},n);if(s!=null&&t!=null)switch(t){case"json":return QL.streamingJson({statusCode:c,description:d.description,responseProperty:Hy(e.operation,Ab.RESPONSE_PROPERTY),fullExamples:s.examples,schema:pS(s.schema,!1,!1,n,i,a,o),source:a});case"sse":return QL.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:pS(s.schema,!1,!1,n,i,a,o),source:a,statusCode:c})}let u=$Fs({context:n,content:d.content??{}});if(u){if(t!=null)switch(t){case"json":return QL.streamingJson({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:pS(u.schema,!1,!1,n,i,a,o),source:a,statusCode:c});case"sse":return QL.streamingSse({description:d.description,responseProperty:void 0,fullExamples:u.examples,schema:pS(u.schema,!1,!1,n,i,a,o),source:a,statusCode:c})}return QL.json({description:d.description,schema:pS(u.schema,!1,!1,n,i,a,o),responseProperty:Hy(e.operation,Ab.RESPONSE_PROPERTY),fullExamples:u.examples,source:a,statusCode:c})}for(let[l,m]of Object.entries(d.content??{})){let A=C7.parse(l);if(A!=null){if(A.isOctetStream()||A.isPDF()||A.isAudio()||A.isImage()||A.isVideo()||A.isMultiPartMixed())return QL.file({description:d.description,source:a,statusCode:c});if(A.isPlainText()){let P=m.schema;if(P==null)return QL.text({description:d.description,source:a,statusCode:c});let C=$g(P)?n.resolveSchemaReference(P):P;return C.type==="string"&&C.format==="byte"?QL.file({description:d.description,source:a,statusCode:c}):QL.text({description:d.description,source:a,statusCode:c})}}}}function vUC({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,o]of Object.entries(e)){if(a==="default")continue;let c=parseInt(a);if(c<400||c>600)continue;let d=$g(o)?t.resolveResponseReference(o):o,s=MGy(d.content??{},t),u=yBf[c];if(u==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[c]={statusCode:c,nameOverride:void 0,generatedName:u,description:d.description,schema:pS(s?.schema??{},!1,!1,t,[u,"Body"],r,n),fullExamples:s?.examples,source:r}}return i}function $Ai({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:o,operation:c,path:d,method:s,baseBreadcrumbs:u}=e,l=Hy(c,Ab.IDEMPOTENT),m=Hy(c,[Ab.REQUEST_NAME_V1,Ab.REQUEST_NAME_V2]),A=[...u,"Request"],P=JFs({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:A,path:d,httpMethod:s,source:a}),C=/{([^}]+)}/g,I=[...d.matchAll(C)].map(te=>te[1]).filter(te=>te!==void 0);if(I.length>0){let te=new Map(P.pathParameters.map(ge=>[ge.name,ge])),ne=[],Oe=new Set;for(let ge of I){let ve=te.get(ge);Oe.add(ge),ve?ne.push(ve):ne.push({name:ge,variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:mh.primitive({schema:z0.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0})}for(let ge of P.pathParameters)Oe.has(ge.name)||ne.push(ge);P.pathParameters=ne}let T=(()=>{if(e.method==="GET")return[void 0];if(!c.requestBody)return[void 0];let te=$g(c.requestBody)?t.resolveRequestBodyReference(c.requestBody):c.requestBody,ne=Object.values(te.content).every(ge=>gUC({mediaTypeObject:ge})!=null),Oe=[];if(ne)return Oe.push(...Object.entries(te.content).map(([ge,ve])=>{let be=cVr({mediaType:ge,mediaTypeObject:ve,description:te.description,document:o,context:new Mla({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:A,source:a,namespace:t.namespace});return xGy({context:t,convertedParameters:P})&&be!=null&&(be.type==="json"||be.type==="formUrlEncoded")&&be.schema.type!=="object"&&c.requestBody!=null?be=cVr({mediaType:ge,mediaTypeObject:ve,description:te.description,document:o,context:t,requestBreadcrumbs:[...A,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(be=cVr({mediaType:ge,mediaTypeObject:ve,description:te.description,document:o,context:t,requestBreadcrumbs:[...A],source:a,namespace:t.namespace})),be}).filter(ge=>ge!=null)),Oe.length===0?[void 0]:Oe;{let ge=XFs({content:te.content,description:te.description,document:o,context:new Mla({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:A,source:a,namespace:t.namespace});return xGy({context:t,convertedParameters:P})&&ge!=null&&(ge.type==="json"||ge.type==="formUrlEncoded")&&ge.schema.type!=="object"&&c.requestBody!=null?ge=XFs({content:te.content,description:te.description,document:o,context:t,requestBreadcrumbs:[...A,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(ge=XFs({content:te.content,description:te.description,document:o,context:t,requestBreadcrumbs:[...A],source:a,namespace:t.namespace})),[ge]}})(),z=T.length>1,U=[...u,"Response"],R=FGy({operationContext:e,streamFormat:i,responses:c.responses,context:t,responseBreadcrumbs:U,responseStatusCode:r,source:a}),V=EGy(c),$=jGy(c),re=wGy(e,c,t),Y=Hy(c,Ab.SERVER_NAME_V2);return T.map(te=>({summary:c.summary,internal:Hy(c,Rbe.INTERNAL),idempotent:l,audiences:Hy(c,Ab.AUDIENCES)??[],operationId:c.operationId!=null&&n!=null?c.operationId+"_"+n:c.operationId,tags:t.resolveTagsToTagIds(c.tags),namespace:t.namespace,sdkName:mUC({operationContext:e,request:te}),pathParameters:P.pathParameters,queryParameters:P.queryParameters,headers:P.headers,requestNameOverride:m??void 0,generatedRequestName:Eie(z?bUC({breadcrumbs:A,request:te}):A,t.options.preserveSchemaIds),request:te,response:R.value,errors:R.errors,servers:Y!=null?[{name:Y,url:void 0,audiences:void 0}]:(c.servers??[]).map(ne=>GFs(ne,{groupMultiApiEnvironments:t.options.groupMultiApiEnvironments})),description:c.description,authed:AUC(c,o),security:OUC(c),availability:$,method:s,path:d,examples:re,pagination:e.pagination,source:a,retries:V}))}function bUC({breadcrumbs:e,request:t}){return t?[...e,t.type]:e}function gUC({mediaTypeObject:e}){return Hy(e,Ab.SDK_METHOD_NAME)}function mUC({operationContext:e,request:t}){return!t||!t.sdkMethodName?e.sdkMethodName:e.sdkMethodName?{groupName:[...e.sdkMethodName.groupName],methodName:t.sdkMethodName??e.sdkMethodName.methodName}:{groupName:[],methodName:t.sdkMethodName}}function OUC(e){return e.security??[]}function AUC(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function xGy({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function QGy({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:o}=e,c=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],u=zGy({context:t,headerToIgnore:c,parameters:a}),l=zGy({context:t,headerToIgnore:c,parameters:o}),m=$Ai({operationContext:{...e,pathItemParameters:u,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([P])=>parseInt(P)!==s))}},context:t,streamFormat:void 0,source:n}),A=$Ai({operationContext:{...e,pathItemParameters:u,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:n});return A.forEach(P=>{P.headers.push({name:c,schema:mh.literal({nameOverride:void 0,generatedName:Eie([c],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:jV.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n})}),{sync:m,async:A}}function zGy({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=$g(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var vBf="stream";function WGy({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:$Ai({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:[]};case"streamCondition":{let n=LGy({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(n?.schemaReference!=null){let s=R2i(n.schemaReference);s!=null&&t.excludeSchema(s)}let i=UGy({operation:e.operation,response:r.responseStream}),a=$Ai({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+vBf}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:n?.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,vBf]},context:t,streamFormat:r.format,suffix:vBf,source:t.source});a.forEach(s=>{s.examples=s.examples.filter(u=>VGy(u,t)!==!1)});let o=LGy({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),c=UGy({operation:e.operation,response:r.response}),d=$Ai({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:o?.requestBody,responses:c}},context:t,source:t.source});return d.forEach(s=>{s.examples=s.examples.filter(u=>VGy(u,t)!==!0)}),{streaming:a,nonStreaming:d}}default:tc(r)}}function LGy({context:e,operation:t,streamingExtension:r,isStreaming:n}){if(t.requestBody==null)return;let i=$g(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=$Fs({content:i.content,context:e});if(a==null)return;let o=$g(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(o.allOf==null&&o.properties==null)return;let c=o.properties?.[r.streamConditionProperty];c!=null&&$g(c)&&(c=void 0);let d={...o,properties:{...o.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...c??{}}},title:void 0,required:[...o.required??[],r.streamConditionProperty]};return{requestBody:{content:{[C7.APPLICATION_JSON]:{schema:d}}},schemaReference:$g(a.schema)?a.schema:void 0}}function UGy({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[C7.APPLICATION_JSON]:{schema:t}}}}}function VGy(e,t){return e._visit({unknown:r=>{let n=zX.serialization.ExampleEndpointCallSchema.parse(r);if(n.ok&&n.value.response!=null)return n.value.response.stream!=null},full:()=>{},_other:()=>{}})}function HGy({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:o,baseBreadcrumbs:c,sdkMethodName:d}=t,s=[...c,"Payload"],u=JFs({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:o,source:r});if(i.requestBody==null)return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Missing a request body`),[];let l=i.operationId;if(l==null)return e.logger.error(`Skipping webhook ${a} because no operation id present`),[];if(o!=="POST"&&o!=="GET")return e.logger.error(`Skipping webhook ${o.toUpperCase()} ${a}: Not POST or GET`),[];let m=$g(i.requestBody)?e.resolveRequestBodyReference(i.requestBody):i.requestBody;return Object.entries(m.content).map(([A,P])=>cVr({mediaType:A,mediaTypeObject:P,description:m.description,document:n,context:e,requestBreadcrumbs:[...c,"Payload"],source:r,namespace:e.namespace})).filter(A=>A!=null).map(A=>{if(A==null||A.type!=="json"&&A.type!=="formUrlEncoded"){e.logger.error(`Skipping webhook ${a} because non-json and non-formUrlEncoded request body`);return}return{summary:i.summary,audiences:Hy(i,Ab.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:o,operationId:l,tags:e.resolveTagsToTagIds(i.tags),headers:u.headers,generatedPayloadName:Eie(s,e.options.preserveSchemaIds),payload:A.schema,description:i.description,examples:PUC(A.fullExamples),source:r}}).filter(A=>A!=null)}function PUC(e){if(e==null)return[];let t=[];for(let r of e){let n=F2i(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function bBf({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=Hy(r,Ab.IGNORE);if(i!=null&&i){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=wUC(r,e),o=yGy(e.document,r),c={...t,sdkMethodName:a,baseBreadcrumbs:jUC({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:o};if(n)return{type:"webhook",value:HGy({context:e,operationContext:c,source:e.source})};let d=_Gy(r);if(d!=null){let l=WGy({context:e,operationContext:c,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let s=dGy(r);if(s!=null){let l=QGy({context:e,operationContext:c,asyncExtension:s,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:$Ai({context:e,operationContext:c,streamFormat:void 0,source:e.source})}}function wUC(e,t){let r=Hy(e,Ab.SDK_METHOD_NAME),n=Hy(e,Ab.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function jUC({sdkMethodName:e,operation:t,httpMethod:r,path:n,shouldUseIdiomaticRequestNames:i}){let a=[];if(e!=null){if(i&&a.push(e.methodName),e.groupName.length>0){let o=e.groupName[e.groupName.length-1];o!=null&&a.push(typeof o=="string"?o:o.name)}i||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(EA(`${r}_${n.split("/").join("_")}`));return a}function GGy(e,t,r,n){let i=[],a=KGy(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(n.filter.skipEndpoint({method:c.method,path:e})){n.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=EUC({operation:c.operation}),s=bBf({context:n,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:d});s&&i.push(s)}return i}function JGy(e,t,r,n){let i=[],a=KGy(t),o={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(n.filter.skipEndpoint({method:c.method,path:e})){n.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=bBf({context:n,pathItemContext:{...o,method:c.method},operation:c.operation,convertToWebhook:!0});d&&i.push(d)}return i}function KGy(e){let t=[];return e.get!=null&&t.push({method:xde.Get,operation:e.get}),e.post!=null&&t.push({method:xde.Post,operation:e.post}),e.put!=null&&t.push({method:xde.Put,operation:e.put}),e.delete!=null&&t.push({method:xde.Delete,operation:e.delete}),e.patch!=null&&t.push({method:xde.Patch,operation:e.patch}),e.head!=null&&t.push({method:xde.Head,operation:e.head}),t}function EUC({operation:e}){return Hy(e,[Ab.WEBHOOK])??!1}function $Gy(e){let t=Hy(e,Ab.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Hy(e,Ab.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function YGy(e){return Hy(e,Ab.FERN_BASIC_AUTH)}function XGy(e,t,r){if($g(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return SUC(e,t,r)}function SUC(e,t,r){try{if(e.type==="apiKey"&&e.in==="header"){let n=Hy(e,Rbe.BEARER_FORMAT),i=Hy(e,Ab.FERN_HEADER_AUTH);return Rde.header({headerName:e.name,prefix:n!=null?"Bearer":i?.prefix,headerVariableName:i?.name??Hy(e,Ab.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="bearer"){let n=Hy(e,Ab.FERN_BEARER_TOKEN);return Rde.bearer({tokenVariableName:n?.name??Hy(e,Ab.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:n?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="basic"){let n=YGy(e),i=$Gy(e);return Rde.basic({usernameVariableName:n?.username?.name??i.usernameVariable,usernameEnvVar:n?.username?.env,passwordVariableName:n?.password?.name??i.passwordVariable,passwordEnvVar:n?.password?.env})}else{if(e.type==="openIdConnect")return Rde.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return Rde.oauth({scopesEnum:DUC(e,t)})}}catch(n){r.logger.debug(`Error converting security scheme: ${n?.message}`)}r.logger.warn(`Skipping security scheme: ${JSON.stringify(e,null)} - not currently supported. Please reach out to Fern support team!`)}function DUC(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let n=q2i({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,o])=>[a,{description:o}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsOptional:!1,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),i=I4(n);if(i.type==="enum")return i}}function ZGy(e){return Hy(e,Ab.BASE_PATH)}var CUC=rl.record(rl.string(),rl.object({summary:rl.string().optional(),description:rl.string().optional()}));function kGy({document:e,context:t}){return DXo(e,Ab.GROUPS,CUC,t.logger)}function eJy({context:e,document:t}){return Hy(t,Ab.FERN_VERSION)??void 0}function tJy(e){let t=Hy(e,Ab.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?CXo({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function rJy(e){let t=Hy(e,Ab.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?CXo({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function nJy(e,t){let r=Hy(e,Ab.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([n,i])=>{if(i.type==="string")return[n,{nameOverride:void 0,generatedName:Eie([n],t),title:i.title,schema:lq.string({default:_no(i),pattern:i.pattern,format:i.format,minLength:i.minLength,maxLength:i.maxLength}),description:i.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${n} has unsupported schema ${JSON.stringify(i)}`)}))}var MUC="webhooks";function iJy(e){return Hy(e,MUC)??{}}var ZFs=class extends gno{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:o})}getDummy(){return new Mla({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discriminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discriminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function aJy(e){return Hy(e,Ab.RESOLUTIONS)}function oJy({openapi:e}){let t=aJy(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=IUC({openapi:e,schemaReference:a,schemaName:n.name}),e=uJy({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(o=>[i,o]))}}return e}function IUC({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),i=e;for(let a of n){let o=i[a];if(o==null)return e;i=o}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function uJy({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let s=r.replace(i,d);return uJy({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),o=e;for(let d of a.slice(0,-1)){let s=o[d];if(s==null)return e;o=s}let c=a[a.length-1];return c==null||(o[c]={$ref:r}),e}function cJy({openApi:e,taskContext:t,options:r,source:n,namespace:i}){e=oJy({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([Y,te])=>{let ne=XGy(te,n,t);return ne==null?null:[Y,ne]}).filter(Y=>Y!==null)),o=new Set(...Object.entries(a).map(([Y,te])=>te.type==="basic"||te.type==="bearer"?"Authorization":te.type==="header"?te.headerName:null)),c=nJy(e,r.preserveSchemaIds),d=tJy(e),s=rJy(e),u=r.audiences??[],l=[],m=[],A=new ZFs({document:e,taskContext:t,authHeaders:o,options:r,source:n,namespace:i});A.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([Y,te])=>{if(te==null)return;t.logger.debug(`Converting path ${Y}`);let ne=GGy(Y,te,e,A);for(let Oe of ne){let ge=sJy({operation:Oe});if(!(u.length>0&&!u.some(ve=>ge.includes(ve))))switch(Oe.type){case"async":l.push(...Oe.sync),l.push(...Oe.async);break;case"http":l.push(...Oe.value);break;case"streaming":l.push(...Oe.streaming),Oe.nonStreaming&&l.push(...Oe.nonStreaming);break;case"webhook":m.push(...Oe.value);break;default:tc(Oe)}}}),Object.entries(iJy(e)).forEach(([Y,te])=>{if(te==null)return;t.logger.debug(`Converting path ${Y}`);let ne=JGy(Y,te,e,A);for(let Oe of ne){let ge=sJy({operation:Oe});u.length>0&&!u.some(ve=>ge.includes(ve))||m.push(...Oe.value)}});let P=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([Y,te])=>{let ne=Hy(te,Ab.SDK_NAMESPACE);if(!$g(te)){let Oe=Hy(te,Ab.IGNORE);if(Oe!=null&&Oe)return[];if(RGy.has(Y))return[Y,pS({...te,"x-fern-type-name":`${Y}Body`},!1,!1,A,[Y],n,ne??i)]}return[Y,pS(te,!1,!1,A,[Y],n,ne??i)]}).filter(Y=>Y.length>0)),C=BUC(P,A,n),I=TUC(C,A),T={};for(let[Y,te]of Object.entries(I)){let ne=I4(te);A.isSchemaExcluded(Y)||(T[Y]=ne,t.logger.debug(`Converted schema ${Y}`))}let z=new x2i(I,A.nonRequestReferencedSchemas,A),U=m.map(Y=>{let ne=Y.examples;if(!r.disableExamples&&ne.length===0){let Oe=z.buildExample({schema:Y.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Oe!=null&&(ne=[{name:void 0,description:void 0,payload:Oe}])}return{...Y,payload:I4(Y.payload),examples:ne}}),R=new QFs(I,A,d),V=l.map(Y=>{let te=Y.examples,ne=te;if(!r.disableExamples&&(te.length===0||te.every(TXo))){let ve=R.buildEndpointExample(Y);ve.length>0&&(ne=[...ve,...te.filter(be=>!TXo(be))])}let Oe=Y.request,ge=Y.response;return{...Y,request:Oe?.type==="json"||Oe?.type==="formUrlEncoded"?{...Oe,schema:I4(Oe.schema)}:Oe,response:ge?.type==="json"?{...ge,schema:I4(ge.schema)}:ge,queryParameters:Y.queryParameters.map(ve=>({description:ve.description,name:ve.name,schema:I4(ve.schema),parameterNameOverride:ve.parameterNameOverride,availability:ve.availability,source:ve.source})),pathParameters:Y.pathParameters.map(ve=>({description:ve.description,name:ve.name,schema:I4(ve.schema),parameterNameOverride:ve.parameterNameOverride,variableReference:ve.variableReference,availability:ve.availability,source:ve.source})),headers:Y.headers.map(ve=>({description:ve.description,name:ve.name,schema:I4(ve.schema),parameterNameOverride:ve.parameterNameOverride,env:ve.env,availability:ve.availability,source:ve.source})),examples:ne,errors:pg(Y.errors,ve=>{let be=ve.fullExamples?.map(Ie=>{let Be=F2i(Ie.value);if(Be!=null)return{name:Ie.name,description:Ie.description,example:Be}}).filter(Gw);if(be?.length===0){let Ie=z.buildExample({schema:ve.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Ie!=null&&be.push({name:void 0,description:void 0,example:Ie})}return{generatedName:ve.generatedName,nameOverride:ve.nameOverride,schema:I4(ve.schema),description:ve.description,source:ve.source,examples:be}}),retries:Y.retries}}),$=kGy({document:e,context:A});return{apiVersion:eJy({context:A,document:e}),basePath:ZGy(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries($??{}).map(([Y,te])=>[Y,{summary:te.summary??void 0,description:te.description??void 0}])),servers:(e.servers??[]).map(Y=>GFs(Y,{groupMultiApiEnvironments:r.groupMultiApiEnvironments})),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(Y=>[Y.name,{id:Y.name,description:Y.description}])),orderedTagIds:e.tags?.map(Y=>Y.name)},endpoints:V,webhooks:U,channels:{},groupedSchemas:vno(i,T),securitySchemes:a,hasEndpointsMarkedInternal:V.some(Y=>Y.internal),nonRequestReferencedSchemas:A.getReferencedSchemas(),variables:c,globalHeaders:d,idempotencyHeaders:s}}function BUC(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let o={$ref:`#/components/schemas/${i}`},c=t.getReferencesFromDiscriminatedUnion(o);if(c==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(u=>!c.discriminants.has(u.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(u=>!c.discriminants.has(u.propertyKey)),source:r};n[i]=d;let s=lJy({schema:a,schemas:e});for(let u of[...new Set(s)]){let l=n[u]??e[u];l==null||l.type!=="object"||(n[u]={...l,type:"object",properties:l.properties.filter(m=>!c.discriminants.has(m.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(m=>!c.discriminants.has(m.propertyKey))})}}return n}function TUC(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},o=t.getDiscriminatedUnionMetadata(a);if(o==null){r[n]=i;continue}let c=[];for(let s of i.properties)if(o.discriminants.has(s.key)){let u=o.discriminants.get(s.key);u!=null&&c.push({...s,schema:mh.literal({nameOverride:void 0,generatedName:Eie([i.generatedName,u],t.options.preserveSchemaIds),title:void 0,value:jV.string(u),namespace:void 0,groupName:void 0,description:void 0,availability:i.availability})})}else c.push(s);let d={...i,type:"object",properties:c};r[n]=d}return r}function lJy({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...lJy({schema:i,schemas:t}))}return r}function kFs(e){return[...new Set(e)]}function sJy({operation:e}){let t=[];switch(e.type){case"async":t=kFs(e.async.flatMap(r=>r.audiences));break;case"http":t=kFs(e.value.flatMap(r=>r.audiences));break;case"streaming":t=kFs(e.streaming.flatMap(r=>r.audiences));break;case"webhook":t=kFs(e.value.flatMap(r=>r.audiences));break;default:tc(e)}return t}function Ila({context:e,documents:t,options:r}){let n={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}},i=0;for(let a of t){let o=a.source!=null?a.source:swe.openapi({file:"<memory>"});switch(a.type){case"openapi":{let c=cJy({taskContext:e,openApi:a.value,options:iyt({options:a.settings,overrides:r}),source:o,namespace:a.namespace});n=FUC(n,c,iyt({options:a.settings,overrides:r})),i++;break}case"asyncapi":{let c=fGy({document:a.value,taskContext:e,options:iyt({options:a.settings,overrides:r}),source:o,asyncApiOptions:qUC({options:a.settings}),namespace:a.namespace});c.servers!=null&&(n.websocketServers=[...n.websocketServers,...c.servers.map(d=>({...d,audiences:void 0,description:void 0}))]),c.channels!=null&&(n.channels={...n.channels,...c.channels}),c.groupedSchemas!=null&&(n.groupedSchemas=exs(n.groupedSchemas,c.groupedSchemas)),c.basePath!=null&&(n.basePath=c.basePath),i++;break}default:tc(a)}}return n}function qUC({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??IHy.naming}}function txs(e){let t=String(e.description||e.name||e["x-fern-server-name"]||"default").trim(),r=t.toUpperCase();return r==="PRODUCTION"||r==="PRD"||r==="PROD"?"PRD":r==="SANDBOX"||r==="SBX"?"SBX":r==="STAGING"||r==="STG"?"STG":r==="PERFORMANCE"||r==="PRF"||r==="PERF"?"PRF":r==="E2E"||r==="E_2_E"?"E2E":r==="QAL"||r==="QUALITY"?"QAL":t}function RUC(e){try{let n=new URL(e).hostname.split("."),i=new Set(["api","www","service","services","example","com","org","net","io"]);for(let o of n){let c=o.split("-")[0];if(c&&!i.has(c.toLowerCase())&&c.length>2)return c.toLowerCase()}let a=n[0]?.split("-")[0];return a?a.toLowerCase():"api"}catch{let t=e.match(/https?:\/\/([^./-]+)/);return t&&t[1]?t[1].toLowerCase():"api"}}function NUC(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let r=new Map;for(let a of e){let o=txs(a);r.set(o,a.url)}let n=!0,i=!0;for(let a of t){let o=txs(a),c=r.get(o);c?c===a.url&&(i=!1):n=!1}return n&&i}function fJy(e){if(e.length===0||!e[0])return"api";let t=e[0].url;return RUC(t)}function FUC(e,t,r){if(!(r?.groupMultiApiEnvironments===!0))return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:exs(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}};if(NUC(e.servers,t.servers)){let a=[],o=[],c=fJy(e.servers),d=fJy(t.servers),s=new Map;for(let m of e.servers){let A=txs(m);s.has(A)||s.set(A,{});let P=s.get(A);P&&(P[c]={url:m.url,audiences:m.audiences})}for(let m of t.servers){let A=txs(m);s.has(A)||s.set(A,{});let P=s.get(A);P&&(P[d]={url:m.url,audiences:m.audiences})}for(let[m,A]of s.entries()){let P={type:"grouped",name:m,description:`${m} environment`,urls:A};a.push(P)}let u=e.endpoints.map(m=>({...m,type:"multi-api",apiName:c,servers:[{name:c,url:void 0,audiences:void 0}]})),l=t.endpoints.map(m=>({...m,type:"multi-api",apiName:d,servers:[{name:d,url:void 0,audiences:void 0}]}));return o=[...u,...l],{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:a.map(m=>(m.type==="single",m)),websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:o.map(m=>{if(m.type==="multi-api"){let{type:C,apiName:I,servers:T,...z}=m;return{...z,__apiName:I,servers:T}}let{type:A,...P}=m;return P}),webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:exs(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:exs(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function exs(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}var Arv=fa(K6s(),1),$6s={config:new Arv.Config({apis:{},styleguide:{plugins:[nBf],rules:{struct:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function hio(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}function zZo(e){return e.swagger!=null}function MFf(e){return e.openapi!=null}function QZo({options:e,overrides:t}={}){return{...iyt({options:e,overrides:t}),...hXo({options:e,overrides:t})}}function d7i(e,t={}){return{...Object.fromEntries(Jk(e.namedDefinitionFiles).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...Jk(e.importedDefinitions).reduce((r,[n,i])=>({...r,...IUo(d7i(i.definition,{defaultURL:i.url}),(a,o)=>TX(n,nw.of(o)))}),{})}}function LZo(e,t={}){return{...Object.fromEntries(Jk(e.packageMarkers).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...Jk(e.importedDefinitions).reduce((r,[n,i])=>({...r,...IUo(LZo(i.definition,{defaultURL:i.url}),(a,o)=>TX(n,nw.of(o)))}),{})}}function pPi(e){return{...LZo(e),...d7i(e)}}function r3e(e,t){return pPi(e.definition)[t]?.contents}function Mee(e,t){for(let[r,n]of Jk(pPi(e.definition)))t(r,n.contents,{isPackageMarker:vaa(r)===rF,defaultUrl:n.defaultUrl})}function nfa(e,t){for(let[r,n]of Jk(LZo(e.definition)))t(r,n.contents)}function pyt({breadcrumbs:e=[],title:t,subtitle:r}){let n=[];return e.length>0&&n.push(md.blue(e.join(" -> "))),n.push(t),r!=null&&n.push(md.dim(r)),n.join(`
2410
2410
  `)}var Prv={None:"none",Header:"header"};var b4s={};ff(b4s,{ConjureAliasDeclaration:()=>r4s,ConjureArgument:()=>h4s,ConjureArgumentWithParamType:()=>_4s,ConjureAuthDefinition:()=>gio,ConjureAuthDefinitionType:()=>d4s,ConjureDefinitions:()=>l4s,ConjureEndpointDefinition:()=>y4s,ConjureEnumDeclaration:()=>s4s,ConjureEnumVariant:()=>u4s,ConjureEnumWithDocs:()=>o4s,ConjureObjectDeclaration:()=>a4s,ConjureParamType:()=>p4s,ConjurePrimitive:()=>t4s,ConjureService:()=>v4s,ConjureServiceName:()=>e4s,ConjureType:()=>h7i,ConjureTypeDeclaration:()=>c4s,ConjureTypeReference:()=>y7i,ConjureTypeWithDocs:()=>n4s,ConjureTypes:()=>f4s,ConjureUnionDeclaration:()=>i4s,DefinitionFile:()=>Xrv,WithDocs:()=>bVr,commons:()=>RFf,conjure:()=>NFf,services:()=>FFf,types:()=>xFf});var RFf={};ff(RFf,{WithDocs:()=>bVr});var Q0={};ff(Q0,{JsonError:()=>yio,ParseError:()=>vio,any:()=>xrv,bigint:()=>jrv,boolean:()=>zrv,booleanLiteral:()=>Frv,date:()=>Erv,discriminant:()=>Krv,enum_:()=>X6s,getObjectLikeUtils:()=>jqr,getObjectUtils:()=>ifa,getSchemaUtils:()=>c5,isProperty:()=>_7i,lazy:()=>Srv,lazyObject:()=>qrv,list:()=>k6s,number:()=>Qrv,object:()=>Z6s,objectWithoutOptionalProperties:()=>Trv,optional:()=>IFf,property:()=>Crv,record:()=>Wrv,set:()=>Hrv,string:()=>Lrv,stringLiteral:()=>Nrv,transform:()=>BFf,undiscriminatedUnion:()=>Jrv,union:()=>Yrv,unknown:()=>Urv,withParsedProperties:()=>qFf});var pq={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function z2(e,t){return`Expected ${t}. Received ${jfM(e)}.`}function jfM(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 Ude(e){return{...e,json:wrv(e.json),parse:wrv(e.parse)}}function wrv(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(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
2411
2411
  `)),{ok:!0,value:t}):n}}function Y6s(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var yio=class e extends Error{errors;constructor(t){super(t.map(Y6s).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var vio=class e extends Error{errors;constructor(t){super(t.map(Y6s).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function c5(e){return{optional:()=>IFf(e),transform:t=>BFf(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new vio(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new yio(n.errors)}}}function IFf(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:()=>pq.OPTIONAL};return{...t,...c5(t)}}function BFf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...c5(r)}}function jrv(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:z2(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:z2(t,"bigint")}]},getType:()=>pq.BIGINT};return{...Ude(e),...c5(e)}}var EfM=/^([+-]?\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 Erv(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:z2(t,"string")}]}:EfM.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:z2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:z2(t,"Date object")}]},getType:()=>pq.DATE};return{...Ude(e),...c5(e)}}function vwe(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Ude(r),...c5(r)}}}function X6s(e){let t=new Set(e);return vwe(pq.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:z2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:z2(n,"enum")}]}:{ok:!0,value:n})()}function Srv(e){let t=TFf(e);return{...t,...c5(t)}}function TFf(e){return{parse:(t,r)=>bio(e).parse(t,r),json:(t,r)=>bio(e).json(t,r),getType:()=>bio(e).getType()}}function bio(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function UZo(e){return Object.entries(e)}function VZo(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function p7i(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function WZo(e){return Object.keys(e)}function Drv(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function jqr(e){return{withParsedProperties:t=>qFf(e,t)}}function qFf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(n,i)=>{if(!p7i(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:z2(n,"object")}]};let a=new Set(Object.keys(t)),o=VZo(n,Object.keys(n).filter(c=>!a.has(c)));return e.json(o,i)},getType:()=>e.getType()};return{...r,...c5(r),...jqr(r)}}function Crv(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function _7i(e){return e.isProperty}function Z6s(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>_7i(n)?n.rawKey:r),_getParsedProperties:()=>WZo(e),parse:(r,n)=>{let i={},a=[];for(let[o,c]of UZo(e)){let d=_7i(c)?c.rawKey:o,s=_7i(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};i[d]=u,Brv(s)&&a.push(d)}return Mrv({value:r,requiredKeys:a,getProperty:o=>{let c=i[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,o]of UZo(e)){let c=_7i(o)?o.valueSchema:o;Brv(c)&&i.push(a)}return Mrv({value:r,requiredKeys:i,getProperty:a=>{let o=e[a];if(o!=null)return _7i(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>pq.OBJECT};return{...Ude(t),...c5(t),...jqr(t),...ifa(t)}}function Mrv({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!p7i(e))return{ok:!1,errors:[{path:a,message:z2(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let m=l.transform(u);m.ok?d[l.transformedKey]=m.value:(d[s]=u,c.push(...m.errors))}else switch(n){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||i?{ok:!0,value:d}:{ok:!1,errors:c}}function ifa(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>Irv({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>Irv({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>pq.OBJECT};return{...r,...c5(r),...jqr(r),...ifa(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,n)=>{let i=e.parse(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},json:(r,n)=>{let i=e.json(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},getType:()=>pq.OBJECT};return{...t,...c5(t),...jqr(t),...ifa(t)}}}}function Irv({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,o]=Drv(WZo(t),s=>i.has(s)),c=r(VZo(t,o)),d=n(VZo(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function Brv(e){return!SfM(e)}function SfM(e){switch(e.getType()){case pq.ANY:case pq.UNKNOWN:case pq.OPTIONAL:return!0;default:return!1}}function Trv(e){return Z6s(e)}function qrv(e){let t={...TFf(e),_getRawProperties:()=>bio(e)._getRawProperties(),_getParsedProperties:()=>bio(e)._getParsedProperties()};return{...t,...c5(t),...jqr(t),...ifa(t)}}function k6s(e){let t={parse:(r,n)=>Rrv(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>Rrv(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>pq.LIST};return{...Ude(t),...c5(t)}}function Rrv(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:z2(e,"list"),path:[]}]}}function Nrv(e){return vwe(pq.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:z2(r,`"${e}"`)}]})()}function Frv(e){return vwe(pq.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:z2(r,`${e.toString()}`)}]})()}var xrv=vwe(pq.ANY,e=>({ok:!0,value:e}));var zrv=vwe(pq.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:z2(e,"boolean")}]});var Qrv=vwe(pq.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:z2(e,"number")}]});var Lrv=vwe(pq.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:z2(e,"string")}]});var Urv=vwe(pq.UNKNOWN,e=>({ok:!0,value:e}));function Wrv(e,t){let r={parse:(n,i)=>Vrv({value:n,isKeyNumeric:e.getType()===pq.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>Vrv({value:n,isKeyNumeric:e.getType()===pq.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>pq.RECORD};return{...Ude(r),...c5(r)}}function Vrv({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return p7i(e)?UZo(e).reduce((a,[o,c])=>{if(c==null)return a;let d=a,s=o;if(t){let A=o.length>0?Number(o):NaN;isNaN(A)||(s=A)}let u=r(s),l=n(c,s);if(d.ok&&u.ok&&l.ok)return{ok:!0,value:{...d.value,[u.value]:l.value}};let m=[];return d.ok||m.push(...d.errors),u.ok||m.push(...u.errors),l.ok||m.push(...l.errors),{ok:!1,errors:m}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:z2(e,"object")}]}}function Hrv(e){let t=k6s(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:z2(n,"Set")}]},getType:()=>pq.SET};return{...Ude(r),...c5(r)}}function Jrv(e){let t={parse:(r,n)=>Grv((i,a)=>i.parse(r,a),e,n),json:(r,n)=>Grv((i,a)=>i.json(r,a),e,n),getType:()=>pq.UNDISCRIMINATED_UNION};return{...Ude(t),...c5(t)}}function Grv(e,t,r){let n=[];for(let[i,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)n.push({path:c.path,message:`[Variant ${i}] ${c.message}`})}return{ok:!1,errors:n}}function Krv(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Yrv(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=X6s(WZo(t)),a={parse:(o,c)=>$rv({value:o,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>$rv({value:o,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>pq.UNION};return{...Ude(a),...c5(a),...jqr(a)}}function $rv({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!p7i(e))return{ok:!1,errors:[{path:c,message:z2(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=n(d);if(!u.ok)return{ok:!1,errors:u.errors};let l=i(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let m=o(s,l);return m.ok?{ok:!0,value:{[r]:d,...m.value}}:m}var bVr=Q0.objectWithoutOptionalProperties({docs:Q0.string().optional()});var NFf={};ff(NFf,{ConjureServiceName:()=>e4s,DefinitionFile:()=>Xrv});var e4s=Q0.string();var t4s=Q0.enum_(["rid","string","safelong","integer","double","boolean"]);var h7i=Q0.undiscriminatedUnion([t4s,Q0.string()]);var r4s=Q0.objectWithoutOptionalProperties({alias:h7i,docs:Q0.string().optional()});var n4s=Q0.objectWithoutOptionalProperties({type:h7i,docs:Q0.string().optional()});var y7i=Q0.undiscriminatedUnion([h7i,n4s]);var i4s=Q0.objectWithoutOptionalProperties({union:Q0.record(Q0.string(),y7i)});var a4s=Q0.objectWithoutOptionalProperties({fields:Q0.record(Q0.string(),y7i)});var o4s=Q0.objectWithoutOptionalProperties({value:Q0.string()}).extend(bVr);var u4s=Q0.undiscriminatedUnion([Q0.string(),o4s]);var s4s=Q0.objectWithoutOptionalProperties({values:Q0.list(u4s)});var c4s=Q0.undiscriminatedUnion([r4s,i4s,a4s,s4s]);var l4s=Q0.objectWithoutOptionalProperties({objects:Q0.record(Q0.string(),c4s).optional()});var f4s=Q0.objectWithoutOptionalProperties({conjureImports:Q0.property("conjure-imports",Q0.record(Q0.string(),Q0.string()).optional()),definitions:l4s.optional()});var d4s=Q0.enum_(["none","header"]);var gio=Q0.undiscriminatedUnion([d4s,Q0.string()]);var p4s=Q0.enum_(["path","query","body"]);var _4s=Q0.objectWithoutOptionalProperties({paramType:Q0.property("param-type",p4s),type:Q0.string()}).extend(bVr);var h4s=Q0.undiscriminatedUnion([Q0.string(),_4s]);var y4s=Q0.objectWithoutOptionalProperties({http:Q0.string(),auth:gio.optional(),args:Q0.record(Q0.string(),h4s).optional(),returns:y7i.optional()}).extend(bVr);var v4s=Q0.objectWithoutOptionalProperties({name:Q0.string().optional(),package:Q0.string().optional(),basePath:Q0.property("base-path",Q0.string().optional()),defaultAuth:Q0.property("default-auth",gio.optional()),endpoints:Q0.record(Q0.string(),y4s).optional()}).extend(bVr);var Xrv=Q0.objectWithoutOptionalProperties({types:f4s.optional(),services:Q0.record(e4s,v4s).optional()});var FFf={};ff(FFf,{ConjureArgument:()=>h4s,ConjureArgumentWithParamType:()=>_4s,ConjureAuthDefinition:()=>gio,ConjureAuthDefinitionType:()=>d4s,ConjureEndpointDefinition:()=>y4s,ConjureParamType:()=>p4s,ConjureService:()=>v4s});var xFf={};ff(xFf,{ConjureAliasDeclaration:()=>r4s,ConjureDefinitions:()=>l4s,ConjureEnumDeclaration:()=>s4s,ConjureEnumVariant:()=>u4s,ConjureEnumWithDocs:()=>o4s,ConjureObjectDeclaration:()=>a4s,ConjurePrimitive:()=>t4s,ConjureType:()=>h7i,ConjureTypeDeclaration:()=>c4s,ConjureTypeReference:()=>y7i,ConjureTypeWithDocs:()=>n4s,ConjureTypes:()=>f4s,ConjureUnionDeclaration:()=>i4s});var Zrv=require("fs/promises");async function krv(e,t){let r=[];for(let n of await sFe(e,t))r.push(await DfM({relativeFilepath:e5(e,n),absoluteFilepath:n}));return r}async function DfM({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,Zrv.readFile)(t)).toString().replaceAll(/: rid(?:$|\s)/g,`: string