fern-api 2.17.1 → 2.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -1152,7 +1152,7 @@ ${KUp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&M9s(th
1152
1152
  `+GHi.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?GHi.default.cyan(r4p(t,this.opt.mask)):GHi.default.italic(GHi.default.dim("[hidden]")):this.opt.mask?r4p(t,this.opt.mask):GHi.default.italic(GHi.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 v0o=ae(b1(),1);var r3p=ae(cGs(),1),y0o=require("child_process"),aTn=require("fs"),h0o=ae(require("path"),1),i3p=ae(require("os"),1),n3p=require("crypto"),KGs=ae(e3p(),1);var d0o=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var kga=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var p0o=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var _0o=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function b0o(e="",t,r){let i=new JGs(e,r);i.runAsync((n,a)=>{if(n)setImmediate(t,n,void 0);else try{i.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function t3p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function zgS(e){let t=[],r="";for(let i=0;i<e.length;i++){let n=e.charAt(i);i>0&&n===" "&&e[i-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${n}`}return r.length>0&&t.push(r),t}var JGs=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=zgS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??i3p.default.tmpdir(),r=(0,n3p.randomUUID)(),i=t3p(this.fileOptions.prefix),n=t3p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=h0o.default.resolve(t,a),c=h0o.default.resolve(t)+h0o.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let f={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(f.mode=this.fileOptions.mode),(0,aTn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new d0o(t)}}readTemporaryFile(){try{let t=(0,aTn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,r3p.detect)(t)??"utf8";KGs.default.encodingExists(r)||(r="utf8"),this.text=KGs.default.decode(t,r)}}catch(t){throw new p0o(t)}}removeTemporaryFile(){try{(0,aTn.unlinkSync)(this.tempFile)}catch(t){throw new _0o(t)}}launchEditor(){try{let t=(0,y0o.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new kga(t)}}launchEditorAsync(t){try{(0,y0o.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new kga(r)}}};var a3p=ae(Z_e(),1);var eOa=class extends v1{_run(t){this.done=t,this.editorResult=new a3p.Subject;let r=qQ(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?v0o.default.dim("Received"):v0o.default.dim("Press <enter> to launch your preferred editor."),t&&(r=v0o.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),b0o(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 l3p=require("stream");var s3p=ae(require("readline"),1),c3p=ae(u3p(),1),$Hi=class{constructor(t){this.rl||=s3p.default.createInterface(FgS(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 FgS(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new c3p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var tOa=class extends $Hi{constructor(t={}){super(t),this.log=new l3p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Fga(this.rl,this.bottomBar.split(`
1153
1153
  `).length),this}updateBottomBar(t){return Fga(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=t,this.render(),this.rl.output.mute(),this}writeLog(t){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(t.toString())),this.render(),this.rl.output.mute(),this}enforceLF(t){return/[\n\r]$/.test(t)?t:t+`
1154
1154
  `}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&&Umo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var dO=ae(Z_e(),1),p3p=ae(aga(),1);var g0o=ae(Z_e(),1),f3p=ae(aga(),1),O0o=function(e,t,r){return typeof e[t]!="function"?(0,g0o.of)(e):(0,g0o.from)((0,f3p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var d3p={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,o)=>{n==="__proto__"||n==="constructor"||(a===o.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},oTn=class extends $Hi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,dO.from)(t):(0,dO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,dO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,dO.from)([t]),this.process=i.pipe((0,dO.concatMap)(this.processQuestion.bind(this)),(0,dO.publish)()),this.process.connect(),this.process.pipe((0,dO.reduce)((n,a)=>(d3p.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,dO.defer)(()=>(0,dO.of)(t).pipe((0,dO.concatMap)(this.setDefaultType.bind(this)),(0,dO.concatMap)(this.filterIfRunnable.bind(this)),(0,dO.concatMap)(()=>O0o(t,"message",this.answers)),(0,dO.concatMap)(()=>O0o(t,"default",this.answers)),(0,dO.concatMap)(()=>O0o(t,"choices",this.answers)),(0,dO.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,dO.defer)(()=>(0,dO.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,dO.defer)(()=>(0,dO.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&d3p.get(this.answers,t.name)!==void 0)return dO.EMPTY;if(t.when===!1)return dO.EMPTY;if(typeof t.when!="function")return(0,dO.of)(t);let{answers:r}=this;return(0,dO.defer)(()=>(0,dO.from)((0,p3p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,dO.filter)(i=>i!=null)))}};function _3p(e){let t=function(r,i){let n;try{n=new oTn(t.prompts,e)}catch(o){return Promise.reject(o)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Uga),this.registerPrompt("input",xHi),this.registerPrompt("number",Lga),this.registerPrompt("confirm",Vga),this.registerPrompt("rawlist",Wga),this.registerPrompt("expand",xga),this.registerPrompt("checkbox",Gga),this.registerPrompt("password",Hga),this.registerPrompt("editor",eOa)},t.restoreDefaultPrompts(),t}var YGs=_3p();function UgS(e,t){YGs.registerPrompt(e,t)}function LgS(){YGs.restoreDefaultPrompts()}var VgS={prompt:YGs,ui:{BottomBar:tOa,Prompt:oTn},createPromptModule:_3p,registerPrompt:UgS,restoreDefaultPrompts:LgS,Separator:w6},A0o=VgS;var gTn=require("path"),KLp=require("fs"),JLp=require("readline"),vLp="posthog-node";function hmS(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[L0o.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(_=>({..._,stacktrace:_.stacktrace?{..._.stacktrace,type:"raw",frames:(_.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),p={$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&&(p.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:p}),a}}var L0o=class{constructor(t,r,i,n){this.name=vLp,this.name=vLp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(hmS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};L0o.POSTHOG_ID_TAG="posthog_distinct_id";var z0o="0123456789abcdef",V0o=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,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=z0o.charAt(this.bytes[r]>>>4),t+=z0o.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+=z0o.charAt(this.bytes[r]>>>4),t+=z0o.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 i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},T7s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??ymS()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return V0o.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,V0o.ofInner(t)}},ymS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),gLp,R7s=()=>bmS().toString(),bmS=()=>(gLp||(gLp=new T7s)).generate();function vmS(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function gmS(e,t){global.process.on("uncaughtException",vmS(e,t))}function OmS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var N0o,OLp,F0o;function AmS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return F0o&&r.length===OLp||(OLp=r.length,F0o=r.reduce((i,n)=>{N0o||(N0o={});let a=N0o[n];if(a)i[a[0]]=a[1];else{let o=e(n);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[n];if(s&&u){i[s]=u,N0o[n]=[s,u];break}}}return i},{})),F0o}function mmS(e){return typeof Event<"u"&&$Lp(e,Event)}function PmS(e){return YLp(e,"Object")}function W7s(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return $Lp(e,Error)}}function $Lp(e,t){try{return e instanceof t}catch{return!1}}function jmS(e){return YLp(e,"ErrorEvent")}function YLp(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function wmS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=XLp(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await CmS(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function XLp(e,t,r){let i=EmS(e,t,r);return i.cause?[i,...XLp(e,i.cause,r)]:[i]}function EmS(e,t,r){if(W7s(t))return t;if(e.synthetic=!0,PmS(t)){let n=SmS(t);if(n)return n;let a=MmS(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function SmS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(W7s(r))return r}}function MmS(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message '${e.message}'`),i}else if("message"in e&&typeof e.message=="string")return e.message;let t=BmS(e);if(jmS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=DmS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function DmS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function BmS(e,t=40){let r=Object.keys(ImS(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return ALp(i,t);for(let n=r.length;n>0;n--){let a=r.slice(0,n).join(", ");if(!(a.length>t))return n===r.length?a:ALp(a,t)}return""}function ALp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function ImS(e){return W7s(e)?{message:e.message,name:e.name,stack:e.stack,...mLp(e)}:mmS(e)?{type:e.type,target:PLp(e.target),currentTarget:PLp(e.currentTarget),...mLp(e)}:e}function mLp(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 PLp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function CmS(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=qmS(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function qmS(e,t){return TmS(e(t.stack||"",1),e)}function TmS(e,t){let r=AmS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var RmS=2e3,yTn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await wmS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||R7s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(gmS(this.onException.bind(this),this.onFatalError.bind(this)),OmS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(RmS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function zmS(e=process.argv[1]?(0,gTn.dirname)(process.argv[1]):process.cwd(),t=gTn.sep==="\\"){let r=t?jLp(e):e;return i=>{if(!i)return;let n=t?jLp(i):i,{dir:a,base:o,ext:c}=gTn.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${f}`:f}return f}}function jLp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var W0o=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)}}},U0o=new W0o(25),ZLp=new W0o(20),x7s=7,NmS=1e3,FmS=1e4;async function QmS(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||WmS(o)||xmS(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(ZLp.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=HmS(a);if(o.every(f=>GmS(n,f)))continue;let c=KmS(U0o,n,{});i.push(UmS(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&LmS(e,U0o),U0o.reduce(),e}function UmS(e,t,r){return new Promise(i=>{let n=(0,KLp.createReadStream)(e),a=(0,JLp.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,f=0,s=t[f];if(s===void 0){o();return}let u=s[0],l=s[1];function p(){ZLp.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=JmS(_,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let h=t[f];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],l=h[1]}})})}function LmS(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;VmS(r.lineno,r,i)}}function VmS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=kLp(e);n<e;n++){let a=r[n];if(a===void 0){wLp(t);return}t.pre_context.push(a)}if(r[e]===void 0){wLp(t);return}t.context_line=r[e];let i=e8p(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function wLp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function WmS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function xmS(e){return e.lineno!==void 0&&e.lineno>FmS||e.colno!==void 0&&e.colno>NmS}function GmS(e,t){let r=U0o.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function HmS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=ELp(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+x7s:(n.push(i),i=ELp(a)),t++}return n}function ELp(e){return[kLp(e),e8p(e)]}function kLp(e){return Math.max(1,e-x7s)}function e8p(e){return e+x7s}function KmS(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function JmS(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var $mS="4.18.0",B6;(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"})(B6||(B6={}));var SLp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(SLp||(SLp={}));var MLp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(MLp||(MLp={}));var DLp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(DLp||(DLp={}));var BLp;(function(e){e.Html="html",e.Text="text"})(BLp||(BLp={}));var ILp;(function(e){e.Number="number",e.Emoji="emoji"})(ILp||(ILp={}));var CLp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(CLp||(CLp={}));var qLp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(qLp||(qLp={}));var TLp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(TLp||(TLp={}));var RLp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(RLp||(RLp={}));var YmS=e=>{if("flags"in e){let t=ZmS(e.flags),r=kmS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,t8p(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,XmS(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function XmS(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 ZmS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,G7s(r)]).filter(([,t])=>t!==void 0)),kmS=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?t8p(i):void 0]}))},G7s=e=>e===void 0?void 0:e.variant??e.enabled,t8p=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},e0S=1,t0S=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"]),r0S="utf8";function i0S(e,t){if(!e||typeof e!="string"||n0S(e))throw new Error(t)}function n0S(e){return e.trim().length===0}function a0S(e){return e?.replace(/\/+$/,"")}async function o0S(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function zLp(){return new Date().getTime()}function C7s(){return new Date().toISOString()}function x0o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function u0S(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function s0S(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 c0S(e,t=0,r){let i=s0S(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function NLp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var fOa=String.fromCharCode,FLp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Q0o={};function l0S(e,t){if(!Q0o[e]){Q0o[e]={};for(let r=0;r<e.length;r++)Q0o[e][e.charAt(r)]=r}return Q0o[e][t]}var _Tn={compressToBase64:function(e){if(e==null)return"";let t=_Tn._compress(e,6,function(r){return FLp.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:_Tn._decompress(e.length,32,function(t){return l0S(FLp,e.charAt(t))})},compress:function(e){return _Tn._compress(e,16,function(t){return fOa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],o,c,f="",s="",u="",l=2,p=3,_=2,h=0,y=0,b;for(b=0;b<e.length;b+=1)if(f=e.charAt(b),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=p++,n[f]=!0),s=u+f,Object.prototype.hasOwnProperty.call(i,s))u=s;else{if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++),i[s]=p++,u=String(f)}if(u!==""){if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++)}for(c=2,o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;for(;;)if(h=h<<1,y==t-1){a.push(r(h));break}else y++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:_Tn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,s="",u,l,p,_,h,y,b;for(u=0;u<3;u+=1)i[u]=u;for(p=0,h=Math.pow(2,2),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=fOa(p);break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=fOa(p);break;case 2:return""}for(i[3]=b,l=b,n.push(b);;){if(a.index>e)return"";for(p=0,h=Math.pow(2,f),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(b=p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=fOa(p),b=c-1,o--;break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=fOa(p),b=c-1,o--;break;case 2:return n.join("")}if(o==0&&(o=Math.pow(2,f),f++),i[b])s=i[b];else if(b===c)s=l+l.charAt(0);else return null;n.push(s),i[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,f),f++)}}},z7s=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}},bTn=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()}},dOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function QLp(e){if(e instanceof bTn){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 q7s(e){return typeof e=="object"&&(e instanceof bTn||e instanceof dOa)}function ULp(e){return typeof e=="object"&&e instanceof bTn&&e.status===413}var N7s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(N7s||(N7s={}));var F7s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new z7s,this._isInitialized=!1,i0S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=a0S(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:q7s},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(B6.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(B6.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(B6.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=R7s();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...o||{}}});this.enqueue("capture",c,n)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let c=c0S(this.apiKey,e0S,t0S)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>YmS(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=G7s(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,i,n,c);if(f!==void 0)return f.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"),f.quotaLimited?.includes(N7s.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:f?.requestId}):f}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"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.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 n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(B6.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(B6.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(B6.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(B6.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(B6.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=x0o(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){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 n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:C7s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${zLp()}&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(_Tn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:C7s(),uuid:i?.uuid?i.uuid:R7s()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await QLp(t)})}async flush(){let t=NLp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),NLp([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(B6.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(p=>p.message),o=()=>{let _=(this.getPersistedProperty(B6.Queue)||[]).slice(n.length);this.setPersistedProperty(B6.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:C7s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${zLp()}&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(_Tn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>ULp(p)?!1:q7s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(ULp(p)&&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 p instanceof dOa||o(),this._events.emit("error",p),p}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){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,r0S)}catch{c=new TextEncoder().encode(o).length}return await o0S(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new dOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new bTn(f,c);return f},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(B6.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!q7s(n))throw n;await QLp(n)}};return Promise.race([new Promise((n,a)=>{x0o(()=>{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)}),i()])}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}},Q7s=u0S();if(!Q7s){let e=bLp();Q7s=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var r8p=Q7s,G0o=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()}},i8p=new G0o(async()=>{try{return await import("crypto")}catch{return}});async function f0S(){return await i8p.getValue()}var d0S=new G0o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await i8p.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function p0S(){return await d0S.getValue()}async function _0S(e){let t=await f0S();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await p0S();if(r){let i=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(i)).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 h0S=60*1e3,y0S=1152921504606847e3,b0S=["is_not"],hTn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},g1=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},U7s=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||r8p,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,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof g1?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let s=await this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let u=await this.computeFeatureFlagPayloadLocally(f.key,s);u&&(o[f.key]=u)}catch(s){s instanceof g1||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new g1("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let f=this.groupTypeMapping[String(c)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new g1("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return await this.matchFeatureFlagProperties(t,i[f],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],o=!1,c,f=[...a].sort((s,u)=>{let l=!!s.variant,p=!!u.variant;return l&&p?0:l?-1:p?1:0});for(let s of f)try{if(await this.isConditionMatch(t,r,s,i)){let u=s.variant,l=n.multivariate?.variants||[];u&&l.some(p=>p.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof g1)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new g1("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((i.properties||[]).length>0){for(let c of i.properties){let f=c.type,s=!1;if(f==="cohort"?s=a8p(c,n,this.cohorts,this.debugMode):s=n8p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await LLp(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await LLp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}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(h0S,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 hTn(`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 hTn(`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 hTn(`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((i,n)=>(i[n.key]=n,i),{}),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 hTn&&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(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=x0o(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=x0o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function LLp(e,t,r=""){let i=await _0S(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/y0S}function n8p(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new g1("Operator is_not_set is not supported")}else throw new g1(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!b0S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function f(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return VLp(String(n))&&String(o).match(String(n))!==null;case"not_regex":return VLp(String(n))&&String(o).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&o!=null?typeof o=="string"?f(o,String(n),a):f(o,s,a):f(String(o),String(n),a)}case"is_date_after":case"is_date_before":{let s=v0S(String(n));if(s==null&&(s=WLp(n)),s==null)throw new g1(`Invalid date: ${n}`);let u=WLp(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new g1(`Unknown operator: ${a}`)}}function a8p(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new g1("can't match cohort without a given cohort property value");let a=r[n];return o8p(a,t,r,i)}function o8p(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=o8p(c,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof g1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new g1("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=a8p(c,t,r,i):f=n8p(c,t);let s=c.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof g1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new g1("can't match cohort without a given cohort property value");return n==="AND"}}function VLp(e){try{return new RegExp(e),!0}catch{return!1}}function WLp(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 g1(`${e} is in an invalid date format`)}else throw new g1(`The date provided ${e} must be a string, number, or date object`)}function v0S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var L7s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},g0S=100,xLp=30*1e3,O0S=50*1e3,V7s=class extends F7s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new L7s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,g0S):xLp,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 U7s({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new yTn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||O0S}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):r8p(t,r)}getLibraryVersion(){return $mS}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:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>{super.captureStateless(r,i,_,{timestamp:c,disableGeoip:f,uuid:s})},l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags,p=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})});this.addPendingPromise(p)}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:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>super.captureStatelessImmediate(r,i,_,{timestamp:c,disableGeoip:f,uuid:s}),l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=xLp){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:s}=i||{},u=this.addLocalPersonAndGroupProperties(r,n,f,s);f=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),p=l!==void 0,_,h;if(!p&&!o){let b=await super.getFeatureFlagDetailStateless(t,r,n,f,s,a);if(b===void 0)return;h=b.response,l=G7s(h),_=b?.requestId}let y=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(y))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(y):this.distinctIdHasSentFlagCalls[r]=[y],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:h?.metadata?.id,$feature_flag_version:h?.metadata?.version,$feature_flag_reason:h?.reason?.description??h?.reason?.code,locally_evaluated:p,[`$feature/${t}`]:l,$feature_flag_request_id:_},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:o}=n||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:s,groupProperties:u}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=l.allGroupProperties;let p;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(p=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(p!==void 0)&&!c&&(p=await super.getFeatureFlagPayloadStateless(t,r,a,s,u,o)),p}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,o,c),u={},l={},p=!0;if(s&&(u=s.response,l=s.payloads,p=s.fallbackToDecide),p&&!a){let _=await super.getFeatureFlagsAndPayloadsStateless(t,i,o,c,n);u={...u,..._.flags||{}},l={...l,..._.payloads||{}}}return{featureFlags:u,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i){let n=new Error("PostHog syntheticException");yTn.captureException(this,t,{syntheticException:n},r,i)}},GLp=/\(error: (.*)\)/,u8p=50,s8p="?";function A0S(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,o,c,f,s;if(n[1]){c=n[1];let p=c.lastIndexOf(".");if(c[p-1]==="."&&p--,p>0){a=c.slice(0,p),o=c.slice(p+1);let _=a.indexOf(".Module");_>0&&(c=c.slice(_+1),a=a.slice(0,_))}f=void 0}o&&(f=a,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||s8p,c=f?`${f}.${s}`:s);let u=n[2]?.startsWith("file://")?n[2].slice(7):n[2],l=n[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&n[5]&&!l&&(u=n[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:HLp(n[3]),colno:HLp(n[4]),in_app:m0S(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function m0S(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 HLp(e){return parseInt(e||"",10)||void 0}function P0S(e){return[90,A0S(e)]}function j0S(e){let r=[P0S(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],o=i.split(`
1155
- `);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=GLp.test(f)?f.replace(GLp,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=u8p)break}}return w0S(a)}}function w0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,u8p).map(r=>({...r,filename:r.filename||E0S(t).filename,function:r.function||s8p}))}function E0S(e){return e[e.length-1]||{}}yTn.stackParser=j0S(zmS());yTn.frameModifiers=[QmS];var vTn=class extends V7s{getLibraryId(){return"posthog-node"}};var H0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new vTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"2.17.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var pOa=class{async sendEvent(){}async identify(){}async flush(){}};var OTn=require("fs/promises"),d8p=require("os"),p8p=require("path");var c8p=ae(require("crypto")),J0o=new Uint8Array(256),K0o=J0o.length;function H7s(){return K0o>J0o.length-16&&(c8p.default.randomFillSync(J0o),K0o=0),J0o.slice(K0o,K0o+=16)}var RQ=[];for(let e=0;e<256;++e)RQ.push((e+256).toString(16).slice(1));function l8p(e,t=0){return RQ[e[t+0]]+RQ[e[t+1]]+RQ[e[t+2]]+RQ[e[t+3]]+"-"+RQ[e[t+4]]+RQ[e[t+5]]+"-"+RQ[e[t+6]]+RQ[e[t+7]]+"-"+RQ[e[t+8]]+RQ[e[t+9]]+"-"+RQ[e[t+10]]+RQ[e[t+11]]+RQ[e[t+12]]+RQ[e[t+13]]+RQ[e[t+14]]+RQ[e[t+15]]}var f8p=ae(require("crypto")),K7s={randomUUID:f8p.default.randomUUID};function S0S(e,t,r){if(K7s.randomUUID&&!t&&!e)return K7s.randomUUID();e=e||{};let i=e.random||(e.rng||H7s)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return l8p(i)}var ehe=S0S;var M0S="id",D0S=".fern",_Oa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new vTn(r),this.userId=t==null?void 0:_8s(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:"2.17.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ft(Lr.of((0,d8p.homedir)()),Ze.of(D0S),Ze.of(M0S));await Ri(t)||(await(0,OTn.mkdir)((0,p8p.dirname)(t),{recursive:!0}),await(0,OTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,OTn.readFile)(t)).toString()}return this.persistedDistinctId}};var J7s;async function ATn(){return J7s==null&&(J7s=await B0S()),J7s}async function B0S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new pOa;let r=await fbo();return r!=null?new _Oa({token:r,posthogApiKey:e}):await jqn()!=null?new H0o({posthogApiKey:e}):new _Oa({token:void 0,posthogApiKey:e})}catch{return new pOa}}function hOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:I0S}=Object.prototype,{getPrototypeOf:Y7s}=Object,{iterator:Y0o,toStringTag:h8p}=Symbol,X0o=(e=>t=>{let r=I0S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>X0o(t)===e),Z0o=e=>t=>typeof t===e,{isArray:PTn}=Array,mTn=Z0o("undefined");function yOa(e){return e!==null&&!mTn(e)&&e.constructor!==null&&!mTn(e.constructor)&&I6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var y8p=NNt("ArrayBuffer");function C0S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&y8p(e.buffer),t}var q0S=Z0o("string"),I6=Z0o("function"),b8p=Z0o("number"),bOa=e=>e!==null&&typeof e=="object",T0S=e=>e===!0||e===!1,$0o=e=>{if(X0o(e)!=="object")return!1;let t=Y7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(h8p in e)&&!(Y0o in e)},R0S=e=>{if(!bOa(e)||yOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},z0S=NNt("Date"),N0S=NNt("File"),F0S=NNt("Blob"),Q0S=NNt("FileList"),U0S=e=>bOa(e)&&I6(e.pipe),L0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||I6(e.append)&&((t=X0o(e))==="formdata"||t==="object"&&I6(e.toString)&&e.toString()==="[object FormData]"))},V0S=NNt("URLSearchParams"),[W0S,x0S,G0S,H0S]=["ReadableStream","Request","Response","Headers"].map(NNt),K0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function vOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),PTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(yOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function v8p(e,t){if(yOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var t6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,g8p=e=>!mTn(e)&&e!==t6i;function $7s(){let{caseless:e,skipUndefined:t}=g8p(this)&&this||{},r={},i=(n,a)=>{let o=e&&v8p(r,a)||a;$0o(r[o])&&$0o(n)?r[o]=$7s(r[o],n):$0o(n)?r[o]=$7s({},n):PTn(n)?r[o]=n.slice():(!t||!mTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&vOa(arguments[n],i);return r}var J0S=(e,t,r,{allOwnKeys:i}={})=>(vOa(t,(n,a)=>{r&&I6(n)?e[a]=hOa(n,r):e[a]=n},{allOwnKeys:i}),e),$0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Y0S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},X0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&Y7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Z0S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},k0S=e=>{if(!e)return null;if(PTn(e))return e;let t=e.length;if(!b8p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ePS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Y7s(Uint8Array)),tPS=(e,t)=>{let i=(e&&e[Y0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},rPS=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},iPS=NNt("HTMLFormElement"),nPS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),_8p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),aPS=NNt("RegExp"),O8p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};vOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},oPS=e=>{O8p(e,(t,r)=>{if(I6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(I6(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},uPS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return PTn(e)?i(e):i(String(e).split(t)),r},sPS=()=>{},cPS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lPS(e){return!!(e&&I6(e.append)&&e[h8p]==="FormData"&&e[Y0o])}var fPS=e=>{let t=new Array(10),r=(i,n)=>{if(bOa(i)){if(t.indexOf(i)>=0)return;if(yOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=PTn(i)?[]:{};return vOa(i,(o,c)=>{let f=r(o,n+1);!mTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},dPS=NNt("AsyncFunction"),pPS=e=>e&&(bOa(e)||I6(e))&&I6(e.then)&&I6(e.catch),A8p=((e,t)=>e?setImmediate:t?((r,i)=>(t6i.addEventListener("message",({source:n,data:a})=>{n===t6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),t6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",I6(t6i.postMessage)),_PS=typeof queueMicrotask<"u"?queueMicrotask.bind(t6i):typeof process<"u"&&process.nextTick||A8p,hPS=e=>e!=null&&I6(e[Y0o]),kt={isArray:PTn,isArrayBuffer:y8p,isBuffer:yOa,isFormData:L0S,isArrayBufferView:C0S,isString:q0S,isNumber:b8p,isBoolean:T0S,isObject:bOa,isPlainObject:$0o,isEmptyObject:R0S,isReadableStream:W0S,isRequest:x0S,isResponse:G0S,isHeaders:H0S,isUndefined:mTn,isDate:z0S,isFile:N0S,isBlob:F0S,isRegExp:aPS,isFunction:I6,isStream:U0S,isURLSearchParams:V0S,isTypedArray:ePS,isFileList:Q0S,forEach:vOa,merge:$7s,extend:J0S,trim:K0S,stripBOM:$0S,inherits:Y0S,toFlatObject:X0S,kindOf:X0o,kindOfTest:NNt,endsWith:Z0S,toArray:k0S,forEachEntry:tPS,matchAll:rPS,isHTMLForm:iPS,hasOwnProperty:_8p,hasOwnProp:_8p,reduceDescriptors:O8p,freezeMethods:oPS,toObjectSet:uPS,toCamelCase:nPS,noop:sPS,toFiniteNumber:cPS,findKey:v8p,global:t6i,isContextDefined:g8p,isSpecCompliantForm:lPS,toJSONObject:fPS,isAsyncFn:dPS,isThenable:pPS,setImmediate:A8p,asap:_PS,isIterable:hPS};function jTn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}kt.inherits(jTn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var m8p=jTn.prototype,P8p={};["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=>{P8p[e]={value:e}});Object.defineProperties(jTn,P8p);Object.defineProperty(m8p,"isAxiosError",{value:!0});jTn.from=(e,t,r,i,n,a)=>{let o=Object.create(m8p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return jTn.call(o,c,f,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var ya=jTn;var j8p=ae(Q7i(),1),k0o=j8p.default;function X7s(e){return kt.isPlainObject(e)||kt.isArray(e)}function E8p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function w8p(e,t,r){return e?e.concat(t).map(function(n,a){return n=E8p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function yPS(e){return kt.isArray(e)&&!e.some(X7s)}var bPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function vPS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(k0o||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&yPS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=E8p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?w8p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return X7s(h)?!0:(t.append(w8p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(bPS,{defaultVisitor:u,convertValue:s,isVisitable:X7s});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var NBi=vPS;function S8p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function M8p(e,t){this._pairs=[],e&&NBi(e,this,t)}var D8p=M8p.prototype;D8p.append=function(t,r){this._pairs.push([t,r])};D8p.toString=function(t){let r=t?function(i){return t.call(this,i,S8p)}:S8p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var B8p=M8p;function gPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function r6i(e,t,r){if(!t)return e;let i=r&&r.encode||gPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new B8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Z7s=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},k7s=Z7s;var wTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var T8p=ae(require("crypto"),1);var I8p=ae(require("url"),1),C8p=I8p.default.URLSearchParams;var eHs="abcdefghijklmnopqrstuvwxyz",q8p="0123456789",R8p={DIGIT:q8p,ALPHA:eHs,ALPHA_DIGIT:eHs+eHs.toUpperCase()+q8p},OPS=(e=16,t=R8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);T8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},z8p={isNode:!0,classes:{URLSearchParams:C8p,FormData:k0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:R8p,generateString:OPS,protocols:["http","https","file","data"]};var iHs={};Kt(iHs,{hasBrowserEnv:()=>rHs,hasStandardBrowserEnv:()=>APS,hasStandardBrowserWebWorkerEnv:()=>mPS,navigator:()=>tHs,origin:()=>PPS});var rHs=typeof window<"u"&&typeof document<"u",tHs=typeof navigator=="object"&&navigator||void 0,APS=rHs&&(!tHs||["ReactNative","NativeScript","NS"].indexOf(tHs.product)<0),mPS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",PPS=rHs&&window.location.href||"http://localhost";var OA={...iHs,...z8p};function nHs(e,t){return NBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function jPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function wPS(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function EPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=wPS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(jPS(i),n,r,0)}),r}return null}var ePo=EPS;function SPS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var aHs={transitional:wTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(ePo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return nHs(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return NBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),SPS(t)):t}],transformResponse:[function(t){let r=this.transitional||aHs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.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:OA.classes.FormData,Blob:OA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{aHs.headers[e]={}});var ETn=aHs;var MPS=kt.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"]),N8p=e=>{let t={},r,i,n;return e&&e.split(`
1155
+ `);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=GLp.test(f)?f.replace(GLp,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=u8p)break}}return w0S(a)}}function w0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,u8p).map(r=>({...r,filename:r.filename||E0S(t).filename,function:r.function||s8p}))}function E0S(e){return e[e.length-1]||{}}yTn.stackParser=j0S(zmS());yTn.frameModifiers=[QmS];var vTn=class extends V7s{getLibraryId(){return"posthog-node"}};var H0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new vTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"2.17.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var pOa=class{async sendEvent(){}async identify(){}async flush(){}};var OTn=require("fs/promises"),d8p=require("os"),p8p=require("path");var c8p=ae(require("crypto")),J0o=new Uint8Array(256),K0o=J0o.length;function H7s(){return K0o>J0o.length-16&&(c8p.default.randomFillSync(J0o),K0o=0),J0o.slice(K0o,K0o+=16)}var RQ=[];for(let e=0;e<256;++e)RQ.push((e+256).toString(16).slice(1));function l8p(e,t=0){return RQ[e[t+0]]+RQ[e[t+1]]+RQ[e[t+2]]+RQ[e[t+3]]+"-"+RQ[e[t+4]]+RQ[e[t+5]]+"-"+RQ[e[t+6]]+RQ[e[t+7]]+"-"+RQ[e[t+8]]+RQ[e[t+9]]+"-"+RQ[e[t+10]]+RQ[e[t+11]]+RQ[e[t+12]]+RQ[e[t+13]]+RQ[e[t+14]]+RQ[e[t+15]]}var f8p=ae(require("crypto")),K7s={randomUUID:f8p.default.randomUUID};function S0S(e,t,r){if(K7s.randomUUID&&!t&&!e)return K7s.randomUUID();e=e||{};let i=e.random||(e.rng||H7s)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return l8p(i)}var ehe=S0S;var M0S="id",D0S=".fern",_Oa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new vTn(r),this.userId=t==null?void 0:_8s(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:"2.17.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ft(Lr.of((0,d8p.homedir)()),Ze.of(D0S),Ze.of(M0S));await Ri(t)||(await(0,OTn.mkdir)((0,p8p.dirname)(t),{recursive:!0}),await(0,OTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,OTn.readFile)(t)).toString()}return this.persistedDistinctId}};var J7s;async function ATn(){return J7s==null&&(J7s=await B0S()),J7s}async function B0S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new pOa;let r=await fbo();return r!=null?new _Oa({token:r,posthogApiKey:e}):await jqn()!=null?new H0o({posthogApiKey:e}):new _Oa({token:void 0,posthogApiKey:e})}catch{return new pOa}}function hOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:I0S}=Object.prototype,{getPrototypeOf:Y7s}=Object,{iterator:Y0o,toStringTag:h8p}=Symbol,X0o=(e=>t=>{let r=I0S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>X0o(t)===e),Z0o=e=>t=>typeof t===e,{isArray:PTn}=Array,mTn=Z0o("undefined");function yOa(e){return e!==null&&!mTn(e)&&e.constructor!==null&&!mTn(e.constructor)&&I6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var y8p=NNt("ArrayBuffer");function C0S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&y8p(e.buffer),t}var q0S=Z0o("string"),I6=Z0o("function"),b8p=Z0o("number"),bOa=e=>e!==null&&typeof e=="object",T0S=e=>e===!0||e===!1,$0o=e=>{if(X0o(e)!=="object")return!1;let t=Y7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(h8p in e)&&!(Y0o in e)},R0S=e=>{if(!bOa(e)||yOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},z0S=NNt("Date"),N0S=NNt("File"),F0S=NNt("Blob"),Q0S=NNt("FileList"),U0S=e=>bOa(e)&&I6(e.pipe),L0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||I6(e.append)&&((t=X0o(e))==="formdata"||t==="object"&&I6(e.toString)&&e.toString()==="[object FormData]"))},V0S=NNt("URLSearchParams"),[W0S,x0S,G0S,H0S]=["ReadableStream","Request","Response","Headers"].map(NNt),K0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function vOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),PTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(yOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function v8p(e,t){if(yOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var t6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,g8p=e=>!mTn(e)&&e!==t6i;function $7s(){let{caseless:e,skipUndefined:t}=g8p(this)&&this||{},r={},i=(n,a)=>{let o=e&&v8p(r,a)||a;$0o(r[o])&&$0o(n)?r[o]=$7s(r[o],n):$0o(n)?r[o]=$7s({},n):PTn(n)?r[o]=n.slice():(!t||!mTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&vOa(arguments[n],i);return r}var J0S=(e,t,r,{allOwnKeys:i}={})=>(vOa(t,(n,a)=>{r&&I6(n)?e[a]=hOa(n,r):e[a]=n},{allOwnKeys:i}),e),$0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Y0S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},X0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&Y7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Z0S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},k0S=e=>{if(!e)return null;if(PTn(e))return e;let t=e.length;if(!b8p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},ePS=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Y7s(Uint8Array)),tPS=(e,t)=>{let i=(e&&e[Y0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},rPS=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},iPS=NNt("HTMLFormElement"),nPS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),_8p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),aPS=NNt("RegExp"),O8p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};vOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},oPS=e=>{O8p(e,(t,r)=>{if(I6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(I6(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},uPS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return PTn(e)?i(e):i(String(e).split(t)),r},sPS=()=>{},cPS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function lPS(e){return!!(e&&I6(e.append)&&e[h8p]==="FormData"&&e[Y0o])}var fPS=e=>{let t=new Array(10),r=(i,n)=>{if(bOa(i)){if(t.indexOf(i)>=0)return;if(yOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=PTn(i)?[]:{};return vOa(i,(o,c)=>{let f=r(o,n+1);!mTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},dPS=NNt("AsyncFunction"),pPS=e=>e&&(bOa(e)||I6(e))&&I6(e.then)&&I6(e.catch),A8p=((e,t)=>e?setImmediate:t?((r,i)=>(t6i.addEventListener("message",({source:n,data:a})=>{n===t6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),t6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",I6(t6i.postMessage)),_PS=typeof queueMicrotask<"u"?queueMicrotask.bind(t6i):typeof process<"u"&&process.nextTick||A8p,hPS=e=>e!=null&&I6(e[Y0o]),kt={isArray:PTn,isArrayBuffer:y8p,isBuffer:yOa,isFormData:L0S,isArrayBufferView:C0S,isString:q0S,isNumber:b8p,isBoolean:T0S,isObject:bOa,isPlainObject:$0o,isEmptyObject:R0S,isReadableStream:W0S,isRequest:x0S,isResponse:G0S,isHeaders:H0S,isUndefined:mTn,isDate:z0S,isFile:N0S,isBlob:F0S,isRegExp:aPS,isFunction:I6,isStream:U0S,isURLSearchParams:V0S,isTypedArray:ePS,isFileList:Q0S,forEach:vOa,merge:$7s,extend:J0S,trim:K0S,stripBOM:$0S,inherits:Y0S,toFlatObject:X0S,kindOf:X0o,kindOfTest:NNt,endsWith:Z0S,toArray:k0S,forEachEntry:tPS,matchAll:rPS,isHTMLForm:iPS,hasOwnProperty:_8p,hasOwnProp:_8p,reduceDescriptors:O8p,freezeMethods:oPS,toObjectSet:uPS,toCamelCase:nPS,noop:sPS,toFiniteNumber:cPS,findKey:v8p,global:t6i,isContextDefined:g8p,isSpecCompliantForm:lPS,toJSONObject:fPS,isAsyncFn:dPS,isThenable:pPS,setImmediate:A8p,asap:_PS,isIterable:hPS};function jTn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}kt.inherits(jTn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var m8p=jTn.prototype,P8p={};["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=>{P8p[e]={value:e}});Object.defineProperties(jTn,P8p);Object.defineProperty(m8p,"isAxiosError",{value:!0});jTn.from=(e,t,r,i,n,a)=>{let o=Object.create(m8p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return jTn.call(o,c,f,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var ya=jTn;var j8p=ae(Q7i(),1),k0o=j8p.default;function X7s(e){return kt.isPlainObject(e)||kt.isArray(e)}function E8p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function w8p(e,t,r){return e?e.concat(t).map(function(n,a){return n=E8p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function yPS(e){return kt.isArray(e)&&!e.some(X7s)}var bPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function vPS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(k0o||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&yPS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=E8p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?w8p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return X7s(h)?!0:(t.append(w8p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(bPS,{defaultVisitor:u,convertValue:s,isVisitable:X7s});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var NBi=vPS;function S8p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function M8p(e,t){this._pairs=[],e&&NBi(e,this,t)}var D8p=M8p.prototype;D8p.append=function(t,r){this._pairs.push([t,r])};D8p.toString=function(t){let r=t?function(i){return t.call(this,i,S8p)}:S8p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var B8p=M8p;function gPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function r6i(e,t,r){if(!t)return e;let i=r&&r.encode||gPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new B8p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Z7s=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},k7s=Z7s;var wTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var T8p=ae(require("crypto"),1);var I8p=ae(require("url"),1),C8p=I8p.default.URLSearchParams;var eHs="abcdefghijklmnopqrstuvwxyz",q8p="0123456789",R8p={DIGIT:q8p,ALPHA:eHs,ALPHA_DIGIT:eHs+eHs.toUpperCase()+q8p},OPS=(e=16,t=R8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);T8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},z8p={isNode:!0,classes:{URLSearchParams:C8p,FormData:k0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:R8p,generateString:OPS,protocols:["http","https","file","data"]};var iHs={};Kt(iHs,{hasBrowserEnv:()=>rHs,hasStandardBrowserEnv:()=>APS,hasStandardBrowserWebWorkerEnv:()=>mPS,navigator:()=>tHs,origin:()=>PPS});var rHs=typeof window<"u"&&typeof document<"u",tHs=typeof navigator=="object"&&navigator||void 0,APS=rHs&&(!tHs||["ReactNative","NativeScript","NS"].indexOf(tHs.product)<0),mPS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",PPS=rHs&&window.location.href||"http://localhost";var OA={...iHs,...z8p};function nHs(e,t){return NBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function jPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function wPS(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function EPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=wPS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(jPS(i),n,r,0)}),r}return null}var ePo=EPS;function SPS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var aHs={transitional:wTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(ePo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return nHs(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return NBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),SPS(t)):t}],transformResponse:[function(t){let r=this.transitional||aHs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.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:OA.classes.FormData,Blob:OA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{aHs.headers[e]={}});var ETn=aHs;var MPS=kt.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"]),N8p=e=>{let t={},r,i,n;return e&&e.split(`
1156
1156
  `).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&MPS[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var F8p=Symbol("internals");function gOa(e){return e&&String(e).trim().toLowerCase()}function tPo(e){return e===!1||e==null?e:kt.isArray(e)?e.map(tPo):String(e)}function DPS(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var BPS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function oHs(e,t,r,i,n){if(kt.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!kt.isString(t)){if(kt.isString(i))return t.indexOf(i)!==-1;if(kt.isRegExp(i))return i.test(t)}}function IPS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function CPS(e,t){let r=kt.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,o){return this[i].call(this,t,n,a,o)},configurable:!0})})}var STn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=gOa(f);if(!u)throw new Error("header name must be a non-empty string");let l=kt.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||f]=tPo(c))}let o=(c,f)=>kt.forEach(c,(s,u)=>a(s,u,f));if(kt.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(kt.isString(t)&&(t=t.trim())&&!BPS(t))o(N8p(t),r);else if(kt.isObject(t)&&kt.isIterable(t)){let c={},f,s;for(let u of t){if(!kt.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(f=c[s])?kt.isArray(f)?[...f,u[1]]:[f,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=gOa(t),t){let i=kt.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return DPS(n);if(kt.isFunction(r))return r.call(this,n,i);if(kt.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=gOa(t),t){let i=kt.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||oHs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=gOa(o),o){let c=kt.findKey(i,o);c&&(!r||oHs(i,i[c],c,r))&&(delete i[c],n=!0)}}return kt.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||oHs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return kt.forEach(this,(n,a)=>{let o=kt.findKey(i,a);if(o){r[o]=tPo(n),delete r[a];return}let c=t?IPS(a):String(a).trim();c!==a&&delete r[a],r[c]=tPo(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return kt.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&kt.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
1157
1157
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[F8p]=this[F8p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=gOa(o);i[c]||(CPS(n,o),i[c]=!0)}return kt.isArray(t)?t.forEach(a):a(t),this}};STn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);kt.reduceDescriptors(STn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});kt.freezeMethods(STn);var US=STn;function OOa(e,t){let r=this||ETn,i=t||r,n=US.from(i.headers),a=i.data;return kt.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function AOa(e){return!!(e&&e.__CANCEL__)}function Q8p(e,t,r){ya.call(this,e??"canceled",ya.ERR_CANCELED,t,r),this.name="CanceledError"}kt.inherits(Q8p,ya,{__CANCEL__:!0});var the=Q8p;function u9t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new ya("Request failed with status code "+r.status,[ya.ERR_BAD_REQUEST,ya.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function uHs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function sHs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function i6i(e,t,r){let i=!uHs(t);return e&&(i||r==!1)?sHs(e,t):t}var tVp=ae(m0o(),1),rVp=ae(require("http"),1),iVp=ae(require("https"),1),nVp=ae(require("util"),1),aVp=ae(c7s(),1),Hbi=ae(require("zlib"),1);var n6i="1.12.2";function mOa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var qPS=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function cHs(e,t,r){let i=r&&r.Blob||OA.classes.Blob,n=mOa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=qPS.exec(e);if(!a)throw new ya("Invalid URL",ya.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!i)throw new ya("Blob is not supported",ya.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new ya("Unsupported protocol "+n,ya.ERR_NOT_SUPPORT)}var o6i=ae(require("stream"),1);var U8p=ae(require("stream"),1);var lHs=Symbol("internals"),fHs=class extends U8p.default.Transform{constructor(t){t=kt.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!kt.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[lHs]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[lHs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[lHs],a=n.maxRate,o=this.readableHighWaterMark,c=n.timeWindow,f=1e3/c,s=a/f,u=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(_,h)=>{let y=Buffer.byteLength(_);n.bytesSeen+=y,n.bytes+=y,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(_)?process.nextTick(h):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(h)}},p=(_,h)=>{let y=Buffer.byteLength(_),b=null,v=o,O,A=0;if(a){let g=Date.now();(!n.ts||(A=g-n.ts)>=c)&&(n.ts=g,O=s-n.bytes,n.bytes=O<0?-O:0,A=0),O=s-n.bytes}if(a){if(O<=0)return setTimeout(()=>{h(null,_)},c-A);O<v&&(v=O)}v&&y>v&&y-v>u&&(b=_.subarray(v),_=_.subarray(0,v)),l(_,b?()=>{process.nextTick(h,null,b)}:h)};p(t,function _(h,y){if(h)return i(h);y?p(y,_):i(null)})}},dHs=fHs;var oVp=require("events");var V8p=ae(require("util"),1),W8p=require("stream");var{asyncIterator:L8p}=Symbol,TPS=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[L8p]?yield*e[L8p]():yield e},rPo=TPS;var RPS=OA.ALPHABET.ALPHA_DIGIT+"-_",POa=typeof TextEncoder=="function"?new TextEncoder:new V8p.default.TextEncoder,a6i=`\r
1158
1158
  `,zPS=POa.encode(a6i),NPS=2,pHs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=kt.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${a6i}`;n?r=POa.encode(String(r).replace(/\r?\n|\r\n?/g,a6i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${a6i}`,this.headers=POa.encode(a+a6i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+NPS,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;kt.isTypedArray(t)?yield t:yield*rPo(t),yield zPS}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},FPS=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+OA.generateString(n,RPS)}=r||{};if(!kt.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=POa.encode("--"+a+a6i),c=POa.encode("--"+a+"--"+a6i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new pHs(l,p);return f+=_.size,_});f+=o.byteLength*s.length,f=kt.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(u["Content-Length"]=f),t&&t(u),W8p.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},x8p=FPS;var G8p=ae(require("stream"),1),_Hs=class extends G8p.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},H8p=_Hs;var QPS=(e,t)=>kt.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,K8p=QPS;function UPS(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),u=i[a];o||(o=s),r[n]=f,i[n]=s;let l=a,p=0;for(;l!==n;)p+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-o<t)return;let _=u&&s-u;return _?Math.round(p*1e3/_):void 0}}var J8p=UPS;function LPS(e,t){let r=0,i=1e3/t,n,a,o=(s,u=Date.now())=>{r=u,n=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=i?o(s,u):(n=s,a||(a=setTimeout(()=>{a=null,o(n)},i-l)))},()=>n&&o(n)]}var $8p=LPS;var Gbi=(e,t,r=3)=>{let i=0,n=J8p(50,250);return $8p(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-i,s=n(f),u=o<=c;i=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,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)},MTn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},DTn=e=>(...t)=>kt.asap(()=>e(...t));function hHs(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),i=e.slice(t+1);if(/;base64/i.test(r)){let a=i.length,o=i.length;for(let p=0;p<o;p++)if(i.charCodeAt(p)===37&&p+2<o){let _=i.charCodeAt(p+1),h=i.charCodeAt(p+2);(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)&&(h>=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102)&&(a-=2,p+=2)}let c=0,f=o-1,s=p=>p>=2&&i.charCodeAt(p-2)===37&&i.charCodeAt(p-1)===51&&(i.charCodeAt(p)===68||i.charCodeAt(p)===100);f>=0&&(i.charCodeAt(f)===61?(c++,f--):s(f)&&(c++,f-=3)),c===1&&f>=0&&(i.charCodeAt(f)===61||s(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(i,"utf8")}var Y8p={flush:Hbi.default.constants.Z_SYNC_FLUSH,finishFlush:Hbi.default.constants.Z_SYNC_FLUSH},VPS={flush:Hbi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Hbi.default.constants.BROTLI_OPERATION_FLUSH},X8p=kt.isFunction(Hbi.default.createBrotliDecompress),{http:WPS,https:xPS}=aVp.default,GPS=/https:?/,Z8p=OA.protocols.map(e=>e+":"),k8p=(e,[t,r])=>(e.on("end",r).on("error",r),t);function HPS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function uVp(e,t,r){let i=t;if(!i&&i!==!1){let n=tVp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){uVp(a,t,a.href)}}var KPS=typeof process<"u"&&kt.kindOf(process)==="process",JPS=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>i=f).catch(c)}),$PS=({address:e,family:t})=>{if(!kt.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},eVp=(e,t)=>$PS(kt.isObject(e)?e:{address:e,family:t}),sVp=KPS&&function(t){return JPS(async function(i,n,a){let{data:o,lookup:c,family:f}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),p,_=!1,h;if(c){let H=K8p(c,oe=>kt.isArray(oe)?oe:[oe]);c=(oe,se,x)=>{H(oe,se,(G,Pe,ne)=>{if(G)return x(G);let Ee=kt.isArray(Pe)?Pe.map(Qe=>eVp(Qe)):[eVp(Pe,ne)];se.all?x(G,Ee):x(G,Ee[0].address,Ee[0].family)})}}let y=new oVp.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((H,oe)=>{p=!0,oe&&(_=!0,b())});function v(H){y.emit("abort",!H||H.type?new the(null,t,h):H)}y.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(v),t.signal&&(t.signal.aborted?v():t.signal.addEventListener("abort",v)));let O=i6i(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,OA.hasBrowserEnv?OA.origin:void 0),g=A.protocol||Z8p[0];if(g==="data:"){if(t.maxContentLength>-1){let oe=String(t.url||O||"");if(hHs(oe)>t.maxContentLength)return n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t))}let H;if(l!=="GET")return u9t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{H=cHs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(oe){throw ya.from(oe,ya.ERR_BAD_REQUEST,t)}return s==="text"?(H=H.toString(u),(!u||u==="utf8")&&(H=kt.stripBOM(H))):s==="stream"&&(H=o6i.default.Readable.from(H)),u9t(i,n,{data:H,status:200,statusText:"OK",headers:new US,config:t})}if(Z8p.indexOf(g)===-1)return n(new ya("Unsupported protocol "+g,ya.ERR_BAD_REQUEST,t));let m=US.from(t.headers).normalize();m.set("User-Agent","axios/"+n6i,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,E=t.maxRate,D,B;if(kt.isSpecCompliantForm(o)){let H=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=x8p(o,oe=>{m.set(oe)},{tag:`axios-${n6i}-boundary`,boundary:H&&H[1]||void 0})}else if(kt.isFormData(o)&&kt.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let H=await nVp.default.promisify(o.getLength).call(o);Number.isFinite(H)&&H>=0&&m.setContentLength(H)}catch{}}else if(kt.isBlob(o)||kt.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=o6i.default.Readable.from(rPo(o));else if(o&&!kt.isStream(o)){if(!Buffer.isBuffer(o))if(kt.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(kt.isString(o))o=Buffer.from(o,"utf-8");else return n(new ya("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ya.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new ya("Request body larger than maxBodyLength limit",ya.ERR_BAD_REQUEST,t))}let F=kt.toFiniteNumber(m.getContentLength());kt.isArray(E)?(D=E[0],B=E[1]):D=B=E,o&&(j||D)&&(kt.isStream(o)||(o=o6i.default.Readable.from(o,{objectMode:!1})),o=o6i.default.pipeline([o,new dHs({maxRate:kt.toFiniteNumber(D)})],kt.noop),j&&o.on("progress",k8p(o,MTn(F,Gbi(DTn(j),!1,3)))));let N;if(t.auth){let H=t.auth.username||"",oe=t.auth.password||"";N=H+":"+oe}if(!N&&A.username){let H=A.username,oe=A.password;N=H+":"+oe}N&&m.delete("authorization");let T;try{T=r6i(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(H){let oe=new Error(H.message);return oe.config=t,oe.url=t.url,oe.exists=!0,n(oe)}m.set("Accept-Encoding","gzip, compress, deflate"+(X8p?", br":""),!1);let R={path:T,method:l,headers:m.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:N,protocol:g,family:f,beforeRedirect:HPS,beforeRedirects:{}};!kt.isUndefined(c)&&(R.lookup=c),t.socketPath?R.socketPath=t.socketPath:(R.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,R.port=A.port,uVp(R,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+R.path));let Q,U=GPS.test(R.protocol);if(R.agent=U?t.httpsAgent:t.httpAgent,t.transport?Q=t.transport:t.maxRedirects===0?Q=U?iVp.default:rVp.default:(t.maxRedirects&&(R.maxRedirects=t.maxRedirects),t.beforeRedirect&&(R.beforeRedirects.config=t.beforeRedirect),Q=U?xPS:WPS),t.maxBodyLength>-1?R.maxBodyLength=t.maxBodyLength:R.maxBodyLength=1/0,t.insecureHTTPParser&&(R.insecureHTTPParser=t.insecureHTTPParser),h=Q.request(R,function(oe){if(h.destroyed)return;let se=[oe],x=+oe.headers["content-length"];if(M||B){let Qe=new dHs({maxRate:kt.toFiniteNumber(B)});M&&Qe.on("progress",k8p(Qe,MTn(x,Gbi(DTn(M),!0,3)))),se.push(Qe)}let G=oe,Pe=oe.req||h;if(t.decompress!==!1&&oe.headers["content-encoding"])switch((l==="HEAD"||oe.statusCode===204)&&delete oe.headers["content-encoding"],(oe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":se.push(Hbi.default.createUnzip(Y8p)),delete oe.headers["content-encoding"];break;case"deflate":se.push(new H8p),se.push(Hbi.default.createUnzip(Y8p)),delete oe.headers["content-encoding"];break;case"br":X8p&&(se.push(Hbi.default.createBrotliDecompress(VPS)),delete oe.headers["content-encoding"])}G=se.length>1?o6i.default.pipeline(se,kt.noop):se[0];let ne=o6i.default.finished(G,()=>{ne(),b()}),Ee={status:oe.statusCode,statusText:oe.statusMessage,headers:new US(oe.headers),config:t,request:Pe};if(s==="stream")Ee.data=G,u9t(i,n,Ee);else{let Qe=[],re=0;G.on("data",function(Ve){Qe.push(Ve),re+=Ve.length,t.maxContentLength>-1&&re>t.maxContentLength&&(_=!0,G.destroy(),n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t,Pe)))}),G.on("aborted",function(){if(_)return;let Ve=new ya("stream has been aborted",ya.ERR_BAD_RESPONSE,t,Pe);G.destroy(Ve),n(Ve)}),G.on("error",function(Ve){h.destroyed||n(ya.from(Ve,null,t,Pe))}),G.on("end",function(){try{let Ve=Qe.length===1?Qe[0]:Buffer.concat(Qe);s!=="arraybuffer"&&(Ve=Ve.toString(u),(!u||u==="utf8")&&(Ve=kt.stripBOM(Ve))),Ee.data=Ve}catch(Ve){return n(ya.from(Ve,null,t,Ee.request,Ee))}u9t(i,n,Ee)})}y.once("abort",Qe=>{G.destroyed||(G.emit("error",Qe),G.destroy())})}),y.once("abort",H=>{n(H),h.destroy(H)}),h.on("error",function(oe){n(ya.from(oe,null,t,h))}),h.on("socket",function(oe){oe.setKeepAlive(!0,1e3*60)}),t.timeout){let H=parseInt(t.timeout,10);if(Number.isNaN(H)){n(new ya("error trying to parse `config.timeout` to int",ya.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(H,function(){if(p)return;let se=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",x=t.transitional||wTn;t.timeoutErrorMessage&&(se=t.timeoutErrorMessage),n(new ya(se,x.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,t,h)),v()})}if(kt.isStream(o)){let H=!1,oe=!1;o.on("end",()=>{H=!0}),o.once("error",se=>{oe=!0,h.destroy(se)}),o.on("close",()=>{!H&&!oe&&v(new the("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var cVp=OA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,OA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(OA.origin),OA.navigator&&/(msie|trident)/i.test(OA.navigator.userAgent)):()=>!0;var lVp=OA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];kt.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),kt.isString(i)&&o.push("path="+i),kt.isString(n)&&o.push("domain="+n),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var fVp=e=>e instanceof US?{...e}:e;function FNt(e,t){t=t||{};let r={};function i(s,u,l,p){return kt.isPlainObject(s)&&kt.isPlainObject(u)?kt.merge.call({caseless:p},s,u):kt.isPlainObject(u)?kt.merge({},u):kt.isArray(u)?u.slice():u}function n(s,u,l,p){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!kt.isUndefined(u))return i(void 0,u)}function o(s,u){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s)}else return i(void 0,u)}function c(s,u,l){if(l in t)return i(s,u);if(l in e)return i(void 0,s)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>n(fVp(s),fVp(u),l,!0)};return kt.forEach(Object.keys({...e,...t}),function(u){let l=f[u]||n,p=l(e[u],t[u],u);kt.isUndefined(p)&&l!==c||(r[u]=p)}),r}var iPo=e=>{let t=FNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=US.from(o),t.url=r6i(i6i(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),kt.isFormData(r)){if(OA.hasStandardBrowserEnv||OA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(kt.isFunction(r.getHeaders)){let f=r.getHeaders(),s=["content-type","content-length"];Object.entries(f).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(OA.hasStandardBrowserEnv&&(i&&kt.isFunction(i)&&(i=i(t)),i||i!==!1&&cVp(t.url))){let f=n&&a&&lVp.read(a);f&&o.set(n,f)}return t};var YPS=typeof XMLHttpRequest<"u",dVp=YPS&&function(e){return new Promise(function(r,i){let n=iPo(e),a=n.data,o=US.from(n.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:s}=n,u,l,p,_,h;function y(){_&&_(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function v(){if(!b)return;let A=US.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:A,config:e,request:b};u9t(function(M){r(M),y()},function(M){i(M),y()},m),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(i(new ya("Request aborted",ya.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new ya(m,ya.ERR_NETWORK,e,b);j.event=g||null,i(j),b=null},b.ontimeout=function(){let g=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",m=n.transitional||wTn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new ya(g,m.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&kt.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),kt.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=Gbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Gbi(f),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new the(null,e,b):A),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=mOa(n.url);if(O&&OA.protocols.indexOf(O)===-1){i(new ya("Unsupported protocol "+O+":",ya.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var XPS=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,c();let u=s instanceof Error?s:this.reason;i.abort(u instanceof ya?u:new the(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new ya(`timeout ${t} of ms exceeded`,ya.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:f}=i;return f.unsubscribe=()=>kt.asap(c),f}},pVp=XPS;var ZPS=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},kPS=async function*(e,t){for await(let r of ejS(e))yield*ZPS(r,t)},ejS=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},yHs=(e,t,r,i)=>{let n=kPS(e,t),a=0,o,c=f=>{o||(o=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:u}=await n.next();if(s){c(),f.close();return}let l=u.byteLength;if(r){let p=a+=l;r(p)}f.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(f){return c(f),n.return()}},{highWaterMark:2})};var _Vp=64*1024,{isFunction:nPo}=kt,tjS=(({Request:e,Response:t})=>({Request:e,Response:t}))(kt.global),{ReadableStream:hVp,TextEncoder:yVp}=kt.global,bVp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},rjS=e=>{e=kt.merge.call({skipUndefined:!0},tjS,e);let{fetch:t,Request:r,Response:i}=e,n=t?nPo(t):typeof fetch=="function",a=nPo(r),o=nPo(i);if(!n)return!1;let c=n&&nPo(hVp),f=n&&(typeof yVp=="function"?(h=>y=>h.encode(y))(new yVp):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&bVp(()=>{let h=!1,y=new r(OA.origin,{body:new hVp,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&bVp(()=>kt.isReadableStream(new i("").body)),l={stream:u&&(h=>h.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!l[h]&&(l[h]=(y,b)=>{let v=y&&y[h];if(v)return v.call(y);throw new ya(`Response type '${h}' is not supported`,ya.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(kt.isBlob(h))return h.size;if(kt.isSpecCompliantForm(h))return(await new r(OA.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(kt.isArrayBufferView(h)||kt.isArrayBuffer(h))return h.byteLength;if(kt.isURLSearchParams(h)&&(h=h+""),kt.isString(h))return(await f(h)).byteLength},_=async(h,y)=>{let b=kt.toFiniteNumber(h.getContentLength());return b??p(y)};return async h=>{let{url:y,method:b,data:v,signal:O,cancelToken:A,timeout:g,onDownloadProgress:m,onUploadProgress:j,responseType:M,headers:E,withCredentials:D="same-origin",fetchOptions:B}=iPo(h),F=t||fetch;M=M?(M+"").toLowerCase():"text";let N=pVp([O,A&&A.toAbortSignal()],g),T=null,R=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),Q;try{if(j&&s&&b!=="get"&&b!=="head"&&(Q=await _(E,v))!==0){let G=new r(y,{method:"POST",body:v,duplex:"half"}),Pe;if(kt.isFormData(v)&&(Pe=G.headers.get("content-type"))&&E.setContentType(Pe),G.body){let[ne,Ee]=MTn(Q,Gbi(DTn(j)));v=yHs(G.body,_Vp,ne,Ee)}}kt.isString(D)||(D=D?"include":"omit");let U=a&&"credentials"in r.prototype,H={...B,signal:N,method:b.toUpperCase(),headers:E.normalize().toJSON(),body:v,duplex:"half",credentials:U?D:void 0};T=a&&new r(y,H);let oe=await(a?F(T,B):F(y,H)),se=u&&(M==="stream"||M==="response");if(u&&(m||se&&R)){let G={};["status","statusText","headers"].forEach(Qe=>{G[Qe]=oe[Qe]});let Pe=kt.toFiniteNumber(oe.headers.get("content-length")),[ne,Ee]=m&&MTn(Pe,Gbi(DTn(m),!0))||[];oe=new i(yHs(oe.body,_Vp,ne,()=>{Ee&&Ee(),R&&R()}),G)}M=M||"text";let x=await l[kt.findKey(l,M)||"text"](oe,h);return!se&&R&&R(),await new Promise((G,Pe)=>{u9t(G,Pe,{data:x,headers:US.from(oe.headers),status:oe.status,statusText:oe.statusText,config:h,request:T})})}catch(U){throw R&&R(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new ya("Network Error",ya.ERR_NETWORK,h,T),{cause:U.cause||U}):ya.from(U,U&&U.code,h,T)}}},ijS=new Map,bHs=e=>{let t=e?e.env:{},{fetch:r,Request:i,Response:n}=t,a=[i,n,r],o=a.length,c=o,f,s,u=ijS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:rjS(t)),u=s;return s},ag5=bHs();var vHs={http:sVp,xhr:dVp,fetch:{get:bHs}};kt.forEach(vHs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var vVp=e=>`- ${e}`,ajS=e=>kt.isFunction(e)||e===null||e===!1,aPo={getAdapter:(e,t)=>{e=kt.isArray(e)?e:[e];let{length:r}=e,i,n,a={};for(let o=0;o<r;o++){i=e[o];let c;if(n=i,!ajS(i)&&(n=vHs[(c=String(i)).toLowerCase()],n===void 0))throw new ya(`Unknown adapter '${c}'`);if(n&&(kt.isFunction(n)||(n=n.get(t))))break;a[c||"#"+o]=n}if(!n){let o=Object.entries(a).map(([f,s])=>`adapter ${f} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
@@ -1396,7 +1396,7 @@ ${g}${O}${m}${AQn}`});function $Qo({message:e,error:t,logger:r,logLevel:i=$s.Err
1396
1396
  Run ${Lt.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
1397
1397
  Run ${Lt.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),UBi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function euc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!ld_(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)n+=`
1398
1398
  ${await WZS(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Lt.dim(c.currentVersion)+Lt.reset(" \u2192 ")+Lt.green(c.latestVersion);return n+=`
1399
- `,i?UBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function WZS(e){let r=await new cd_.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 xZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await dd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=FMi(u.name,l),_=await pNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await dd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=FMi(s.name,u),p=await pNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function dd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function pd_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=k6(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function kQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await xZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...pd_(s,f,t.logger));else o.push(...pd_(c.versions,void 0,t.logger))}return o}var NPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var wQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var tuc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),_d_=typeof globalThis.AbortController=="function",hd_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",yd_=typeof globalThis.ReadableStream=="function",bd_=typeof globalThis.FormData=="function",eUo=["get","post","put","patch","head","delete"],GZS=()=>{};GZS();var vd_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},tUo=2147483647,gd_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,rUo=Symbol("stop"),Od_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Ad_={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 HZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=gd_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},md_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},Pd_=(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(md_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},jd_=(e,t,r)=>{if(!e.body)return e;let i=HZS(r??e.body);return new Request(e,{duplex:"half",body:md_(e.body,i,t)})};var EQn=e=>e!==null&&typeof e=="object";var FPa=(...e)=>{for(let t of e)if((!EQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return nuc({},...e)},ruc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:nuc(e[r]??[],t[r]??[])}var iuc=(e={},t={})=>({beforeRequest:iUo(e,t,"beforeRequest"),beforeRetry:iUo(e,t,"beforeRetry"),afterResponse:iUo(e,t,"afterResponse"),beforeError:iUo(e,t,"beforeError")}),nuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(EQn(n)){for(let[a,o]of Object.entries(n))EQn(o)&&a in t&&(o=nuc(t[a],o)),t={...t,[a]:o};EQn(n.hooks)&&(i=iuc(i,n.hooks),t.hooks=i),EQn(n.headers)&&(r=ruc(r,n.headers),t.headers=r)}return t};var Ed_=e=>eUo.includes(e)?e.toUpperCase():e,KZS=["get","put","head","delete","options","trace"],JZS=[408,413,429,500,502,503,504],$ZS=[413,429,503],wd_={limit:2,methods:KZS,statusCodes:JZS,afterStatusCodes:$ZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Sd_=(e={})=>{if(typeof e=="number")return{...wd_,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{...wd_,...e}};async function auc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function ouc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Md_=(e,t)=>{let r={};for(let i in t)!(i in Ad_)&&!(i in Od_)&&!(i in e)&&(r[i]=t[i]);return r},Dd_=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 QPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>tUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${tUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new NPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Pd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(vd_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);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:ruc(this._input.headers,r.headers),hooks:iuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Ed_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Sd_(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(_d_&&hd_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(tuc&&(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),Dd_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(bd_&&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(!tuc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=jd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wQn)throw t;if(t instanceof NPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),tUo);if(this._retryCount<1)throw r;await ouc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===rUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Md_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):auc(this._originalRequest,t,this.abortController,this._options)}};var uuc=e=>{let t=(r,i)=>QPa.create(r,FPa(e,i));for(let r of eUo)t[r]=(i,n)=>QPa.create(i,FPa(e,n,{method:r}));return t.create=r=>uuc(FPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),uuc(FPa(e,r))),t.stop=rUo,t},YZS=uuc(),Bd_=YZS;var kd_=ae(Zd_(),1);function duc(e){let t=(0,kd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Kp_=ae(Hp_(),1),Jp_=ae(A_e(),1),wuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Euc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Suc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??duc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Kp_.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await Bd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new wuc(e):l}if(t.allVersions)return s;let u=new Euc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Jp_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function GPa(e,t){let{version:r}=await Suc(e.toLowerCase(),t);return r}async function qCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:GPa(e.packageName,{version:t?"prerelease":"latest"})}var $p_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],hUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new ZQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"2.17.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Lt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qE}failWithoutThrowing(t,r){this.didSucceed=!1,$Qo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ATn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await fd_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1399
+ `,i?UBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function WZS(e){let r=await new cd_.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 xZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await dd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=FMi(u.name,l),_=await pNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await dd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=FMi(s.name,u),p=await pNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function dd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function pd_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=k6(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function kQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await xZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...pd_(s,f,t.logger));else o.push(...pd_(c.versions,void 0,t.logger))}return o}var NPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var wQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var tuc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),_d_=typeof globalThis.AbortController=="function",hd_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",yd_=typeof globalThis.ReadableStream=="function",bd_=typeof globalThis.FormData=="function",eUo=["get","post","put","patch","head","delete"],GZS=()=>{};GZS();var vd_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},tUo=2147483647,gd_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,rUo=Symbol("stop"),Od_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Ad_={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 HZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=gd_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},md_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},Pd_=(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(md_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},jd_=(e,t,r)=>{if(!e.body)return e;let i=HZS(r??e.body);return new Request(e,{duplex:"half",body:md_(e.body,i,t)})};var EQn=e=>e!==null&&typeof e=="object";var FPa=(...e)=>{for(let t of e)if((!EQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return nuc({},...e)},ruc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:nuc(e[r]??[],t[r]??[])}var iuc=(e={},t={})=>({beforeRequest:iUo(e,t,"beforeRequest"),beforeRetry:iUo(e,t,"beforeRetry"),afterResponse:iUo(e,t,"afterResponse"),beforeError:iUo(e,t,"beforeError")}),nuc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(EQn(n)){for(let[a,o]of Object.entries(n))EQn(o)&&a in t&&(o=nuc(t[a],o)),t={...t,[a]:o};EQn(n.hooks)&&(i=iuc(i,n.hooks),t.hooks=i),EQn(n.headers)&&(r=ruc(r,n.headers),t.headers=r)}return t};var Ed_=e=>eUo.includes(e)?e.toUpperCase():e,KZS=["get","put","head","delete","options","trace"],JZS=[408,413,429,500,502,503,504],$ZS=[413,429,503],wd_={limit:2,methods:KZS,statusCodes:JZS,afterStatusCodes:$ZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Sd_=(e={})=>{if(typeof e=="number")return{...wd_,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{...wd_,...e}};async function auc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function ouc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Md_=(e,t)=>{let r={};for(let i in t)!(i in Ad_)&&!(i in Od_)&&!(i in e)&&(r[i]=t[i]);return r},Dd_=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 QPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>tUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${tUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new NPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Pd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(vd_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);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:ruc(this._input.headers,r.headers),hooks:iuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Ed_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Sd_(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(_d_&&hd_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(tuc&&(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),Dd_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(bd_&&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(!tuc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=jd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wQn)throw t;if(t instanceof NPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),tUo);if(this._retryCount<1)throw r;await ouc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===rUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Md_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):auc(this._originalRequest,t,this.abortController,this._options)}};var uuc=e=>{let t=(r,i)=>QPa.create(r,FPa(e,i));for(let r of eUo)t[r]=(i,n)=>QPa.create(i,FPa(e,n,{method:r}));return t.create=r=>uuc(FPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),uuc(FPa(e,r))),t.stop=rUo,t},YZS=uuc(),Bd_=YZS;var kd_=ae(Zd_(),1);function duc(e){let t=(0,kd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Kp_=ae(Hp_(),1),Jp_=ae(A_e(),1),wuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Euc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function Suc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??duc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Kp_.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await Bd_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new wuc(e):l}if(t.allVersions)return s;let u=new Euc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Jp_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function GPa(e,t){let{version:r}=await Suc(e.toLowerCase(),t);return r}async function qCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:GPa(e.packageName,{version:t?"prerelease":"latest"})}var $p_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],hUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new ZQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"2.17.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Lt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qE}failWithoutThrowing(t,r){this.didSucceed=!1,$Qo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ATn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await fd_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1400
1400
  `)||(r+=`
1401
1401
  `),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=Aws(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new IPa(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new qE}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await ATn()).sendEvent(t)}logger=H8t((t,...r)=>this.log(t,...r));stderr=H8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Yp_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Yp_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=$p_[this.numTasks++%$p_.length],o=Lt.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===gj.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>sMi.indexOf(n.level)>=sMi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===$s.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 qCi({cliEnvironment:this.environment,includePreReleases:t}),i=k6(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await kQo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await Voc({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Lt.yellow("?"),style:{answer:n=>Lt.cyan(n),message:n=>Lt.bold(n),highlight:n=>Lt.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
1402
1402
  Cancelled by user.`),new qE):i}}async getInput(t){return await Foc({message:t.message,default:t.default})}};function Yp_(e){return`[${e}]:`}var hFt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};function yUo(e,t,r,i){if(typeof r!="function")throw new Error("method for before hook must be a function");return i||(i={}),Array.isArray(t)?t.reverse().reduce((n,a)=>yUo.bind(null,e,a,n,i),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((n,a)=>a.hook.bind(null,n,i),r)():r(i))}function Xp_(e,t,r,i){let n=i;e.registry[r]||(e.registry[r]=[]),t==="before"&&(i=(a,o)=>Promise.resolve().then(n.bind(null,o)).then(a.bind(null,o))),t==="after"&&(i=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,n(c,o))).then(()=>c)}),t==="error"&&(i=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>n(c,o))),e.registry[r].push({hook:i,orig:n})}function Zp_(e,t,r){if(!e.registry[t])return;let i=e.registry[t].map(n=>n.orig).indexOf(r);i!==-1&&e.registry[t].splice(i,1)}var kp_=Function.bind,e__=kp_.bind(kp_);function t__(e,t,r){let i=e__(Zp_,null).apply(null,r?[t,r]:[t]);e.api={remove:i},e.remove=i,["before","error","after","wrap"].forEach(n=>{let a=r?[t,n,r]:[t,n];e[n]=e.api[n]=e__(Xp_,null).apply(null,a)})}function rkS(){let e=Symbol("Singular"),t={registry:{}},r=yUo.bind(null,t,e);return t__(r,t,e),r}function ikS(){let e={registry:{}},t=yUo.bind(null,e);return t__(t,e),t}var r__={Singular:rkS,Collection:ikS};var nkS="0.0.0-development",akS=`octokit-endpoint.js/${nkS} ${TR()}`,okS={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":akS},mediaType:{format:""}};function ukS(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function skS(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function a__(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{skS(t[i])?i in e?r[i]=a__(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function i__(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Duc(e,t,r){if(typeof t=="string"){let[n,a]=t.split(" ");r=Object.assign(a?{method:n,url:a}:{url:n},r)}else r=Object.assign({},t);r.headers=ukS(r.headers),i__(r),i__(r.headers);let i=a__(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(i.mediaType.previews=e.mediaType.previews.filter(n=>!i.mediaType.previews.includes(n)).concat(i.mediaType.previews)),i.mediaType.previews=(i.mediaType.previews||[]).map(n=>n.replace(/-preview/,""))),i}function ckS(e,t){let r=/\?/.test(e)?"&":"?",i=Object.keys(t);return i.length===0?e:e+r+i.map(n=>n==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${n}=${encodeURIComponent(t[n])}`).join("&")}var lkS=/\{[^{}}]+\}/g;function fkS(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function dkS(e){let t=e.match(lkS);return t?t.map(fkS).reduce((r,i)=>r.concat(i),[]):[]}function n__(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function o__(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function TQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function HPa(e,t,r){return t=e==="+"||e==="#"?o__(t):TQn(t),r?TQn(r)+"="+t:t}function qQn(e){return e!=null}function Muc(e){return e===";"||e==="&"||e==="?"}function pkS(e,t,r,i){var n=e[r],a=[];if(qQn(n)&&n!=="")if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")n=n.toString(),i&&i!=="*"&&(n=n.substring(0,parseInt(i,10))),a.push(HPa(t,n,Muc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(qQn).forEach(function(o){a.push(HPa(t,o,Muc(t)?r:""))}):Object.keys(n).forEach(function(o){qQn(n[o])&&a.push(HPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(qQn).forEach(function(c){o.push(HPa(t,c))}):Object.keys(n).forEach(function(c){qQn(n[c])&&(o.push(TQn(c)),o.push(HPa(t,n[c].toString())))}),Muc(t)?a.push(TQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?qQn(n)&&a.push(TQn(r)):n===""&&(t==="&"||t==="?")?a.push(TQn(r)+"="):n===""&&a.push("");return a}function _kS(e){return{expand:hkS.bind(null,e)}}function hkS(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(i,n,a){if(n){let c="",f=[];if(r.indexOf(n.charAt(0))!==-1&&(c=n.charAt(0),n=n.substr(1)),n.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);f.push(pkS(t,c,u[1],u[2]||u[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return o__(a)}),e==="/"?e:e.replace(/\/$/,"")}function u__(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=n__(e,["method","baseUrl","url","headers","request","mediaType"]),o=dkS(r);r=_kS(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),f=n__(a,c);if(!/application\/octet-stream/i.test(i.accept)&&(e.mediaType.format&&(i.accept=i.accept.split(/,/).map(u=>u.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let u=i.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];i.accept=u.concat(e.mediaType.previews).map(l=>{let p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?r=ckS(r,f):"data"in f?n=f.data:Object.keys(f).length&&(n=f),!i["content-type"]&&typeof n<"u"&&(i["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof n>"u"&&(n=""),Object.assign({method:t,url:r,headers:i},typeof n<"u"?{body:n}:null,e.request?{request:e.request}:null)}function ykS(e,t,r){return u__(Duc(e,t,r))}function s__(e,t){let r=Duc(e,t),i=ykS.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:s__.bind(null,r),merge:Duc.bind(null,r),parse:u__})}var c__=s__(null,okS);var h__=ae(p__(),1);var yFt=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var bkS="10.0.6",vkS={headers:{"user-agent":`octokit-request.js/${bkS} ${TR()}`}};function gkS(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function ___(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,i=e.request?.parseSuccessResponseBody!==!1,n=gkS(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new yFt(p,500,{request:e});throw _.cause=l,_}let c=o.status,f=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:f,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new yFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await Buc(o),new yFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await Buc(o),new yFt(AkS(u.data),c,{response:u,request:e});return u.data=i?await Buc(o):o.body,u}async function Buc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,h__.safeParse)(t);if(OkS(r)){let i="";try{return i=await e.text(),JSON.parse(i)}catch{return i}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function OkS(e){return e.type==="application/json"||e.type==="application/scim+json"}function AkS(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function Iuc(e,t){let r=e.defaults(t);return Object.assign(function(n,a){let o=r.merge(n,a);if(!o.request||!o.request.hook)return ___(r.parse(o));let c=(f,s)=>___(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:Iuc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:Iuc.bind(null,r)})}var WO=Iuc(c__,vkS);var mkS="0.0.0-development";function PkS(e){return`Request failed due to following response errors:
@@ -1413,7 +1413,7 @@ Cancelled by user.`),new qE):i}}async getInput(t){return await Foc({message:t.me
1413
1413
  })
1414
1414
  `);let s={},u=new i.Events(s);return s.on("secondary-limit",f.onSecondaryRateLimit),s.on("rate-limit",f.onRateLimit),s.on("error",l=>e.log.warn("Error in throttling-plugin limit handler",l)),f.retryLimiter.on("failed",async function(l,p){let[_,h,y]=p.args,{pathname:b}=new URL(y.url,"http://github.test");if(!(b.startsWith("/graphql")&&l.status!==401||l.status===403||l.status===429))return;let O=~~h.retryCount;h.retryCount=O,y.request.retryCount=O;let{wantRetry:A,retryAfter:g=0}=await(async function(){if(/\bsecondary rate\b/i.test(l.message)){let m=Number(l.response.headers["retry-after"])||_.fallbackSecondaryRateRetryAfter;return{wantRetry:await u.trigger("secondary-limit",m,y,e,O),retryAfter:m}}if(l.response.headers!=null&&l.response.headers["x-ratelimit-remaining"]==="0"||(l.response.data?.errors??[]).some(m=>m.type==="RATE_LIMITED")){let m=new Date(~~l.response.headers["x-ratelimit-reset"]*1e3).getTime(),j=Math.max(Math.ceil((m-Date.now())/1e3)+1,0);return{wantRetry:await u.trigger("rate-limit",j,y,e,O),retryAfter:j}}return{}})();if(A)return h.retryCount++,g*_.retryAfterBaseValue}),e.hook.wrap("request",eeM.bind(null,f)),{}}AUo.VERSION=kkS;AUo.triggersNotification=R__;function z__(e){let t=e.clientType||"oauth-app",r=e.baseUrl||"https://github.com",i={clientType:t,allowSignup:e.allowSignup!==!1,clientId:e.clientId,login:e.login||null,redirectUrl:e.redirectUrl||null,state:e.state||Math.random().toString(36).substr(2),url:""};if(t==="oauth-app"){let n="scopes"in e?e.scopes:[];i.scopes=typeof n=="string"?n.split(/[,\s]+/).filter(Boolean):n}return i.url=oeM(`${r}/login/oauth/authorize`,i),i}function oeM(e,t){let r={allowSignup:"allow_signup",clientId:"client_id",login:"login",redirectUrl:"redirect_uri",scopes:"scope",state:"state"},i=e;return Object.keys(r).filter(n=>t[n]!==null).filter(n=>n!=="scopes"?!0:t.clientType==="github-app"?!1:!Array.isArray(t[n])||t[n].length>0).map(n=>[r[n],`${t[n]}`]).forEach(([n,a],o)=>{i+=o===0?"?":"&",i+=`${n}=${encodeURIComponent(a)}`}),i}function U__(e){let t=e.endpoint.DEFAULTS;return/^https:\/\/(api\.)?github\.com$/.test(t.baseUrl)?"https://github.com":t.baseUrl.replace("/api/v3","")}async function mUo(e,t,r){let i={baseUrl:U__(e),headers:{accept:"application/json"},...r},n=await e(t,i);if("error"in n.data){let a=new yFt(`${n.data.error_description} (${n.data.error}, ${n.data.error_uri})`,400,{request:e.endpoint.merge(t,i)});throw a.response=n,a}return n}function L__({request:e=WO,...t}){let r=U__(e);return z__({...t,baseUrl:r})}async function V__(e){let t=e.request||WO,r=await mUo(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,code:e.code,redirect_uri:e.redirectUrl}),i={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if(e.clientType==="github-app"){if("refresh_token"in r.data){let n=new Date(r.headers.date).getTime();i.refreshToken=r.data.refresh_token,i.expiresAt=N__(n,r.data.expires_in),i.refreshTokenExpiresAt=N__(n,r.data.refresh_token_expires_in)}delete i.scopes}return{...r,authentication:i}}function N__(e,t){return new Date(e+t*1e3).toISOString()}async function W__(e){let t=e.request||WO,r={client_id:e.clientId};return"scopes"in e&&Array.isArray(e.scopes)&&(r.scope=e.scopes.join(" ")),mUo(t,"POST /login/device/code",r)}async function Wuc(e){let t=e.request||WO,r=await mUo(t,"POST /login/oauth/access_token",{client_id:e.clientId,device_code:e.code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"}),i={clientType:e.clientType,clientId:e.clientId,token:r.data.access_token,scopes:r.data.scope.split(/\s+/).filter(Boolean)};if("clientSecret"in e&&(i.clientSecret=e.clientSecret),e.clientType==="github-app"){if("refresh_token"in r.data){let n=new Date(r.headers.date).getTime();i.refreshToken=r.data.refresh_token,i.expiresAt=F__(n,r.data.expires_in),i.refreshTokenExpiresAt=F__(n,r.data.refresh_token_expires_in)}delete i.scopes}return{...r,authentication:i}}function F__(e,t){return new Date(e+t*1e3).toISOString()}async function PUo(e){let r=await(e.request||WO)("POST /applications/{client_id}/token",{headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`},client_id:e.clientId,access_token:e.token}),i={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.token,scopes:r.data.scopes};return r.data.expires_at&&(i.expiresAt=r.data.expires_at),e.clientType==="github-app"&&delete i.scopes,{...r,authentication:i}}async function jUo(e){let t=e.request||WO,r=await mUo(t,"POST /login/oauth/access_token",{client_id:e.clientId,client_secret:e.clientSecret,grant_type:"refresh_token",refresh_token:e.refreshToken}),i=new Date(r.headers.date).getTime(),n={clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,token:r.data.access_token,refreshToken:r.data.refresh_token,expiresAt:Q__(i,r.data.expires_in),refreshTokenExpiresAt:Q__(i,r.data.refresh_token_expires_in)};return{...r,authentication:n}}function Q__(e,t){return new Date(e+t*1e3).toISOString()}async function x__(e){let{request:t,clientType:r,clientId:i,clientSecret:n,token:a,...o}=e,f=await(e.request||WO)("POST /applications/{client_id}/token/scoped",{headers:{authorization:`basic ${btoa(`${i}:${n}`)}`},client_id:i,access_token:a,...o}),s=Object.assign({clientType:r,clientId:i,clientSecret:n,token:f.data.token},f.data.expires_at?{expiresAt:f.data.expires_at}:{});return{...f,authentication:s}}async function $Pa(e){let t=e.request||WO,r=btoa(`${e.clientId}:${e.clientSecret}`),i=await t("PATCH /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token}),n={clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:i.data.token,scopes:i.data.scopes};return i.data.expires_at&&(n.expiresAt=i.data.expires_at),e.clientType==="github-app"&&delete n.scopes,{...i,authentication:n}}async function YPa(e){let t=e.request||WO,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/token",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function XPa(e){let t=e.request||WO,r=btoa(`${e.clientId}:${e.clientSecret}`);return t("DELETE /applications/{client_id}/grant",{headers:{authorization:`basic ${r}`},client_id:e.clientId,access_token:e.token})}async function H__(e,t){let r=ueM(e,t.auth);if(r)return r;let{data:i}=await W__({clientType:e.clientType,clientId:e.clientId,request:t.request||e.request,scopes:t.auth.scopes||e.scopes});await e.onVerification(i);let n=await xuc(t.request||e.request,e.clientId,e.clientType,i);return e.authentication=n,n}function ueM(e,t){if(t.refresh===!0||!e.authentication)return!1;if(e.clientType==="github-app")return e.authentication;let r=e.authentication,i=("scopes"in t&&t.scopes||e.scopes).join(" "),n=r.scopes.join(" ");return i===n?r:!1}async function G__(e){await new Promise(t=>setTimeout(t,e*1e3))}async function xuc(e,t,r,i){try{let n={clientId:t,request:e,code:i.device_code},{authentication:a}=r==="oauth-app"?await Wuc({...n,clientType:"oauth-app"}):await Wuc({...n,clientType:"github-app"});return{type:"token",tokenType:"oauth",...a}}catch(n){if(!n.response)throw n;let a=n.response.data.error;if(a==="authorization_pending")return await G__(i.interval),xuc(e,t,r,i);if(a==="slow_down")return await G__(i.interval+7),xuc(e,t,r,i);throw n}}async function seM(e,t){return H__(e,{auth:t})}async function ceM(e,t,r,i){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);let{token:a}=await H__(e,{request:t,auth:{type:"oauth"}});return n.headers.authorization=`token ${a}`,t(n)}var leM="0.0.0-development";function K__(e){let t=e.request||WO.defaults({headers:{"user-agent":`octokit-auth-oauth-device.js/${leM} ${TR()}`}}),{request:r=t,...i}=e,n=e.clientType==="github-app"?{...i,clientType:"github-app",request:r}:{...i,clientType:"oauth-app",request:r,scopes:e.scopes||[]};if(!e.clientId)throw new Error('[@octokit/auth-oauth-device] "clientId" option must be set (https://github.com/octokit/auth-oauth-device.js#usage)');if(!e.onVerification)throw new Error('[@octokit/auth-oauth-device] "onVerification" option must be a function (https://github.com/octokit/auth-oauth-device.js#usage)');return Object.assign(seM.bind(null,n),{hook:ceM.bind(null,n)})}var $__="0.0.0-development";async function J__(e){if("code"in e.strategyOptions){let{authentication:t}=await V__({clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request});return{type:"token",tokenType:"oauth",...t}}if("onVerification"in e.strategyOptions){let r=await K__({clientType:e.clientType,clientId:e.clientId,onTokenCreated:e.onTokenCreated,...e.strategyOptions,request:e.request})({type:"oauth"});return{clientSecret:e.clientSecret,...r}}if("token"in e.strategyOptions)return{type:"token",tokenType:"oauth",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,onTokenCreated:e.onTokenCreated,...e.strategyOptions};throw new Error("[@octokit/auth-oauth-user] Invalid strategy options")}async function Guc(e,t={}){if(e.authentication||(e.authentication=e.clientType==="oauth-app"?await J__(e):await J__(e)),e.authentication.invalid)throw new Error("[@octokit/auth-oauth-user] Token is invalid");let r=e.authentication;if("expiresAt"in r&&(t.type==="refresh"||new Date(r.expiresAt)<new Date)){let{authentication:i}=await jUo({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:r.refreshToken,request:e.request});e.authentication={tokenType:"oauth",type:"token",...i}}if(t.type==="refresh"){if(e.clientType==="oauth-app")throw new Error("[@octokit/auth-oauth-user] OAuth Apps do not support expiring tokens");if(!r.hasOwnProperty("expiresAt"))throw new Error("[@octokit/auth-oauth-user] Refresh token missing");await e.onTokenCreated?.(e.authentication,{type:t.type})}if(t.type==="check"||t.type==="reset"){let i=t.type==="check"?PUo:$Pa;try{let{authentication:n}=await i({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request});return e.authentication={tokenType:"oauth",type:"token",...n},t.type==="reset"&&await e.onTokenCreated?.(e.authentication,{type:t.type}),e.authentication}catch(n){throw n.status===404&&(n.message="[@octokit/auth-oauth-user] Token is invalid",e.authentication.invalid=!0),n}}if(t.type==="delete"||t.type==="deleteAuthorization"){let i=t.type==="delete"?YPa:XPa;try{await i({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:e.authentication.token,request:e.request})}catch(n){if(n.status!==404)throw n}return e.authentication.invalid=!0,e.authentication}return e.authentication}var feM=/\/applications\/[^/]+\/(token|grant)s?/;function ZPa(e){return e&&feM.test(e)}async function deM(e,t,r,i={}){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);if(ZPa(n.url)){let o=btoa(`${e.clientId}:${e.clientSecret}`);return n.headers.authorization=`basic ${o}`,t(n)}let{token:a}=e.clientType==="oauth-app"?await Guc({...e,request:t}):await Guc({...e,request:t});return n.headers.authorization="token "+a,t(n)}function WL({clientId:e,clientSecret:t,clientType:r="oauth-app",request:i=WO.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${$__} ${TR()}`}}),onTokenCreated:n,...a}){let o=Object.assign({clientType:r,clientId:e,clientSecret:t,onTokenCreated:n,strategyOptions:a,request:i});return Object.assign(Guc.bind(null,o),{hook:deM.bind(null,o)})}WL.VERSION=$__;async function peM(e,t){if(t.type==="oauth-app")return{type:"oauth-app",clientId:e.clientId,clientSecret:e.clientSecret,clientType:e.clientType,headers:{authorization:`basic ${btoa(`${e.clientId}:${e.clientSecret}`)}`}};if("factory"in t){let{type:n,...a}={...t,...e};return t.factory(a)}let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.request,...t};return(e.clientType==="oauth-app"?await WL({...r,clientType:e.clientType}):await WL({...r,clientType:e.clientType}))()}async function _eM(e,t,r,i){let n=t.endpoint.merge(r,i);if(/\/login\/(oauth\/access_token|device\/code)$/.test(n.url))return t(n);if(e.clientType==="github-app"&&!ZPa(n.url))throw new Error(`[@octokit/auth-oauth-app] GitHub Apps cannot use their client ID/secret for basic authentication for endpoints other than "/applications/{client_id}/**". "${n.method} ${n.url}" is not supported.`);let a=btoa(`${e.clientId}:${e.clientSecret}`);n.headers.authorization=`basic ${a}`;try{return await t(n)}catch(o){throw o.status!==401||(o.message=`[@octokit/auth-oauth-app] "${n.method} ${n.url}" does not support clientId/clientSecret basic authentication.`),o}}var heM="0.0.0-development";function wUo(e){let t=Object.assign({request:WO.defaults({headers:{"user-agent":`octokit-auth-oauth-app.js/${heM} ${TR()}`}}),clientType:"oauth-app"},e);return Object.assign(peM.bind(null,t),{hook:_eM.bind(null,t)})}async function SUo({appId:e,privateKey:t,timeDifference:r,createJwt:i}){try{if(i){let{jwt:o,expiresAt:c}=await i(e,r);return{type:"app",token:o,appId:e,expiresAt:c}}let n={id:e,privateKey:t};r&&Object.assign(n,{now:Math.floor(Date.now()/1e3)+r});let a=await jUs(n);return{type:"app",token:a.token,appId:a.appId,expiresAt:new Date(a.expiration*1e3).toISOString()}}catch(n){throw t==="-----BEGIN RSA PRIVATE KEY-----"?new Error("The 'privateKey` option contains only the first line '-----BEGIN RSA PRIVATE KEY-----'. If you are setting it using a `.env` file, make sure it is set on a single line with newlines replaced by '\n'"):n}}function beM(){return new X_o(15e3,1e3*60*59)}async function veM(e,t){let r=Huc(t),i=await e.get(r);if(!i)return;let[n,a,o,c,f,s]=i.split("|"),u=t.permissions||f.split(/,/).reduce((l,p)=>(/!$/.test(p)?l[p.slice(0,-1)]="write":l[p]="read",l),{});return{token:n,createdAt:a,expiresAt:o,permissions:u,repositoryIds:t.repositoryIds,repositoryNames:t.repositoryNames,singleFileName:s,repositorySelection:c}}async function geM(e,t,r){let i=Huc(t),n=t.permissions?"":Object.keys(r.permissions).map(o=>`${o}${r.permissions[o]==="write"?"!":""}`).join(","),a=[r.token,r.createdAt,r.expiresAt,r.repositorySelection,n,r.singleFileName].join("|");await e.set(i,a)}function Huc({installationId:e,permissions:t={},repositoryIds:r=[],repositoryNames:i=[]}){let n=Object.keys(t).sort().map(c=>t[c]==="read"?c:`${c}!`).join(","),a=r.sort().join(","),o=i.join(",");return[e,a,o,n].filter(Boolean).join("|")}function Y__({installationId:e,token:t,createdAt:r,expiresAt:i,repositorySelection:n,permissions:a,repositoryIds:o,repositoryNames:c,singleFileName:f}){return Object.assign({type:"token",tokenType:"installation",token:t,installationId:e,permissions:a,createdAt:r,expiresAt:i,repositorySelection:n},o?{repositoryIds:o}:null,c?{repositoryNames:c}:null,f?{singleFileName:f}:null)}async function X__(e,t,r){let i=Number(t.installationId||e.installationId);if(!i)throw new Error("[@octokit/auth-app] installationId option is required for installation authentication.");if(t.factory){let{type:a,factory:o,oauthApp:c,...f}={...e,...t};return o(f)}let n=r||e.request;return OeM(e,{...t,installationId:i},n)}var EUo=new Map;function OeM(e,t,r){let i=Huc(t);if(EUo.has(i))return EUo.get(i);let n=AeM(e,t,r).finally(()=>EUo.delete(i));return EUo.set(i,n),n}async function AeM(e,t,r){if(!t.refresh){let O=await veM(e.cache,t);if(O){let{token:A,createdAt:g,expiresAt:m,permissions:j,repositoryIds:M,repositoryNames:E,singleFileName:D,repositorySelection:B}=O;return Y__({installationId:t.installationId,token:A,createdAt:g,expiresAt:m,permissions:j,repositorySelection:B,repositoryIds:M,repositoryNames:E,singleFileName:D})}}let i=await SUo(e),n={installation_id:t.installationId,mediaType:{previews:["machine-man"]},headers:{authorization:`bearer ${i.token}`}};t.repositoryIds&&Object.assign(n,{repository_ids:t.repositoryIds}),t.repositoryNames&&Object.assign(n,{repositories:t.repositoryNames}),t.permissions&&Object.assign(n,{permissions:t.permissions});let{data:{token:a,expires_at:o,repositories:c,permissions:f,repository_selection:s,single_file:u}}=await r("POST /app/installations/{installation_id}/access_tokens",n),l=f||{},p=s||"all",_=c?c.map(O=>O.id):void 0,h=c?c.map(O=>O.name):void 0,y=new Date().toISOString(),b={token:a,createdAt:y,expiresAt:o,repositorySelection:p,permissions:l,repositoryIds:_,repositoryNames:h};u&&Object.assign(n,{singleFileName:u}),await geM(e.cache,t,b);let v={installationId:t.installationId,token:a,createdAt:y,expiresAt:o,repositorySelection:p,permissions:l,repositoryIds:_,repositoryNames:h};return u&&Object.assign(v,{singleFileName:u}),Y__(v)}async function meM(e,t){switch(t.type){case"app":return SUo(e);case"oauth-app":return e.oauthApp({type:"oauth-app"});case"installation":return X__(e,{...t,type:"installation"});case"oauth-user":return e.oauthApp(t);default:throw new Error(`Invalid auth type: ${t.type}`)}}var PeM=["/app","/app/hook/config","/app/hook/deliveries","/app/hook/deliveries/{delivery_id}","/app/hook/deliveries/{delivery_id}/attempts","/app/installations","/app/installations/{installation_id}","/app/installations/{installation_id}/access_tokens","/app/installations/{installation_id}/suspended","/app/installation-requests","/marketplace_listing/accounts/{account_id}","/marketplace_listing/plan","/marketplace_listing/plans","/marketplace_listing/plans/{plan_id}/accounts","/marketplace_listing/stubbed/accounts/{account_id}","/marketplace_listing/stubbed/plan","/marketplace_listing/stubbed/plans","/marketplace_listing/stubbed/plans/{plan_id}/accounts","/orgs/{org}/installation","/repos/{owner}/{repo}/installation","/users/{username}/installation"];function jeM(e){let r=`^(?:${e.map(i=>i.split("/").map(n=>n.startsWith("{")?"(?:.+?)":n).join("/")).map(i=>`(?:${i})`).join("|")})$`;return new RegExp(r,"i")}var weM=jeM(PeM);function EeM(e){return!!e&&weM.test(e.split("?")[0])}var SeM=5*1e3;function MeM(e){return!(e.message.match(/'Expiration time' claim \('exp'\) must be a numeric value representing the future time at which the assertion expires/)||e.message.match(/'Issued at' claim \('iat'\) must be an Integer representing the time that the assertion was issued/))}async function DeM(e,t,r,i){let n=t.endpoint.merge(r,i),a=n.url;if(/\/login\/oauth\/access_token$/.test(a))return t(n);if(EeM(a.replace(t.endpoint.DEFAULTS.baseUrl,""))){let{token:f}=await SUo(e);n.headers.authorization=`bearer ${f}`;let s;try{s=await t(n)}catch(u){if(MeM(u)||typeof u.response.headers.date>"u")throw u;let l=Math.floor((Date.parse(u.response.headers.date)-Date.parse(new Date().toString()))/1e3);e.log.warn(u.message),e.log.warn(`[@octokit/auth-app] GitHub API time and system time are different by ${l} seconds. Retrying request with the difference accounted for.`);let{token:p}=await SUo({...e,timeDifference:l});return n.headers.authorization=`bearer ${p}`,t(n)}return s}if(ZPa(a)){let f=await e.oauthApp({type:"oauth-app"});return n.headers.authorization=f.headers.authorization,t(n)}let{token:o,createdAt:c}=await X__(e,{},t.defaults({baseUrl:n.baseUrl}));return n.headers.authorization=`token ${o}`,Z__(e,t,n,c)}async function Z__(e,t,r,i,n=0){let a=+new Date-+new Date(i);try{return await t(r)}catch(o){if(o.status!==401)throw o;if(a>=SeM)throw n>0&&(o.message=`After ${n} retries within ${a/1e3}s of creating the installation access token, the response remains 401. At this point, the cause may be an authentication problem or a system outage. Please check https://www.githubstatus.com for status information`),o;++n;let c=n*1e3;return e.log.warn(`[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: ${n}, wait: ${c/1e3}s)`),await new Promise(f=>setTimeout(f,c)),Z__(e,t,r,i,n)}}var BeM="8.1.2";function RQn(e){if(!e.appId)throw new Error("[@octokit/auth-app] appId option is required");if(!e.privateKey&&!e.createJwt)throw new Error("[@octokit/auth-app] privateKey option is required");if(e.privateKey&&e.createJwt)throw new Error("[@octokit/auth-app] privateKey and createJwt options are mutually exclusive");if("installationId"in e&&!e.installationId)throw new Error("[@octokit/auth-app] installationId is set to a falsy value");let t=e.log||{};typeof t.warn!="function"&&(t.warn=console.warn.bind(console));let r=e.request||WO.defaults({headers:{"user-agent":`octokit-auth-app.js/${BeM} ${TR()}`}}),i=Object.assign({request:r,cache:beM()},e,e.installationId?{installationId:Number(e.installationId)}:{},{log:t,oauthApp:wUo({clientType:"github-app",clientId:e.clientId||"",clientSecret:e.clientSecret||"",request:r})});return Object.assign(meM.bind(null,i),{hook:DeM.bind(null,i)})}async function IeM(e){return{type:"unauthenticated",reason:e}}function CeM(e){return e.status!==403||!e.response?!1:e.response.headers["x-ratelimit-remaining"]==="0"}var qeM=/\babuse\b/i;function TeM(e){return e.status!==403?!1:qeM.test(e.message)}async function ReM(e,t,r,i){let n=t.endpoint.merge(r,i);return t(n).catch(a=>{throw a.status===404?(a.message=`Not found. May be due to lack of authentication. Reason: ${e}`,a):CeM(a)?(a.message=`API rate limit exceeded. This maybe caused by the lack of authentication. Reason: ${e}`,a):TeM(a)?(a.message=`You have triggered an abuse detection mechanism. This maybe caused by the lack of authentication. Reason: ${e}`,a):a.status===401?(a.message=`Unauthorized. "${n.method} ${n.url}" failed most likely due to lack of authentication. Reason: ${e}`,a):(a.status>=400&&a.status<500&&(a.message=a.message.replace(/\.?$/,`. May be caused by lack of authentication (${e}).`)),a)})}var MJi=function(t){if(!t||!t.reason)throw new Error("[@octokit/auth-unauthenticated] No reason passed to createUnauthenticatedAuth");return Object.assign(IeM.bind(null,t.reason),{hook:ReM.bind(null,t.reason)})};var k__="8.0.3";function eh_(e,t,r){if(Array.isArray(t)){for(let i of t)eh_(e,i,r);return}e.eventHandlers[t]||(e.eventHandlers[t]=[]),e.eventHandlers[t].push(r)}var zeM=TCi.defaults({userAgent:`octokit-oauth-app.js/${k__} ${TR()}`});async function Kvi(e,t){let{name:r,action:i}=t;if(e.eventHandlers[`${r}.${i}`])for(let n of e.eventHandlers[`${r}.${i}`])await n(t);if(e.eventHandlers[r])for(let n of e.eventHandlers[r])await n(t)}async function NeM(e,t){return e.octokit.auth({type:"oauth-user",...t,async factory(r){let i=new e.Octokit({authStrategy:WL,auth:r}),n=await i.auth({type:"get"});return await Kvi(e,{name:"token",action:"created",token:n.token,scopes:n.scopes,authentication:n,octokit:i}),i}})}function FeM(e,t){let r={clientId:e.clientId,request:e.octokit.request,...t,allowSignup:e.allowSignup??t.allowSignup,redirectUrl:t.redirectUrl??e.redirectUrl,scopes:t.scopes??e.defaultScopes};return L__({clientType:e.clientType,...r})}async function QeM(e,t){let r=await e.octokit.auth({type:"oauth-user",...t});return await Kvi(e,{name:"token",action:"created",token:r.token,scopes:r.scopes,authentication:r,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.token,scopes:r.scopes,refreshToken:r.refreshToken,expiresAt:r.expiresAt,refreshTokenExpiresAt:r.refreshTokenExpiresAt}})}),{authentication:r}}async function UeM(e,t){let r=await PUo({clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t});return Object.assign(r.authentication,{type:"token",tokenType:"oauth"}),r}async function LeM(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t};if(e.clientType==="oauth-app"){let a=await $Pa({clientType:"oauth-app",...r}),o=Object.assign(a.authentication,{type:"token",tokenType:"oauth"});return await Kvi(e,{name:"token",action:"reset",token:a.authentication.token,scopes:a.authentication.scopes||void 0,authentication:o,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:a.authentication.token,scopes:a.authentication.scopes}})}),{...a,authentication:o}}let i=await $Pa({clientType:"github-app",...r}),n=Object.assign(i.authentication,{type:"token",tokenType:"oauth"});return await Kvi(e,{name:"token",action:"reset",token:i.authentication.token,authentication:n,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:i.authentication.token}})}),{...i,authentication:n}}async function VeM(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.refreshToken() is not supported for OAuth Apps");let r=await jUo({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,refreshToken:t.refreshToken}),i=Object.assign(r.authentication,{type:"token",tokenType:"oauth"});return await Kvi(e,{name:"token",action:"refreshed",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function WeM(e,t){if(e.clientType==="oauth-app")throw new Error("[@octokit/oauth-app] app.scopeToken() is not supported for OAuth Apps");let r=await x__({clientType:"github-app",clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t}),i=Object.assign(r.authentication,{type:"token",tokenType:"oauth"});return await Kvi(e,{name:"token",action:"scoped",token:r.authentication.token,authentication:i,octokit:new e.Octokit({authStrategy:WL,auth:{clientType:e.clientType,clientId:e.clientId,clientSecret:e.clientSecret,token:r.authentication.token}})}),{...r,authentication:i}}async function xeM(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t},i=e.clientType==="oauth-app"?await YPa({clientType:"oauth-app",...r}):await YPa({clientType:"github-app",...r});return await Kvi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:MJi,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),i}async function GeM(e,t){let r={clientId:e.clientId,clientSecret:e.clientSecret,request:e.octokit.request,...t},i=e.clientType==="oauth-app"?await XPa({clientType:"oauth-app",...r}):await XPa({clientType:"github-app",...r});return await Kvi(e,{name:"token",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:MJi,auth:{reason:'Handling "token.deleted" event. The access for the token has been revoked.'}})}),await Kvi(e,{name:"authorization",action:"deleted",token:t.token,octokit:new e.Octokit({authStrategy:MJi,auth:{reason:'Handling "authorization.deleted" event. The access for the app has been revoked.'}})}),i}var MUo=class{static VERSION=k__;static defaults(e){return class extends this{constructor(...r){super({...e,...r[0]})}}}constructor(e){let t=e.Octokit||zeM;this.type=e.clientType||"oauth-app";let r=new t({authStrategy:wUo,auth:{clientType:this.type,clientId:e.clientId,clientSecret:e.clientSecret}}),i={clientType:this.type,clientId:e.clientId,clientSecret:e.clientSecret,defaultScopes:e.defaultScopes||[],allowSignup:e.allowSignup,baseUrl:e.baseUrl,redirectUrl:e.redirectUrl,log:e.log,Octokit:t,octokit:r,eventHandlers:{}};this.on=eh_.bind(null,i),this.octokit=r,this.getUserOctokit=NeM.bind(null,i),this.getWebFlowAuthorizationUrl=FeM.bind(null,i),this.createToken=QeM.bind(null,i),this.checkToken=UeM.bind(null,i),this.resetToken=LeM.bind(null,i),this.refreshToken=VeM.bind(null,i),this.scopeToken=WeM.bind(null,i),this.deleteToken=xeM.bind(null,i),this.deleteAuthorization=GeM.bind(null,i)}type;on;octokit;getUserOctokit;getWebFlowAuthorizationUrl;createToken;checkToken;resetToken;refreshToken;scopeToken;deleteToken;deleteAuthorization};var th_=require("crypto"),ih_=require("crypto"),Kuc=require("buffer"),rh_="6.0.0";async function DUo(e,t){if(!e||!t)throw new TypeError("[@octokit/webhooks-methods] secret & payload required for sign()");if(typeof t!="string")throw new TypeError("[@octokit/webhooks-methods] payload must be a string");let r="sha256";return`${r}=${(0,th_.createHmac)(r,e).update(t).digest("hex")}`}DUo.VERSION=rh_;async function kPa(e,t,r){if(!e||!t||!r)throw new TypeError("[@octokit/webhooks-methods] secret, eventPayload & signature required");if(typeof t!="string")throw new TypeError("[@octokit/webhooks-methods] eventPayload must be a string");let i=Kuc.Buffer.from(r),n=Kuc.Buffer.from(await DUo(e,t));return i.length!==n.length?!1:(0,ih_.timingSafeEqual)(i,n)}kPa.VERSION=rh_;async function nh_(e,t,r,i){if(await kPa(e,t,r))return!0;if(i!==void 0)for(let a of i){let o=await kPa(a,t,r);if(o)return o}return!1}var uh_=(e={})=>(typeof e.debug!="function"&&(e.debug=()=>{}),typeof e.info!="function"&&(e.info=()=>{}),typeof e.warn!="function"&&(e.warn=console.warn.bind(console)),typeof e.error!="function"&&(e.error=console.error.bind(console)),e),HeM=["branch_protection_configuration","branch_protection_configuration.disabled","branch_protection_configuration.enabled","branch_protection_rule","branch_protection_rule.created","branch_protection_rule.deleted","branch_protection_rule.edited","check_run","check_run.completed","check_run.created","check_run.requested_action","check_run.rerequested","check_suite","check_suite.completed","check_suite.requested","check_suite.rerequested","code_scanning_alert","code_scanning_alert.appeared_in_branch","code_scanning_alert.closed_by_user","code_scanning_alert.created","code_scanning_alert.fixed","code_scanning_alert.reopened","code_scanning_alert.reopened_by_user","commit_comment","commit_comment.created","create","custom_property","custom_property.created","custom_property.deleted","custom_property.promote_to_enterprise","custom_property.updated","custom_property_values","custom_property_values.updated","delete","dependabot_alert","dependabot_alert.auto_dismissed","dependabot_alert.auto_reopened","dependabot_alert.created","dependabot_alert.dismissed","dependabot_alert.fixed","dependabot_alert.reintroduced","dependabot_alert.reopened","deploy_key","deploy_key.created","deploy_key.deleted","deployment","deployment.created","deployment_protection_rule","deployment_protection_rule.requested","deployment_review","deployment_review.approved","deployment_review.rejected","deployment_review.requested","deployment_status","deployment_status.created","discussion","discussion.answered","discussion.category_changed","discussion.closed","discussion.created","discussion.deleted","discussion.edited","discussion.labeled","discussion.locked","discussion.pinned","discussion.reopened","discussion.transferred","discussion.unanswered","discussion.unlabeled","discussion.unlocked","discussion.unpinned","discussion_comment","discussion_comment.created","discussion_comment.deleted","discussion_comment.edited","fork","github_app_authorization","github_app_authorization.revoked","gollum","installation","installation.created","installation.deleted","installation.new_permissions_accepted","installation.suspend","installation.unsuspend","installation_repositories","installation_repositories.added","installation_repositories.removed","installation_target","installation_target.renamed","issue_comment","issue_comment.created","issue_comment.deleted","issue_comment.edited","issues","issues.assigned","issues.closed","issues.deleted","issues.demilestoned","issues.edited","issues.labeled","issues.locked","issues.milestoned","issues.opened","issues.pinned","issues.reopened","issues.transferred","issues.typed","issues.unassigned","issues.unlabeled","issues.unlocked","issues.unpinned","issues.untyped","label","label.created","label.deleted","label.edited","marketplace_purchase","marketplace_purchase.cancelled","marketplace_purchase.changed","marketplace_purchase.pending_change","marketplace_purchase.pending_change_cancelled","marketplace_purchase.purchased","member","member.added","member.edited","member.removed","membership","membership.added","membership.removed","merge_group","merge_group.checks_requested","merge_group.destroyed","meta","meta.deleted","milestone","milestone.closed","milestone.created","milestone.deleted","milestone.edited","milestone.opened","org_block","org_block.blocked","org_block.unblocked","organization","organization.deleted","organization.member_added","organization.member_invited","organization.member_removed","organization.renamed","package","package.published","package.updated","page_build","personal_access_token_request","personal_access_token_request.approved","personal_access_token_request.cancelled","personal_access_token_request.created","personal_access_token_request.denied","ping","project","project.closed","project.created","project.deleted","project.edited","project.reopened","project_card","project_card.converted","project_card.created","project_card.deleted","project_card.edited","project_card.moved","project_column","project_column.created","project_column.deleted","project_column.edited","project_column.moved","projects_v2","projects_v2.closed","projects_v2.created","projects_v2.deleted","projects_v2.edited","projects_v2.reopened","projects_v2_item","projects_v2_item.archived","projects_v2_item.converted","projects_v2_item.created","projects_v2_item.deleted","projects_v2_item.edited","projects_v2_item.reordered","projects_v2_item.restored","projects_v2_status_update","projects_v2_status_update.created","projects_v2_status_update.deleted","projects_v2_status_update.edited","public","pull_request","pull_request.assigned","pull_request.auto_merge_disabled","pull_request.auto_merge_enabled","pull_request.closed","pull_request.converted_to_draft","pull_request.demilestoned","pull_request.dequeued","pull_request.edited","pull_request.enqueued","pull_request.labeled","pull_request.locked","pull_request.milestoned","pull_request.opened","pull_request.ready_for_review","pull_request.reopened","pull_request.review_request_removed","pull_request.review_requested","pull_request.synchronize","pull_request.unassigned","pull_request.unlabeled","pull_request.unlocked","pull_request_review","pull_request_review.dismissed","pull_request_review.edited","pull_request_review.submitted","pull_request_review_comment","pull_request_review_comment.created","pull_request_review_comment.deleted","pull_request_review_comment.edited","pull_request_review_thread","pull_request_review_thread.resolved","pull_request_review_thread.unresolved","push","registry_package","registry_package.published","registry_package.updated","release","release.created","release.deleted","release.edited","release.prereleased","release.published","release.released","release.unpublished","repository","repository.archived","repository.created","repository.deleted","repository.edited","repository.privatized","repository.publicized","repository.renamed","repository.transferred","repository.unarchived","repository_advisory","repository_advisory.published","repository_advisory.reported","repository_dispatch","repository_dispatch.sample.collected","repository_import","repository_ruleset","repository_ruleset.created","repository_ruleset.deleted","repository_ruleset.edited","repository_vulnerability_alert","repository_vulnerability_alert.create","repository_vulnerability_alert.dismiss","repository_vulnerability_alert.reopen","repository_vulnerability_alert.resolve","secret_scanning_alert","secret_scanning_alert.created","secret_scanning_alert.publicly_leaked","secret_scanning_alert.reopened","secret_scanning_alert.resolved","secret_scanning_alert.validated","secret_scanning_alert_location","secret_scanning_alert_location.created","secret_scanning_scan","secret_scanning_scan.completed","security_advisory","security_advisory.published","security_advisory.updated","security_advisory.withdrawn","security_and_analysis","sponsorship","sponsorship.cancelled","sponsorship.created","sponsorship.edited","sponsorship.pending_cancellation","sponsorship.pending_tier_change","sponsorship.tier_changed","star","star.created","star.deleted","status","sub_issues","sub_issues.parent_issue_added","sub_issues.parent_issue_removed","sub_issues.sub_issue_added","sub_issues.sub_issue_removed","team","team.added_to_repository","team.created","team.deleted","team.edited","team.removed_from_repository","team_add","watch","watch.started","workflow_dispatch","workflow_job","workflow_job.completed","workflow_job.in_progress","workflow_job.queued","workflow_job.waiting","workflow_run","workflow_run.completed","workflow_run.in_progress","workflow_run.requested"];function KeM(e,t={}){if(typeof e!="string")throw new TypeError("eventName must be of type string");if(e==="*")throw new TypeError('Using the "*" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onAny() method instead');if(e==="error")throw new TypeError('Using the "error" event with the regular Webhooks.on() function is not supported. Please use the Webhooks.onError() method instead');if(t.onUnknownEventName!=="ignore"&&!HeM.includes(e)){if(t.onUnknownEventName!=="warn")throw new TypeError(`"${e}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`);(t.log||console).warn(`"${e}" is not a known webhook name (https://developer.github.com/v3/activity/events/types/)`)}}function Juc(e,t,r){e.hooks[t]||(e.hooks[t]=[]),e.hooks[t].push(r)}function sh_(e,t,r){if(Array.isArray(t)){t.forEach(i=>sh_(e,i,r));return}KeM(t,{onUnknownEventName:"warn",log:e.log}),Juc(e,t,r)}function JeM(e,t){Juc(e,"*",t)}function $eM(e,t){Juc(e,"error",t)}function ah_(e,t){let r;try{r=e(t)}catch(i){console.log('FATAL: Error occurred in "error" event handler'),console.log(i)}r&&r.catch&&r.catch(i=>{console.log('FATAL: Error occurred in "error" event handler'),console.log(i)})}function YeM(e,t,r){let i=[e.hooks[r],e.hooks["*"]];return t&&i.unshift(e.hooks[`${r}.${t}`]),[].concat(...i.filter(Boolean))}function XeM(e,t){let r=e.hooks.error||[];if(t instanceof Error){let o=Object.assign(new AggregateError([t],t.message),{event:t});return r.forEach(c=>ah_(c,o)),Promise.reject(o)}if(!t||!t.name){let o=new Error("Event name not passed");throw new AggregateError([o],o.message)}if(!t.payload){let o=new Error("Event name not passed");throw new AggregateError([o],o.message)}let i=YeM(e,"action"in t.payload?t.payload.action:null,t.name);if(i.length===0)return Promise.resolve();let n=[],a=i.map(o=>{let c=Promise.resolve(t);return e.transform&&(c=c.then(e.transform)),c.then(f=>o(f)).catch(f=>n.push(Object.assign(f,{event:t})))});return Promise.all(a).then(()=>{if(n.length===0)return;let o=new AggregateError(n,n.map(c=>c.message).join(`
1415
1415
  `));throw Object.assign(o,{event:t}),r.forEach(c=>ah_(c,o)),o})}function ch_(e,t,r){if(Array.isArray(t)){t.forEach(i=>ch_(e,i,r));return}if(e.hooks[t]){for(let i=e.hooks[t].length-1;i>=0;i--)if(e.hooks[t][i]===r){e.hooks[t].splice(i,1);return}}}function ZeM(e){let t={hooks:{},log:uh_(e&&e.log)};return e&&e.transform&&(t.transform=e.transform),{on:sh_.bind(null,t),onAny:JeM.bind(null,t),onError:$eM.bind(null,t),removeListener:ch_.bind(null,t),receive:XeM.bind(null,t)}}async function keM(e,t){if(!await nh_(e.secret,t.payload,t.signature,e.additionalSecrets).catch(()=>!1)){let n=new Error("[@octokit/webhooks] signature does not match event payload and secret");return n.event=t,n.status=400,e.eventHandler.receive(n)}let i;try{i=JSON.parse(t.payload)}catch(n){throw n.message="Invalid JSON",n.status=400,new AggregateError([n],n.message)}return e.eventHandler.receive({id:t.id,name:t.name,payload:i})}var oh_=new TextDecoder("utf-8",{fatal:!1}),AHW=oh_.decode.bind(oh_);var lh_=class{sign;verify;on;onAny;onError;removeListener;receive;verifyAndReceive;constructor(e){if(!e||!e.secret)throw new Error("[@octokit/webhooks] options.secret required");let t={eventHandler:ZeM(e),secret:e.secret,additionalSecrets:e.additionalSecrets,hooks:{},log:uh_(e.log)};this.sign=DUo.bind(null,e.secret),this.verify=kPa.bind(null,e.secret),this.on=t.eventHandler.on,this.onAny=t.eventHandler.onAny,this.onError=t.eventHandler.onError,this.removeListener=t.eventHandler.removeListener,this.receive=t.eventHandler.receive,this.verifyAndReceive=keM.bind(null,t)}};var etM="16.1.2";function ttM(e,t){return new lh_({secret:t.secret,transform:async r=>{if(!("installation"in r.payload)||typeof r.payload.installation!="object"){let a=new e.constructor({authStrategy:MJi,auth:{reason:'"installation" key missing in webhook event payload'}});return{...r,octokit:a}}let i=r.payload.installation.id,n=await e.auth({type:"installation",installationId:i,factory(a){return new a.octokit.constructor({...a.octokitOptions,authStrategy:RQn,auth:{...a,installationId:i}})}});return n.hook.before("request",a=>{a.headers["x-github-delivery"]=r.id}),{...r,octokit:n}}})}async function fh_(e,t){return e.octokit.auth({type:"installation",installationId:t,factory(r){let i={...r.octokitOptions,authStrategy:RQn,auth:{...r,installationId:t}};return new r.octokit.constructor(i)}})}function rtM(e){return Object.assign(itM.bind(null,e),{iterator:dh_.bind(null,e)})}async function itM(e,t){let r=dh_(e)[Symbol.asyncIterator](),i=await r.next();for(;!i.done;)await t(i.value),i=await r.next()}function dh_(e){return{async*[Symbol.asyncIterator](){let t=OUo.iterator(e.octokit,"GET /app/installations");for await(let{data:r}of t)for(let i of r)yield{octokit:await fh_(e,i.id),installation:i}}}}function ntM(e){return Object.assign(atM.bind(null,e),{iterator:ph_.bind(null,e)})}async function atM(e,t,r){let i=ph_(e,r?t:void 0)[Symbol.asyncIterator](),n=await i.next();for(;!n.done;)r?await r(n.value):await t(n.value),n=await i.next()}function otM(e,t){return{async*[Symbol.asyncIterator](){yield{octokit:await e.getInstallationOctokit(t)}}}}function ph_(e,t){return{async*[Symbol.asyncIterator](){let r=t?otM(e,t.installationId):e.eachInstallation.iterator();for await(let{octokit:i}of r){let n=OUo.iterator(i,"GET /installation/repositories");for await(let{data:a}of n)for(let o of a)yield{octokit:i,repository:o}}}}}function utM(e){let t;return async function(i={}){t||(t=stM(e));let n=await t,a=new URL(n);return i.target_id!==void 0&&(a.pathname+="/permissions",a.searchParams.append("target_id",i.target_id.toFixed())),i.state!==void 0&&a.searchParams.append("state",i.state),a.href}}async function stM(e){let{data:t}=await e.octokit.request("GET /app");if(!t)throw new Error("[@octokit/app] unable to fetch metadata for app");return`${t.html_url}/installations/new`}var _h_=class{static VERSION=etM;static defaults(e){return class extends this{constructor(...r){super({...e,...r[0]})}}}octokit;webhooks;oauth;getInstallationOctokit;eachInstallation;eachRepository;getInstallationUrl;log;constructor(e){let t=e.Octokit||TCi,r=Object.assign({appId:e.appId,privateKey:e.privateKey},e.oauth?{clientId:e.oauth.clientId,clientSecret:e.oauth.clientSecret}:{}),i={authStrategy:RQn,auth:r};"log"in e&&typeof e.log<"u"&&(i.log=e.log),this.octokit=new t(i),this.log=Object.assign({debug:()=>{},info:()=>{},warn:console.warn.bind(console),error:console.error.bind(console)},e.log),e.webhooks?this.webhooks=ttM(this.octokit,e.webhooks):Object.defineProperty(this,"webhooks",{get(){throw new Error("[@octokit/app] webhooks option not set")}}),e.oauth?this.oauth=new MUo({...e.oauth,clientType:"github-app",Octokit:t}):Object.defineProperty(this,"oauth",{get(){throw new Error("[@octokit/app] oauth.clientId / oauth.clientSecret options are not set")}}),this.getInstallationOctokit=fh_.bind(null,this),this.eachInstallation=rtM(this),this.eachRepository=ntM(this),this.getInstallationUrl=utM(this)}};var ctM="0.0.0-development",BUo=TCi.plugin(Uuc,zuc,D__,Luc,AUo).defaults({userAgent:`octokit.js/${ctM}`,throttle:{onRateLimit:ltM,onSecondaryRateLimit:ftM}});function ltM(e,t,r){if(r.log.warn(`Request quota exhausted for request ${t.method} ${t.url}`),t.request.retryCount===0)return r.log.info(`Retrying after ${e} seconds!`),!0}function ftM(e,t,r){if(r.log.warn(`SecondaryRateLimit detected for request ${t.method} ${t.url}`),t.request.retryCount===0)return r.log.info(`Retrying after ${e} seconds!`),!0}var xHW=_h_.defaults({Octokit:BUo}),GHW=MUo.defaults({Octokit:BUo});var hh_=ae(A_e(),1);async function $uc({packageName:e,generatorInvocation:t}){if(t.language==null||e==null)return;let r=await dtM({packageName:e,language:t.language,githubRepository:btM(t)});return r==null?void 0:hh_.default.inc(r,"patch")??void 0}async function dtM({packageName:e,language:t,githubRepository:r}){let i;switch(t){case"typescript":i=await ptM(e);break;case"python":i=await _tM(e);break;case"csharp":case"go":case"java":case"ruby":case"php":case"swift":break}return i!=null||r!=null&&(i=await htM(r)),i}async function ptM(e){try{return await GPa(e)}catch{return}}async function _tM(e){try{let t=await fetch(`https://pypi.org/pypi/${e}/json`);return t.ok?(await t.json()).info.version:void 0}catch{return}}async function htM(e){try{let{owner:t,repo:r}=ytM(e);return(await new BUo().rest.repos.listTags({owner:t,repo:r,per_page:1})).data?.[0]?.name}catch{return}}function ytM(e){let[t,r]=e.split("/");if(t==null||r==null)throw new Error(`Invalid github repository: ${e}`);return{owner:t,repo:r}}function btM(e){if(e.outputMode.type==="githubV2")return`${e.outputMode.githubV2.owner}/${e.outputMode.githubV2.repo}`}var rK=class extends hFt{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var vtM={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!0,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,groupEnvironmentsByHost:!1,removeDiscriminantsFromSchemas:wn.RemoveDiscriminantsFromSchemas.Always};function gtM(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function DJi({options:e,overrides:t}){return gtM({defaults:vtM,options:e,overrides:t})}var xL={openapi:e=>({...e,type:"openapi",_visit:function(t){return xL._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return xL._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 zQn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return zQn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var yz={basic:e=>({...e,type:"basic",_visit:function(t){return yz._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return yz._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return yz._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return yz._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return yz._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 Sl={primitive:e=>({value:e,type:"primitive",_visit:function(t){return Sl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Sl._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return Sl._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return Sl._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return Sl._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Sl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Sl._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return Sl._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return Sl._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 Ha={int:e=>({value:e,type:"int",_visit:function(t){return Ha._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Ha._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Ha._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Ha._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Ha._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Ha._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Ha._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Ha._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Ha._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Ha._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Ha._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 RCi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return RCi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return RCi._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 zCi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return zCi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return zCi._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 IUo={};Kt(IUo,{Availability:()=>bz,CustomCodeSample:()=>pGt,EndpointExample:()=>H0e,EndpointResponseExample:()=>K0e,HttpMethod:()=>gz,LiteralSchemaValue:()=>Fj,MultipartRequestPropertyEncoding:()=>Zuc,MultipartSchema:()=>_Gt,OneOfSchema:()=>hGt,Pagination:()=>Dhe,PrimitiveSchemaValue:()=>ah,Request:()=>bFt,Response:()=>KQ,RetriesConfiguration:()=>eja,Schema:()=>Zs,SupportedSdkLanguage:()=>vz,WebhookHttpMethod:()=>Xuc,WebsocketMessageOrigin:()=>Yuc});var Yuc={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case Yuc.Client:return t.client();case Yuc.Server:return t.server();default:return t._other()}}};var Xuc={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case Xuc.Get:return t.get();case Xuc.Post:return t.post();default:return t._other()}}};var bz={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case bz.GenerallyAvailable:return t.generallyAvailable();case bz.Beta:return t.beta();case bz.Deprecated:return t.deprecated();default:return t._other()}}};var eja={disabled:e=>({value:e,type:"disabled",_visit:function(t){return eja._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var Dhe={cursor:e=>({...e,type:"cursor",_visit:function(t){return Dhe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Dhe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Dhe._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 pGt={language:e=>({...e,type:"language",_visit:function(t){return pGt._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return pGt._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 vz={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 vz.Curl:return t.curl();case vz.Python:return t.python();case vz.Javascript:return t.javascript();case vz.Typescript:return t.typescript();case vz.Go:return t.go();case vz.Ruby:return t.ruby();case vz.Csharp:return t.csharp();case vz.Java:return t.java();case vz.Js:return t.js();case vz.Node:return t.node();case vz.Ts:return t.ts();case vz.Nodets:return t.nodets();case vz.Golang:return t.golang();case vz.Dotnet:return t.dotnet();case vz.Jvm:return t.jvm();default:return t._other()}}};var H0e={unknown:e=>({value:e,type:"unknown",_visit:function(t){return H0e._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return H0e._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 K0e={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return K0e._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return K0e._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 gz={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case gz.Get:return t.get();case gz.Post:return t.post();case gz.Put:return t.put();case gz.Patch:return t.patch();case gz.Delete:return t.delete();case gz.Head:return t.head();case gz.Options:return t.options();case gz.Trace:return t.trace();default:return t._other()}}};var bFt={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return bFt._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return bFt._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return bFt._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return bFt._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 Zuc={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case Zuc.Json:return t.json();case Zuc.Form:return t.form();default:return t._other()}}};var _Gt={file:e=>({...e,type:"file",_visit:function(t){return _Gt._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return _Gt._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 KQ={file:e=>({...e,type:"file",_visit:function(t){return KQ._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return KQ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return KQ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return KQ._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return KQ._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return KQ._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return KQ._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 Zs={primitive:e=>({...e,type:"primitive",_visit:function(t){return Zs._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Zs._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Zs._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Zs._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Zs._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Zs._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Zs._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Zs._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Zs._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Zs._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Zs._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 ah={int:e=>({...e,type:"int",_visit:function(t){return ah._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return ah._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return ah._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return ah._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return ah._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return ah._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return ah._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return ah._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return ah._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return ah._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return ah._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 Fj={boolean:e=>({value:e,type:"boolean",_visit:function(t){return Fj._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Fj._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 hGt={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return hGt._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return hGt._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 bx={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return bx._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return bx._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return bx._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return bx._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 mP={file:e=>({...e,type:"file",_visit:function(t){return mP._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return mP._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return mP._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return mP._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return mP._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return mP._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return mP._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 ri={primitive:e=>({...e,type:"primitive",_visit:function(t){return ri._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ri._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return ri._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return ri._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return ri._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ri._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return ri._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return ri._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return ri._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return ri._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return ri._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 Bhe={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Bhe._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Bhe._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 Ln={int:e=>({...e,type:"int",_visit:function(t){return Ln._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Ln._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Ln._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Ln._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Ln._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Ln._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Ln._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Ln._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Ln._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Ln._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Ln._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 Ns={};Kt(Ns,{AllOfPropertyConflict:()=>uUn,ArraySchema:()=>$4o,ArraySchemaWithExample:()=>E3o,Availability:()=>LUo,Base64WithExample:()=>A3o,BasicSecurityScheme:()=>WUo,BearerSecurityScheme:()=>xUo,BooleanSchema:()=>V4o,BooleanWithExample:()=>m3o,BytesResponse:()=>XQn,CasingOverrides:()=>KUo,CommonProperty:()=>i3o,CommonPropertyWithExample:()=>R3o,CursorPagination:()=>w4o,CustomCodeSample:()=>P4o,CustomCodeSampleLanguage:()=>O4o,CustomCodeSampleSdk:()=>m4o,CustomPagination:()=>S4o,DateWithExample:()=>O3o,DatetimeWithExample:()=>g3o,DiscriminatedOneOfSchema:()=>t3o,DiscriminatedOneOfSchemaWithExample:()=>q3o,DoubleSchema:()=>U4o,DoubleWithExample:()=>b3o,Encoding:()=>UUo,Endpoint:()=>M4o,EndpointExample:()=>tUn,EndpointResponseExample:()=>g4o,EndpointSdkName:()=>vGt,EndpointSecurity:()=>WQn,EndpointWithExample:()=>Gh_,EnumSchema:()=>UQn,EnumSchemaWithExample:()=>j3o,EnumValue:()=>UCi,ErrorExample:()=>_4o,FernExample:()=>y4o,FileResponse:()=>$Qn,FileSchema:()=>o4o,FloatWithExample:()=>y3o,FormUrlEncodedRequest:()=>f4o,FullEndpointExample:()=>j4o,FullExample:()=>Xm,FullObjectExample:()=>t4o,FullOneOfExample:()=>i4o,GlobalHeader:()=>G4o,GlobalSecurity:()=>x4o,Header:()=>VCi,HeaderExample:()=>eUn,HeaderSecurityScheme:()=>GUo,HeaderWithExample:()=>GCi,HttpEndpointServer:()=>ZQn,HttpError:()=>h4o,HttpErrorWithExample:()=>f3o,HttpMethod:()=>xQn,IdempotencyHeader:()=>H4o,Int64WithExample:()=>p3o,IntSchema:()=>F4o,IntWithExample:()=>d3o,JsonRequest:()=>l4o,JsonRequestWithExample:()=>u3o,JsonResponse:()=>YQn,JsonResponseWithExample:()=>lUn,KeyValuePair:()=>r4o,LiteralExample:()=>kUo,LiteralSchema:()=>oUn,LiteralSchemaValue:()=>K4o,LongSchema:()=>Q4o,MapSchema:()=>Y4o,MapSchemaWithExample:()=>S3o,MultipartRequest:()=>JQn,MultipartRequestProperty:()=>c4o,MultipartRequestPropertyEncoding:()=>s4o,MultipartSchema:()=>u4o,NamedFullExample:()=>$0e,Namespace:()=>JUo,NamespaceId:()=>ZUo,NullExample:()=>e4o,NullableSchema:()=>Z4o,NullableSchemaWithExample:()=>D3o,OauthSecurityScheme:()=>YUo,ObjectProperty:()=>e3o,ObjectPropertyConflictInfo:()=>sUn,ObjectPropertyWithExample:()=>C3o,ObjectSchema:()=>J4o,ObjectSchemaWithExample:()=>B3o,OctetStreamRequest:()=>KQn,OffsetPagination:()=>E4o,OneOfSchema:()=>k4o,OneOfSchemaWithExample:()=>I3o,OpenApiIntermediateRepresentation:()=>Wh_,OpenApiSource:()=>zUo,OptionalSchema:()=>X4o,OptionalSchemaWithExample:()=>M3o,Pagination:()=>rUn,ParseFormUrlEncodedRequest:()=>s3o,ParseMultipartRequest:()=>o3o,ParseOctetStreamRequest:()=>a3o,PathParameter:()=>GQn,PathParameterExample:()=>b4o,PathParameterWithExample:()=>n3o,PrimitiveExample:()=>VQn,PrimitiveSchema:()=>xCi,PrimitiveSchemaValue:()=>W4o,PrimitiveSchemaValueWithExample:()=>P3o,PrimitiveSchemaWithExample:()=>fUn,PropertyKey:()=>LQn,ProtobufEncoding:()=>QUo,ProtobufSource:()=>NUo,QueryParameter:()=>HQn,QueryParameterExample:()=>kQn,QueryParameterWithExample:()=>cUn,QuerySecurityScheme:()=>HUo,ReferencedSchema:()=>gGt,Request:()=>d4o,RequestWithExample:()=>c3o,Response:()=>p4o,ResponseWithExample:()=>l3o,RetriesConfiguration:()=>iUn,Schema:()=>nd,SchemaId:()=>vx,SchemaWithExample:()=>_O,Schemas:()=>N4o,SdkGroup:()=>$Uo,SdkGroupInfo:()=>n4o,SdkGroupName:()=>LCi,SecurityScheme:()=>XUo,SecuritySchemeId:()=>QCi,Server:()=>nja,Source:()=>FUo,StatusCode:()=>yGt,StreamingResponseExample:()=>v4o,StringSchema:()=>L4o,StringSchemaWithExample:()=>v3o,SupportedSdkLanguage:()=>A4o,Tag:()=>VUo,TagId:()=>gx,Tags:()=>a4o,TextResponse:()=>WCi,Uint64WithExample:()=>h3o,UintWithExample:()=>_3o,UnDiscriminatedOneOfSchema:()=>r3o,UnDiscriminatedOneOfSchemaWithExample:()=>T3o,UnknownSchemaWithExample:()=>w3o,Webhook:()=>D4o,WebhookExampleCall:()=>aUn,WebhookHttpMethod:()=>nUn,WebhookWithExample:()=>Hh_,WebsocketChannel:()=>z4o,WebsocketHandshake:()=>B4o,WebsocketHandshakeWithExample:()=>xh_,WebsocketMessageExample:()=>T4o,WebsocketMessageOrigin:()=>I4o,WebsocketMessageSchema:()=>C4o,WebsocketServer:()=>q4o,WebsocketSessionExample:()=>R4o,WithAvailability:()=>gu,WithDescription:()=>Ti,WithEncoding:()=>iK,WithInline:()=>pO,WithName:()=>Gl,WithNamespace:()=>Ml,WithSdkGroupName:()=>Hd,WithSdkMethodName:()=>bGt,WithSource:()=>tu,WithStatusCode:()=>J0e,WithTitle:()=>Gd,commons:()=>isc,example:()=>nsc,finalIr:()=>asc,parseIr:()=>osc});var isc={};Kt(isc,{BasicSecurityScheme:()=>WUo,BearerSecurityScheme:()=>xUo,Encoding:()=>UUo,HeaderSecurityScheme:()=>GUo,Namespace:()=>JUo,NamespaceId:()=>ZUo,OauthSecurityScheme:()=>YUo,OpenApiSource:()=>zUo,ProtobufEncoding:()=>QUo,ProtobufSource:()=>NUo,QuerySecurityScheme:()=>HUo,SchemaId:()=>vx,SdkGroup:()=>$Uo,SdkGroupName:()=>LCi,SecurityScheme:()=>XUo,SecuritySchemeId:()=>QCi,Server:()=>nja,Source:()=>FUo,StatusCode:()=>yGt,Tag:()=>VUo,TagId:()=>gx,WithAvailability:()=>gu,WithDescription:()=>Ti,WithEncoding:()=>iK,WithInline:()=>pO,WithName:()=>Gl,WithNamespace:()=>Ml,WithSdkGroupName:()=>Hd,WithSdkMethodName:()=>bGt,WithSource:()=>tu,WithStatusCode:()=>J0e,WithTitle:()=>Gd});var L={};Kt(L,{JsonError:()=>NQn,ParseError:()=>FQn,any:()=>Bh_,bigint:()=>bh_,boolean:()=>Ih_,booleanLiteral:()=>Dh_,date:()=>vh_,discriminant:()=>Uh_,enum_:()=>qUo,getObjectLikeUtils:()=>vFt,getObjectUtils:()=>BJi,getSchemaUtils:()=>Ym,isProperty:()=>FCi,lazy:()=>gh_,lazyObject:()=>Eh_,list:()=>RUo,number:()=>Ch_,object:()=>TUo,objectWithoutOptionalProperties:()=>wh_,optional:()=>kuc,property:()=>Ah_,record:()=>zh_,set:()=>Nh_,string:()=>qh_,stringLiteral:()=>Mh_,transform:()=>esc,undiscriminatedUnion:()=>Qh_,union:()=>Vh_,unknown:()=>Th_,withParsedProperties:()=>rsc});var oh={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 DA(e,t){return`Expected ${t}. Received ${OtM(e)}.`}function OtM(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 Oz(e){return{...e,json:yh_(e.json),parse:yh_(e.parse)}}function yh_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
1416
- `)),{ok:!0,value:t}):i}}function CUo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var NQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var FQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Ym(e){return{optional:()=>kuc(e),transform:t=>esc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new FQn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new NQn(i.errors)}}}function kuc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>oh.OPTIONAL};return{...t,...Ym(t)}}function esc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...Ym(r)}}function bh_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(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:DA(t,"bigint")}]},getType:()=>oh.BIGINT};return{...Oz(e),...Ym(e)}}var AtM=/^([+-]?\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 vh_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(t,"string")}]}:AtM.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:DA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:DA(t,"Date object")}]},getType:()=>oh.DATE};return{...Oz(e),...Ym(e)}}function GL(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Oz(r),...Ym(r)}}}function qUo(e){let t=new Set(e);return GL(oh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:DA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:DA(i,"enum")}]}:{ok:!0,value:i})()}function gh_(e){let t=tsc(e);return{...t,...Ym(t)}}function tsc(e){return{parse:(t,r)=>QQn(e).parse(t,r),json:(t,r)=>QQn(e).json(t,r),getType:()=>QQn(e).getType()}}function QQn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function tja(e){return Object.entries(e)}function rja(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function NCi(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 ija(e){return Object.keys(e)}function Oh_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function vFt(e){return{withParsedProperties:t=>rsc(e,t)}}function rsc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[f,s])=>({...c,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!NCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DA(i,"object")}]};let a=new Set(Object.keys(t)),o=rja(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...Ym(r),...vFt(r)}}function Ah_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function FCi(e){return e.isProperty}function TUo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>FCi(i)?i.rawKey:r),_getParsedProperties:()=>ija(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of tja(e)){let f=FCi(c)?c.rawKey:o,s=FCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,jh_(s)&&a.push(f)}return mh_({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:f=>c.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of tja(e)){let c=FCi(o)?o.valueSchema:o;jh_(c)&&n.push(a)}return mh_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return FCi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>oh.OBJECT};return{...Oz(t),...Ym(t),...vFt(t),...BJi(t)}}function mh_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!NCi(e))return{ok:!1,errors:[{path:a,message:DA(e,"object")}]};let o=new Set(t),c=[],f={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let p=l.transform(u);p.ok?f[l.transformedKey]=p.value:(f[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:f}:{ok:!1,errors:c}}function BJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Ph_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Ph_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>oh.OBJECT};return{...r,...Ym(r),...vFt(r),...BJi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>oh.OBJECT};return{...t,...Ym(t),...vFt(t),...BJi(t)}}}}function Ph_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=Oh_(ija(t),s=>n.has(s)),c=r(rja(t,o)),f=i(rja(t,a));return c.ok&&f.ok?{ok:!0,value:{...c.value,...f.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...f.ok?[]:f.errors]}}function jh_(e){return!mtM(e)}function mtM(e){switch(e.getType()){case oh.ANY:case oh.UNKNOWN:case oh.OPTIONAL:return!0;default:return!1}}function wh_(e){return TUo(e)}function Eh_(e){let t={...tsc(e),_getRawProperties:()=>QQn(e)._getRawProperties(),_getParsedProperties:()=>QQn(e)._getParsedProperties()};return{...t,...Ym(t),...vFt(t),...BJi(t)}}function RUo(e){let t={parse:(r,i)=>Sh_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Sh_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>oh.LIST};return{...Oz(t),...Ym(t)}}function Sh_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:DA(e,"list"),path:[]}]}}function Mh_(e){return GL(oh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`"${e}"`)}]})()}function Dh_(e){return GL(oh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`${e.toString()}`)}]})()}var Bh_=GL(oh.ANY,e=>({ok:!0,value:e}));var Ih_=GL(oh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"boolean")}]});var Ch_=GL(oh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"number")}]});var qh_=GL(oh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"string")}]});var Th_=GL(oh.UNKNOWN,e=>({ok:!0,value:e}));function zh_(e,t){let r={parse:(i,n)=>Rh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Rh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>oh.RECORD};return{...Oz(r),...Ym(r)}}function Rh_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return NCi(e)?tja(e).reduce((a,[o,c])=>{if(c==null)return a;let f=a,s=o;if(t){let _=o.length>0?Number(o):NaN;isNaN(_)||(s=_)}let u=r(s),l=i(c,s);if(f.ok&&u.ok&&l.ok)return{ok:!0,value:{...f.value,[u.value]:l.value}};let p=[];return f.ok||p.push(...f.errors),u.ok||p.push(...u.errors),l.ok||p.push(...l.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:DA(e,"object")}]}}function Nh_(e){let t=RUo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DA(i,"Set")}]},getType:()=>oh.SET};return{...Oz(r),...Ym(r)}}function Qh_(e){let t={parse:(r,i)=>Fh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>Fh_((n,a)=>n.json(r,a),e,i),getType:()=>oh.UNDISCRIMINATED_UNION};return{...Oz(t),...Ym(t)}}function Fh_(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function Uh_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Vh_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=qUo(ija(t)),a={parse:(o,c)=>Lh_({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>Lh_({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>oh.UNION};return{...Oz(a),...Ym(a),...vFt(a)}}function Lh_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!NCi(e))return{ok:!1,errors:[{path:c,message:DA(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(f);if(!u.ok)return{ok:!1,errors:u.errors};let l=n(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let p=o(s,l);return p.ok?{ok:!0,value:{[r]:f,...p.value}}:p}var Gd=L.objectWithoutOptionalProperties({title:L.string().optional()});var zUo=L.objectWithoutOptionalProperties({file:L.string()});var NUo=L.objectWithoutOptionalProperties({file:L.string()});var FUo=L.union("type",{openapi:zUo,protobuf:NUo}).transform({transform:e=>{switch(e.type){case"openapi":return xL.openapi(e);case"protobuf":return xL.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var tu=L.objectWithoutOptionalProperties({source:FUo.optional()});var QUo=L.objectWithoutOptionalProperties({typeName:L.string()});var UUo=L.union("type",{protobuf:QUo}).transform({transform:e=>{switch(e.type){case"protobuf":return zQn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var iK=L.objectWithoutOptionalProperties({encoding:UUo.optional()});var Ti=L.objectWithoutOptionalProperties({description:L.string().optional()});var LUo=L.enum_(["GenerallyAvailable","Beta","Deprecated"]);var gu=L.objectWithoutOptionalProperties({availability:LUo.optional()});var yGt=L.number();var J0e=L.objectWithoutOptionalProperties({statusCode:yGt.optional()});var Gl=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string()});var pO=L.objectWithoutOptionalProperties({inline:L.boolean().optional()});var vx=L.string();var gx=L.string();var VUo=L.objectWithoutOptionalProperties({id:gx}).extend(Ti);var QCi=L.string();var WUo=L.objectWithoutOptionalProperties({usernameVariableName:L.string().optional(),usernameEnvVar:L.string().optional(),passwordVariableName:L.string().optional(),passwordEnvVar:L.string().optional()});var xUo=L.objectWithoutOptionalProperties({tokenVariableName:L.string().optional(),tokenEnvVar:L.string().optional()});var GUo=L.objectWithoutOptionalProperties({headerName:L.string(),prefix:L.string().optional(),headerVariableName:L.string().optional(),headerEnvVar:L.string().optional()});var HUo=L.objectWithoutOptionalProperties({queryParameterName:L.string()});var KUo=L.objectWithoutOptionalProperties({snake:L.string().optional(),camel:L.string().optional(),screamingSnake:L.string().optional(),pascal:L.string().optional()});var UCi=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string(),value:L.string(),casing:KUo.optional()}).extend(Ti).extend(gu);var JUo=L.objectWithoutOptionalProperties({type:L.stringLiteral("namespace"),name:L.string()});var $Uo=L.undiscriminatedUnion([L.string(),JUo]);var LCi=L.list($Uo);var Hd=L.objectWithoutOptionalProperties({groupName:LCi.optional()});var Ml=L.objectWithoutOptionalProperties({namespace:L.string().optional()});var UQn=L.objectWithoutOptionalProperties({default:UCi.optional(),values:L.list(UCi)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var YUo=L.objectWithoutOptionalProperties({scopesEnum:UQn.optional()});var XUo=L.union("type",{basic:WUo,bearer:xUo,header:GUo,query:HUo,oauth:YUo}).transform({transform:e=>{switch(e.type){case"basic":return yz.basic(e);case"bearer":return yz.bearer(e);case"header":return yz.header(e);case"query":return yz.query(e);case"oauth":return yz.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var nja=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string(),audiences:L.list(L.string()).optional()}).extend(Ti);var ZUo=L.string();var bGt=L.objectWithoutOptionalProperties({sdkMethodName:L.string().optional()});var nsc={};Kt(nsc,{FullExample:()=>Xm,FullObjectExample:()=>t4o,FullOneOfExample:()=>i4o,KeyValuePair:()=>r4o,LiteralExample:()=>kUo,NullExample:()=>e4o,PrimitiveExample:()=>VQn,PropertyKey:()=>LQn});var LQn=L.string();var VQn=L.union("type",{int:L.object({value:L.number()}),int64:L.object({value:L.number()}),uint:L.object({value:L.number()}),uint64:L.object({value:L.number()}),float:L.object({value:L.number()}),double:L.object({value:L.number()}),string:L.object({value:L.string()}),datetime:L.object({value:L.string()}),date:L.object({value:L.string()}),base64:L.object({value:L.string()}),boolean:L.object({value:L.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Ha.int(e.value);case"int64":return Ha.int64(e.value);case"uint":return Ha.uint(e.value);case"uint64":return Ha.uint64(e.value);case"float":return Ha.float(e.value);case"double":return Ha.double(e.value);case"string":return Ha.string(e.value);case"datetime":return Ha.datetime(e.value);case"date":return Ha.date(e.value);case"base64":return Ha.base64(e.value);case"boolean":return Ha.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var kUo=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return RCi.boolean(e.value);case"string":return RCi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var e4o=L.objectWithoutOptionalProperties({});var Xm=L.union("type",{primitive:L.object({value:VQn}),object:L.lazyObject(()=>t4o),array:L.object({value:L.list(L.lazy(()=>Xm))}),map:L.object({value:L.list(L.lazyObject(()=>r4o))}),enum:L.object({value:L.string()}),literal:L.object({value:kUo}),oneOf:L.object({value:L.lazy(()=>i4o)}),null:e4o,unknown:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"primitive":return Sl.primitive(e.value);case"object":return Sl.object(e);case"array":return Sl.array(e.value);case"map":return Sl.map(e.value);case"enum":return Sl.enum(e.value);case"literal":return Sl.literal(e.value);case"oneOf":return Sl.oneOf(e.value);case"null":return Sl.null(e);case"unknown":return Sl.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var t4o=L.objectWithoutOptionalProperties({properties:L.record(LQn,L.lazy(()=>Xm))});var r4o=L.objectWithoutOptionalProperties({key:VQn,value:L.lazy(()=>Xm)});var i4o=L.union("type",{discriminated:L.object({value:L.record(LQn,L.lazy(()=>Xm))}),undiscriminated:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return zCi.discriminated(e.value);case"undiscriminated":return zCi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var asc={};Kt(asc,{AllOfPropertyConflict:()=>uUn,ArraySchema:()=>$4o,Availability:()=>LUo,BooleanSchema:()=>V4o,BytesResponse:()=>XQn,CasingOverrides:()=>KUo,CommonProperty:()=>i3o,CursorPagination:()=>w4o,CustomCodeSample:()=>P4o,CustomCodeSampleLanguage:()=>O4o,CustomCodeSampleSdk:()=>m4o,CustomPagination:()=>S4o,DiscriminatedOneOfSchema:()=>t3o,DoubleSchema:()=>U4o,Endpoint:()=>M4o,EndpointExample:()=>tUn,EndpointResponseExample:()=>g4o,EndpointSdkName:()=>vGt,EndpointSecurity:()=>WQn,EnumSchema:()=>UQn,EnumValue:()=>UCi,ErrorExample:()=>_4o,FernExample:()=>y4o,FileResponse:()=>$Qn,FileSchema:()=>o4o,FormUrlEncodedRequest:()=>f4o,FullEndpointExample:()=>j4o,GlobalHeader:()=>G4o,GlobalSecurity:()=>x4o,Header:()=>VCi,HeaderExample:()=>eUn,HttpEndpointServer:()=>ZQn,HttpError:()=>h4o,HttpMethod:()=>xQn,IdempotencyHeader:()=>H4o,IntSchema:()=>F4o,JsonRequest:()=>l4o,JsonResponse:()=>YQn,LiteralSchema:()=>oUn,LiteralSchemaValue:()=>K4o,LongSchema:()=>Q4o,MapSchema:()=>Y4o,MultipartRequest:()=>JQn,MultipartRequestProperty:()=>c4o,MultipartRequestPropertyEncoding:()=>s4o,MultipartSchema:()=>u4o,NullableSchema:()=>Z4o,ObjectProperty:()=>e3o,ObjectPropertyConflictInfo:()=>sUn,ObjectSchema:()=>J4o,OctetStreamRequest:()=>KQn,OffsetPagination:()=>E4o,OneOfSchema:()=>k4o,OpenApiIntermediateRepresentation:()=>Wh_,OptionalSchema:()=>X4o,Pagination:()=>rUn,PathParameter:()=>GQn,PathParameterExample:()=>b4o,PrimitiveSchema:()=>xCi,PrimitiveSchemaValue:()=>W4o,QueryParameter:()=>HQn,QueryParameterExample:()=>kQn,ReferencedSchema:()=>gGt,Request:()=>d4o,Response:()=>p4o,RetriesConfiguration:()=>iUn,Schema:()=>nd,Schemas:()=>N4o,SdkGroupInfo:()=>n4o,StreamingResponseExample:()=>v4o,StringSchema:()=>L4o,SupportedSdkLanguage:()=>A4o,Tags:()=>a4o,TextResponse:()=>WCi,UnDiscriminatedOneOfSchema:()=>r3o,Webhook:()=>D4o,WebhookExampleCall:()=>aUn,WebhookHttpMethod:()=>nUn,WebsocketChannel:()=>z4o,WebsocketHandshake:()=>B4o,WebsocketMessageExample:()=>T4o,WebsocketMessageOrigin:()=>I4o,WebsocketMessageSchema:()=>C4o,WebsocketServer:()=>q4o,WebsocketSessionExample:()=>R4o});var n4o=L.objectWithoutOptionalProperties({summary:L.string().optional(),description:L.string().optional()});var a4o=L.objectWithoutOptionalProperties({tagsById:L.record(gx,VUo),orderedTagIds:L.list(gx).optional()});var WQn=L.list(L.record(QCi,L.list(L.string())));var xQn=L.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var GQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var HQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var VCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var vGt=L.objectWithoutOptionalProperties({groupName:LCi,methodName:L.string()});var KQn=L.objectWithoutOptionalProperties({contentType:L.string().optional()}).extend(Ti).extend(tu);var o4o=L.objectWithoutOptionalProperties({isOptional:L.boolean(),isArray:L.boolean()}).extend(Ti);var u4o=L.union("type",{file:o4o,json:L.object({value:L.lazy(()=>nd)})}).transform({transform:e=>{switch(e.type){case"file":return _Gt.file(e);case"json":return _Gt.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var s4o=L.enum_(["json","form"]);var c4o=L.objectWithoutOptionalProperties({key:L.string(),schema:u4o,contentType:L.string().optional(),exploded:L.boolean().optional(),encoding:s4o.optional()}).extend(Ti);var JQn=L.objectWithoutOptionalProperties({name:L.string().optional(),properties:L.list(c4o)}).extend(Ti).extend(tu);var l4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var f4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var d4o=L.union("type",{octetStream:KQn,multipart:JQn,json:l4o,formUrlEncoded:f4o}).transform({transform:e=>{switch(e.type){case"octetStream":return bFt.octetStream(e);case"multipart":return bFt.multipart(e);case"json":return bFt.json(e);case"formUrlEncoded":return bFt.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var $Qn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(J0e);var YQn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),responseProperty:L.string().optional()}).extend(Ti).extend(tu).extend(J0e);var WCi=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(J0e);var XQn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(J0e);var p4o=L.union("type",{file:$Qn,json:YQn,text:WCi,bytes:XQn,streamingSse:YQn,streamingText:WCi,streamingJson:YQn}).transform({transform:e=>{switch(e.type){case"file":return KQ.file(e);case"json":return KQ.json(e);case"text":return KQ.text(e);case"bytes":return KQ.bytes(e);case"streamingSse":return KQ.streamingSse(e);case"streamingText":return KQ.streamingText(e);case"streamingJson":return KQ.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var _4o=L.objectWithoutOptionalProperties({name:L.string().optional(),description:L.string().optional(),example:L.lazy(()=>Xm)});var h4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd).optional(),examples:L.list(_4o).optional()}).extend(Ti).extend(Gl).extend(tu);var ZQn=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string().optional(),audiences:L.list(L.string()).optional()});var y4o=L.unknown();var b4o=L.objectWithoutOptionalProperties({name:L.string(),parameterNameOverride:L.string().optional(),value:L.lazy(()=>Xm)});var kQn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var eUn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var v4o=L.objectWithoutOptionalProperties({sse:L.boolean(),events:L.list(L.lazy(()=>Xm))});var g4o=L.union("type",{withStreaming:v4o,withoutStreaming:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return K0e.withStreaming(e);case"withoutStreaming":return K0e.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var O4o=L.objectWithoutOptionalProperties({name:L.string().optional(),language:L.string(),code:L.string(),install:L.string().optional()}).extend(Ti);var A4o=L.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var m4o=L.objectWithoutOptionalProperties({name:L.string().optional(),sdk:A4o,code:L.string()}).extend(Ti);var P4o=L.union("type",{language:O4o,sdk:m4o}).transform({transform:e=>{switch(e.type){case"language":return pGt.language(e);case"sdk":return pGt.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var j4o=L.objectWithoutOptionalProperties({name:L.string().optional(),pathParameters:L.list(b4o).optional(),queryParameters:L.list(kQn).optional(),headers:L.list(eUn).optional(),request:L.lazy(()=>Xm).optional(),response:g4o.optional(),codeSamples:L.list(P4o)}).extend(Ti);var tUn=L.union("type",{unknown:L.object({value:y4o}),full:j4o}).transform({transform:e=>{switch(e.type){case"unknown":return H0e.unknown(e.value);case"full":return H0e.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var w4o=L.objectWithoutOptionalProperties({cursor:L.string(),nextCursor:L.property("next_cursor",L.string()),results:L.string()});var E4o=L.objectWithoutOptionalProperties({offset:L.string(),results:L.string(),step:L.string().optional(),hasNextPage:L.string().optional()});var S4o=L.objectWithoutOptionalProperties({results:L.string()});var rUn=L.union("type",{cursor:w4o,offset:E4o,custom:S4o}).transform({transform:e=>{switch(e.type){case"cursor":return Dhe.cursor(e);case"offset":return Dhe.offset(e);case"custom":return Dhe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var iUn=L.union("type",{disabled:L.object({value:L.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return eja.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var M4o=L.objectWithoutOptionalProperties({authed:L.boolean(),security:WQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:xQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(GQn),queryParameters:L.list(HQn),headers:L.list(VCi),sdkName:vGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:d4o.optional(),response:p4o.optional(),errors:L.record(yGt,h4o),servers:L.list(ZQn),examples:L.list(tUn),pagination:rUn.optional(),retries:iUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var nUn=L.enum_(["GET","POST"]);var aUn=L.objectWithoutOptionalProperties({name:L.string().optional(),payload:L.lazy(()=>Xm)}).extend(Ti);var D4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:vGt.optional(),method:nUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(VCi),generatedPayloadName:L.string(),payload:L.lazy(()=>nd),examples:L.list(aUn)}).extend(Ti).extend(tu).extend(Ml);var B4o=L.objectWithoutOptionalProperties({queryParameters:L.list(HQn),headers:L.list(VCi),pathParameters:L.list(GQn)});var I4o=L.enum_(["client","server"]);var C4o=L.objectWithoutOptionalProperties({name:L.string(),origin:I4o,body:L.lazy(()=>nd)});var q4o=L.objectWithoutOptionalProperties({name:L.string(),url:L.string()});var T4o=L.objectWithoutOptionalProperties({messageType:L.string(),payload:L.lazy(()=>Xm)}).extend(Ti);var R4o=L.objectWithoutOptionalProperties({name:L.string().optional(),queryParameters:L.list(kQn).optional(),headers:L.list(eUn).optional(),messages:L.list(T4o)}).extend(Ti);var z4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),path:L.string(),groupName:LCi,summary:L.string().optional(),handshake:B4o,messages:L.list(C4o),servers:L.list(q4o),examples:L.list(R4o)}).extend(Ti).extend(tu);var N4o=L.objectWithoutOptionalProperties({rootSchemas:L.record(vx,L.lazy(()=>nd)),namespacedSchemas:L.record(ZUo,L.record(vx,L.lazy(()=>nd)))});var F4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Q4o=L.objectWithoutOptionalProperties({default:L.number().optional()});var U4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var L4o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional()});var V4o=L.objectWithoutOptionalProperties({default:L.boolean().optional()});var W4o=L.union("type",{int:F4o,int64:Q4o,uint:L.object({}),uint64:L.object({}),float:L.object({}),double:U4o,string:L4o,datetime:L.object({}),date:L.object({}),base64:L.object({}),boolean:V4o}).transform({transform:e=>{switch(e.type){case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();case"float":return ah.float();case"double":return ah.double(e);case"string":return ah.string(e);case"datetime":return ah.datetime();case"date":return ah.date();case"base64":return ah.base64();case"boolean":return ah.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var xCi=L.objectWithoutOptionalProperties({schema:W4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var x4o=L.list(L.record(QCi,L.list(L.string())));var G4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),optional:L.boolean().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var H4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var Wh_=L.objectWithoutOptionalProperties({apiVersion:L.unknown().optional(),title:L.string().optional(),description:L.string().optional(),basePath:L.string().optional(),servers:L.list(nja),websocketServers:L.list(nja),groups:L.record(L.string(),n4o),tags:a4o,hasEndpointsMarkedInternal:L.boolean(),endpoints:L.list(M4o),webhooks:L.list(D4o),channels:L.record(L.string(),z4o),groupedSchemas:N4o,variables:L.record(L.string(),xCi),nonRequestReferencedSchemas:L.set(vx),securitySchemes:L.record(QCi,XUo),security:x4o.optional(),globalHeaders:L.list(G4o).optional(),idempotencyHeaders:L.list(H4o).optional()});var gGt=L.objectWithoutOptionalProperties({schema:vx}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd);var K4o=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Fj.boolean(e.value);case"string":return Fj.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var oUn=L.objectWithoutOptionalProperties({value:K4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var nd=L.union("type",{primitive:xCi,object:L.lazyObject(()=>J4o),array:L.lazyObject(()=>$4o),map:L.lazyObject(()=>Y4o),optional:L.lazyObject(()=>X4o),enum:UQn,reference:gGt,literal:oUn,oneOf:L.object({value:L.lazy(()=>k4o)}),nullable:L.lazyObject(()=>Z4o),unknown:Gl}).transform({transform:e=>{switch(e.type){case"primitive":return Zs.primitive(e);case"object":return Zs.object(e);case"array":return Zs.array(e);case"map":return Zs.map(e);case"optional":return Zs.optional(e);case"enum":return Zs.enum(e);case"reference":return Zs.reference(e);case"literal":return Zs.literal(e);case"oneOf":return Zs.oneOf(e.value);case"nullable":return Zs.nullable(e);case"unknown":return Zs.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var uUn=L.objectWithoutOptionalProperties({propertyKey:L.string(),allOfSchemaIds:L.list(vx),conflictingTypeSignatures:L.boolean()});var J4o=L.objectWithoutOptionalProperties({allOf:L.list(gGt),properties:L.list(L.lazyObject(()=>e3o)),allOfPropertyConflicts:L.list(uUn),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var sUn=L.objectWithoutOptionalProperties({differentSchema:L.boolean()});var e3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),conflict:L.record(vx,sUn),generatedName:L.string(),nameOverride:L.string().optional(),audiences:L.list(L.string())}).extend(gu);var $4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Y4o=L.objectWithoutOptionalProperties({key:xCi,value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var X4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Z4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var k4o=L.union("type",{discriminated:L.lazyObject(()=>t3o),undiscriminated:L.lazyObject(()=>r3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return hGt.discriminated(e);case"undiscriminated":return hGt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var t3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>i3o)),schemas:L.record(L.string(),L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var i3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd)});var r3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var osc={};Kt(osc,{ArraySchemaWithExample:()=>E3o,Base64WithExample:()=>A3o,BooleanWithExample:()=>m3o,CommonPropertyWithExample:()=>R3o,DateWithExample:()=>O3o,DatetimeWithExample:()=>g3o,DiscriminatedOneOfSchemaWithExample:()=>q3o,DoubleWithExample:()=>b3o,EndpointWithExample:()=>Gh_,EnumSchemaWithExample:()=>j3o,FloatWithExample:()=>y3o,HeaderWithExample:()=>GCi,HttpErrorWithExample:()=>f3o,Int64WithExample:()=>p3o,IntWithExample:()=>d3o,JsonRequestWithExample:()=>u3o,JsonResponseWithExample:()=>lUn,MapSchemaWithExample:()=>S3o,NamedFullExample:()=>$0e,NullableSchemaWithExample:()=>D3o,ObjectPropertyWithExample:()=>C3o,ObjectSchemaWithExample:()=>B3o,OneOfSchemaWithExample:()=>I3o,OptionalSchemaWithExample:()=>M3o,ParseFormUrlEncodedRequest:()=>s3o,ParseMultipartRequest:()=>o3o,ParseOctetStreamRequest:()=>a3o,PathParameterWithExample:()=>n3o,PrimitiveSchemaValueWithExample:()=>P3o,PrimitiveSchemaWithExample:()=>fUn,QueryParameterWithExample:()=>cUn,RequestWithExample:()=>c3o,ResponseWithExample:()=>l3o,SchemaWithExample:()=>_O,StringSchemaWithExample:()=>v3o,Uint64WithExample:()=>h3o,UintWithExample:()=>_3o,UnDiscriminatedOneOfSchemaWithExample:()=>T3o,UnknownSchemaWithExample:()=>w3o,WebhookWithExample:()=>Hh_,WebsocketHandshakeWithExample:()=>xh_});var $0e=L.objectWithoutOptionalProperties({name:L.string().optional(),value:L.unknown()}).extend(Ti);var cUn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var GCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var xh_=L.objectWithoutOptionalProperties({queryParameters:L.list(cUn),headers:L.list(GCi)});var n3o=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var a3o=L.objectWithoutOptionalProperties({}).extend(KQn).extend(bGt);var o3o=L.objectWithoutOptionalProperties({}).extend(JQn).extend(bGt);var u3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list($0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(bGt);var s3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list($0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(bGt);var c3o=L.union("type",{octetStream:a3o,multipart:o3o,json:u3o,formUrlEncoded:s3o}).transform({transform:e=>{switch(e.type){case"octetStream":return bx.octetStream(e);case"multipart":return bx.multipart(e);case"json":return bx.json(e);case"formUrlEncoded":return bx.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var lUn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),responseProperty:L.string().optional(),fullExamples:L.list($0e).optional()}).extend(Ti).extend(tu).extend(J0e);var l3o=L.union("type",{file:$Qn,json:lUn,text:WCi,bytes:XQn,streamingSse:lUn,streamingText:WCi,streamingJson:lUn}).transform({transform:e=>{switch(e.type){case"file":return mP.file(e);case"json":return mP.json(e);case"text":return mP.text(e);case"bytes":return mP.bytes(e);case"streamingSse":return mP.streamingSse(e);case"streamingText":return mP.streamingText(e);case"streamingJson":return mP.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var f3o=L.objectWithoutOptionalProperties({statusCode:yGt,schema:L.lazy(()=>_O),fullExamples:L.list($0e).optional()}).extend(Ti).extend(Gl).extend(tu);var Gh_=L.objectWithoutOptionalProperties({authed:L.boolean(),security:WQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:xQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(n3o),queryParameters:L.list(cUn),headers:L.list(GCi),sdkName:vGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:c3o.optional(),response:l3o.optional(),errors:L.record(yGt,f3o),servers:L.list(ZQn),examples:L.list(tUn),pagination:rUn.optional(),retries:iUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var Hh_=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:vGt.optional(),method:nUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(GCi),generatedPayloadName:L.string(),payload:L.lazy(()=>_O),examples:L.list(aUn)}).extend(Ti).extend(tu).extend(Ml);var d3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var p3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var _3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var h3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var y3o=L.objectWithoutOptionalProperties({example:L.number().optional()});var b3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var v3o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional(),example:L.string().optional()});var g3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var O3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var A3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var m3o=L.objectWithoutOptionalProperties({default:L.boolean().optional(),example:L.boolean().optional()});var P3o=L.union("type",{int:d3o,int64:p3o,uint:_3o,uint64:h3o,float:y3o,double:b3o,string:v3o,datetime:g3o,date:O3o,base64:A3o,boolean:m3o}).transform({transform:e=>{switch(e.type){case"int":return Ln.int(e);case"int64":return Ln.int64(e);case"uint":return Ln.uint(e);case"uint64":return Ln.uint64(e);case"float":return Ln.float(e);case"double":return Ln.double(e);case"string":return Ln.string(e);case"datetime":return Ln.datetime(e);case"date":return Ln.date(e);case"base64":return Ln.base64(e);case"boolean":return Ln.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var fUn=L.objectWithoutOptionalProperties({schema:P3o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var j3o=L.objectWithoutOptionalProperties({default:UCi.optional(),values:L.list(UCi),example:L.string().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var w3o=L.objectWithoutOptionalProperties({example:L.unknown()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var _O=L.union("type",{primitive:fUn,object:L.lazyObject(()=>B3o),array:L.lazyObject(()=>E3o),map:L.lazyObject(()=>S3o),optional:L.lazyObject(()=>M3o),enum:j3o,reference:gGt,literal:oUn,oneOf:L.object({value:L.lazy(()=>I3o)}),nullable:L.lazyObject(()=>D3o),unknown:w3o}).transform({transform:e=>{switch(e.type){case"primitive":return ri.primitive(e);case"object":return ri.object(e);case"array":return ri.array(e);case"map":return ri.map(e);case"optional":return ri.optional(e);case"enum":return ri.enum(e);case"reference":return ri.reference(e);case"literal":return ri.literal(e);case"oneOf":return ri.oneOf(e.value);case"nullable":return ri.nullable(e);case"unknown":return ri.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var E3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O),example:L.list(L.unknown()).optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var S3o=L.objectWithoutOptionalProperties({key:fUn,value:L.lazy(()=>_O),example:L.unknown().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var M3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var D3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var B3o=L.objectWithoutOptionalProperties({allOf:L.list(gGt),properties:L.list(L.lazyObject(()=>C3o)),allOfPropertyConflicts:L.list(uUn),fullExamples:L.list($0e).optional(),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var C3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),audiences:L.list(L.string()),conflict:L.record(vx,sUn),nameOverride:L.string().optional(),generatedName:L.string()}).extend(gu);var I3o=L.union("type",{discriminated:L.lazyObject(()=>q3o),undiscriminated:L.lazyObject(()=>T3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return Bhe.discriminated(e);case"undiscriminated":return Bhe.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var q3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>R3o)),schemas:L.record(L.string(),L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var R3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O)});var T3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var Kh_=/^(\d+)/,dUn=/^[a-zA-Z][a-zA-Z0-9_]*$/,Jh_={"<":"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 IJi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let o=Math.floor(e/10),c=e%10;return c===0?i[o]:`${i[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${IJi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${IJi(a)}`}function aja(e){let t=e.match(Kh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=IJi(n);return i.length>0?`${a}_${i}`:a}}}function pUn(e){let t=aja(e),r=Jh_[e];return t!=null?QP(No(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":QP(No(e)))}function nK(e,t){return e.type==="primitive"&&t.type==="primitive"?$h_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?PtM(e.values,t.values):e.type==="array"&&t.type==="array"?nK(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"?nK(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?jtM(e.value,t.value):e.type==="object"&&t.type==="object"?wtM(e,t):e.type==="map"&&t.type==="map"?$h_(e.key.schema,t.key.schema)&&nK(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function $h_(e,t){return e.type===t.type}function PtM(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return r1(r,i)}function jtM(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:nK(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:nK(r,n)}):!1}function wtM(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:nK(a,n.schema)})}function ZE(e){switch(e){case bz.Deprecated:return"deprecated";case bz.Beta:return"pre-release";case bz.GenerallyAvailable:return"generally-available";default:return}}function EtM(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function Yh_(e){let t=e?EtM(e):void 0;if(t==null||t.length===0)return Jxi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(No(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(No(n.name)):r.push(n.name,Jxi);break}default:vt(n.type)}else vt(n);return r.join("/")}function HCi(e){return Tu.of(`${Yh_(e)}.yml`)}function usc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Jxi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,Yh_(r))}function Xh_({sdkName:e,namespaceOverride:t}){return Tu.of(`${usc({sdkName:e,namespaceOverride:t})}.yml`)}function Zh_({location:e,namespaceOverride:t}){return t!=null?iD(Tu.of(t),e):e}function z3o(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:vt(e.type)}}function _Un(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:vt(e)}}function hO(e){return typeof e=="string"?e:e.type}function hUn(e){if(typeof e!="string")return e.docs}function oja(e){if(typeof e!="string")return e.default}function ssc(e){if(typeof e!="string")return e.validation}function ey_(e){let t=hO(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?kh_(e):{...e,type:kh_(e.type)}}function kh_(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function CJi(e){return hO(e).startsWith("optional<")?e:typeof e=="string"?ty_(e):{...e,type:ty_(e.type)}}function ty_(e){return e.startsWith("optional<")?e:`optional<${e}>`}var StM=-2147483648,MtM=2147483647,DtM=-17976931348623157e292,BtM=17976931348623157e292;function Af({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return N3o(e);case"array":return fsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return dsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return lsc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return _sc();case"optional":return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return psc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return QtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,hsc(e);case"object":return UtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return LtM({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:vt(e)}}function N3o(e){switch(e.schema.type){case"string":return qtM({description:e.description,schema:e.schema});case"int":return TtM({description:e.description,schema:e.schema});case"float":return RtM({description:e.description,schema:e.schema});case"double":return ztM({description:e.description,schema:e.schema});case"boolean":return ItM({description:e.description,schema:e.schema});case"int64":return CtM({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:ZE(e.availability)}:{}}}function ItM({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function CtM({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function qtM({description:e,schema:t}){let r="string",i=NtM(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function TtM({description:e,schema:t}){let r="integer",i=ry_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function RtM({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function ztM({description:e,schema:t}){let r="double",i=ry_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function NtM(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=FtM(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function FtM(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 ry_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=csc(r,t),i=csc(i,t),n=csc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function csc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[StM,MtM]:[DtM,BtM];return e<r||e>i?void 0:e}function lsc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=VtM(n)??e.schema,o=_Un(n),c=WtM(n),s=Q3o({context:r,fileContainingReference:t,declarationFile:HCi(o),type:a});return n.type==="nullable"&&(s=r.options.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),n.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function fsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${hO(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{},type:c}}function dsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=N3o(e.key),c=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?z3o(e.encoding):void 0,s=`map<${hO(o)}, ${hO(c)}>`;if(e.description==null&&f==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=f),e.availability!=null&&(u.availability=ZE(e.availability)),u}function psc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=hUn(o),s=oja(o),u=ssc(o),l=ey_(c);if(i.options.wrapReferencesToNullableInOptional&&(l=CJi(l)),e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function F3o({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=hUn(o),s=oja(o),u=ssc(o),l=CJi(c);if(e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function _sc(){return"unknown"}function hsc(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:vt(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function QtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=uja(e,n),o=e.nameOverride??e.generatedName;i.builder.addType(r,{name:o,schema:a.schema});let c=Q3o({type:o,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let f={type:c};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=ZE(e.availability)),f}function UtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=ysc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function LtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=bsc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function Q3o({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function VtM(e){return Zs._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 WtM(e){return Zs._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 q1;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(q1||(q1={}));function Jvi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:vt(e)}}function ny_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=HtM(e);break;case"array":a=xtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=GtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=KtM({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=$tM(e.nameOverride,e.generatedName);break;case"optional":a=oy_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=JtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=uja(e,n);break;case"literal":a=YtM(e,e.nameOverride,e.generatedName);break;case"object":a=ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=bsc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:vt(e)}return a}function ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(q1.Request)&&t.options.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},f=new Set;for(let _ of e.properties){if(_.readonly&&(o=!0),a&&_.readonly)continue;if(Object.keys(_.conflict).length>0){if(Object.entries(_.conflict).every(([g,m])=>!m.differentSchema))continue;Object.entries(_.conflict).forEach(([g])=>{vsc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{f.add(j)})})}let h=Af({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=ZE(_.availability),O=erM(_);c[_.key]=ktM({typeReference:h,audiences:y,name:b,availability:v,propertyAccess:O})}let s=new Set;for(let _ of e.allOfPropertyConflicts)_.allOfSchemaIds.forEach(h=>f.add(h)),_.conflictingTypeSignatures&&s.add(_.propertyKey);let u=[];for(let _ of e.allOf){let h=uy_({schema:_.schema,context:t,namespace:i});if(h==null||f.has(_.schema)||f.has(h))continue;let y=Af({schema:Zs.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(y))}for(let _ of f){let h=gsc(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=Af({schema:y.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let y of h.allOf){if(f.has(y.schema))continue;let b=Af({schema:Zs.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(b))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>ZtM(_)?[_,typeof h=="string"?{type:h,name:`_${_}`}:{...h,name:`_${_}`}]:[_,h]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=ZE(e.availability)),e.source!=null&&(l.source=Jvi(e.source)),l.inline=Osc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function vsc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return vsc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=gsc(r,t,i),c=a.some(s=>s.key===e),f=[...o.flatMap(s=>vsc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||f.length>0)return[t,...f]}return[]}function ay_(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?gsc(e,t.schema,r):t.type==="nullable"?ay_(e,t.value,r):{properties:[],allOf:[]}}function gsc(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:ay_(e,i,r)}function xtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:fsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function GtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:dsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function HtM(e){let t=N3o(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function iy_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function uja(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||iy_(a.casing)))return o;let f={value:a.value};if(o!==c&&(f.name=o),a.description!=null&&(f.docs=a.description),a.casing!=null&&!iy_(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&&(f.casing=s)}return f})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=Osc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Jvi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;i.has(o.toLowerCase())||(n.enum.push(a),i.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function KtM({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:lsc({schema:e,context:t,fileContainingReference:r,namespace:i})}}function JtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:psc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:oy_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function oy_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:F3o({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function $tM(e,t){return{name:e??t,schema:_sc()}}function YtM(e,t,r){return{name:t??r,schema:hsc(e)}}function bsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?z3o(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=Af({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let f={};for(let[s,u]of Object.entries(e.schemas))f[s]=Af({schema:u,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?ZE(e.availability):void 0,union:f,encoding:a,source:e.source!=null?Jvi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(Af({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?Jvi(e.source):void 0,inline:Osc(e,n)}}}var XtM=/^[0-9]/;function ZtM(e){return XtM.test(e)}function uy_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?uy_({context:t,schema:i.schema,namespace:r}):e}function ktM({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function Osc(e,t){return e.inline===!0||t>0?!0:void 0}function erM(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return AD.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return AD.ObjectPropertyAccess.WriteOnly}}function sy_(e){let t=e.replace(/^x-|^X-/,"");return No(t)}function cy_(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??sy_(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Tu.of("__package__.yml"),{name:"OauthScope",schema:uja(i.scopesEnum,0).schema})}}function OGt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=hO(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:No(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let f={type:a};return c!==e.name&&(f.name=c),e.description!=null&&(f.docs=e.description),e.env!=null&&(f.env=e.env),e.availability!=null&&(f.availability=ZE(e.availability)),f}function U3o({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return hO(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:hO(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=ZE(e.availability)),a}function V3o({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Asc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=hO(n.value),o=oja(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=ZE(e.availability)),trM(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function Asc({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Tu.of(ob),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(n.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(dUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:pUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,f]=n.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,f]of Object.entries(n.value.schemas))return Asc({schema:f,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let n=e.type==="optional"?Zs.optional:Zs.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,i);if(a==null)return;if(a.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(e.value.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(dUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:pUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,f]=e.value.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:f,primitive:c}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,f]of Object.entries(e.value.value.schemas))return Asc({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function L3o({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function trM(e){return typeof e=="object"&&e!==null&&"type"in e}function ly_({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"]=rrM(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=irM({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=KCi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function rrM(e){let t={};return e.forEach(r=>{let i=KCi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function irM({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=KCi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function KCi(e){switch(e.type){case"primitive":return fy_(e.value);case"object":return dy_(e.properties);case"array":return nrM(e.value);case"map":return arM(e.value);case"oneOf":return orM(e.value);case"enum":return e.value;case"literal":return urM(e.value);case"unknown":return KCi(e.value);case"null":return null;default:vt(e)}}function fy_(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:vt(e)}}function dy_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,KCi(r)]))}function nrM(e){return e.map(t=>KCi(t))}function arM(e){return Object.fromEntries(e.map(t=>[fy_(t.key),KCi(t.value)]))}function orM(e){return e.type==="discriminated"?dy_(e.value):KCi(e.value)}function urM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:vt(e)}}function sja(e){try{let r=new URL(e).pathname.split("/").filter(i=>i.length>0);if(r.length>0)return r[r.length-1]}catch{}}function W3o(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function x3o(e,t,r=!1){let i=sja(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function $vi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function G3o(e,t){return t??(e?.groupName!=null?$vi(e.groupName):void 0)}function py_({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??x3o(i.name,i.url,!0):i.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${i?.name}", server url="${i?.url}", resolved urlId="${n}" (from collision map: ${t.getUrlId(i?.url??"")!=null})`);let a={path:e.path,url:n,auth:!1};e.audiences!=null&&e.audiences.length>0&&(a.audiences=e.audiences),e.summary!=null&&(a["display-name"]=e.summary),e.description!=null&&(a.docs=e.description);let o=$vi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=U3o({pathParameter:u,context:t,fileContainingReference:r,namespace:o});Object.keys(c).length>0&&(a["path-parameters"]=c);let f={};if(e.handshake.queryParameters.length>0)for(let u of e.handshake.queryParameters){let l=V3o({queryParameter:u,context:t,fileContainingReference:r,namespace:o});l!=null&&(f[u.name]=l)}Object.keys(f).length>0&&(a["query-parameters"]=f);let s={};if(e.handshake.headers.length>0)for(let u of e.handshake.headers){let l=OGt({header:u,context:t,fileContainingReference:r,namespace:o});s[u.name]=l}Object.keys(s).length>0&&(a.headers=s),t.builder.addChannel(r,{channel:a});for(let u of e.messages)t.builder.addChannelMessage(r,{messageId:u.name,message:{origin:u.origin,body:Af({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})}});for(let u of e.examples){let l=ly_({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function msc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var Y0e="Base",yy_="Default";function _y_(e){try{return new URL(e).hostname}catch{return}}function hy_(e){return e??yy_}function srM(e,t){let r=new Map;for(let i of e){if(msc(i)||!("url"in i)||!i.url)continue;let n=_y_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:hy_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.httpServers.push({name:i.name,url:i.url,audiences:i.audiences})}for(let i of t){let n=_y_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:hy_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function qJi(e){return Object.entries(e).reduce((t,[r,i])=>(ghe(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function by_(e){if(e.environmentOverrides!=null){for(let[v,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:v,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],i=e.ir.servers.some(v=>msc(v)),n=e.ir.servers;for(let v of n)if(msc(v)){let O={urls:{}};for(let[A,g]of Object.entries(v.urls))O.urls[A]=g.url;v.name&&(t[v.name]=O)}else if("url"in v&&v.url){let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){r.push(O);continue}t[v.name]=O}let a={},o={},c=[];for(let v of e.ir.endpoints)for(let O of v.servers){if(O.url==null&&O.name!=null){a[O.name]||(a[O.name]=[]);continue}if(O.url==null)continue;let A=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){c.push(A);continue}a[O.name]||(a[O.name]=[]),a[O.name]?.push({url:O.url,audiences:O.audiences}),o[O.name]=A}let f={},s=[];for(let v of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${v.name}", url="${v.url}"`);let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){s.push(O);continue}f[v.name]=O}let u=Object.keys(t).length,l=u>0,p=Object.keys(o).length>0,_=Object.keys(a).some(v=>a[v]?.length===0),h=Object.keys(f).length>0;if(e.options.groupEnvironmentsByHost&&h&&(l||e.ir.servers.length>0)){let v=Object.entries(f).map(([A,g])=>({name:A,url:typeof g=="string"?g:g.url,audiences:typeof g=="string"?void 0:g.audiences})),O=srM(n,v);if(O.size>0){let A=!0;for(let[g,m]of O.entries()){let j={},M=[...m.httpServers.map(D=>({...D,isHttp:!0})),...m.websocketServers.map(D=>({...D,isHttp:!1}))],E=new Map;for(let D of M){let B=sja(D.url),F=W3o(D.url);B&&F&&(E.has(B)||E.set(B,new Set),E.get(B)?.add(F))}if(m.httpServers.length>0){let D=m.httpServers[0];D!=null&&(j[Y0e]=D.url,e.setUrlId(D.url,Y0e));for(let B=1;B<m.httpServers.length;B++){let F=m.httpServers[B];if(F!=null){let N=sja(F.url),T=W3o(F.url),R=N?E.get(N):void 0,Q=R&&R.size>1,H=Q&&T!=="https"?`${N}_${T}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${F.url}", pathSegment="${N}", protocol="${T}", hasCollision=${Q}, urlId="${H}"`),j[H]=F.url,e.setUrlId(F.url,H)}}}for(let D of m.websocketServers){let B=sja(D.url),F=W3o(D.url),N=B?E.get(B):void 0,T=N&&N.size>1,R=T?`${B}_${F}`:x3o(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${F}", hasCollision=${T}, urlId="${R}"`),j[R]=D.url,e.setUrlId(D.url,R)}if(Object.keys(j).length>1)e.builder.addEnvironment({name:m.environmentName,schema:{urls:j}});else if(Object.keys(j).length===1){let D=Object.values(j)[0];D!=null&&e.builder.addEnvironment({name:m.environmentName,schema:D})}A&&(e.builder.setDefaultEnvironment(m.environmentName),Object.keys(j).length>1&&e.builder.setDefaultUrl(Y0e),A=!1)}return}}if(!l&&!p&&h&&e.ir.servers.length===0){for(let[v,O]of Object.entries(f))e.builder.addEnvironment({name:v,schema:O});e.builder.setDefaultEnvironment(Object.keys(f)[0]),e.builder.setDefaultUrl(Y0e);return}if(c.length>0&&e.logger.debug(`Skipping endpoint level servers ${c.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),!l){let v=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(v!=null){let A=O?{url:v,audiences:O}:v;t[yy_]=A}}let y=Object.values(t).map(v=>typeof v=="string"?v:ghe(v)?Object.values(v.urls)[0]:v.url),b=r.filter(v=>{let O=typeof v=="string"?v:v.url;return!y.includes(O)});if(b.length>0&&e.logger.debug(`Skipping top level servers ${b.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),i){let v=!0;for(let[O,A]of Object.entries(t))if(e.builder.addEnvironment({name:O,schema:A}),v){if(e.builder.setDefaultEnvironment(O),ghe(A)){let g=Object.keys(A.urls)[0];g&&e.builder.setDefaultUrl(g)}v=!1}return}if(!p&&!_){let v=!0;for(let[O,A]of Object.entries(t))if(v){if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[Y0e]:g??"",...qJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});e.builder.setDefaultEnvironment(O),v=!1}else if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[Y0e]:g??"",...qJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl(Y0e)}else if(u===1){let v=Object.keys(t)[0],O=Object.values(t)[0],A=typeof O=="string"?O:ghe(O)?Object.values(O.urls)[0]:O.url;e.builder.addEnvironment({name:v,schema:{urls:{[Y0e]:A??"",...qJi(o),...qJi(f)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl(Y0e)}else{let v=new Map;for(let O of e.ir.endpoints)for(let A of O.servers)if(A.url!=null&&A.name!=null){v.has(A.name)||v.set(A.name,new Map);let g=A.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",m=v.get(A.name);m&&m.set(g,A.url)}if(v.size>0){let O=!0;for(let[A,g]of Object.entries(t)){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;if(!m)continue;let j=m.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",M={[Y0e]:m};for(let[E,D]of v.entries()){let B=D.get(j)||D.get("production")||D.values().next().value;B&&(M[E]=B)}h&&Object.assign(M,qJi(f)),Object.keys(M).length>1?e.builder.addEnvironment({name:A,schema:{urls:M}}):e.builder.addEnvironment({name:A,schema:m}),O&&(e.builder.setDefaultEnvironment(A),O=!1)}v.size>0&&e.builder.setDefaultUrl(Y0e)}else{let O=!0;for(let[A,g]of Object.entries(t)){if(h||Object.keys(o).length>0){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;e.builder.addEnvironment({name:A,schema:{urls:{[Y0e]:m??"",...qJi(o),...qJi(f)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var Psc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},crM=.75,lrM=new Set("authorization");function vy_(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?_Un(i.schema):void 0,o=a!=null?$vi(a):void 0,c=Tu.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?hO(Af({schema:i.schema,context:e,fileContainingReference:o?iD(Tu.of(No(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.options.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(lrM.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],f=OGt({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Tu.of(n1),context:e,namespace:void 0});o=new Psc(f),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*crM;for(let[n,a]of Object.entries(r)){let o=t[n],c=a.count===e.ir.endpoints.length,f=a.count>=i;o==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):f&&e.builder.addGlobalHeader({name:n,schema:CJi(a.schema)}))}}}function gy_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?_Un(t.schema):void 0,i=r!=null?$vi(r):void 0,n=OGt({header:{...t,schema:t.schema??Zs.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:ah.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:Tu.of(n1),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:CJi(n)})}}function HL(e){switch(e.type){case"primitive":return Ay_(e.value);case"object":return my_(e.properties);case"array":return Py_(e.value);case"map":return drM(e.value);case"oneOf":return prM(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return _rM(e.value);case"unknown":return HL(e.value);case"null":return null;default:vt(e)}}function Oy_(e){switch(e.type){case"withStreaming":return e.sse?{stream:frM(e.events)}:{stream:Py_(e.events)};case"withoutStreaming":return{body:HL(e.value)};default:vt(e)}}function Ay_(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:vt(e)}}function my_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,HL(r)]))}function frM(e){return e.map(t=>({event:"",data:HL(t)}))}function Py_(e){return e.map(t=>HL(t))}function drM(e){return Object.fromEntries(e.map(t=>[Ay_(t.key),HL(t.value)]))}function prM(e){return e.type==="discriminated"?my_(e.value):HL(e.value)}function _rM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:vt(e)}}function jy_({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"]=hrM(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=yrM(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let f of e.headers)f.name!==t.builder.getAuthHeaderName()&&c.push(f);for(let[f,s]of Object.entries(n))if(!o.has(f))if(s!=null&&typeof s=="object"&&s.type!=null){let u=PB({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:Et}});u!=null&&c.push({name:f,value:Sl.literal(RCi.string(u))})}else c.push({name:f,value:Sl.primitive(Ha.string(f))});r.headers=brM({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=HL(e.request)),e.response!=null&&(r.response=Oy_(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(ps)),r}function hrM(e){let t={};return e.forEach(r=>{let i=HL(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function yrM(e){let t={};return e.forEach(r=>{let i=HL(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function brM({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=HL(i.value);n!=null&&(r[i.name]=n)}),r}function wy_(e){return gz._visit(e,{get:()=>AD.HttpMethodSchema.Get,post:()=>AD.HttpMethodSchema.Post,put:()=>AD.HttpMethodSchema.Put,patch:()=>AD.HttpMethodSchema.Patch,delete:()=>AD.HttpMethodSchema.Delete,head:()=>AD.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 Ey_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Sy_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=G3o(e.sdkName,e.namespace),f={};for(let b of e.pathParameters)b.parameterNameOverride&&(o=o.replace(b.name,b.parameterNameOverride)),f[b.parameterNameOverride??b.name]=U3o({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=V3o({queryParameter:b,context:r,fileContainingReference:t,namespace:c});v!=null&&(s[b.name]=v,a.add(b.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:vt(e.pagination)}let l={path:o,method:wy_(e.method),auth:vrM({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Jvi(e.source):void 0};!mrM({context:r,request:e.request})&&Object.keys(f).length>0&&(l["path-parameters"]=f),e.summary!=null&&(l["display-name"]=e.summary);let p={},_=r.builder.getGlobalHeaderNames(),h=r.builder.getAuthHeaderName();h!=null&&_.add(h);let y=e.headers.filter(b=>!_.has(b.name));for(let b of y){let v=OGt({header:b,context:r,fileContainingReference:t,namespace:c});p[b.name]=v,a.add(typeof v=="string"?b.name:v.name??b.name)}if(e.request!=null){r.setInState(q1.Request);let b=ArM({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(p).length>0?p:void 0,usedNames:a,namespace:c});l.request=b.value,n=[...n,...b.schemaIdsToExclude??[]],r.unsetInState(q1.Request)}else{let b=r.options.inlinePathParameters&&Object.keys(f).length>0,v=Object.keys(s).length>0,O=Object.keys(p).length>0,A={};(b||v||O)&&(A.name=e.requestNameOverride??e.generatedRequestName),b&&(A["path-parameters"]=f),v&&(A["query-parameters"]=s),O&&(A.headers=p),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:hO(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"json"}},streamingSse:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"sse"}},file:b=>{l.response={docs:b.description??void 0,type:"file","status-code":b.statusCode}},bytes:b=>{l.response={docs:b.description??void 0,type:"bytes","status-code":b.statusCode}},streamingText:b=>{l["response-stream"]={docs:b.description??void 0,type:"text"}},text:b=>{l.response={docs:b.description??void 0,type:"text","status-code":b.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let b=r.getDefaultServerName(),v=e.servers[0];v==null?b!=null&&(l.url=b):l.url=v.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=ZE(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=Tu.of(ob);r.builder.enableUniqueErrorsPerEndpoint&&(O=`${e.generatedRequestName}${v.generatedName}`,v.schema!=null&&(v.schema.type!=="reference"&&v.schema.type!=="oneOf"?v.schema.generatedName=`${e.generatedRequestName}${v.schema.generatedName}`:v.schema.type==="oneOf"&&(v.schema.value.generatedName=`${e.generatedRequestName}${v.schema.value.generatedName}`)));let g={"status-code":parseInt(b)},m=Zh_({location:My_,namespaceOverride:c});if(v.schema!=null){let E=Af({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=hO(E),g.docs=v.description}r.builder.addError(m,{name:O,schema:r.isErrorUnknownSchema(parseInt(b))?{...g,type:"unknown"}:g}),l.errors==null&&(l.errors=[]);let j=r.builder.addImport({file:t,fileToImport:m});l.errors.push(j!=null?`${j}.${O}`:O),g.type!=null&&v.examples?.forEach(E=>{let D={value:HL(E.example),name:E.name,docs:E.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=grM({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=OrM({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[jsc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function vrM({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function grM({endpointExamples:e,context:t}){return e.map(r=>{try{return jy_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function OrM({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:vt(e)}}function ArM({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:f,headers:s,usedNames:u,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let p=i.schema.type==="reference"?i.schema.schema:void 0,_=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(_?.type!=="object"||p!=null&&f.includes(p)){let O=Af({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),A={schemaIdsToExclude:[],value:{body:O}},g=Object.keys(o??{}).length>0,m=Object.keys(c??{}).length>0,j=Object.keys(s??{}).length>0;return g&&(A.value["path-parameters"]=o),m&&(A.value["query-parameters"]=c),j&&(A.value.headers=s),(g||m||j)&&(A.value.name=n??a),i.contentType!=null&&(A.value["content-type"]=i.contentType),i.description!=null&&(A.value.docs=i.description),A}let h=Object.fromEntries(_.properties.filter(O=>O.readonly==null?!0:!(Ey_(e.method)&&O.readonly)).map(O=>{let A=Af({schema:O.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),g=O.nameOverride??O.key,m=ZE(O.availability);if(!u.has(g)&&O.audiences.length<=0)return u.add(g),O.nameOverride!=null?[O.key,{type:hO(A),docs:hUn(A),name:O.nameOverride,availability:m}]:[O.key,m?{...typeof A=="string"?{type:A}:A,availability:m}:A];let j={type:hO(A),docs:hUn(A)};return u.has(g)&&(j.name=O.generatedName),O.audiences.length>0&&(j.audiences=O.audiences),m!=null&&(j.availability=m),u.add(g),[O.key,j]})),y=_.allOf.map(O=>{let A=Af({schema:Zs.reference(O),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return hO(A)}).filter(O=>O!=="unknown"),b={properties:h};y.length>0&&(b.extends=y),i.additionalProperties&&(b["extra-properties"]=!0);let v={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:b};return i.contentType!=null&&(v["content-type"]=i.contentType),i.description!=null&&(v.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:v}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??VA.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(p.name=n??a),i.description!=null&&(p.docs=i.description),{schemaIdsToExclude:[],value:p}}else if(i.type==="multipart"){let p=Object.fromEntries(i.properties.map(_=>{if(_.schema.type==="file"){let h=_.schema.isArray?"list<file>":"file";if(h=_.schema.isOptional?`optional<${h}>`:h,_.description!=null||_.contentType!=null){let y={type:h};if(_.description!=null&&(y.docs=_.description),_.contentType!=null){let b=_.contentType.split(",")[0];y["content-type"]=b}return[_.key,y]}return[_.key,h]}else{let h=Af({schema:_.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(_.contentType||_.exploded||_.encoding){let y=typeof h=="string"?{type:h}:h;_.contentType!=null&&(y["content-type"]=_.contentType),_.encoding==="form"?y.style="form":_.encoding==="json"?y.style="json":_.exploded&&(y.style="exploded"),h=y}return[_.key,h]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:p},"content-type":VA.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else vt(i)}function mrM({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:vt(t)}}function PrM({location:e,namespaceOverride:t}){return t!=null?{...e,file:iD(Tu.of(t),e.file)}:e}function jrM(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Tu.of(`${No(r)}.yml`),endpointId:e.summary!=null?No(e.summary):No(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Tu.of(ob),endpointId:No(e.summary)}:{file:Tu.of(ob),endpointId:No(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Tu.of(ob),endpointId:i};let n=cja(r),a=cja(i);if(r1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=SrM({operationId:i,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let f=0;f<n.length;++f){let s=n[f];if(s!=null&&s===a[f])c.push(s);else{let u=No(r);return{file:Tu.of(`${u}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Tu.of(No(c.join("_"))+".yml"),endpointId:No(a.slice(c.length).join("_")),tag:r}}function lja(e){let t=e.tags[0];if(e.sdkName!=null){let r=usc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Tu.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return PrM({namespaceOverride:e.namespace,location:jrM(e)})}function cja(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=$Oe(t),t}var wrM=new RegExp("[^a-zA-Z0-9{}]+"),ErM=new RegExp("[{}]","g");function SrM({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(wrM).join("_").replaceAll(ErM,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Tu.of(No(t)+".yml"),endpointId:No(e.slice(0,-1*a.length)),tag:t}}function Dy_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:o,file:c,tag:f}=lja(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let _=e.ir.groups;for(let h of a.sdkName.groupName){let y=typeof h=="string"?h:h.name,b=_[y];if(b==null)break;if(b.summary!=null||b.description!=null){u=_[y];break}}}let l=f==null?void 0:i.tagsById[f];e.setInState(q1.Endpoint),e.setEndpointMethod(a.method);let p=Sy_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(q1.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?Jvi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function By_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?$vi(r.groupName):void 0,n=Af({schema:Zs.primitive(r),context:e,fileContainingReference:Tu.of(ob),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:hO(n),docs:r.description??void 0}})}}function Iy_(e){for(let t of e.ir.webhooks){let r=BrM({webhook:t,context:e});if(r==null)continue;let i=G3o(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=OGt({header:o,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Af({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:HL(o.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function MrM({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:iD(Tu.of(t),e.file)}:e}function DrM({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Tu.of(ob),endpointId:i};let n=cja(r),a=cja(i);if(r1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<n.length;++c){let f=n[c];if(f!=null&&f===a[c])o.push(f);else{let s=No(r);return{file:Tu.of(`${s}.yml`),endpointId:i,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Tu.of(No(o.join("_"))+".yml"),endpointId:No(a.slice(o.length).join("_")),tag:r}}function BrM({webhook:e,context:t}){return e.sdkName!=null?{file:Xh_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:MrM({namespaceOverride:e.namespace,location:DrM({webhook:e,context:t})})}var IrM=Tu.of(ob);function qy_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return Cy_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return Cy_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return IrM;default:vt(e)}}function Cy_({namespace:e,groupName:t}){return e!=null&&t!=null?HCi([{type:"namespace",name:e},...t]):e!=null?HCi([{type:"namespace",name:e}]):HCi(t)}var jsc="external",My_=Tu.of(ob);function Ty_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=qy_(a),c=ny_({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(OCi(c.schema)){let f=hO(c.schema);if(f===(c.name??n)||f===`optional<${c.name??n}>`||f===`nullable<${c.name??n}>`||f===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(o,{name:c.name??n,schema:c.schema})}}function Ry_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),by_(e),vy_(e),gy_(e),cy_(e),By_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(jsc);let t=Dy_(e),r=t.sdkGroups;e.setInState(q1.Webhook),Iy_(e),e.unsetInState(q1.Webhook),e.setInState(q1.Channel);for(let n of Object.values(e.ir.channels)){let a=HCi(n.groupName);py_({channel:n,context:e,declarationFile:a})}e.unsetInState(q1.Channel);let i=CrM({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});Ty_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))Ty_({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function CrM({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var fja=class{context;constructor(t){this.context=t}};var H3o=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let f=n!=null?Tu.of(`${n}${"/"}${o}`):Tu.of(o);t[f]=c}let a=Object.keys(i.directories).sort();for(let o of a){let c=n!=null?`${n}${"/"}${o}`:o,f=i.directories[o];r(f,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Tu.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var TJi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new H3o,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),i!=null&&(o.service["base-path"]=i),n!=null&&(o.service["display-name"]=n),a!=null&&(o.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return oGt(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))zy_(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(zy_(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??No((dAe(r)+"/"+v9i(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Tu.of(n1))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Puo(dAe(JDn.of(`/${t}`)),JDn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Puo(dAe(JDn.of(`/${t}`)),JDn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Tu.of(n1))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>r1(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=iD(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let i=Object.values(r.service.endpoints);if(i.length===0)continue;if(i.every(a=>a.auth===!0)){r.service.auth=!0;for(let a of Object.values(r.service.endpoints))delete a.auth}}}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:iD(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,o])=>[a,{...o,path:iD(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ob?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 zy_(e){return e?.header!=null}var K3o=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=o,this.globalHeaderOverrides=a,this.options=DJi({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new TJi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let f of r.endpoints)for(let[s,u]of Object.entries(f.errors)){let l=parseInt(s),p=c[l];p==null&&u.schema!=null?c[l]=u.schema:p!=null&&u.schema!=null&&nK(p,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(t)}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.options.onlyIncludeReferencedSchemas&&this.isInAnyState(q1.Channel,q1.Endpoint,q1.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:vt(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:vt(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function wsc(e){let t=new K3o(e);return Ry_(t)}function qrM(e){return xKi(e,{single:t=>[typeof t=="string"?t:t.scheme],any:t=>t.any.map(r=>typeof r=="string"?r:r.scheme)})}function TrM(e,t){if(e==null)return;let r=qrM(t),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var J3o=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let i=this.args.generatorsConfiguration?.api?.["auth-schemes"],n=this.args.generatorsConfiguration?.api?.auth,a=t??n;if(a==null)return;let o=r!=null||i!=null?{...i,...r}:void 0,c=TrM(o,a);return{auth:a,"auth-schemes":c}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=wsc({taskContext:t,ir:r,options:DJi({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth,i?.authSchemes),environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Fi.dump(a.rootApiFile)},namedDefinitionFiles:{...bn(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Fi.dump(o),contents:o})),[Tu.of(ob)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Fi.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var dja=class extends hFt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;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.groupEnvironmentsByHost=t.groupEnvironmentsByHost,this.removeDiscriminantsFromSchemas=t.removeDiscriminantsFromSchemas,this.converter=new J3o(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r,i){let n=await this.getDefinition({context:t},r);return new rK({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var JQ={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 yUn={of(e){return e}};var Ny_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},Esc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Ny_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Gi={SOURCE:yUn.of("source"),SDK_NAMESPACE:yUn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:yUn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:yUn.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:yUn.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated",EXPLORER_ENABLED:"x-fern-explorer-enabled"};var RrM={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!1,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!1,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,preserveSchemaIds:!1,objectQueryParameters:!0,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!0,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!1,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,groupEnvironmentsByHost:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,removeDiscriminantsFromSchemas:wn.RemoveDiscriminantsFromSchemas.Always};function zrM(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function X0e({options:e,overrides:t}){return zrM({defaults:RrM,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var Fy_={naming:"v1"};function Di(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function pja(e,t,r,i,n=[]){try{let a=Di(e,t);if(a!=null)return r.parse(a)}catch{let o=$Oe(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function RJi(e){let t=Di(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 Qy_({schema:e,logger:t}){return Di(e,Gi.ENCODING)??void 0}function Uy_(e){return Di(e,Gi.FERN_ENUM)}function Ly_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Di(i,Gi.SDK_NAMESPACE),c=Di(i,Gi.SDK_GROUP_NAME),f=Di(i,Gi.TYPE_DEFINITION);if(f!=null)return _ja({fernType:f,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function _ja({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c}){return PB({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.base64({example:void 0})});case"BOOLEAN":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.boolean({default:void 0,example:void 0})});case"DATE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.date({example:void 0})});case"DATE_TIME":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.datetime({example:void 0})});case"FLOAT":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.float({example:void 0})});case"DOUBLE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint({default:void 0,example:void 0})});case"INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint64({default:void 0,example:void 0})});case"LONG":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:vt(f.v1)}},unknown:()=>ri.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:o,groupName:c}),map:({keyType:f,valueType:s})=>f?.type==="primitive"&&s!=null?ri.map({nameOverride:t,generatedName:r,title:i,key:f,value:s,description:n,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:f=>f!=null?ri.optional({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:f=>f!=null?ri.nullable({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:f=>ri.literal({nameOverride:t,generatedName:r,title:i,value:f._visit({string:s=>Fj.string(s),boolean:s=>Fj.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:f=>ri.reference({schema:f,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:xL.openapi({file:"<memory>"})})}})}function Vy_(e){let t=Di(e,Gi.SOURCE);if(t!=null)return t.endsWith(".proto")?xL.protobuf({file:t}):xL.openapi({file:t})}function zJi(e){if(e!=null&&typeof e=="boolean")return e}function jn(e){return e?.$ref!=null}function Wy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,encoding:_,source:h}){return n===void 0&&(n=s.options.additionalPropertiesDefaultsTo),Ssc({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:typeof n=="boolean"||hja(n,s.options)?ri.unknown({...NrM(n),generatedName:`${t}Value`}):xy_(Dl(n,!1,s.options.optionalAdditionalProperties?f:!1,s,[...i,"Value"],h,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:p,encoding:_})}function xy_(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=xy_(e.value);break;case"oneOf":e.value.inline=!0;break;default:vt(e)}return e}function Ssc({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:f,namespace:s,groupName:u,example:l,encoding:p}){let _=ri.map({nameOverride:e,generatedName:t,title:r,description:c,availability:f,key:i,value:n,namespace:s,groupName:u,encoding:p,example:l,inline:void 0});return o&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),a&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),_}function hja(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!(jn(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 NrM(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"||jn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function Gy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,source:_}){let h=n==null?ri.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Dl(n,!1,!1,s,[...i,"Item"],_,u);return FrM({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,example:p})}function FrM({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,example:u}){let l=ri.array({nameOverride:e,generatedName:t,title:r,value:i,description:o,availability:c,namespace:f,groupName:s,example:u,inline:void 0});return a&&(l=ri.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(l=ri.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),l}function KL(e){switch(Di(e,Gi.AVAILABILITY)){case"deprecated":return bz.Deprecated;case"beta":return bz.Beta;case"generally-available":return bz.GenerallyAvailable;default:break}if(!jn(e)&&e.deprecated)return bz.Deprecated}function Msc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminator:u,context:l,namespace:p,groupName:_,encoding:h,source:y}){let b=u.propertyName,v=Object.fromEntries(Object.entries(u.mapping??{}).map(([A,g])=>{let m=Yvi({$ref:g},!1,!1,l,[g],h,y,p);return l.markReferencedByDiscriminatedUnion({$ref:g},b,1),[A,m]})),O=Object.entries(n).filter(([A])=>A!==b).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=l.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,l,[...i,A],y,p);return{key:A,schema:E}});return Hy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:b,subtypes:v,namespace:p,groupName:_,source:y})}function Dsc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminant:u,variants:l,context:p,namespace:_,groupName:h,encoding:y,source:b}){let v=Object.fromEntries(Object.entries(l).map(([A,g])=>{if(jn(g)){let m=Yvi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=bUn(g,!1,!1,p,[...i,A],y,b,_,new Set([u]));return[A,m]}})),O=Object.entries(n).filter(([A])=>A!==u).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=p.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,p,[...i,A],b,_);return{key:A,schema:E}});return Hy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:u,subtypes:v,namespace:_,groupName:h,source:b})}function Hy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,availability:c,discriminant:f,subtypes:s,namespace:u,groupName:l,source:p}){let _=ri.oneOf(Bhe.discriminated({description:o,availability:c,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:p,inline:void 0}));return n&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),_}function Ky_(e){if(e.proto!=null)return zQn.protobuf({typeName:e.proto.type})}function JCi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:o,description:c,availability:f,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:p,context:_,source:h,inline:y}){let b=UrM(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],M=b[m],E=dUn.test(g),D=j?.name??M,B=E?g:pUn(g);return D!=null&&!dUn.test(D)&&(_?.logger.warn(`Enum name override ${D} is not a valid name. Falling back on ${B}.`),D=void 0),{nameOverride:D,generatedName:B,value:g,description:j?.description,availability:f,casing:{snake:j?.casing?.snake??void 0,pascal:j?.casing?.pascal??void 0,screamingSnake:j?.casing?.screamingSnake??void 0,camel:j?.casing?.camel??void 0}}}),A=o!=null?O.find(g=>g.value===o):void 0;return QrM({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:O,_default:A,description:c,availability:f,namespace:l,groupName:p,source:h,inline:y})}function QrM({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:i,title:n,values:a,_default:o,description:c,availability:f,namespace:s,groupName:u,source:l,inline:p}){let _=ri.enum({nameOverride:r,generatedName:i,title:n,values:a,description:c,availability:f,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:p});return t&&(_=ri.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),e&&(_=ri.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),_}function UrM(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function Jy_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==="int64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function LrM(e){return typeof e=="string"?Fj.string(e):typeof e=="boolean"?Fj.boolean(e):Fj.string(`${e}`)}function $y_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:f,groupName:s}){let u=ri.literal({nameOverride:e,generatedName:t,title:r,value:LrM(a),description:o,availability:c,namespace:f,groupName:s});return n&&(u=ri.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),i&&(u=ri.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),u}function Bsc({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==null||i==="double"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.double({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="float"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var VrM={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},WrM={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}}},xrM={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}}},GrM={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},HrM={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},KrM={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},JrM={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},$rM={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function yja(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[VrM,WrM,xrM,GrM,HrM,KrM,JrM,$rM],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function TC(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:QP(No(n))).join("");return/^\d/.test(i)?aja(i)??i:i}function Yy_(e){let t=e.join("_");return No(t)}function xO(e){switch(e.type){case"object":return Zs.object({allOf:e.allOf,properties:e.properties.map(t=>XrM(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 Zs.array({description:e.description,availability:e.availability,value:xO(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Zs.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 Zs.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 Zs.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Zs.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Zs.primitive({description:e.description,availability:e.availability,schema:Xy_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Zs.map({description:e.description,availability:e.availability,key:Zs.primitive({description:e.key.description,availability:e.key.availability,schema:Xy_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:xO(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 Zs.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 Zs.oneOf(YrM(e.value));case"unknown":return Zs.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:vt(e)}}function YrM(e){switch(e.type){case"discriminated":return hGt.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:xO(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,xO(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return hGt.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>xO(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:vt(e)}}function Xy_(e){switch(e.type){case"string":return ah.string(e);case"base64":return ah.base64();case"boolean":return ah.boolean(e);case"date":return ah.date();case"datetime":return ah.datetime();case"double":return ah.double(e);case"float":return ah.float();case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();default:vt(e)}}function XrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:xO(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function $3o(e,t){return nK(xO(e),xO(t))}function Zy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:o,wrapAsOptional:c,wrapAsNullable:f,allOf:s,context:u,propertiesToExclude:l,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v}){let O=[...o??[]],A={...ky_({properties:n,breadcrumbs:i,context:u})},g=[],m=[];for(let B of s)if(!u.options.inlineAllOfSchemas&&jn(B)){let F=u.resolveSchemaReference(B);if(F.discriminator!=null&&F.discriminator.mapping!=null)continue;if(F.oneOf!=null||F.anyOf!=null){let T=F.oneOf??F.anyOf;if(T!=null){for(let R of T){let Q=jn(R)?u.resolveSchemaReference(R):R,U=Dl(Q,!1,!1,u.DUMMY,i,v,p);U.type==="object"&&g.push(...U.properties.map(H=>H.schema.type!=="optional"&&H.schema.type!=="nullable"?{...H,schema:ri.optional({nameOverride:void 0,generatedName:"",title:void 0,value:H.schema,description:void 0,availability:H.availability,namespace:void 0,groupName:void 0,inline:void 0})}:H))}continue}}let N=$Ci(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:Isc(B,[N],v,u.options.preserveSchemaIds),properties:eb_({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(jn(B)){let F=u.resolveSchemaReference(B),N=Dl(F,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let F=B.required??[];g=g.map(T=>(T.schema.type==="optional"||T.schema.type==="nullable")&&F.includes(T.key)?{...T,schema:T.schema.value}:T);let N=Dl(B,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}let j={};for(let B of m)for(let[F,N]of Object.entries(B.properties)){let T=j[F];T!=null?(T.schemaIds.push(B.schemaId),T.schemas.some(Q=>$3o(Q,N))||T.schemas.push(N)):j[F]={schemaIds:[B.schemaId],schemas:[N]}}let M=[];for(let[B,F]of Object.entries(j))F.schemaIds.length>1&&M.push({propertyKey:B,allOfSchemaIds:F.schemaIds,conflictingTypeSignatures:F.schemas.length>1});let E=Object.fromEntries(Object.entries(A).filter(([B,F])=>!(!jn(F)&&F.type==="null"))),D=Object.entries(E).map(([B,F])=>{let N=Di(F,Gi.AUDIENCES)??[],T=KL(F),R=jn(F)?!1:F.readOnly,Q=jn(F)?!1:F.writeOnly,H=!(O.includes(B)&&!R),oe=Di(F,Gi.FERN_PROPERTY_NAME),se=[...i,B],x=Yy_(se),G=Dl(F,H,!1,u,se,v,p),Pe={};for(let ne of m){let Ee=ne.properties[B];Ee!=null&&!$3o(G,Ee)?Pe[ne.schemaId]={differentSchema:!0}:Ee!=null&&(Pe[ne.schemaId]={differentSchema:!1})}return{key:B,schema:G,nameOverride:oe,audiences:N,conflict:Pe,generatedName:x,availability:T,readonly:R,writeonly:Q}});return D.push(...g.map(B=>{let F=B.conflict;for(let N of m){let T=N.properties[B.key];T!=null&&!$3o(B.schema,T)?F[N.schemaId]={differentSchema:!0}:T!=null&&(F[N.schemaId]={differentSchema:!1})}return{...B,conflict:F}})),ZrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,properties:D.filter(B=>!l.has(B.key)),description:a,allOf:m.map(B=>B.convertedSchema),allOfPropertyConflicts:M,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v,context:u})}function ZrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:p,availability:_,source:h,context:y}){let b=ri.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:hja(p,y.options),availability:_,source:h,inline:void 0});return n&&(b=ri.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ri.optional({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),b}function ky_({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([i,n])=>{let a=Di(n,Gi.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function eb_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=jn(e)?[t.resolveSchemaReference(e),yja(e.$ref)]:[e,r];for(let f of o.allOf??[])a={...a,...eb_({schema:f,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[f,s]of Object.entries(ky_({properties:o.properties??{},breadcrumbs:r,context:t}))){let u=Dl(s,!1,!1,t,[...c,f],i,n);a[f]=u}return a}function YCi({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:f,subtypes:s,namespace:u,groupName:l,encoding:p,source:_,subtypeSuffixOverrides:h}){let y=tiM({schemas:s}),b=s.flatMap((O,A)=>{if(!jn(O)&&O.enum!=null&&f.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ri.literal({nameOverride:void 0,generatedName:TC([t,m],f.options.preserveSchemaIds),title:void 0,value:Fj.string(String(m)),namespace:u,groupName:void 0,description:void 0,availability:m.availability}));let g=y[A];if(h!=null){let m=h[A];m!=null&&"name"in m&&(g=m.name)}return[Dl(O,!1,!1,f,[...i,g??`${A}`],_,u)]}),v=krM(b);return eiM({uniqueSubtypes:v,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:n,availability:a,namespace:u,groupName:l,context:f,encoding:p,source:_})}function krM(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(i!=null&&o!=null&&nK(i,o)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function eiM({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,context:u,encoding:l,source:p}){if(Object.entries(e).every(([h,y])=>y.type==="literal")){let h={},y=[];return Object.entries(e).forEach(([b,v])=>{v.type==="literal"&&v.value.type==="string"&&(y.push(v.value.value),v.description!=null&&(h[v.value.value]={description:v.description}))}),JCi({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,fernEnum:h,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:f,groupName:s,context:u,source:p,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let h=e[0];return a&&(h=ri.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(h=ri.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),h}return tb_({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:f,groupName:s,encoding:l,source:p})}function Csc({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:f,groupName:s,discriminator:u,encoding:l,source:p}){let _=Object.entries(u.mapping??{}).map(([b,v],O)=>{let A={$ref:v},g=Yvi(A,!1,!1,c,[v],l,p,f);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ri.literal({nameOverride:void 0,generatedName:TC([t,b],c.options.preserveSchemaIds),title:void 0,value:Fj.string(b),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...g.properties.filter(m=>m.key!==u.propertyName)}),g}),h=[];for(let b=0;b<_.length;++b){let v=_[b],O=!1;for(let A=b+1;A<_.length;++A){let g=_[A];if(v!=null&&g!=null&&nK(v,g)){O=!0;break}}v!=null&&!O&&h.push(v)}if(Object.entries(h).every(([b,v])=>v.type==="literal")){let b={},v=[];return Object.entries(h).forEach(([O,A])=>{A.type==="literal"&&A.value.type==="string"&&(v.push(A.value.value),A.description!=null&&(b[A.value.value]={description:A.description}))}),JCi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,fernEnum:b,enumVarNames:void 0,enumValues:v,_default:void 0,namespace:f,groupName:s,context:c,source:p,inline:void 0})}return h.length===1&&h[0]!=null&&!c.options.preserveSingleSchemaOneOf?h[0]:tb_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,subtypes:h,namespace:f,groupName:s,encoding:l,source:p})}function tiM({schemas:e}){let t={},r=0;for(let n of e){if(!jn(n)){if(n.properties!=null&&Object.entries(n.properties).length>0){let a=Object.keys(n.properties),o={},c=a;for(let[f,s]of Object.entries(t)){let u=Rro(s,a);c=Rro(c,s),o[f]=u}o[r]=c,t=o}}r++}return e.map((n,a)=>{let o=t[a];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null)return c[0]}return IJi(a)??`${a}`})}function tb_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,description:a,availability:o,subtypes:c,namespace:f,groupName:s,encoding:u,source:l}){let p=ri.oneOf(Bhe.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:f,groupName:s,encoding:u,source:l,inline:void 0}));return n&&(p=ri.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),i&&(p=ri.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),p}function vUn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Y3o({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=RJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function rb_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=RJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function AGt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=RJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function ib_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=RJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var NJi="#/components/schemas/";function ob_(e,t){let r=jn(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"integer":return!0;case"string":return r.enum==null;case"array":return ob_(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 riM(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:ob_(t,r):!1}function Dl(e,t,r,i,n,a,o,c=!1,f=new Set,s){let u=Vy_(e)??a,l=liM({schema:e,logger:i.logger});if(jn(e)){let p=$Ci(e);return p!=null?riM(p,e,i)?bUn(i.resolveSchemaReference(e),t,r,i,yja(e.$ref),l,u,o,f,c,s):(c?i.markSchemaAsReferencedByRequest(p):i.markSchemaAsReferencedByNonRequest(p),Yvi(e,t,r,i,n,l,u,o)):bUn(i.resolveSchemaReference(e),t,r,i,yja(e.$ref),l,u,o,f,c,s)}return bUn(e,t,r,i,n,l,u,o,f,c,s)}function Yvi(e,t,r,i,n,a,o,c){let f=e.$ref.includes("properties")?bUn(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ri.reference(Isc(e,n,o,i.options.preserveSchemaIds));if(r===!1){let s=i.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(f=ri.nullable({title:void 0,nameOverride:void 0,generatedName:TC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(f=ri.optional({title:void 0,nameOverride:void 0,generatedName:TC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),f}function iiM(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function bUn(e,t,r,i,n,a,o,c,f=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Di(e,Gi.TYPE_NAME)??(i.options.useTitlesAsName?iiM(e.title):void 0),p=Di(e,Gi.SDK_GROUP_NAME)??Di(e,JQ.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=TC(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=KL(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Di(e,JQ.EXAMPLES);A!=null&&Object.keys(A).length>0&&O.push(...Object.entries(A).map(([j,M])=>({name:M?.summary??j,value:M.value,description:M.description})));let g=RJi(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=Ly_({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),j}try{if(Array.isArray(e.type)){let E=e.type.indexOf("null"),D=E!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&D)e.type.splice(E,1),e.type=e.type[0],e.nullable=!0;else if(D&&(e.type.splice(E,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let B=new Set([...e.oneOf,...e.type]);e.oneOf=[...B]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(D=>D!==null),!k3o(e.enum))return T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:vUn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:AGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let E=Uy_(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&E==null?$y_({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):JCi({nameOverride:l,generatedName:h,title:y,fernEnum:E,enumVarNames:Di(e,[JQ.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0})}if(k3o(e.type)&&e.type.length>1){let E=e.type.includes("null"),D=e.type.filter(B=>B!=="null").map(B=>({type:B,nullable:E}));return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:D,namespace:c,groupName:_,encoding:a,source:o})}if(e.type==="boolean"){let E=Di(e,Gi.BOOLEAN_LITERAL);return E!=null?nb_({nameOverride:l,generatedName:h,title:y,literal:Fj.boolean(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.boolean({default:niM(e.default),example:rb_({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return Bsc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zJi(e.exclusiveMinimum),exclusiveMaximum:zJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return Jy_({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zJi(e.exclusiveMinimum),exclusiveMaximum:zJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="float")return Bsc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zJi(e.exclusiveMinimum),exclusiveMaximum:zJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.datetime({example:AGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="date"&&i.options.typeDatesAsStrings===!1)return T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.date({example:AGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="json-string"){let D=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let E=sb_(e,"const");return E!=null?nb_({nameOverride:l,generatedName:h,title:y,literal:Fj.string(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:vUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:AGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return Gy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,item:e.items,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,example:ib_({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&X3o(e))return Wy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,additionalProperties:e.additionalProperties,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Di(e,Gi.IS_DISCRIMINATED)===!1)return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf,namespace:c,groupName:_,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return i.options.discriminatedUnionV2?Csc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let E=Di(e,Gi.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||E?Csc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(i.options.preserveSingleSchemaOneOf)return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Dl(e.oneOf[0],t,r,i,n,o,c,s);return mGt(D,b,c,_)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],T=e.oneOf[1];if(!jn(N)&&N.type==="null"){let R=Dl(T,t,!0,i,n,o,c);return mGt(R,b,c,_)}else if(!jn(T)&&T.type==="null"){let R=Dl(N,t,!0,i,n,o,c);return mGt(R,b,c,_)}}let D=uiM({schemas:e.oneOf});if(D!=null)return JCi({nameOverride:l,generatedName:h,title:y,fernEnum:void 0,enumVarNames:void 0,enumValues:D,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0});let B=ab_({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!E)return Dsc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:B.discriminant,variants:B.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let F=e.oneOf.filter(N=>!jn(N)&&N.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||F,context:i,subtypes:e.oneOf.filter(N=>jn(N)||N.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let B=Dl(e.anyOf[0],t,r,i,n,o,c,s);return mGt(B,b,c,_)}if(e.anyOf.length===2){let[B,F]=e.anyOf;if(B!=null&&F!=null){if(!jn(B)&&B.type==="null"){let N=Dl(F,t,!0,i,n,o,c);return mGt(N,b,c,_)}else if(!jn(F)&&F.type==="null"){let N=Dl(B,t,!0,i,n,o,c);return mGt(N,b,c,_)}}}let E=ab_({schemas:e.anyOf,context:i});if(E!=null&&!i.options.discriminatedUnionV2)return Dsc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:E.discriminant,variants:E.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let D=e.anyOf.filter(B=>!jn(B)&&B.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}if(e.allOf!=null||e.properties!=null){let E=[];for(let B of e.allOf??[])(jn(B)||Object.keys(B).length>0)&&E.push(B);if((e.properties==null||X3o(e))&&E.length===1&&E[0]!=null){let B=Dl(E[0],t,r,i,n,o,c,s);return mGt(B,b,c,_)}let D=E.filter(B=>{let F=Z3o(B);return F||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),F});if((e.properties==null||X3o(e))&&D.length===1&&D[0]!=null){let B=Dl(D[0],t,r,i,n,o,c,s);return mGt(B,b,c,_)}return Zy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},description:b,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:D,context:i,propertiesToExclude:f,namespace:c,groupName:_,fullExamples:O,additionalProperties:e.additionalProperties,availability:v,encoding:a,source:o})}if(e.type==="object"&&aiM(e)&&oiM(e)&&X3o(e))return Ssc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${h}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:vUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:AGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ri.unknown({nameOverride:void 0,generatedName:`${h}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:_}),namespace:c,groupName:_,encoding:a,example:e.example});e.type!=null&&i.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${n.join("->")}. Coercing to unknown.`);let j=e.example??e.default,M=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(M=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),t&&(M=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),M}catch(j){return i.logger.debug(`Error converting schema: ${j.message}
1416
+ `)),{ok:!0,value:t}):i}}function CUo(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var NQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var FQn=class e extends Error{errors;constructor(t){super(t.map(CUo).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function Ym(e){return{optional:()=>kuc(e),transform:t=>esc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new FQn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new NQn(i.errors)}}}function kuc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>oh.OPTIONAL};return{...t,...Ym(t)}}function esc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...Ym(r)}}function bh_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(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:DA(t,"bigint")}]},getType:()=>oh.BIGINT};return{...Oz(e),...Ym(e)}}var AtM=/^([+-]?\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 vh_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:DA(t,"string")}]}:AtM.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:DA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:DA(t,"Date object")}]},getType:()=>oh.DATE};return{...Oz(e),...Ym(e)}}function GL(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Oz(r),...Ym(r)}}}function qUo(e){let t=new Set(e);return GL(oh.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:DA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:DA(i,"enum")}]}:{ok:!0,value:i})()}function gh_(e){let t=tsc(e);return{...t,...Ym(t)}}function tsc(e){return{parse:(t,r)=>QQn(e).parse(t,r),json:(t,r)=>QQn(e).json(t,r),getType:()=>QQn(e).getType()}}function QQn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function tja(e){return Object.entries(e)}function rja(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function NCi(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 ija(e){return Object.keys(e)}function Oh_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function vFt(e){return{withParsedProperties:t=>rsc(e,t)}}function rsc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[f,s])=>({...c,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!NCi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DA(i,"object")}]};let a=new Set(Object.keys(t)),o=rja(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...Ym(r),...vFt(r)}}function Ah_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function FCi(e){return e.isProperty}function TUo(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>FCi(i)?i.rawKey:r),_getParsedProperties:()=>ija(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of tja(e)){let f=FCi(c)?c.rawKey:o,s=FCi(c)?c.valueSchema:c,u={rawKey:f,parsedKey:o,valueSchema:s};n[f]=u,jh_(s)&&a.push(f)}return mh_({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:f=>c.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of tja(e)){let c=FCi(o)?o.valueSchema:o;jh_(c)&&n.push(a)}return mh_({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return FCi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>oh.OBJECT};return{...Oz(t),...Ym(t),...vFt(t),...BJi(t)}}function mh_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!NCi(e))return{ok:!1,errors:[{path:a,message:DA(e,"object")}]};let o=new Set(t),c=[],f={};for(let[s,u]of Object.entries(e)){let l=r(s);if(l!=null){o.delete(s);let p=l.transform(u);p.ok?f[l.transformedKey]=p.value:(f[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:f}:{ok:!1,errors:c}}function BJi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Ph_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Ph_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>oh.OBJECT};return{...r,...Ym(r),...vFt(r),...BJi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>oh.OBJECT};return{...t,...Ym(t),...vFt(t),...BJi(t)}}}}function Ph_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,o]=Oh_(ija(t),s=>n.has(s)),c=r(rja(t,o)),f=i(rja(t,a));return c.ok&&f.ok?{ok:!0,value:{...c.value,...f.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...f.ok?[]:f.errors]}}function jh_(e){return!mtM(e)}function mtM(e){switch(e.getType()){case oh.ANY:case oh.UNKNOWN:case oh.OPTIONAL:return!0;default:return!1}}function wh_(e){return TUo(e)}function Eh_(e){let t={...tsc(e),_getRawProperties:()=>QQn(e)._getRawProperties(),_getParsedProperties:()=>QQn(e)._getParsedProperties()};return{...t,...Ym(t),...vFt(t),...BJi(t)}}function RUo(e){let t={parse:(r,i)=>Sh_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Sh_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>oh.LIST};return{...Oz(t),...Ym(t)}}function Sh_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:DA(e,"list"),path:[]}]}}function Mh_(e){return GL(oh.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`"${e}"`)}]})()}function Dh_(e){return GL(oh.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:DA(r,`${e.toString()}`)}]})()}var Bh_=GL(oh.ANY,e=>({ok:!0,value:e}));var Ih_=GL(oh.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"boolean")}]});var Ch_=GL(oh.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"number")}]});var qh_=GL(oh.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:DA(e,"string")}]});var Th_=GL(oh.UNKNOWN,e=>({ok:!0,value:e}));function zh_(e,t){let r={parse:(i,n)=>Rh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Rh_({value:i,isKeyNumeric:e.getType()===oh.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>oh.RECORD};return{...Oz(r),...Ym(r)}}function Rh_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return NCi(e)?tja(e).reduce((a,[o,c])=>{if(c==null)return a;let f=a,s=o;if(t){let _=o.length>0?Number(o):NaN;isNaN(_)||(s=_)}let u=r(s),l=i(c,s);if(f.ok&&u.ok&&l.ok)return{ok:!0,value:{...f.value,[u.value]:l.value}};let p=[];return f.ok||p.push(...f.errors),u.ok||p.push(...u.errors),l.ok||p.push(...l.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:DA(e,"object")}]}}function Nh_(e){let t=RUo(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:DA(i,"Set")}]},getType:()=>oh.SET};return{...Oz(r),...Ym(r)}}function Qh_(e){let t={parse:(r,i)=>Fh_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>Fh_((n,a)=>n.json(r,a),e,i),getType:()=>oh.UNDISCRIMINATED_UNION};return{...Oz(t),...Ym(t)}}function Fh_(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function Uh_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Vh_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=qUo(ija(t)),a={parse:(o,c)=>Lh_({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>Lh_({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>oh.UNION};return{...Oz(a),...Ym(a),...vFt(a)}}function Lh_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!NCi(e))return{ok:!1,errors:[{path:c,message:DA(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(f);if(!u.ok)return{ok:!1,errors:u.errors};let l=n(u.value);if(l==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let p=o(s,l);return p.ok?{ok:!0,value:{[r]:f,...p.value}}:p}var Gd=L.objectWithoutOptionalProperties({title:L.string().optional()});var zUo=L.objectWithoutOptionalProperties({file:L.string()});var NUo=L.objectWithoutOptionalProperties({file:L.string()});var FUo=L.union("type",{openapi:zUo,protobuf:NUo}).transform({transform:e=>{switch(e.type){case"openapi":return xL.openapi(e);case"protobuf":return xL.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var tu=L.objectWithoutOptionalProperties({source:FUo.optional()});var QUo=L.objectWithoutOptionalProperties({typeName:L.string()});var UUo=L.union("type",{protobuf:QUo}).transform({transform:e=>{switch(e.type){case"protobuf":return zQn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var iK=L.objectWithoutOptionalProperties({encoding:UUo.optional()});var Ti=L.objectWithoutOptionalProperties({description:L.string().optional()});var LUo=L.enum_(["GenerallyAvailable","Beta","Deprecated"]);var gu=L.objectWithoutOptionalProperties({availability:LUo.optional()});var yGt=L.number();var J0e=L.objectWithoutOptionalProperties({statusCode:yGt.optional()});var Gl=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string()});var pO=L.objectWithoutOptionalProperties({inline:L.boolean().optional()});var vx=L.string();var gx=L.string();var VUo=L.objectWithoutOptionalProperties({id:gx}).extend(Ti);var QCi=L.string();var WUo=L.objectWithoutOptionalProperties({usernameVariableName:L.string().optional(),usernameEnvVar:L.string().optional(),passwordVariableName:L.string().optional(),passwordEnvVar:L.string().optional()});var xUo=L.objectWithoutOptionalProperties({tokenVariableName:L.string().optional(),tokenEnvVar:L.string().optional()});var GUo=L.objectWithoutOptionalProperties({headerName:L.string(),prefix:L.string().optional(),headerVariableName:L.string().optional(),headerEnvVar:L.string().optional()});var HUo=L.objectWithoutOptionalProperties({queryParameterName:L.string()});var KUo=L.objectWithoutOptionalProperties({snake:L.string().optional(),camel:L.string().optional(),screamingSnake:L.string().optional(),pascal:L.string().optional()});var UCi=L.objectWithoutOptionalProperties({nameOverride:L.string().optional(),generatedName:L.string(),value:L.string(),casing:KUo.optional()}).extend(Ti).extend(gu);var JUo=L.objectWithoutOptionalProperties({type:L.stringLiteral("namespace"),name:L.string()});var $Uo=L.undiscriminatedUnion([L.string(),JUo]);var LCi=L.list($Uo);var Hd=L.objectWithoutOptionalProperties({groupName:LCi.optional()});var Ml=L.objectWithoutOptionalProperties({namespace:L.string().optional()});var UQn=L.objectWithoutOptionalProperties({default:UCi.optional(),values:L.list(UCi)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var YUo=L.objectWithoutOptionalProperties({scopesEnum:UQn.optional()});var XUo=L.union("type",{basic:WUo,bearer:xUo,header:GUo,query:HUo,oauth:YUo}).transform({transform:e=>{switch(e.type){case"basic":return yz.basic(e);case"bearer":return yz.bearer(e);case"header":return yz.header(e);case"query":return yz.query(e);case"oauth":return yz.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var nja=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string(),audiences:L.list(L.string()).optional()}).extend(Ti);var ZUo=L.string();var bGt=L.objectWithoutOptionalProperties({sdkMethodName:L.string().optional()});var nsc={};Kt(nsc,{FullExample:()=>Xm,FullObjectExample:()=>t4o,FullOneOfExample:()=>i4o,KeyValuePair:()=>r4o,LiteralExample:()=>kUo,NullExample:()=>e4o,PrimitiveExample:()=>VQn,PropertyKey:()=>LQn});var LQn=L.string();var VQn=L.union("type",{int:L.object({value:L.number()}),int64:L.object({value:L.number()}),uint:L.object({value:L.number()}),uint64:L.object({value:L.number()}),float:L.object({value:L.number()}),double:L.object({value:L.number()}),string:L.object({value:L.string()}),datetime:L.object({value:L.string()}),date:L.object({value:L.string()}),base64:L.object({value:L.string()}),boolean:L.object({value:L.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Ha.int(e.value);case"int64":return Ha.int64(e.value);case"uint":return Ha.uint(e.value);case"uint64":return Ha.uint64(e.value);case"float":return Ha.float(e.value);case"double":return Ha.double(e.value);case"string":return Ha.string(e.value);case"datetime":return Ha.datetime(e.value);case"date":return Ha.date(e.value);case"base64":return Ha.base64(e.value);case"boolean":return Ha.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var kUo=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return RCi.boolean(e.value);case"string":return RCi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var e4o=L.objectWithoutOptionalProperties({});var Xm=L.union("type",{primitive:L.object({value:VQn}),object:L.lazyObject(()=>t4o),array:L.object({value:L.list(L.lazy(()=>Xm))}),map:L.object({value:L.list(L.lazyObject(()=>r4o))}),enum:L.object({value:L.string()}),literal:L.object({value:kUo}),oneOf:L.object({value:L.lazy(()=>i4o)}),null:e4o,unknown:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"primitive":return Sl.primitive(e.value);case"object":return Sl.object(e);case"array":return Sl.array(e.value);case"map":return Sl.map(e.value);case"enum":return Sl.enum(e.value);case"literal":return Sl.literal(e.value);case"oneOf":return Sl.oneOf(e.value);case"null":return Sl.null(e);case"unknown":return Sl.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var t4o=L.objectWithoutOptionalProperties({properties:L.record(LQn,L.lazy(()=>Xm))});var r4o=L.objectWithoutOptionalProperties({key:VQn,value:L.lazy(()=>Xm)});var i4o=L.union("type",{discriminated:L.object({value:L.record(LQn,L.lazy(()=>Xm))}),undiscriminated:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"discriminated":return zCi.discriminated(e.value);case"undiscriminated":return zCi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var asc={};Kt(asc,{AllOfPropertyConflict:()=>uUn,ArraySchema:()=>$4o,Availability:()=>LUo,BooleanSchema:()=>V4o,BytesResponse:()=>XQn,CasingOverrides:()=>KUo,CommonProperty:()=>i3o,CursorPagination:()=>w4o,CustomCodeSample:()=>P4o,CustomCodeSampleLanguage:()=>O4o,CustomCodeSampleSdk:()=>m4o,CustomPagination:()=>S4o,DiscriminatedOneOfSchema:()=>t3o,DoubleSchema:()=>U4o,Endpoint:()=>M4o,EndpointExample:()=>tUn,EndpointResponseExample:()=>g4o,EndpointSdkName:()=>vGt,EndpointSecurity:()=>WQn,EnumSchema:()=>UQn,EnumValue:()=>UCi,ErrorExample:()=>_4o,FernExample:()=>y4o,FileResponse:()=>$Qn,FileSchema:()=>o4o,FormUrlEncodedRequest:()=>f4o,FullEndpointExample:()=>j4o,GlobalHeader:()=>G4o,GlobalSecurity:()=>x4o,Header:()=>VCi,HeaderExample:()=>eUn,HttpEndpointServer:()=>ZQn,HttpError:()=>h4o,HttpMethod:()=>xQn,IdempotencyHeader:()=>H4o,IntSchema:()=>F4o,JsonRequest:()=>l4o,JsonResponse:()=>YQn,LiteralSchema:()=>oUn,LiteralSchemaValue:()=>K4o,LongSchema:()=>Q4o,MapSchema:()=>Y4o,MultipartRequest:()=>JQn,MultipartRequestProperty:()=>c4o,MultipartRequestPropertyEncoding:()=>s4o,MultipartSchema:()=>u4o,NullableSchema:()=>Z4o,ObjectProperty:()=>e3o,ObjectPropertyConflictInfo:()=>sUn,ObjectSchema:()=>J4o,OctetStreamRequest:()=>KQn,OffsetPagination:()=>E4o,OneOfSchema:()=>k4o,OpenApiIntermediateRepresentation:()=>Wh_,OptionalSchema:()=>X4o,Pagination:()=>rUn,PathParameter:()=>GQn,PathParameterExample:()=>b4o,PrimitiveSchema:()=>xCi,PrimitiveSchemaValue:()=>W4o,QueryParameter:()=>HQn,QueryParameterExample:()=>kQn,ReferencedSchema:()=>gGt,Request:()=>d4o,Response:()=>p4o,RetriesConfiguration:()=>iUn,Schema:()=>nd,Schemas:()=>N4o,SdkGroupInfo:()=>n4o,StreamingResponseExample:()=>v4o,StringSchema:()=>L4o,SupportedSdkLanguage:()=>A4o,Tags:()=>a4o,TextResponse:()=>WCi,UnDiscriminatedOneOfSchema:()=>r3o,Webhook:()=>D4o,WebhookExampleCall:()=>aUn,WebhookHttpMethod:()=>nUn,WebsocketChannel:()=>z4o,WebsocketHandshake:()=>B4o,WebsocketMessageExample:()=>T4o,WebsocketMessageOrigin:()=>I4o,WebsocketMessageSchema:()=>C4o,WebsocketServer:()=>q4o,WebsocketSessionExample:()=>R4o});var n4o=L.objectWithoutOptionalProperties({summary:L.string().optional(),description:L.string().optional()});var a4o=L.objectWithoutOptionalProperties({tagsById:L.record(gx,VUo),orderedTagIds:L.list(gx).optional()});var WQn=L.list(L.record(QCi,L.list(L.string())));var xQn=L.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var GQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var HQn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var VCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>nd),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var vGt=L.objectWithoutOptionalProperties({groupName:LCi,methodName:L.string()});var KQn=L.objectWithoutOptionalProperties({contentType:L.string().optional()}).extend(Ti).extend(tu);var o4o=L.objectWithoutOptionalProperties({isOptional:L.boolean(),isArray:L.boolean()}).extend(Ti);var u4o=L.union("type",{file:o4o,json:L.object({value:L.lazy(()=>nd)})}).transform({transform:e=>{switch(e.type){case"file":return _Gt.file(e);case"json":return _Gt.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var s4o=L.enum_(["json","form"]);var c4o=L.objectWithoutOptionalProperties({key:L.string(),schema:u4o,contentType:L.string().optional(),exploded:L.boolean().optional(),encoding:s4o.optional()}).extend(Ti);var JQn=L.objectWithoutOptionalProperties({name:L.string().optional(),properties:L.list(c4o)}).extend(Ti).extend(tu);var l4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var f4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),contentType:L.string().optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu);var d4o=L.union("type",{octetStream:KQn,multipart:JQn,json:l4o,formUrlEncoded:f4o}).transform({transform:e=>{switch(e.type){case"octetStream":return bFt.octetStream(e);case"multipart":return bFt.multipart(e);case"json":return bFt.json(e);case"formUrlEncoded":return bFt.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var $Qn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(J0e);var YQn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd),responseProperty:L.string().optional()}).extend(Ti).extend(tu).extend(J0e);var WCi=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(J0e);var XQn=L.objectWithoutOptionalProperties({}).extend(Ti).extend(tu).extend(J0e);var p4o=L.union("type",{file:$Qn,json:YQn,text:WCi,bytes:XQn,streamingSse:YQn,streamingText:WCi,streamingJson:YQn}).transform({transform:e=>{switch(e.type){case"file":return KQ.file(e);case"json":return KQ.json(e);case"text":return KQ.text(e);case"bytes":return KQ.bytes(e);case"streamingSse":return KQ.streamingSse(e);case"streamingText":return KQ.streamingText(e);case"streamingJson":return KQ.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var _4o=L.objectWithoutOptionalProperties({name:L.string().optional(),description:L.string().optional(),example:L.lazy(()=>Xm)});var h4o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>nd).optional(),examples:L.list(_4o).optional()}).extend(Ti).extend(Gl).extend(tu);var ZQn=L.objectWithoutOptionalProperties({name:L.string().optional(),url:L.string().optional(),audiences:L.list(L.string()).optional()});var y4o=L.unknown();var b4o=L.objectWithoutOptionalProperties({name:L.string(),parameterNameOverride:L.string().optional(),value:L.lazy(()=>Xm)});var kQn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var eUn=L.objectWithoutOptionalProperties({name:L.string(),value:L.lazy(()=>Xm)});var v4o=L.objectWithoutOptionalProperties({sse:L.boolean(),events:L.list(L.lazy(()=>Xm))});var g4o=L.union("type",{withStreaming:v4o,withoutStreaming:L.object({value:L.lazy(()=>Xm)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return K0e.withStreaming(e);case"withoutStreaming":return K0e.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var O4o=L.objectWithoutOptionalProperties({name:L.string().optional(),language:L.string(),code:L.string(),install:L.string().optional()}).extend(Ti);var A4o=L.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var m4o=L.objectWithoutOptionalProperties({name:L.string().optional(),sdk:A4o,code:L.string()}).extend(Ti);var P4o=L.union("type",{language:O4o,sdk:m4o}).transform({transform:e=>{switch(e.type){case"language":return pGt.language(e);case"sdk":return pGt.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var j4o=L.objectWithoutOptionalProperties({name:L.string().optional(),pathParameters:L.list(b4o).optional(),queryParameters:L.list(kQn).optional(),headers:L.list(eUn).optional(),request:L.lazy(()=>Xm).optional(),response:g4o.optional(),codeSamples:L.list(P4o)}).extend(Ti);var tUn=L.union("type",{unknown:L.object({value:y4o}),full:j4o}).transform({transform:e=>{switch(e.type){case"unknown":return H0e.unknown(e.value);case"full":return H0e.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var w4o=L.objectWithoutOptionalProperties({cursor:L.string(),nextCursor:L.property("next_cursor",L.string()),results:L.string()});var E4o=L.objectWithoutOptionalProperties({offset:L.string(),results:L.string(),step:L.string().optional(),hasNextPage:L.string().optional()});var S4o=L.objectWithoutOptionalProperties({results:L.string()});var rUn=L.union("type",{cursor:w4o,offset:E4o,custom:S4o}).transform({transform:e=>{switch(e.type){case"cursor":return Dhe.cursor(e);case"offset":return Dhe.offset(e);case"custom":return Dhe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var iUn=L.union("type",{disabled:L.object({value:L.boolean().optional()})}).transform({transform:e=>{switch(e.type){case"disabled":return eja.disabled(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var M4o=L.objectWithoutOptionalProperties({authed:L.boolean(),security:WQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:xQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(GQn),queryParameters:L.list(HQn),headers:L.list(VCi),sdkName:vGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:d4o.optional(),response:p4o.optional(),errors:L.record(yGt,h4o),servers:L.list(ZQn),examples:L.list(tUn),pagination:rUn.optional(),retries:iUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var nUn=L.enum_(["GET","POST"]);var aUn=L.objectWithoutOptionalProperties({name:L.string().optional(),payload:L.lazy(()=>Xm)}).extend(Ti);var D4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:vGt.optional(),method:nUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(VCi),generatedPayloadName:L.string(),payload:L.lazy(()=>nd),examples:L.list(aUn)}).extend(Ti).extend(tu).extend(Ml);var B4o=L.objectWithoutOptionalProperties({queryParameters:L.list(HQn),headers:L.list(VCi),pathParameters:L.list(GQn)});var I4o=L.enum_(["client","server"]);var C4o=L.objectWithoutOptionalProperties({name:L.string(),origin:I4o,body:L.lazy(()=>nd)});var q4o=L.objectWithoutOptionalProperties({name:L.string(),url:L.string()});var T4o=L.objectWithoutOptionalProperties({messageType:L.string(),payload:L.lazy(()=>Xm)}).extend(Ti);var R4o=L.objectWithoutOptionalProperties({name:L.string().optional(),queryParameters:L.list(kQn).optional(),headers:L.list(eUn).optional(),messages:L.list(T4o)}).extend(Ti);var z4o=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),path:L.string(),groupName:LCi,summary:L.string().optional(),handshake:B4o,messages:L.list(C4o),servers:L.list(q4o),examples:L.list(R4o)}).extend(Ti).extend(tu);var N4o=L.objectWithoutOptionalProperties({rootSchemas:L.record(vx,L.lazy(()=>nd)),namespacedSchemas:L.record(ZUo,L.record(vx,L.lazy(()=>nd)))});var F4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var Q4o=L.objectWithoutOptionalProperties({default:L.number().optional()});var U4o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional()});var L4o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional()});var V4o=L.objectWithoutOptionalProperties({default:L.boolean().optional()});var W4o=L.union("type",{int:F4o,int64:Q4o,uint:L.object({}),uint64:L.object({}),float:L.object({}),double:U4o,string:L4o,datetime:L.object({}),date:L.object({}),base64:L.object({}),boolean:V4o}).transform({transform:e=>{switch(e.type){case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();case"float":return ah.float();case"double":return ah.double(e);case"string":return ah.string(e);case"datetime":return ah.datetime();case"date":return ah.date();case"base64":return ah.base64();case"boolean":return ah.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var xCi=L.objectWithoutOptionalProperties({schema:W4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var x4o=L.list(L.record(QCi,L.list(L.string())));var G4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),optional:L.boolean().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var H4o=L.objectWithoutOptionalProperties({header:L.string(),name:L.string().optional(),env:L.string().optional(),schema:L.lazy(()=>nd).optional()});var Wh_=L.objectWithoutOptionalProperties({apiVersion:L.unknown().optional(),title:L.string().optional(),description:L.string().optional(),basePath:L.string().optional(),servers:L.list(nja),websocketServers:L.list(nja),groups:L.record(L.string(),n4o),tags:a4o,hasEndpointsMarkedInternal:L.boolean(),endpoints:L.list(M4o),webhooks:L.list(D4o),channels:L.record(L.string(),z4o),groupedSchemas:N4o,variables:L.record(L.string(),xCi),nonRequestReferencedSchemas:L.set(vx),securitySchemes:L.record(QCi,XUo),security:x4o.optional(),globalHeaders:L.list(G4o).optional(),idempotencyHeaders:L.list(H4o).optional()});var gGt=L.objectWithoutOptionalProperties({schema:vx}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd);var K4o=L.union("type",{boolean:L.object({value:L.boolean()}),string:L.object({value:L.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return Fj.boolean(e.value);case"string":return Fj.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var oUn=L.objectWithoutOptionalProperties({value:K4o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var nd=L.union("type",{primitive:xCi,object:L.lazyObject(()=>J4o),array:L.lazyObject(()=>$4o),map:L.lazyObject(()=>Y4o),optional:L.lazyObject(()=>X4o),enum:UQn,reference:gGt,literal:oUn,oneOf:L.object({value:L.lazy(()=>k4o)}),nullable:L.lazyObject(()=>Z4o),unknown:Gl}).transform({transform:e=>{switch(e.type){case"primitive":return Zs.primitive(e);case"object":return Zs.object(e);case"array":return Zs.array(e);case"map":return Zs.map(e);case"optional":return Zs.optional(e);case"enum":return Zs.enum(e);case"reference":return Zs.reference(e);case"literal":return Zs.literal(e);case"oneOf":return Zs.oneOf(e.value);case"nullable":return Zs.nullable(e);case"unknown":return Zs.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var uUn=L.objectWithoutOptionalProperties({propertyKey:L.string(),allOfSchemaIds:L.list(vx),conflictingTypeSignatures:L.boolean()});var J4o=L.objectWithoutOptionalProperties({allOf:L.list(gGt),properties:L.list(L.lazyObject(()=>e3o)),allOfPropertyConflicts:L.list(uUn),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var sUn=L.objectWithoutOptionalProperties({differentSchema:L.boolean()});var e3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),conflict:L.record(vx,sUn),generatedName:L.string(),nameOverride:L.string().optional(),audiences:L.list(L.string())}).extend(gu);var $4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Y4o=L.objectWithoutOptionalProperties({key:xCi,value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var X4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var Z4o=L.objectWithoutOptionalProperties({value:L.lazy(()=>nd)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var k4o=L.union("type",{discriminated:L.lazyObject(()=>t3o),undiscriminated:L.lazyObject(()=>r3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return hGt.discriminated(e);case"undiscriminated":return hGt.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var t3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>i3o)),schemas:L.record(L.string(),L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var i3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>nd)});var r3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>nd))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var osc={};Kt(osc,{ArraySchemaWithExample:()=>E3o,Base64WithExample:()=>A3o,BooleanWithExample:()=>m3o,CommonPropertyWithExample:()=>R3o,DateWithExample:()=>O3o,DatetimeWithExample:()=>g3o,DiscriminatedOneOfSchemaWithExample:()=>q3o,DoubleWithExample:()=>b3o,EndpointWithExample:()=>Gh_,EnumSchemaWithExample:()=>j3o,FloatWithExample:()=>y3o,HeaderWithExample:()=>GCi,HttpErrorWithExample:()=>f3o,Int64WithExample:()=>p3o,IntWithExample:()=>d3o,JsonRequestWithExample:()=>u3o,JsonResponseWithExample:()=>lUn,MapSchemaWithExample:()=>S3o,NamedFullExample:()=>$0e,NullableSchemaWithExample:()=>D3o,ObjectPropertyWithExample:()=>C3o,ObjectSchemaWithExample:()=>B3o,OneOfSchemaWithExample:()=>I3o,OptionalSchemaWithExample:()=>M3o,ParseFormUrlEncodedRequest:()=>s3o,ParseMultipartRequest:()=>o3o,ParseOctetStreamRequest:()=>a3o,PathParameterWithExample:()=>n3o,PrimitiveSchemaValueWithExample:()=>P3o,PrimitiveSchemaWithExample:()=>fUn,QueryParameterWithExample:()=>cUn,RequestWithExample:()=>c3o,ResponseWithExample:()=>l3o,SchemaWithExample:()=>_O,StringSchemaWithExample:()=>v3o,Uint64WithExample:()=>h3o,UintWithExample:()=>_3o,UnDiscriminatedOneOfSchemaWithExample:()=>T3o,UnknownSchemaWithExample:()=>w3o,WebhookWithExample:()=>Hh_,WebsocketHandshakeWithExample:()=>xh_});var $0e=L.objectWithoutOptionalProperties({name:L.string().optional(),value:L.unknown()}).extend(Ti);var cUn=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var GCi=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),env:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var xh_=L.objectWithoutOptionalProperties({queryParameters:L.list(cUn),headers:L.list(GCi)});var n3o=L.objectWithoutOptionalProperties({name:L.string(),schema:L.lazy(()=>_O),variableReference:L.string().optional(),parameterNameOverride:L.string().optional()}).extend(Ti).extend(gu).extend(tu);var a3o=L.objectWithoutOptionalProperties({}).extend(KQn).extend(bGt);var o3o=L.objectWithoutOptionalProperties({}).extend(JQn).extend(bGt);var u3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list($0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(bGt);var s3o=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),contentType:L.string().optional(),fullExamples:L.list($0e).optional(),additionalProperties:L.boolean()}).extend(Ti).extend(tu).extend(bGt);var c3o=L.union("type",{octetStream:a3o,multipart:o3o,json:u3o,formUrlEncoded:s3o}).transform({transform:e=>{switch(e.type){case"octetStream":return bx.octetStream(e);case"multipart":return bx.multipart(e);case"json":return bx.json(e);case"formUrlEncoded":return bx.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var lUn=L.objectWithoutOptionalProperties({schema:L.lazy(()=>_O),responseProperty:L.string().optional(),fullExamples:L.list($0e).optional()}).extend(Ti).extend(tu).extend(J0e);var l3o=L.union("type",{file:$Qn,json:lUn,text:WCi,bytes:XQn,streamingSse:lUn,streamingText:WCi,streamingJson:lUn}).transform({transform:e=>{switch(e.type){case"file":return mP.file(e);case"json":return mP.json(e);case"text":return mP.text(e);case"bytes":return mP.bytes(e);case"streamingSse":return mP.streamingSse(e);case"streamingText":return mP.streamingText(e);case"streamingJson":return mP.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var f3o=L.objectWithoutOptionalProperties({statusCode:yGt,schema:L.lazy(()=>_O),fullExamples:L.list($0e).optional()}).extend(Ti).extend(Gl).extend(tu);var Gh_=L.objectWithoutOptionalProperties({authed:L.boolean(),security:WQn.optional(),internal:L.boolean().optional(),idempotent:L.boolean().optional(),method:xQn,audiences:L.list(L.string()),path:L.string(),summary:L.string().optional(),operationId:L.string().optional(),tags:L.list(gx),pathParameters:L.list(n3o),queryParameters:L.list(cUn),headers:L.list(GCi),sdkName:vGt.optional(),generatedRequestName:L.string(),requestNameOverride:L.string().optional(),request:c3o.optional(),response:l3o.optional(),errors:L.record(yGt,f3o),servers:L.list(ZQn),examples:L.list(tUn),pagination:rUn.optional(),retries:iUn.optional()}).extend(Ti).extend(gu).extend(tu).extend(Ml);var Hh_=L.objectWithoutOptionalProperties({audiences:L.list(L.string()),sdkName:vGt.optional(),method:nUn,summary:L.string().optional(),operationId:L.string(),tags:L.list(gx),headers:L.list(GCi),generatedPayloadName:L.string(),payload:L.lazy(()=>_O),examples:L.list(aUn)}).extend(Ti).extend(tu).extend(Ml);var d3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var p3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var _3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var h3o=L.objectWithoutOptionalProperties({default:L.number().optional(),example:L.number().optional()});var y3o=L.objectWithoutOptionalProperties({example:L.number().optional()});var b3o=L.objectWithoutOptionalProperties({default:L.number().optional(),minimum:L.number().optional(),maximum:L.number().optional(),exclusiveMinimum:L.boolean().optional(),exclusiveMaximum:L.boolean().optional(),multipleOf:L.number().optional(),example:L.number().optional()});var v3o=L.objectWithoutOptionalProperties({default:L.string().optional(),pattern:L.string().optional(),format:L.string().optional(),minLength:L.number().optional(),maxLength:L.number().optional(),example:L.string().optional()});var g3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var O3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var A3o=L.objectWithoutOptionalProperties({example:L.string().optional()});var m3o=L.objectWithoutOptionalProperties({default:L.boolean().optional(),example:L.boolean().optional()});var P3o=L.union("type",{int:d3o,int64:p3o,uint:_3o,uint64:h3o,float:y3o,double:b3o,string:v3o,datetime:g3o,date:O3o,base64:A3o,boolean:m3o}).transform({transform:e=>{switch(e.type){case"int":return Ln.int(e);case"int64":return Ln.int64(e);case"uint":return Ln.uint(e);case"uint64":return Ln.uint64(e);case"float":return Ln.float(e);case"double":return Ln.double(e);case"string":return Ln.string(e);case"datetime":return Ln.datetime(e);case"date":return Ln.date(e);case"base64":return Ln.base64(e);case"boolean":return Ln.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var fUn=L.objectWithoutOptionalProperties({schema:P3o}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var j3o=L.objectWithoutOptionalProperties({default:UCi.optional(),values:L.list(UCi),example:L.string().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var w3o=L.objectWithoutOptionalProperties({example:L.unknown()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd);var _O=L.union("type",{primitive:fUn,object:L.lazyObject(()=>B3o),array:L.lazyObject(()=>E3o),map:L.lazyObject(()=>S3o),optional:L.lazyObject(()=>M3o),enum:j3o,reference:gGt,literal:oUn,oneOf:L.object({value:L.lazy(()=>I3o)}),nullable:L.lazyObject(()=>D3o),unknown:w3o}).transform({transform:e=>{switch(e.type){case"primitive":return ri.primitive(e);case"object":return ri.object(e);case"array":return ri.array(e);case"map":return ri.map(e);case"optional":return ri.optional(e);case"enum":return ri.enum(e);case"reference":return ri.reference(e);case"literal":return ri.literal(e);case"oneOf":return ri.oneOf(e.value);case"nullable":return ri.nullable(e);case"unknown":return ri.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var E3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O),example:L.list(L.unknown()).optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var S3o=L.objectWithoutOptionalProperties({key:fUn,value:L.lazy(()=>_O),example:L.unknown().optional()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(Gd).extend(pO);var M3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var D3o=L.objectWithoutOptionalProperties({value:L.lazy(()=>_O)}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(Gd).extend(pO);var B3o=L.objectWithoutOptionalProperties({allOf:L.list(gGt),properties:L.list(L.lazyObject(()=>C3o)),allOfPropertyConflicts:L.list(uUn),fullExamples:L.list($0e).optional(),additionalProperties:L.boolean()}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(tu).extend(Gd).extend(pO);var C3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O),readonly:L.boolean().optional(),writeonly:L.boolean().optional(),audiences:L.list(L.string()),conflict:L.record(vx,sUn),nameOverride:L.string().optional(),generatedName:L.string()}).extend(gu);var I3o=L.union("type",{discriminated:L.lazyObject(()=>q3o),undiscriminated:L.lazyObject(()=>T3o)}).transform({transform:e=>{switch(e.type){case"discriminated":return Bhe.discriminated(e);case"undiscriminated":return Bhe.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var q3o=L.objectWithoutOptionalProperties({discriminantProperty:L.string(),commonProperties:L.list(L.lazyObject(()=>R3o)),schemas:L.record(L.string(),L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var R3o=L.objectWithoutOptionalProperties({key:L.string(),schema:L.lazy(()=>_O)});var T3o=L.objectWithoutOptionalProperties({schemas:L.list(L.lazy(()=>_O))}).extend(Hd).extend(Ml).extend(Gl).extend(Ti).extend(gu).extend(iK).extend(tu).extend(Gd).extend(pO);var Kh_=/^(\d+)/,dUn=/^[a-zA-Z][a-zA-Z0-9_]*$/,Jh_={"<":"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 IJi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let o=Math.floor(e/10),c=e%10;return c===0?i[o]:`${i[o]}_${t[c]}`}if(e<1e3){let o=Math.floor(e/100),c=e%100;return c===0?`${t[o]}_hundred`:`${t[o]}_hundred_${IJi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${IJi(a)}`}function aja(e){let t=e.match(Kh_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=IJi(n);return i.length>0?`${a}_${i}`:a}}}function pUn(e){let t=aja(e),r=Jh_[e];return t!=null?QP(No(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":QP(No(e)))}function nK(e,t){return e.type==="primitive"&&t.type==="primitive"?$h_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?PtM(e.values,t.values):e.type==="array"&&t.type==="array"?nK(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"?nK(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?jtM(e.value,t.value):e.type==="object"&&t.type==="object"?wtM(e,t):e.type==="map"&&t.type==="map"?$h_(e.key.schema,t.key.schema)&&nK(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function $h_(e,t){return e.type===t.type}function PtM(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return r1(r,i)}function jtM(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:nK(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:nK(r,n)}):!1}function wtM(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:nK(a,n.schema)})}function ZE(e){switch(e){case bz.Deprecated:return"deprecated";case bz.Beta:return"pre-release";case bz.GenerallyAvailable:return"generally-available";default:return}}function EtM(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function Yh_(e){let t=e?EtM(e):void 0;if(t==null||t.length===0)return Jxi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(No(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(No(n.name)):r.push(n.name,Jxi);break}default:vt(n.type)}else vt(n);return r.join("/")}function HCi(e){return Tu.of(`${Yh_(e)}.yml`)}function usc({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Jxi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,Yh_(r))}function Xh_({sdkName:e,namespaceOverride:t}){return Tu.of(`${usc({sdkName:e,namespaceOverride:t})}.yml`)}function Zh_({location:e,namespaceOverride:t}){return t!=null?iD(Tu.of(t),e):e}function z3o(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:vt(e.type)}}function _Un(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:vt(e)}}function hO(e){return typeof e=="string"?e:e.type}function hUn(e){if(typeof e!="string")return e.docs}function oja(e){if(typeof e!="string")return e.default}function ssc(e){if(typeof e!="string")return e.validation}function ey_(e){let t=hO(e);return t.startsWith("nullable<")||t.startsWith("optional<nullable<")?e:typeof e=="string"?kh_(e):{...e,type:kh_(e.type)}}function kh_(e){return e.startsWith("nullable<")||e.startsWith("optional<nullable<")?e:e.startsWith("optional<")?e.replace("optional<","optional<nullable<")+">":`nullable<${e}>`}function CJi(e){return hO(e).startsWith("optional<")?e:typeof e=="string"?ty_(e):{...e,type:ty_(e.type)}}function ty_(e){return e.startsWith("optional<")?e:`optional<${e}>`}var StM=-2147483648,MtM=2147483647,DtM=-17976931348623157e292,BtM=17976931348623157e292;function Af({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return N3o(e);case"array":return fsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return dsc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return lsc({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return _sc();case"optional":return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return psc({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return QtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,hsc(e);case"object":return UtM({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return LtM({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:vt(e)}}function N3o(e){switch(e.schema.type){case"string":return qtM({description:e.description,schema:e.schema});case"int":return TtM({description:e.description,schema:e.schema});case"float":return RtM({description:e.description,schema:e.schema});case"double":return ztM({description:e.description,schema:e.schema});case"boolean":return ItM({description:e.description,schema:e.schema});case"int64":return CtM({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:ZE(e.availability)}:{}}}function ItM({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function CtM({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function qtM({description:e,schema:t}){let r="string",i=NtM(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function TtM({description:e,schema:t}){let r="integer",i=ry_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function RtM({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function ztM({description:e,schema:t}){let r="double",i=ry_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function NtM(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=FtM(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function FtM(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 ry_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:o}=e;if(r=csc(r,t),i=csc(i,t),n=csc(n,t),!(r==null&&i==null&&a==null&&o==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:o,multipleOf:n}}function csc(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[StM,MtM]:[DtM,BtM];return e<r||e>i?void 0:e}function lsc({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=VtM(n)??e.schema,o=_Un(n),c=WtM(n),s=Q3o({context:r,fileContainingReference:t,declarationFile:HCi(o),type:a});return n.type==="nullable"&&(s=r.options.wrapReferencesToNullableInOptional?`optional<${s}>`:`nullable<${s}>`),n.type==="optional"&&!s.startsWith("optional<")&&(s=`optional<${s}>`),e.description==null&&c==null?s:{type:s,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function fsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${hO(o)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{},type:c}}function dsc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=N3o(e.key),c=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),f=e.encoding!=null?z3o(e.encoding):void 0,s=`map<${hO(o)}, ${hO(c)}>`;if(e.description==null&&f==null&&e.title==null)return s;let u={type:s};return e.description!=null&&(u.docs=e.description),e.encoding!=null&&(u.encoding=f),e.availability!=null&&(u.availability=ZE(e.availability)),u}function psc({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.options.respectNullableSchemas)return F3o({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=hUn(o),s=oja(o),u=ssc(o),l=ey_(c);if(i.options.wrapReferencesToNullableInOptional&&(l=CJi(l)),e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function F3o({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=Af({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hO(o),f=hUn(o),s=oja(o),u=ssc(o),l=CJi(c);if(e.availability==null&&e.description==null&&f==null&&s==null&&u==null&&e.title==null)return l;let p=typeof l=="string"?{type:l}:l;return(e.description!=null||f!=null)&&(p.docs=e.description??f),s!=null&&(p.default=s),u!=null&&(p.validation=u),e.availability!=null&&(p.availability=ZE(e.availability)),p}function _sc(){return"unknown"}function hsc(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:vt(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function QtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=uja(e,n),o=e.nameOverride??e.generatedName;i.builder.addType(r,{name:o,schema:a.schema});let c=Q3o({type:o,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let f={type:c};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=ZE(e.availability)),f}function UtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=ysc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function LtM({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let o=bsc({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:o.schema});let f=Q3o({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ZE(e.availability)}:{}}}function Q3o({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function VtM(e){return Zs._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 WtM(e){return Zs._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 q1;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(q1||(q1={}));function Jvi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:vt(e)}}function ny_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=HtM(e);break;case"array":a=xtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=GtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=KtM({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=$tM(e.nameOverride,e.generatedName);break;case"optional":a=oy_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=JtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=uja(e,n);break;case"literal":a=YtM(e,e.nameOverride,e.generatedName);break;case"object":a=ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=bsc({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:vt(e)}return a}function ysc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(q1.Request)&&t.options.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),o=!1,c={},f=new Set;for(let _ of e.properties){if(_.readonly&&(o=!0),a&&_.readonly)continue;if(Object.keys(_.conflict).length>0){if(Object.entries(_.conflict).every(([g,m])=>!m.differentSchema))continue;Object.entries(_.conflict).forEach(([g])=>{vsc({property:_.key,schemaId:g,context:t,namespace:i}).forEach(j=>{f.add(j)})})}let h=Af({schema:_.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),y=_.audiences,b=_.nameOverride,v=ZE(_.availability),O=erM(_);c[_.key]=ktM({typeReference:h,audiences:y,name:b,availability:v,propertyAccess:O})}let s=new Set;for(let _ of e.allOfPropertyConflicts)_.allOfSchemaIds.forEach(h=>f.add(h)),_.conflictingTypeSignatures&&s.add(_.propertyKey);let u=[];for(let _ of e.allOf){let h=uy_({schema:_.schema,context:t,namespace:i});if(h==null||f.has(_.schema)||f.has(h))continue;let y=Af({schema:Zs.reference(_),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(y))}for(let _ of f){let h=gsc(t,_,i);for(let y of h.properties)c[y.key]==null&&(s.has(y.key)&&(c[y.key]="unknown"),c[y.key]=Af({schema:y.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let y of h.allOf){if(f.has(y.schema))continue;let b=Af({schema:Zs.reference(y),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});u.push(hO(b))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([_,h])=>ZtM(_)?[_,typeof h=="string"?{type:h,name:`_${_}`}:{...h,name:`_${_}`}]:[_,h]))};u.length>0&&(l.extends=u),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=ZE(e.availability)),e.source!=null&&(l.source=Jvi(e.source)),l.inline=Osc(e,n);let p=e.nameOverride??e.generatedName;return{name:o&&t.options.respectReadonlySchemas&&!a?`${p}Read`:p,schema:l}}function vsc({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return vsc({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:o}=gsc(r,t,i),c=a.some(s=>s.key===e),f=[...o.flatMap(s=>vsc({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||f.length>0)return[t,...f]}return[]}function ay_(e,t,r){return t.type==="object"?{properties:t.properties,allOf:t.allOf}:t.type==="reference"?gsc(e,t.schema,r):t.type==="nullable"?ay_(e,t.value,r):{properties:[],allOf:[]}}function gsc(e,t,r){let i=e.getSchema(t,r);return i==null?{properties:[],allOf:[]}:ay_(e,i,r)}function xtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:fsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function GtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:dsc({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function HtM(e){let t=N3o(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function iy_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function uja(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||iy_(a.casing)))return o;let f={value:a.value};if(o!==c&&(f.name=o),a.description!=null&&(f.docs=a.description),a.casing!=null&&!iy_(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&&(f.casing=s)}return f})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=Osc(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?Jvi(e.source):void 0};for(let a of r.enum){let o=typeof a=="string"?a:a.name??a.value;i.has(o.toLowerCase())||(n.enum.push(a),i.add(o.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function KtM({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:lsc({schema:e,context:t,fileContainingReference:r,namespace:i})}}function JtM({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.options.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:psc({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:oy_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function oy_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:F3o({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function $tM(e,t){return{name:e??t,schema:_sc()}}function YtM(e,t,r){return{name:t??r,schema:hsc(e)}}function bsc({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?z3o(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=Af({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let f={};for(let[s,u]of Object.entries(e.schemas))f[s]=Af({schema:u,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?ZE(e.availability):void 0,union:f,encoding:a,source:e.source!=null?Jvi(e.source):void 0}}}let o=[];for(let c of e.schemas)o.push(Af({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:o,encoding:a,source:e.source!=null?Jvi(e.source):void 0,inline:Osc(e,n)}}}var XtM=/^[0-9]/;function ZtM(e){return XtM.test(e)}function uy_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?uy_({context:t,schema:i.schema,namespace:r}):e}function ktM({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function Osc(e,t){return e.inline===!0||t>0?!0:void 0}function erM(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return AD.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return AD.ObjectPropertyAccess.WriteOnly}}function sy_(e){let t=e.replace(/^x-|^X-/,"");return No(t)}function cy_(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??sy_(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:r,schema:n}),t||(e.builder.setAuth(r),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Tu.of("__package__.yml"),{name:"OauthScope",schema:uja(i.scopesEnum,0).schema})}}function OGt({header:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=hO(n),o=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:No(o);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let f={type:a};return c!==e.name&&(f.name=c),e.description!=null&&(f.docs=e.description),e.env!=null&&(f.env=e.env),e.availability!=null&&(f.availability=ZE(e.availability)),f}function U3o({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Af({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return hO(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:hO(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=ZE(e.availability)),a}function V3o({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=Asc({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=hO(n.value),o=oja(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return o!=null&&(c.default=o),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=ZE(e.availability)),trM(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function Asc({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Tu.of(ob),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(n.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(dUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:pUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,f]=n.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,f]of Object.entries(n.value.schemas))return Asc({schema:f,context:t,fileContainingReference:r,namespace:i})}else if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){let n=e.type==="optional"?Zs.optional:Zs.nullable;if(e.value.type==="reference"){let a=t.getSchema(e.value.schema,i);if(a==null)return;if(a.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a.value,description:e.description??a.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let a=[],o=!1;for(let[c,f]of Object.entries(e.value.value.schemas))f.type==="primitive"&&f.schema.type==="string"&&(o=!0),f.type==="literal"&&f.value.type==="string"&&(dUn.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:pUn(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),o&&t.options.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[c,f]=e.value.value.schemas;if(c!=null&&f!=null&&L3o({array:c,primitive:f}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&f!=null&&L3o({array:f,primitive:c}))return{value:Af({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.options.objectQueryParameters)return{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[c,f]of Object.entries(e.value.value.schemas))return Asc({schema:n({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.options.objectQueryParameters?{value:Af({schema:e,context:t,fileContainingReference:r,declarationFile:Tu.of(ob),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:Af({schema:Zs.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:Af({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function L3o({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function trM(e){return typeof e=="object"&&e!==null&&"type"in e}function ly_({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"]=rrM(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=irM({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=KCi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function rrM(e){let t={};return e.forEach(r=>{let i=KCi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function irM({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=KCi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function KCi(e){switch(e.type){case"primitive":return fy_(e.value);case"object":return dy_(e.properties);case"array":return nrM(e.value);case"map":return arM(e.value);case"oneOf":return orM(e.value);case"enum":return e.value;case"literal":return urM(e.value);case"unknown":return KCi(e.value);case"null":return null;default:vt(e)}}function fy_(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:vt(e)}}function dy_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,KCi(r)]))}function nrM(e){return e.map(t=>KCi(t))}function arM(e){return Object.fromEntries(e.map(t=>[fy_(t.key),KCi(t.value)]))}function orM(e){return e.type==="discriminated"?dy_(e.value):KCi(e.value)}function urM(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:vt(e)}}function sja(e){try{let r=new URL(e).pathname.split("/").filter(i=>i.length>0);if(r.length>0)return r[r.length-1]}catch{}}function W3o(e){try{return new URL(e).protocol.replace(":","")}catch{return}}function x3o(e,t,r=!1){let i=sja(t);return r&&i!=null?i:e!=null&&i!=null?`${e}_${i}`:i??e??"websocket"}function $vi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function G3o(e,t){return t??(e?.groupName!=null?$vi(e.groupName):void 0)}function py_({channel:e,context:t,declarationFile:r}){let i=e.servers[0],n=i!=null?t.options.groupEnvironmentsByHost?t.getUrlId(i.url)??x3o(i.name,i.url,!0):i.name:void 0;t.logger.debug(`[buildChannel] Channel path="${e.path}", server name="${i?.name}", server url="${i?.url}", resolved urlId="${n}" (from collision map: ${t.getUrlId(i?.url??"")!=null})`);let a={path:e.path,url:n,auth:!1};e.audiences!=null&&e.audiences.length>0&&(a.audiences=e.audiences),e.summary!=null&&(a["display-name"]=e.summary),e.description!=null&&(a.docs=e.description);let o=$vi(e.groupName),c={};if(e.handshake.pathParameters.length>0)for(let u of e.handshake.pathParameters)c[u.name]=U3o({pathParameter:u,context:t,fileContainingReference:r,namespace:o});Object.keys(c).length>0&&(a["path-parameters"]=c);let f={};if(e.handshake.queryParameters.length>0)for(let u of e.handshake.queryParameters){let l=V3o({queryParameter:u,context:t,fileContainingReference:r,namespace:o});l!=null&&(f[u.name]=l)}Object.keys(f).length>0&&(a["query-parameters"]=f);let s={};if(e.handshake.headers.length>0)for(let u of e.handshake.headers){let l=OGt({header:u,context:t,fileContainingReference:r,namespace:o});s[u.name]=l}Object.keys(s).length>0&&(a.headers=s),t.builder.addChannel(r,{channel:a});for(let u of e.messages)t.builder.addChannelMessage(r,{messageId:u.name,message:{origin:u.origin,body:Af({schema:u.body,context:t,fileContainingReference:r,namespace:o,declarationDepth:0})}});for(let u of e.examples){let l=ly_({context:t,websocketExample:u});t.builder.addChannelExample(r,{example:l})}}function msc(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var Y0e="Base",yy_="Default";function _y_(e){try{return new URL(e).hostname}catch{return}}function hy_(e){return e??yy_}function srM(e,t){let r=new Map;for(let i of e){if(msc(i)||!("url"in i)||!i.url)continue;let n=_y_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:hy_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.httpServers.push({name:i.name,url:i.url,audiences:i.audiences})}for(let i of t){let n=_y_(i.url)??i.url;r.has(n)||r.set(n,{environmentName:hy_(i.name),httpServers:[],websocketServers:[]}),r.get(n)?.websocketServers.push(i)}return r}function qJi(e){return Object.entries(e).reduce((t,[r,i])=>(ghe(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function by_(e){if(e.environmentOverrides!=null){for(let[v,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:v,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],i=e.ir.servers.some(v=>msc(v)),n=e.ir.servers;for(let v of n)if(msc(v)){let O={urls:{}};for(let[A,g]of Object.entries(v.urls))O.urls[A]=g.url;v.name&&(t[v.name]=O)}else if("url"in v&&v.url){let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){r.push(O);continue}t[v.name]=O}let a={},o={},c=[];for(let v of e.ir.endpoints)for(let O of v.servers){if(O.url==null&&O.name!=null){a[O.name]||(a[O.name]=[]);continue}if(O.url==null)continue;let A=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){c.push(A);continue}a[O.name]||(a[O.name]=[]),a[O.name]?.push({url:O.url,audiences:O.audiences}),o[O.name]=A}let f={},s=[];for(let v of e.ir.websocketServers){e.logger.debug(`[buildEnvironments] Processing WebSocket server: name="${v.name}", url="${v.url}"`);let O=v.audiences?{url:v.url,audiences:v.audiences}:v.url;if(v.name==null){s.push(O);continue}f[v.name]=O}let u=Object.keys(t).length,l=u>0,p=Object.keys(o).length>0,_=Object.keys(a).some(v=>a[v]?.length===0),h=Object.keys(f).length>0;if(e.options.groupEnvironmentsByHost&&h&&(l||e.ir.servers.length>0)){let v=Object.entries(f).map(([A,g])=>({name:A,url:typeof g=="string"?g:g.url,audiences:typeof g=="string"?void 0:g.audiences})),O=srM(n,v);if(O.size>0){let A=!0;for(let[g,m]of O.entries()){let j={},M=[...m.httpServers.map(D=>({...D,isHttp:!0})),...m.websocketServers.map(D=>({...D,isHttp:!1}))],E=new Map;for(let D of M){let B=sja(D.url),F=W3o(D.url);B&&F&&(E.has(B)||E.set(B,new Set),E.get(B)?.add(F))}if(m.httpServers.length>0){let D=m.httpServers[0];D!=null&&(j[Y0e]=D.url,e.setUrlId(D.url,Y0e));for(let B=1;B<m.httpServers.length;B++){let F=m.httpServers[B];if(F!=null){let N=sja(F.url),T=W3o(F.url),R=N?E.get(N):void 0,Q=R&&R.size>1,H=Q&&T!=="https"?`${N}_${T}`:N||`Http${B+1}`;e.logger.debug(`[buildEnvironments] HTTP server: url="${F.url}", pathSegment="${N}", protocol="${T}", hasCollision=${Q}, urlId="${H}"`),j[H]=F.url,e.setUrlId(F.url,H)}}}for(let D of m.websocketServers){let B=sja(D.url),F=W3o(D.url),N=B?E.get(B):void 0,T=N&&N.size>1,R=T?`${B}_${F}`:x3o(D.name,D.url,!0);e.logger.debug(`[buildEnvironments] WebSocket server: name="${D.name}", url="${D.url}", pathSegment="${B}", protocol="${F}", hasCollision=${T}, urlId="${R}"`),j[R]=D.url,e.setUrlId(D.url,R)}if(Object.keys(j).length>1)e.builder.addEnvironment({name:m.environmentName,schema:{urls:j}});else if(Object.keys(j).length===1){let D=Object.values(j)[0];D!=null&&e.builder.addEnvironment({name:m.environmentName,schema:D})}A&&(e.builder.setDefaultEnvironment(m.environmentName),Object.keys(j).length>1&&e.builder.setDefaultUrl(Y0e),A=!1)}return}}if(!l&&!p&&h&&e.ir.servers.length===0){for(let[v,O]of Object.entries(f))e.builder.addEnvironment({name:v,schema:O});e.builder.setDefaultEnvironment(Object.keys(f)[0]),e.builder.setDefaultUrl(Y0e);return}if(c.length>0&&e.logger.debug(`Skipping endpoint level servers ${c.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),!l){let v=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(v!=null){let A=O?{url:v,audiences:O}:v;t[yy_]=A}}let y=Object.values(t).map(v=>typeof v=="string"?v:ghe(v)?Object.values(v.urls)[0]:v.url),b=r.filter(v=>{let O=typeof v=="string"?v:v.url;return!y.includes(O)});if(b.length>0&&e.logger.debug(`Skipping top level servers ${b.map(v=>typeof v=="string"?v:v.url).join(", ")} because x-fern-server-name was not provided.`),i){let v=!0;for(let[O,A]of Object.entries(t))if(e.builder.addEnvironment({name:O,schema:A}),v){if(e.builder.setDefaultEnvironment(O),ghe(A)){let g=Object.keys(A.urls)[0];g&&e.builder.setDefaultUrl(g)}v=!1}return}if(!p&&!_){let v=!0;for(let[O,A]of Object.entries(t))if(v){if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[Y0e]:g??"",...qJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});e.builder.setDefaultEnvironment(O),v=!1}else if(h){let g=typeof A=="string"?A:ghe(A)?Object.values(A.urls)[0]:A.url;e.builder.addEnvironment({name:O,schema:{urls:{[Y0e]:g??"",...qJi(f)}}})}else e.builder.addEnvironment({name:O,schema:A});h&&e.builder.setDefaultUrl(Y0e)}else if(u===1){let v=Object.keys(t)[0],O=Object.values(t)[0],A=typeof O=="string"?O:ghe(O)?Object.values(O.urls)[0]:O.url;e.builder.addEnvironment({name:v,schema:{urls:{[Y0e]:A??"",...qJi(o),...qJi(f)}}}),e.builder.setDefaultEnvironment(v),e.builder.setDefaultUrl(Y0e)}else{let v=new Map;for(let O of e.ir.endpoints)for(let A of O.servers)if(A.url!=null&&A.name!=null){v.has(A.name)||v.set(A.name,new Map);let g=A.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",m=v.get(A.name);m&&m.set(g,A.url)}if(v.size>0){let O=!0;for(let[A,g]of Object.entries(t)){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;if(!m)continue;let j=m.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",M={[Y0e]:m};for(let[E,D]of v.entries()){let B=D.get(j)||D.get("production")||D.values().next().value;B&&(M[E]=B)}h&&Object.assign(M,qJi(f)),Object.keys(M).length>1?e.builder.addEnvironment({name:A,schema:{urls:M}}):e.builder.addEnvironment({name:A,schema:m}),O&&(e.builder.setDefaultEnvironment(A),O=!1)}v.size>0&&e.builder.setDefaultUrl(Y0e)}else{let O=!0;for(let[A,g]of Object.entries(t)){if(h||Object.keys(o).length>0){let m=typeof g=="string"?g:ghe(g)?Object.values(g.urls)[0]:g.url;e.builder.addEnvironment({name:A,schema:{urls:{[Y0e]:m??"",...qJi(o),...qJi(f)}}})}else e.builder.addEnvironment({name:A,schema:g});O&&(e.builder.setDefaultEnvironment(A),O=!1)}}}}var Psc=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},crM=.75,lrM=new Set("authorization");function vy_(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?_Un(i.schema):void 0,o=a!=null?$vi(a):void 0,c=Tu.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?hO(Af({schema:i.schema,context:e,fileContainingReference:o?iD(Tu.of(No(o)),c):c,namespace:o,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.options.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(lrM.has(a.name.toLowerCase()))continue;let o=r[a.name];if(o==null){let c=t[a.name],f=OGt({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Tu.of(n1),context:e,namespace:void 0});o=new Psc(f),r[a.name]=o}o.increment()}let i=e.ir.endpoints.length*crM;for(let[n,a]of Object.entries(r)){let o=t[n],c=a.count===e.ir.endpoints.length,f=a.count>=i;o==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):f&&e.builder.addGlobalHeader({name:n,schema:CJi(a.schema)}))}}}function gy_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?_Un(t.schema):void 0,i=r!=null?$vi(r):void 0,n=OGt({header:{...t,schema:t.schema??Zs.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:ah.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:Tu.of(n1),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:CJi(n)})}}function HL(e){switch(e.type){case"primitive":return Ay_(e.value);case"object":return my_(e.properties);case"array":return Py_(e.value);case"map":return drM(e.value);case"oneOf":return prM(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return _rM(e.value);case"unknown":return HL(e.value);case"null":return null;default:vt(e)}}function Oy_(e){switch(e.type){case"withStreaming":return e.sse?{stream:frM(e.events)}:{stream:Py_(e.events)};case"withoutStreaming":return{body:HL(e.value)};default:vt(e)}}function Ay_(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:vt(e)}}function my_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,HL(r)]))}function frM(e){return e.map(t=>({event:"",data:HL(t)}))}function Py_(e){return e.map(t=>HL(t))}function drM(e){return Object.fromEntries(e.map(t=>[Ay_(t.key),HL(t.value)]))}function prM(e){return e.type==="discriminated"?my_(e.value):HL(e.value)}function _rM(e){switch(e.type){case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"boolean":return e.value;default:vt(e)}}function jy_({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"]=hrM(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=yrM(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,o=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let f of e.headers)f.name!==t.builder.getAuthHeaderName()&&c.push(f);for(let[f,s]of Object.entries(n))if(!o.has(f))if(s!=null&&typeof s=="object"&&s.type!=null){let u=PB({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:Et}});u!=null&&c.push({name:f,value:Sl.literal(RCi.string(u))})}else c.push({name:f,value:Sl.primitive(Ha.string(f))});r.headers=brM({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=HL(e.request)),e.response!=null&&(r.response=Oy_(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(ps)),r}function hrM(e){let t={};return e.forEach(r=>{let i=HL(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function yrM(e){let t={};return e.forEach(r=>{let i=HL(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function brM({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=HL(i.value);n!=null&&(r[i.name]=n)}),r}function wy_(e){return gz._visit(e,{get:()=>AD.HttpMethodSchema.Get,post:()=>AD.HttpMethodSchema.Post,put:()=>AD.HttpMethodSchema.Put,patch:()=>AD.HttpMethodSchema.Patch,delete:()=>AD.HttpMethodSchema.Delete,head:()=>AD.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 Ey_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Sy_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,o=e.path,c=G3o(e.sdkName,e.namespace),f={};for(let b of e.pathParameters)b.parameterNameOverride&&(o=o.replace(b.name,b.parameterNameOverride)),f[b.parameterNameOverride??b.name]=U3o({pathParameter:b,context:r,fileContainingReference:t,namespace:c}),a.add(b.name);let s={};for(let b of e.queryParameters){let v=V3o({queryParameter:b,context:r,fileContainingReference:t,namespace:c});v!=null&&(s[b.name]=v,a.add(b.name))}let u;if(e.pagination!=null)switch(e.pagination.type){case"cursor":u={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":u={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":u={type:"custom",results:e.pagination.results};break;default:vt(e.pagination)}let l={path:o,method:wy_(e.method),auth:vrM({endpoint:e,context:r}),docs:e.description??void 0,pagination:u,source:e.source!=null?Jvi(e.source):void 0};!mrM({context:r,request:e.request})&&Object.keys(f).length>0&&(l["path-parameters"]=f),e.summary!=null&&(l["display-name"]=e.summary);let p={},_=r.builder.getGlobalHeaderNames(),h=r.builder.getAuthHeaderName();h!=null&&_.add(h);let y=e.headers.filter(b=>!_.has(b.name));for(let b of y){let v=OGt({header:b,context:r,fileContainingReference:t,namespace:c});p[b.name]=v,a.add(typeof v=="string"?b.name:v.name??b.name)}if(e.request!=null){r.setInState(q1.Request);let b=ArM({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.options.inlinePathParameters&&Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(p).length>0?p:void 0,usedNames:a,namespace:c});l.request=b.value,n=[...n,...b.schemaIdsToExclude??[]],r.unsetInState(q1.Request)}else{let b=r.options.inlinePathParameters&&Object.keys(f).length>0,v=Object.keys(s).length>0,O=Object.keys(p).length>0,A={};(b||v||O)&&(A.name=e.requestNameOverride??e.generatedRequestName),b&&(A["path-parameters"]=f),v&&(A["query-parameters"]=s),O&&(A.headers=p),Object.keys(A).length>0&&(l.request=A)}if(e.response!=null&&e.response._visit({json:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:b.description??void 0,type:hO(v)},b.statusCode!=null&&(l.response["status-code"]=b.statusCode),b.responseProperty!=null&&(l.response.property=b.responseProperty)},streamingJson:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"json"}},streamingSse:b=>{let v=Af({schema:b.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:b.description??void 0,type:hO(v),format:"sse"}},file:b=>{l.response={docs:b.description??void 0,type:"file","status-code":b.statusCode}},bytes:b=>{l.response={docs:b.description??void 0,type:"bytes","status-code":b.statusCode}},streamingText:b=>{l["response-stream"]={docs:b.description??void 0,type:"text"}},text:b=>{l.response={docs:b.description??void 0,type:"text","status-code":b.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let b=r.getDefaultServerName(),v=e.servers[0];v==null?b!=null&&(l.url=b):l.url=v.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=ZE(e.availability)),Object.entries(e.errors).forEach(([b,v])=>{let O=v.generatedName,A=Tu.of(ob);r.builder.enableUniqueErrorsPerEndpoint&&(O=`${e.generatedRequestName}${v.generatedName}`,v.schema!=null&&(v.schema.type!=="reference"&&v.schema.type!=="oneOf"?v.schema.generatedName=`${e.generatedRequestName}${v.schema.generatedName}`:v.schema.type==="oneOf"&&(v.schema.value.generatedName=`${e.generatedRequestName}${v.schema.value.generatedName}`)));let g={"status-code":parseInt(b)},m=Zh_({location:My_,namespaceOverride:c});if(v.schema!=null){let E=Af({schema:v.schema,context:r,fileContainingReference:m,declarationFile:m,namespace:c,declarationDepth:0});g.type=hO(E),g.docs=v.description}r.builder.addError(m,{name:O,schema:r.isErrorUnknownSchema(parseInt(b))?{...g,type:"unknown"}:g}),l.errors==null&&(l.errors=[]);let j=r.builder.addImport({file:t,fileToImport:m});l.errors.push(j!=null?`${j}.${O}`:O),g.type!=null&&v.examples?.forEach(E=>{let D={value:HL(E.example),name:E.name,docs:E.description};r.builder.addErrorExample(m,{name:O,example:D})})}),e.examples.length>0&&(l.examples=grM({endpointExamples:e.examples,context:r})),e.retries!=null&&(l.retries=OrM({retries:e.retries})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[jsc,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function vrM({endpoint:e,context:t}){if(e.security==null)return t.authOverrides?.auth!=null?!0:t.ir.security==null?void 0:t.ir.security.length>0?!0:void 0;if(e.security.length!==0)return JSON.stringify(e.security)===JSON.stringify(t.ir.security)?!0:e.security}function grM({endpointExamples:e,context:t}){return e.map(r=>{try{return jy_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function OrM({retries:e}){if(e!=null)switch(e.type){case"disabled":return{disabled:e.value??void 0};default:vt(e)}}function ArM({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:o,queryParameters:c,nonRequestReferencedSchemas:f,headers:s,usedNames:u,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let p=i.schema.type==="reference"?i.schema.schema:void 0,_=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(_?.type!=="object"||p!=null&&f.includes(p)){let O=Af({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),A={schemaIdsToExclude:[],value:{body:O}},g=Object.keys(o??{}).length>0,m=Object.keys(c??{}).length>0,j=Object.keys(s??{}).length>0;return g&&(A.value["path-parameters"]=o),m&&(A.value["query-parameters"]=c),j&&(A.value.headers=s),(g||m||j)&&(A.value.name=n??a),i.contentType!=null&&(A.value["content-type"]=i.contentType),i.description!=null&&(A.value.docs=i.description),A}let h=Object.fromEntries(_.properties.filter(O=>O.readonly==null?!0:!(Ey_(e.method)&&O.readonly)).map(O=>{let A=Af({schema:O.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),g=O.nameOverride??O.key,m=ZE(O.availability);if(!u.has(g)&&O.audiences.length<=0)return u.add(g),O.nameOverride!=null?[O.key,{type:hO(A),docs:hUn(A),name:O.nameOverride,availability:m}]:[O.key,m?{...typeof A=="string"?{type:A}:A,availability:m}:A];let j={type:hO(A),docs:hUn(A)};return u.has(g)&&(j.name=O.generatedName),O.audiences.length>0&&(j.audiences=O.audiences),m!=null&&(j.availability=m),u.add(g),[O.key,j]})),y=_.allOf.map(O=>{let A=Af({schema:Zs.reference(O),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return hO(A)}).filter(O=>O!=="unknown"),b={properties:h};y.length>0&&(b.extends=y),i.additionalProperties&&(b["extra-properties"]=!0);let v={name:n??_.nameOverride??_.generatedName,"path-parameters":o,"query-parameters":c,headers:s,body:b};return i.contentType!=null&&(v["content-type"]=i.contentType),i.description!=null&&(v.docs=i.description),{schemaIdsToExclude:p!=null?[p]:[],value:v}}else if(i.type==="octetStream"){let p={body:"bytes","content-type":i.contentType??VA.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(p.name=n??a),i.description!=null&&(p.docs=i.description),{schemaIdsToExclude:[],value:p}}else if(i.type==="multipart"){let p=Object.fromEntries(i.properties.map(_=>{if(_.schema.type==="file"){let h=_.schema.isArray?"list<file>":"file";if(h=_.schema.isOptional?`optional<${h}>`:h,_.description!=null||_.contentType!=null){let y={type:h};if(_.description!=null&&(y.docs=_.description),_.contentType!=null){let b=_.contentType.split(",")[0];y["content-type"]=b}return[_.key,y]}return[_.key,h]}else{let h=Af({schema:_.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(_.contentType||_.exploded||_.encoding){let y=typeof h=="string"?{type:h}:h;_.contentType!=null&&(y["content-type"]=_.contentType),_.encoding==="form"?y.style="form":_.encoding==="json"?y.style="json":_.exploded&&(y.style="exploded"),h=y}return[_.key,h]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":o,"query-parameters":c,headers:s,body:{properties:p},"content-type":VA.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else vt(i)}function mrM({context:e,request:t}){if(!e.options.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:vt(t)}}function PrM({location:e,namespaceOverride:t}){return t!=null?{...e,file:iD(Tu.of(t),e.file)}:e}function jrM(e){let t=e.namespace,r=e.tags.filter(f=>f!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Tu.of(`${No(r)}.yml`),endpointId:e.summary!=null?No(e.summary):No(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Tu.of(ob),endpointId:No(e.summary)}:{file:Tu.of(ob),endpointId:No(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Tu.of(ob),endpointId:i};let n=cja(r),a=cja(i);if(r1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=SrM({operationId:i,tag:r,path:e.path,method:e.method});if(o!=null)return o;let c=[];for(let f=0;f<n.length;++f){let s=n[f];if(s!=null&&s===a[f])c.push(s);else{let u=No(r);return{file:Tu.of(`${u}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Tu.of(No(c.join("_"))+".yml"),endpointId:No(a.slice(c.length).join("_")),tag:r}}function lja(e){let t=e.tags[0];if(e.sdkName!=null){let r=usc({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Tu.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return PrM({namespaceOverride:e.namespace,location:jrM(e)})}function cja(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=$Oe(t),t}var wrM=new RegExp("[^a-zA-Z0-9{}]+"),ErM=new RegExp("[{}]","g");function SrM({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(wrM).join("_").replaceAll(ErM,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Tu.of(No(t)+".yml"),endpointId:No(e.slice(0,-1*a.length)),tag:t}}function Dy_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:o,file:c,tag:f}=lja(a),s=c.split(".")[0];s!=null&&t.add(s);let u;if(a.sdkName!=null){let _=e.ir.groups;for(let h of a.sdkName.groupName){let y=typeof h=="string"?h:h.name,b=_[y];if(b==null)break;if(b.summary!=null||b.description!=null){u=_[y];break}}}let l=f==null?void 0:i.tagsById[f];e.setInState(q1.Endpoint),e.setEndpointMethod(a.method);let p=Sy_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(q1.Endpoint),n=[...n,...p.schemaIdsToExclude],e.builder.addEndpoint(c,{name:o,schema:p.value,source:a.source!=null?Jvi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":u?.summary??l?.id,docs:u?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function By_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?$vi(r.groupName):void 0,n=Af({schema:Zs.primitive(r),context:e,fileContainingReference:Tu.of(ob),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:hO(n),docs:r.description??void 0}})}}function Iy_(e){for(let t of e.ir.webhooks){let r=BrM({webhook:t,context:e});if(r==null)continue;let i=G3o(t.sdkName,t.namespace),n={};for(let o of t.headers)n[o.name]=OGt({header:o,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:Af({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(o=>({docs:o.description,name:o.name,payload:HL(o.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function MrM({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:iD(Tu.of(t),e.file)}:e}function DrM({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Tu.of(ob),endpointId:i};let n=cja(r),a=cja(i);if(r1(n,a))return{file:Tu.of("__package__.yml"),endpointId:r};let o=[];for(let c=0;c<n.length;++c){let f=n[c];if(f!=null&&f===a[c])o.push(f);else{let s=No(r);return{file:Tu.of(`${s}.yml`),endpointId:i,tag:r}}}if(o.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Tu.of(No(o.join("_"))+".yml"),endpointId:No(a.slice(o.length).join("_")),tag:r}}function BrM({webhook:e,context:t}){return e.sdkName!=null?{file:Xh_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:MrM({namespaceOverride:e.namespace,location:DrM({webhook:e,context:t})})}var IrM=Tu.of(ob);function qy_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return Cy_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return Cy_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return IrM;default:vt(e)}}function Cy_({namespace:e,groupName:t}){return e!=null&&t!=null?HCi([{type:"namespace",name:e},...t]):e!=null?HCi([{type:"namespace",name:e}]):HCi(t)}var jsc="external",My_=Tu.of(ob);function Ty_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let o=qy_(a),c=ny_({schema:a,context:i,declarationFile:o,namespace:r,declarationDepth:0});if(OCi(c.schema)){let f=hO(c.schema);if(f===(c.name??n)||f===`optional<${c.name??n}>`||f===`nullable<${c.name??n}>`||f===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(o,{name:c.name??n,schema:c.schema})}}function Ry_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),by_(e),vy_(e),gy_(e),cy_(e),By_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(jsc);let t=Dy_(e),r=t.sdkGroups;e.setInState(q1.Webhook),Iy_(e),e.unsetInState(q1.Webhook),e.setInState(q1.Channel);for(let n of Object.values(e.ir.channels)){let a=HCi(n.groupName);py_({channel:n,context:e,declarationFile:a})}e.unsetInState(q1.Channel);let i=CrM({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});Ty_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))Ty_({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.optimizeServiceAuth(),e.builder.build()}function CrM({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var fja=class{context;constructor(t){this.context=t}};var H3o=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[o,c]of Object.entries(i.files)){let f=n!=null?Tu.of(`${n}${"/"}${o}`):Tu.of(o);t[f]=c}let a=Object.keys(i.directories).sort();for(let o of a){let c=n!=null?`${n}${"/"}${o}`:o,f=i.directories[o];r(f,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Tu.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var TJi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new H3o,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let o=this.getOrCreateFile(t);o.service==null&&(o.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(o.service.auth=r),i!=null&&(o.service["base-path"]=i),n!=null&&(o.service["display-name"]=n),a!=null&&(o.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return oGt(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))zy_(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(zy_(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??No((dAe(r)+"/"+v9i(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Tu.of(n1))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Puo(dAe(JDn.of(`/${t}`)),JDn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Puo(dAe(JDn.of(`/${t}`)),JDn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Tu.of(n1))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>r1(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=iD(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}optimizeServiceAuth(){let t=[this.packageMarkerFile,...Object.values(this.root.getAllFiles())];for(let r of t){if(r.service==null)continue;let i=Object.values(r.service.endpoints);if(i.length===0)continue;if(i.every(a=>a.auth===!0)){r.service.auth=!0;for(let a of Object.values(r.service.endpoints))delete a.auth}}}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:iD(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,o])=>[a,{...o,path:iD(r,o.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===ob?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 zy_(e){return e?.header!=null}var K3o=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;options;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;urlIdMap=new Map;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:o}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=o,this.globalHeaderOverrides=a,this.options=DJi({options:i}),this.enableUniqueErrorsPerEndpoint=this.options.enableUniqueErrorsPerEndpoint,this.referencedSchemaIds=this.options.onlyIncludeReferencedSchemas?new Set:void 0,this.builder=new TJi(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let f of r.endpoints)for(let[s,u]of Object.entries(f.errors)){let l=parseInt(s),p=c[l];p==null&&u.schema!=null?c[l]=u.schema:p!=null&&u.schema!=null&&nK(p,u.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}setUrlId(t,r){this.urlIdMap.set(t,r)}getUrlId(t){return this.urlIdMap.get(t)}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.options.onlyIncludeReferencedSchemas&&this.isInAnyState(q1.Channel,q1.Endpoint,q1.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:vt(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:vt(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function wsc(e){let t=new K3o(e);return Ry_(t)}function qrM(e){return xKi(e,{single:t=>[typeof t=="string"?t:t.scheme],any:t=>t.any.map(r=>typeof r=="string"?r:r.scheme)})}function TrM(e,t){if(e==null)return;let r=qrM(t),i={};for(let n of r)e[n]!=null&&(i[n]=e[n]);return Object.keys(i).length>0?i:void 0}var J3o=class{args;constructor(t){this.args=t}buildAuthOverrides(t,r){let i=this.args.generatorsConfiguration?.api?.["auth-schemes"],n=this.args.generatorsConfiguration?.api?.auth,a=t??n;if(a==null)return;let o=r!=null||i!=null?{...i,...r}:void 0,c=TrM(o,a);return{auth:a,"auth-schemes":c}}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=wsc({taskContext:t,ir:r,options:DJi({options:i,overrides:this.args}),authOverrides:this.buildAuthOverrides(i?.auth,i?.authSchemes),environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Fi.dump(a.rootApiFile)},namedDefinitionFiles:{...bn(a.definitionFiles,o=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Fi.dump(o),contents:o})),[Tu.of(ob)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Fi.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var dja=class extends hFt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;wrapReferencesToNullableInOptional;coerceOptionalSchemasToNullable;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;resolveAliases;groupEnvironmentsByHost;removeDiscriminantsFromSchemas;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.groupEnvironmentsByHost=t.groupEnvironmentsByHost,this.removeDiscriminantsFromSchemas=t.removeDiscriminantsFromSchemas,this.converter=new J3o(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r,i){let n=await this.getDefinition({context:t},r);return new rK({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var JQ={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 yUn={of(e){return e}};var Ny_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},Esc={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Ny_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},Gi={SOURCE:yUn.of("source"),SDK_NAMESPACE:yUn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:yUn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:yUn.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:yUn.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",RETRIES:"x-fern-retries",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated",EXPLORER_ENABLED:"x-fern-explorer-enabled"};var RrM={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!1,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!1,respectReadonlySchemas:!1,respectNullableSchemas:!0,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!0,preserveSchemaIds:!1,objectQueryParameters:!0,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!0,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!1,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,resolveAliases:!1,groupMultiApiEnvironments:!1,groupEnvironmentsByHost:!1,wrapReferencesToNullableInOptional:!1,coerceOptionalSchemasToNullable:!1,removeDiscriminantsFromSchemas:wn.RemoveDiscriminantsFromSchemas.Always};function zrM(e){let{defaults:t,options:r,overrides:i,overrideOnly:n=new Set,undefinedIfAbsent:a=new Set}=e,o={};for(let c of Object.keys(t))n.has(c)?o[c]=i?.[c]!==void 0?i[c]:t[c]:a.has(c)?o[c]=i?.[c]!==void 0?i[c]:r?.[c]!==void 0?r[c]:void 0:o[c]=i?.[c]??r?.[c]??t[c];return o}function X0e({options:e,overrides:t}){return zrM({defaults:RrM,options:e,overrides:t,overrideOnly:new Set(["disableExamples","preserveSchemaIds"]),undefinedIfAbsent:new Set(["exampleGeneration","defaultFormParameterEncoding"])})}var Fy_={naming:"v1"};function Di(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function pja(e,t,r,i,n=[]){try{let a=Di(e,t);if(a!=null)return r.parse(a)}catch{let o=$Oe(n).join(" -> ");i.error(`${o.length>0?`${o}: `:""}Failed to parse ${t}`)}}function RJi(e){let t=Di(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 Qy_({schema:e,logger:t}){return Di(e,Gi.ENCODING)??void 0}function Uy_(e){return Di(e,Gi.FERN_ENUM)}function Ly_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let o=Di(i,Gi.SDK_NAMESPACE),c=Di(i,Gi.SDK_GROUP_NAME),f=Di(i,Gi.TYPE_DEFINITION);if(f!=null)return _ja({fernType:f,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:o,groupName:typeof c=="string"?[c]:c})}function _ja({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c}){return PB({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.base64({example:void 0})});case"BOOLEAN":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.boolean({default:void 0,example:void 0})});case"DATE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.date({example:void 0})});case"DATE_TIME":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.datetime({example:void 0})});case"FLOAT":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.float({example:void 0})});case"DOUBLE":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint({default:void 0,example:void 0})});case"INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.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 ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.uint64({default:void 0,example:void 0})});case"LONG":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return ri.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,schema:Ln.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:vt(f.v1)}},unknown:()=>ri.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:o,groupName:c}),map:({keyType:f,valueType:s})=>f?.type==="primitive"&&s!=null?ri.map({nameOverride:t,generatedName:r,title:i,key:f,value:s,description:n,availability:a,namespace:o,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,optional:f=>f!=null?ri.optional({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,nullable:f=>f!=null?ri.nullable({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,inline:void 0}):void 0,set:f=>f!=null?ri.array({nameOverride:t,generatedName:r,title:i,value:f,description:n,availability:a,namespace:o,groupName:c,example:void 0,inline:void 0}):void 0,literal:f=>ri.literal({nameOverride:t,generatedName:r,title:i,value:f._visit({string:s=>Fj.string(s),boolean:s=>Fj.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:o,groupName:c}),named:f=>ri.reference({schema:f,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:o,groupName:c,source:xL.openapi({file:"<memory>"})})}})}function Vy_(e){let t=Di(e,Gi.SOURCE);if(t!=null)return t.endsWith(".proto")?xL.protobuf({file:t}):xL.openapi({file:t})}function zJi(e){if(e!=null&&typeof e=="boolean")return e}function jn(e){return e?.$ref!=null}function Wy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,encoding:_,source:h}){return n===void 0&&(n=s.options.additionalPropertiesDefaultsTo),Ssc({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:typeof n=="boolean"||hja(n,s.options)?ri.unknown({...NrM(n),generatedName:`${t}Value`}):xy_(Dl(n,!1,s.options.optionalAdditionalProperties?f:!1,s,[...i,"Value"],h,u,void 0,void 0,void 0)),namespace:u,groupName:l,example:p,encoding:_})}function xy_(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=xy_(e.value);break;case"oneOf":e.value.inline=!0;break;default:vt(e)}return e}function Ssc({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsOptional:a,wrapAsNullable:o,description:c,availability:f,namespace:s,groupName:u,example:l,encoding:p}){let _=ri.map({nameOverride:e,generatedName:t,title:r,description:c,availability:f,key:i,value:n,namespace:s,groupName:u,encoding:p,example:l,inline:void 0});return o&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),a&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,description:c,availability:f,namespace:s,groupName:u,inline:void 0})),_}function hja(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!(jn(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 NrM(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"||jn(e)||typeof e!="object"||(e.title!=null&&(t.title=e.title),e.description!=null&&(t.description=e.description)),t}function Gy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:o,wrapAsOptional:c,wrapAsNullable:f,context:s,namespace:u,groupName:l,example:p,source:_}){let h=n==null?ri.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:l}):Dl(n,!1,!1,s,[...i,"Item"],_,u);return FrM({nameOverride:e,generatedName:t,title:r,namespace:u,groupName:l,itemSchema:h,wrapAsOptional:c,wrapAsNullable:f,description:a,availability:o,example:p})}function FrM({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,example:u}){let l=ri.array({nameOverride:e,generatedName:t,title:r,value:i,description:o,availability:c,namespace:f,groupName:s,example:u,inline:void 0});return a&&(l=ri.nullable({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(l=ri.optional({nameOverride:e,generatedName:t,title:r,value:l,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),l}function KL(e){switch(Di(e,Gi.AVAILABILITY)){case"deprecated":return bz.Deprecated;case"beta":return bz.Beta;case"generally-available":return bz.GenerallyAvailable;default:break}if(!jn(e)&&e.deprecated)return bz.Deprecated}function Msc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminator:u,context:l,namespace:p,groupName:_,encoding:h,source:y}){let b=u.propertyName,v=Object.fromEntries(Object.entries(u.mapping??{}).map(([A,g])=>{let m=Yvi({$ref:g},!1,!1,l,[g],h,y,p);return l.markReferencedByDiscriminatedUnion({$ref:g},b,1),[A,m]})),O=Object.entries(n).filter(([A])=>A!==b).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=l.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,l,[...i,A],y,p);return{key:A,schema:E}});return Hy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:b,subtypes:v,namespace:p,groupName:_,source:y})}function Dsc({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:o,required:c,wrapAsOptional:f,wrapAsNullable:s,discriminant:u,variants:l,context:p,namespace:_,groupName:h,encoding:y,source:b}){let v=Object.fromEntries(Object.entries(l).map(([A,g])=>{if(jn(g)){let m=Yvi(g,!1,!1,p,[g.$ref],y,b,_);return p.markReferencedByDiscriminatedUnion(g,u,1),[A,m]}else{let m=bUn(g,!1,!1,p,[...i,A],y,b,_,new Set([u]));return[A,m]}})),O=Object.entries(n).filter(([A])=>A!==u).map(([A,g])=>{let m=c!=null&&c.includes(A),[j,M]=p.options.coerceOptionalSchemasToNullable?[!1,!m]:[!m,!1],E=Dl(g,j,M,p,[...i,A],b,_);return{key:A,schema:E}});return Hy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:f,wrapAsNullable:s,properties:O,description:a,availability:o,discriminant:u,subtypes:v,namespace:_,groupName:h,source:b})}function Hy_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,availability:c,discriminant:f,subtypes:s,namespace:u,groupName:l,source:p}){let _=ri.oneOf(Bhe.discriminated({description:o,availability:c,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:s,commonProperties:a,namespace:u,groupName:l,encoding:void 0,source:p,inline:void 0}));return n&&(_=ri.nullable({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),i&&(_=ri.optional({nameOverride:e,generatedName:t,title:r,value:_,namespace:u,groupName:l,description:o,availability:c,inline:void 0})),_}function Ky_(e){if(e.proto!=null)return zQn.protobuf({typeName:e.proto.type})}function JCi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:o,description:c,availability:f,wrapAsOptional:s,wrapAsNullable:u,namespace:l,groupName:p,context:_,source:h,inline:y}){let b=UrM(n??[]),v=new Set(a),O=Array.from(v).map((g,m)=>{let j=i?.[g],M=b[m],E=dUn.test(g),D=j?.name??M,B=E?g:pUn(g);return D!=null&&!dUn.test(D)&&(_?.logger.warn(`Enum name override ${D} is not a valid name. Falling back on ${B}.`),D=void 0),{nameOverride:D,generatedName:B,value:g,description:j?.description,availability:f,casing:{snake:j?.casing?.snake??void 0,pascal:j?.casing?.pascal??void 0,screamingSnake:j?.casing?.screamingSnake??void 0,camel:j?.casing?.camel??void 0}}}),A=o!=null?O.find(g=>g.value===o):void 0;return QrM({wrapAsOptional:s,wrapAsNullable:u,nameOverride:e,generatedName:t,title:r,values:O,_default:A,description:c,availability:f,namespace:l,groupName:p,source:h,inline:y})}function QrM({wrapAsOptional:e,wrapAsNullable:t,nameOverride:r,generatedName:i,title:n,values:a,_default:o,description:c,availability:f,namespace:s,groupName:u,source:l,inline:p}){let _=ri.enum({nameOverride:r,generatedName:i,title:n,values:a,description:c,availability:f,default:o,example:void 0,namespace:s,groupName:u,source:l,inline:p});return t&&(_=ri.nullable({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),e&&(_=ri.optional({nameOverride:r,generatedName:i,title:n,value:_,description:c,availability:f,namespace:s,groupName:u,inline:p})),_}function UrM(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function Jy_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==="int64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}function LrM(e){return typeof e=="string"?Fj.string(e):typeof e=="boolean"?Fj.boolean(e):Fj.string(`${e}`)}function $y_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,value:a,description:o,availability:c,namespace:f,groupName:s}){let u=ri.literal({nameOverride:e,generatedName:t,title:r,value:LrM(a),description:o,availability:c,namespace:f,groupName:s});return n&&(u=ri.nullable({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),i&&(u=ri.optional({nameOverride:e,generatedName:t,title:r,value:u,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),u}function Bsc({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,description:u,availability:l,wrapAsOptional:p,wrapAsNullable:_,example:h,namespace:y,groupName:b}){return i==null||i==="double"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.double({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="float"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int32"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int({default:n,minimum:a,maximum:o,exclusiveMinimum:c,exclusiveMaximum:f,multipleOf:s,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="int64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.int64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint32"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="uint64"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.uint64({default:n,example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):i==="time-delta"?T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b}):T1({nameOverride:e,generatedName:t,title:r,primitive:Ln.float({example:h}),wrapAsOptional:p,wrapAsNullable:_,description:u,availability:l,namespace:y,groupName:b})}var VrM={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},WrM={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}}},xrM={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}}},GrM={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},HrM={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},KrM={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},JrM={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},$rM={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function yja(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[VrM,WrM,xrM,GrM,HrM,KrM,JrM,$rM],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:o,newBreadcrumbs:c}=a.applyStrategy(t);t=o,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function TC(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:QP(No(n))).join("");return/^\d/.test(i)?aja(i)??i:i}function Yy_(e){let t=e.join("_");return No(t)}function xO(e){switch(e.type){case"object":return Zs.object({allOf:e.allOf,properties:e.properties.map(t=>XrM(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 Zs.array({description:e.description,availability:e.availability,value:xO(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return Zs.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 Zs.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 Zs.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return Zs.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:xO(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return Zs.primitive({description:e.description,availability:e.availability,schema:Xy_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Zs.map({description:e.description,availability:e.availability,key:Zs.primitive({description:e.key.description,availability:e.key.availability,schema:Xy_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:xO(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 Zs.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 Zs.oneOf(YrM(e.value));case"unknown":return Zs.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:vt(e)}}function YrM(e){switch(e.type){case"discriminated":return hGt.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:xO(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,xO(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return hGt.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>xO(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:vt(e)}}function Xy_(e){switch(e.type){case"string":return ah.string(e);case"base64":return ah.base64();case"boolean":return ah.boolean(e);case"date":return ah.date();case"datetime":return ah.datetime();case"double":return ah.double(e);case"float":return ah.float();case"int":return ah.int(e);case"int64":return ah.int64(e);case"uint":return ah.uint();case"uint64":return ah.uint64();default:vt(e)}}function XrM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:xO(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function $3o(e,t){return nK(xO(e),xO(t))}function Zy_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:o,wrapAsOptional:c,wrapAsNullable:f,allOf:s,context:u,propertiesToExclude:l,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v}){let O=[...o??[]],A={...ky_({properties:n,breadcrumbs:i,context:u})},g=[],m=[];for(let B of s)if(!u.options.inlineAllOfSchemas&&jn(B)){let F=u.resolveSchemaReference(B);if(F.discriminator!=null&&F.discriminator.mapping!=null)continue;if(F.oneOf!=null||F.anyOf!=null){let T=F.oneOf??F.anyOf;if(T!=null){for(let R of T){let Q=jn(R)?u.resolveSchemaReference(R):R,U=Dl(Q,!1,!1,u.DUMMY,i,v,p);U.type==="object"&&g.push(...U.properties.map(H=>H.schema.type!=="optional"&&H.schema.type!=="nullable"?{...H,schema:ri.optional({nameOverride:void 0,generatedName:"",title:void 0,value:H.schema,description:void 0,availability:H.availability,namespace:void 0,groupName:void 0,inline:void 0})}:H))}continue}}let N=$Ci(B);if(N==null)continue;m.push({schemaId:N,convertedSchema:Isc(B,[N],v,u.options.preserveSchemaIds),properties:eb_({schema:B,context:u,breadcrumbs:i,source:v,namespace:p})}),u.markSchemaAsReferencedByNonRequest(N)}else if(jn(B)){let F=u.resolveSchemaReference(B),N=Dl(F,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}else{let F=B.required??[];g=g.map(T=>(T.schema.type==="optional"||T.schema.type==="nullable")&&F.includes(T.key)?{...T,schema:T.schema.value}:T);let N=Dl(B,!1,!1,u,i,v,p);N.type==="object"&&g.push(...N.properties)}let j={};for(let B of m)for(let[F,N]of Object.entries(B.properties)){let T=j[F];T!=null?(T.schemaIds.push(B.schemaId),T.schemas.some(Q=>$3o(Q,N))||T.schemas.push(N)):j[F]={schemaIds:[B.schemaId],schemas:[N]}}let M=[];for(let[B,F]of Object.entries(j))F.schemaIds.length>1&&M.push({propertyKey:B,allOfSchemaIds:F.schemaIds,conflictingTypeSignatures:F.schemas.length>1});let E=Object.fromEntries(Object.entries(A).filter(([B,F])=>!(!jn(F)&&F.type==="null"))),D=Object.entries(E).map(([B,F])=>{let N=Di(F,Gi.AUDIENCES)??[],T=KL(F),R=jn(F)?!1:F.readOnly,Q=jn(F)?!1:F.writeOnly,H=!(O.includes(B)&&!R),oe=Di(F,Gi.FERN_PROPERTY_NAME),se=[...i,B],x=Yy_(se),G=Dl(F,H,!1,u,se,v,p),Pe={};for(let ne of m){let Ee=ne.properties[B];Ee!=null&&!$3o(G,Ee)?Pe[ne.schemaId]={differentSchema:!0}:Ee!=null&&(Pe[ne.schemaId]={differentSchema:!1})}return{key:B,schema:G,nameOverride:oe,audiences:N,conflict:Pe,generatedName:x,availability:T,readonly:R,writeonly:Q}});return D.push(...g.map(B=>{let F=B.conflict;for(let N of m){let T=N.properties[B.key];T!=null&&!$3o(B.schema,T)?F[N.schemaId]={differentSchema:!0}:T!=null&&(F[N.schemaId]={differentSchema:!1})}return{...B,conflict:F}})),ZrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:c,wrapAsNullable:f,properties:D.filter(B=>!l.has(B.key)),description:a,allOf:m.map(B=>B.convertedSchema),allOfPropertyConflicts:M,namespace:p,groupName:_,fullExamples:h,additionalProperties:y,availability:b,source:v,context:u})}function ZrM({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,properties:a,description:o,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:p,availability:_,source:h,context:y}){let b=ri.object({description:o,properties:a,nameOverride:e,generatedName:t,title:r,allOf:c,allOfPropertyConflicts:f,namespace:s,groupName:u,fullExamples:l,additionalProperties:hja(p,y.options),availability:_,source:h,inline:void 0});return n&&(b=ri.nullable({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),i&&(b=ri.optional({nameOverride:e,generatedName:t,title:r,value:b,description:o,availability:_,namespace:s,groupName:u,inline:void 0})),b}function ky_({properties:e,breadcrumbs:t,context:r}){return Object.fromEntries(Object.entries(e).filter(([i,n])=>{let a=Di(n,Gi.IGNORE);return a&&r.logger.debug(`Property ${t.join(".")}.${i} is marked with x-fern-ignore. Skipping.`),!a}))}function eb_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[o,c]=jn(e)?[t.resolveSchemaReference(e),yja(e.$ref)]:[e,r];for(let f of o.allOf??[])a={...a,...eb_({schema:f,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[f,s]of Object.entries(ky_({properties:o.properties??{},breadcrumbs:r,context:t}))){let u=Dl(s,!1,!1,t,[...c,f],i,n);a[f]=u}return a}function YCi({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsOptional:o,wrapAsNullable:c,context:f,subtypes:s,namespace:u,groupName:l,encoding:p,source:_,subtypeSuffixOverrides:h}){let y=tiM({schemas:s}),b=s.flatMap((O,A)=>{if(!jn(O)&&O.enum!=null&&f.options.coerceEnumsToLiterals&&O.type==="string")return O.enum.map(m=>ri.literal({nameOverride:void 0,generatedName:TC([t,m],f.options.preserveSchemaIds),title:void 0,value:Fj.string(String(m)),namespace:u,groupName:void 0,description:void 0,availability:m.availability}));let g=y[A];if(h!=null){let m=h[A];m!=null&&"name"in m&&(g=m.name)}return[Dl(O,!1,!1,f,[...i,g??`${A}`],_,u)]}),v=krM(b);return eiM({uniqueSubtypes:v,nameOverride:e,generatedName:t,title:r,wrapAsOptional:o,wrapAsNullable:c,description:n,availability:a,namespace:u,groupName:l,context:f,encoding:p,source:_})}function krM(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let o=e[a];if(i!=null&&o!=null&&nK(i,o)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function eiM({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,namespace:f,groupName:s,context:u,encoding:l,source:p}){if(Object.entries(e).every(([h,y])=>y.type==="literal")){let h={},y=[];return Object.entries(e).forEach(([b,v])=>{v.type==="literal"&&v.value.type==="string"&&(y.push(v.value.value),v.description!=null&&(h[v.value.value]={description:v.description}))}),JCi({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,fernEnum:h,enumVarNames:void 0,enumValues:y,_default:void 0,namespace:f,groupName:s,context:u,source:p,inline:void 0})}if(e.length===1&&e[0]!=null&&!u.options.preserveSingleSchemaOneOf){let h=e[0];return a&&(h=ri.nullable({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),n&&(h=ri.optional({nameOverride:t,generatedName:r,title:i,value:h,description:o,availability:c,namespace:f,groupName:s,inline:void 0})),h}return tb_({nameOverride:t,generatedName:r,title:i,wrapAsOptional:n,wrapAsNullable:a,description:o,availability:c,subtypes:e,namespace:f,groupName:s,encoding:l,source:p})}function Csc({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsOptional:a,wrapAsNullable:o,context:c,namespace:f,groupName:s,discriminator:u,encoding:l,source:p}){let _=Object.entries(u.mapping??{}).map(([b,v],O)=>{let A={$ref:v},g=Yvi(A,!1,!1,c,[v],l,p,f);return c.markSchemaWithDiscriminantValue(A,u.propertyName,b),g.type==="object"&&(g.properties={[u.propertyName]:ri.literal({nameOverride:void 0,generatedName:TC([t,b],c.options.preserveSchemaIds),title:void 0,value:Fj.string(b),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...g.properties.filter(m=>m.key!==u.propertyName)}),g}),h=[];for(let b=0;b<_.length;++b){let v=_[b],O=!1;for(let A=b+1;A<_.length;++A){let g=_[A];if(v!=null&&g!=null&&nK(v,g)){O=!0;break}}v!=null&&!O&&h.push(v)}if(Object.entries(h).every(([b,v])=>v.type==="literal")){let b={},v=[];return Object.entries(h).forEach(([O,A])=>{A.type==="literal"&&A.value.type==="string"&&(v.push(A.value.value),A.description!=null&&(b[A.value.value]={description:A.description}))}),JCi({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,fernEnum:b,enumVarNames:void 0,enumValues:v,_default:void 0,namespace:f,groupName:s,context:c,source:p,inline:void 0})}return h.length===1&&h[0]!=null&&!c.options.preserveSingleSchemaOneOf?h[0]:tb_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:a,wrapAsNullable:o,description:i,availability:n,subtypes:h,namespace:f,groupName:s,encoding:l,source:p})}function tiM({schemas:e}){let t={},r=0;for(let n of e){if(!jn(n)){if(n.properties!=null&&Object.entries(n.properties).length>0){let a=Object.keys(n.properties),o={},c=a;for(let[f,s]of Object.entries(t)){let u=Rro(s,a);c=Rro(c,s),o[f]=u}o[r]=c,t=o}}r++}return e.map((n,a)=>{let o=t[a];if(o!=null&&o.length>0){let c=o.sort();if(c[0]!=null)return c[0]}return IJi(a)??`${a}`})}function tb_({nameOverride:e,generatedName:t,title:r,wrapAsOptional:i,wrapAsNullable:n,description:a,availability:o,subtypes:c,namespace:f,groupName:s,encoding:u,source:l}){let p=ri.oneOf(Bhe.undiscriminated({description:a,availability:o,nameOverride:e,generatedName:t,title:r,schemas:c,namespace:f,groupName:s,encoding:u,source:l,inline:void 0}));return n&&(p=ri.nullable({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),i&&(p=ri.optional({nameOverride:e,generatedName:t,title:r,value:p,description:a,availability:o,namespace:f,groupName:s,inline:void 0})),p}function vUn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Y3o({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=RJi(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function rb_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=RJi(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function AGt({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=RJi(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function ib_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=RJi(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var NJi="#/components/schemas/";function ob_(e,t){let r=jn(e)?t.resolveSchemaReference(e):e;switch(r.type){case"boolean":case"number":case"integer":return!0;case"string":return r.enum==null;case"array":return ob_(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 riM(e,t,r){return r.options.resolveAliases?typeof r.options.resolveAliases=="object"&&r.options.resolveAliases.except?.includes(e)?!1:ob_(t,r):!1}function Dl(e,t,r,i,n,a,o,c=!1,f=new Set,s){let u=Vy_(e)??a,l=liM({schema:e,logger:i.logger});if(jn(e)){let p=$Ci(e);return p!=null?riM(p,e,i)?bUn(i.resolveSchemaReference(e),t,r,i,yja(e.$ref),l,u,o,f,c,s):(c?i.markSchemaAsReferencedByRequest(p):i.markSchemaAsReferencedByNonRequest(p),Yvi(e,t,r,i,n,l,u,o)):bUn(i.resolveSchemaReference(e),t,r,i,yja(e.$ref),l,u,o,f,c,s)}return bUn(e,t,r,i,n,l,u,o,f,c,s)}function Yvi(e,t,r,i,n,a,o,c){let f=e.$ref.includes("properties")?bUn(i.resolveSchemaReference(e),t,r,i,n,a,o,c,new Set):ri.reference(Isc(e,n,o,i.options.preserveSchemaIds));if(r===!1){let s=i.resolveSchemaReference(e);(s.nullable===!0||Array.isArray(s.type)&&s.type.length>=2&&s.type.includes("null"))&&(r=!0)}return r&&(f=ri.nullable({title:void 0,nameOverride:void 0,generatedName:TC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),t&&(f=ri.optional({title:void 0,nameOverride:void 0,generatedName:TC(n,i.options.preserveSchemaIds),value:f,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0})),f}function iiM(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function bUn(e,t,r,i,n,a,o,c,f=new Set,s=!1,u){typeof e=="string"&&(e={type:e});let l=Di(e,Gi.TYPE_NAME)??(i.options.useTitlesAsName?iiM(e.title):void 0),p=Di(e,Gi.SDK_GROUP_NAME)??Di(e,JQ.TAGS)?.[0],_=(typeof p=="string"?[p]:p)??[];_=i.resolveGroupName(_);let h=TC(n,i.options.preserveSchemaIds),y=e.title,b=e.description,v=KL(e),O=[];e.example!=null&&O.push({name:void 0,value:e.example,description:void 0});let A=Di(e,JQ.EXAMPLES);A!=null&&Object.keys(A).length>0&&O.push(...Object.entries(A).map(([j,M])=>({name:M?.summary??j,value:M.value,description:M.description})));let g=RJi(e);g!=null&&Object.keys(g).length>0&&O.push(...g.map(j=>({name:void 0,value:j,description:void 0})));let m=Ly_({schema:e,description:b,title:y,nameOverride:l,generatedName:h,availability:v});if(m!=null){let j=m;return r&&(j=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),t&&(j=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:j})),j}try{if(Array.isArray(e.type)){let E=e.type.indexOf("null"),D=E!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&D)e.type.splice(E,1),e.type=e.type[0],e.nullable=!0;else if(D&&(e.type.splice(E,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let B=new Set([...e.oneOf,...e.type]);e.oneOf=[...B]}}if(r=r||e.nullable===!0,"const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(e.enum=e.enum.filter(D=>D!==null),!k3o(e.enum))return T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:vUn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:AGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v});let E=Uy_(e);return i.options.coerceEnumsToLiterals&&e.enum.length===1&&e.enum[0]!=null&&E==null?$y_({nameOverride:l,generatedName:h,title:y,wrapAsOptional:t,wrapAsNullable:r,value:e.enum[0],description:b,availability:v,namespace:c,groupName:_}):JCi({nameOverride:l,generatedName:h,title:y,fernEnum:E,enumVarNames:Di(e,[JQ.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0})}if(k3o(e.type)&&e.type.length>1){let E=e.type.includes("null"),D=e.type.filter(B=>B!=="null").map(B=>({type:B,nullable:E}));return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:D,namespace:c,groupName:_,encoding:a,source:o})}if(e.type==="boolean"){let E=Di(e,Gi.BOOLEAN_LITERAL);return E!=null?nb_({nameOverride:l,generatedName:h,title:y,literal:Fj.boolean(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.boolean({default:niM(e.default),example:rb_({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_})}if(e.type==="number")return Bsc({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zJi(e.exclusiveMinimum),exclusiveMaximum:zJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="integer")return Jy_({nameOverride:l,generatedName:h,title:y,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zJi(e.exclusiveMinimum),exclusiveMaximum:zJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="float")return Bsc({nameOverride:l,generatedName:h,title:y,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:zJi(e.exclusiveMinimum),exclusiveMaximum:zJi(e.exclusiveMaximum),multipleOf:e.multipleOf,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,example:Y3o({schema:e,logger:i.logger,fallback:u}),namespace:c,groupName:_});if(e.type==="string"){if(e.format==="date-time")return T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.datetime({example:AGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="date"&&i.options.typeDatesAsStrings===!1)return T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.date({example:AGt({schema:e,logger:i.logger,fallback:u})}),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_});if(e.format==="json-string"){let D=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0});return r&&(D=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),t&&(D=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:D})),D}let E=sb_(e,"const");return E!=null?nb_({nameOverride:l,generatedName:h,title:y,literal:Fj.string(E),wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v,namespace:c,groupName:_}):T1({nameOverride:l,generatedName:h,title:y,primitive:Ln.string({default:vUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:AGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_,wrapAsOptional:t,wrapAsNullable:r,description:b,availability:v})}if(e.type==="array")return Gy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,item:e.items,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,example:ib_({schema:e,logger:i.logger,fallback:u}),source:o});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&X3o(e))return Wy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,additionalProperties:e.additionalProperties,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,example:e.example,source:o});if(e.oneOf!=null&&e.oneOf.length>0&&Di(e,Gi.IS_DISCRIMINATED)===!1)return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf,namespace:c,groupName:_,encoding:a,source:o});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return i.options.discriminatedUnionV2?Csc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf!=null&&e.oneOf.length>0){let E=Di(e,Gi.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return i.options.discriminatedUnionV2||E?Csc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,discriminator:e.discriminator,encoding:a,source:o}):Msc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsOptional:t,wrapAsNullable:r,context:i,namespace:c,groupName:_,encoding:a,source:o});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(i.options.preserveSingleSchemaOneOf)return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,context:i,subtypes:e.oneOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o});let D=Dl(e.oneOf[0],t,r,i,n,o,c,s);return mGt(D,b,c,_)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],T=e.oneOf[1];if(!jn(N)&&N.type==="null"){let R=Dl(T,t,!0,i,n,o,c);return mGt(R,b,c,_)}else if(!jn(T)&&T.type==="null"){let R=Dl(N,t,!0,i,n,o,c);return mGt(R,b,c,_)}}let D=uiM({schemas:e.oneOf});if(D!=null)return JCi({nameOverride:l,generatedName:h,title:y,fernEnum:void 0,enumVarNames:void 0,enumValues:D,_default:e.default,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,namespace:c,groupName:_,context:i,source:o,inline:void 0});let B=ab_({schemas:e.oneOf,context:i});if(B!=null&&!i.options.discriminatedUnionV2&&!E)return Dsc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:B.discriminant,variants:B.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let F=e.oneOf.filter(N=>!jn(N)&&N.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||F,context:i,subtypes:e.oneOf.filter(N=>jn(N)||N.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let B=Dl(e.anyOf[0],t,r,i,n,o,c,s);return mGt(B,b,c,_)}if(e.anyOf.length===2){let[B,F]=e.anyOf;if(B!=null&&F!=null){if(!jn(B)&&B.type==="null"){let N=Dl(F,t,!0,i,n,o,c);return mGt(N,b,c,_)}else if(!jn(F)&&F.type==="null"){let N=Dl(B,t,!0,i,n,o,c);return mGt(N,b,c,_)}}}let E=ab_({schemas:e.anyOf,context:i});if(E!=null&&!i.options.discriminatedUnionV2)return Dsc({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},required:e.required,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,discriminant:E.discriminant,variants:E.schemas,context:i,namespace:c,groupName:_,encoding:a,source:o});let D=e.anyOf.filter(B=>!jn(B)&&B.type==="null").length>0;return YCi({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r||D,context:i,subtypes:e.anyOf.filter(B=>jn(B)||B.type!=="null"),encoding:a,namespace:c,groupName:_,source:o})}if(e.allOf!=null||e.properties!=null){let E=[];for(let B of e.allOf??[])(jn(B)||Object.keys(B).length>0)&&E.push(B);if((e.properties==null||X3o(e))&&E.length===1&&E[0]!=null){let B=Dl(E[0],t,r,i,n,o,c,s);return mGt(B,b,c,_)}let D=E.filter(B=>{let F=Z3o(B);return F||i.logger.debug(`Skipping non-object allOf element: ${JSON.stringify(B)}`),F});if((e.properties==null||X3o(e))&&D.length===1&&D[0]!=null){let B=Dl(D[0],t,r,i,n,o,c,s);return mGt(B,b,c,_)}return Zy_({nameOverride:l,generatedName:h,title:y,breadcrumbs:n,properties:e.properties??{},description:b,required:e.required,wrapAsOptional:t,wrapAsNullable:r,allOf:D,context:i,propertiesToExclude:f,namespace:c,groupName:_,fullExamples:O,additionalProperties:e.additionalProperties,availability:v,encoding:a,source:o})}if(e.type==="object"&&aiM(e)&&oiM(e)&&X3o(e))return Ssc({nameOverride:l,generatedName:h,title:y,description:b,availability:v,wrapAsOptional:t,wrapAsNullable:r,keySchema:{nameOverride:void 0,generatedName:`${h}Key`,title:void 0,description:void 0,availability:void 0,schema:Ln.string({default:vUn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:AGt({schema:e,logger:i.logger,fallback:u})}),namespace:c,groupName:_},valueSchema:ri.unknown({nameOverride:void 0,generatedName:`${h}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:c,groupName:_}),namespace:c,groupName:_,encoding:a,example:e.example});e.type!=null&&i.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${n.join("->")}. Coercing to unknown.`);let j=e.example??e.default,M=ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:j});return r&&(M=ri.nullable({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),t&&(M=ri.optional({availability:v,namespace:c,groupName:_,description:b,generatedName:h,inline:void 0,nameOverride:l,title:y,value:M})),M}catch(j){return i.logger.debug(`Error converting schema: ${j.message}
1417
1417
  Location: ${n.join("-> ")}`),ri.unknown({nameOverride:l,generatedName:h,title:y,description:b,availability:v,namespace:c,groupName:_,example:void 0})}}function niM(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 $Ci(e){if(e.$ref.startsWith(NJi))return e.$ref.replace(NJi,"")}function Isc(e,t,r,i){let n=Di(e,Gi.TYPE_NAME),a=TC(t,i),o=e.description,c=KL(e),f=$Ci(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return Zs.reference({generatedName:a,nameOverride:n,title:void 0,schema:f,description:o??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function aiM(e){return e.oneOf==null||e.oneOf.length===0}function oiM(e){return e.allOf==null||e.allOf.length===0}function X3o(e){return e.properties==null||WA(e.properties)===0}function k3o(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function mGt(e,t,r,i){if(e.type==="reference")return ri.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i});if(e.type==="optional"){let n=mGt(e.value,t,r,i);return ri.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0})}else if(e.type==="nullable"){let n=mGt(e.value,t,r,i);return ri.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0})}else if(e.type==="primitive"&&t!=null&&e.description==null)return ri.primitive({...e,description:t});return e}function Z3o(e){return jn(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>Z3o(t)):e.oneOf!=null?e.oneOf.every(t=>Z3o(t)):e.anyOf!=null?e.anyOf.every(t=>Z3o(t)):!1}function nb_({literal:e,wrapAsOptional:t,wrapAsNullable:r,namespace:i,groupName:n,description:a,availability:o,nameOverride:c,generatedName:f,title:s}){let u=ri.literal({nameOverride:c,generatedName:f,title:s,value:e,namespace:i,groupName:n,description:a,availability:o});return r&&(u=ri.nullable({nameOverride:c,generatedName:f,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ri.optional({nameOverride:c,generatedName:f,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function T1({primitive:e,wrapAsOptional:t,wrapAsNullable:r,namespace:i,groupName:n,description:a,availability:o,generatedName:c,nameOverride:f,title:s}){n=typeof n=="string"?[n]:n;let u=ri.primitive({nameOverride:f,generatedName:c,title:s,schema:e,description:a,availability:o,namespace:i,groupName:n});return r&&(u=ri.nullable({nameOverride:f,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),t&&(u=ri.optional({nameOverride:f,generatedName:c,title:s,value:u,namespace:i,groupName:n,description:a,availability:o,inline:void 0})),u}function uiM({schemas:e}){let t=new Set;for(let r of e){if(jn(r))return;if(r.enum!=null&&k3o(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function ab_({schemas:e,context:t}){let r={};for(let i of e){let n=ub_({schema:i,context:t});for(let[a,o]of Object.entries(n)){let c=r[a];c!=null?c[o]=i:r[a]={[o]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function ub_({schema:e,context:t}){let r=jn(e)?t.resolveSchemaReference(e):e;return siM({schema:r,context:t})}function siM({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=ub_({schema:i,context:t});for(let[a,o]of Object.entries(n??{}))r[a]=o}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=jn(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&k3o(a.enum)&&ciM(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let o=sb_(a,"const");a.type==="string"&&o!=null&&(r[i]=o),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function ciM(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 sb_(e,t){let r=e[t];if(r!=null)return r}function liM({schema:e,logger:t}){let r=Qy_({schema:e,logger:t});if(r!=null)return Ky_(r)}var gUn=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(NJi))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(NJi.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,o,c]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let f=n.schemas[a];if(f==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(jn(f)&&(f=this.resolveSchemaReference(f)),o==="properties"&&c!=null){let s=f.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);jn(s)?f=this.resolveSchemaReference(s):f=s}return f}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var eLo=class extends gUn{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function OUn(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let o=a.namespace;i[o]??={},i[o][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:vt(a)}return{rootSchemas:r,namespacedSchemas:i}}var AUn=ae(require("fs"),1),FJi=ae(require("path"),1);function XCi(e){if(typeof e=="string")return Sl.primitive(Ha.string(e));if(typeof e=="number")return Number.isInteger(e)?Sl.primitive(Ha.int(e)):Sl.primitive(Ha.double(e));if(typeof e=="boolean")return Sl.primitive(Ha.boolean(e));if(Array.isArray(e)){let t=e.map(r=>XCi(r));return t.length===0?void 0:Sl.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,i]of Object.entries(e)){let n=XCi(i);n!=null&&t.push({key:Ha.string(r),value:n})}return Sl.map(t)}}function bja(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function cb_(e){if(e!=null&&Array.isArray(e))return e}var ZCi=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:o,skipReadonly:c}){switch(i.type){case"enum":return typeof r=="string"&&lb_({schema:i,value:r})?Sl.enum(r):i.values[0]!=null?Sl.enum(i.values[0]?.value):void 0;case"literal":return Sl.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,o)&&this.exceedsMaxDepth(n,o))return Sl.null({});let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:o,skipReadonly:c});return f??Sl.null({})}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,o)&&(o.ignoreOptionals||this.exceedsMaxDepth(n,o))||Object.is(r,null))return;let f=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:o,skipReadonly:c});return f!=null&&f.type==="array"&&f.value.length===0||f!=null&&f.type==="map"&&f.value.length===0||f!=null&&f.type==="object"&&Object.keys(f.properties).length===0?void 0:f}case"primitive":{let f=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:o});return Sl.primitive(f)}case"reference":{let f=this.schemas[i.schema];if(f!=null&&!a.has(i.schema)){a.add(i.schema);let s=f?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),u=this.buildExampleHelper({example:r,schema:f,exampleId:t,visitedSchemaIds:a,depth:n,options:o,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(i.schema),u}return}case"oneOf":switch(i.value.type){case"discriminated":{let f={},s={},u={},l=bja(r),p=l?.[i.value.discriminantProperty],_=i.value.schemas[p],h=[],y=this.getDiscriminatedUnionVariantSchema(i.value,l);y!=null&&h.push(y),h.push(...Object.entries(i.value.schemas));for(let b of h)if(p!=null&&_!=null&&_.type==="object"){s=this.getAllProperties(_),u=this.getAllRequiredProperties(_),f[i.value.discriminantProperty]=Sl.primitive(Ha.string(p));break}else{let v=this.buildExampleHelper({exampleId:t,schema:b[1],example:void 0,visitedSchemaIds:a,depth:n,options:o,skipReadonly:c});if(v!=null){this.mergeExampleWith(v,f),f[i.value.discriminantProperty]=Sl.primitive(Ha.string(b[0]));break}}for(let b of i.value.commonProperties){s[b.key]={schema:b.schema,readonly:!1};let v=this.getResolvedSchema(b.schema);v.type!=="optional"&&v.type!=="nullable"&&(u[b.key]=b.schema)}for(let[b,v]of Object.entries(s)){let O=b in u;if(O&&l?.[b]!=null){let A=this.buildExampleHelper({schema:v.schema,exampleId:t,example:l[b],visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});if(A!=null)f[b]=A;else return}else{let A=this.buildExampleHelper({exampleId:t,schema:v.schema,example:l?.[b],visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});if(A!=null)f[b]=A;else if(O)return}}return Sl.oneOf(zCi.discriminated(f))}case"undiscriminated":{let f=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(f!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:f,visitedSchemaIds:a,depth:n,options:o,skipReadonly:c});break}}return;case"unknown":if(r!=null){let f=XCi(r);if(f!=null)return Sl.unknown(f)}return o.ignoreOptionals||this.exceedsMaxDepth(n,o)?void 0:o.isParameter?Sl.primitive(Ha.string(o.name??"string")):Sl.map([{key:Ha.string("key"),value:Sl.primitive(Ha.string("value"))}]);case"array":{let f=cb_(r),s=[];if(f!=null&&f.length>0)for(let u of f){let l=this.buildExampleHelper({exampleId:t,example:u,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else if(i.example!=null&&i.example.length>0)for(let u of i.example){let l=this.buildExampleHelper({exampleId:t,example:u,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});l!=null&&s.push(l)}else{let u=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:o,skipReadonly:c});u!=null&&s.push(u)}return Sl.array(s)}case"map":{let f=bja(r??i.example);if(f!=null&&Object.entries(f).length>0){let l=[];for(let[p,_]of Object.entries(f)){let h=this.buildExampleFromPrimitive({schema:i.key.schema,example:p,options:o}),y=this.buildExampleHelper({exampleId:t,example:_,schema:i.value,visitedSchemaIds:a,depth:n+1,options:o,skipReadonly:c});y!=null&&l.push({key:h,value:y})}return Sl.map(l)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return Sl.map([{key:Ha.string("key"),value:Sl.unknown(Sl.primitive(Ha.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...o,name:"key"}}),u=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...o,name:"value"},skipReadonly:c});return u!=null&&u.type!=="null"?Sl.map([{key:s,value:u}]):Sl.map([])}case"object":{let f={},s=i.fullExamples?.find(_=>_.name===t)??i.fullExamples?.find(_=>_.name==null)??i.fullExamples?.[0],u=bja(r)??(s!=null?bja(s.value):{})??{},l=this.getAllProperties(i),p=this.getAllRequiredProperties(i);for(let[_,h]of Object.entries(l)){if(c&&h.readonly||h.schema._visit({optional:m=>typeof m.availability=="string"&&m.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let y=_ in p,b=Object.keys(u).includes(_),v=u[_],O=this.getSchemaExample(h.schema),A=v??O,g=this.buildExampleHelper({schema:h.schema,exampleId:t,example:A,visitedSchemaIds:a,depth:n+1,options:{...o,name:_},skipReadonly:c});if(y&&g!=null)f[_]=g;else{if(y)return;(b&&g!=null||!o.ignoreOptionals&&g!=null)&&(f[_]=g)}}if(i.additionalProperties){for(let[_,h]of Object.entries(u))if(!(_ in f)){let y=this.buildExampleHelper({schema:ri.unknown({example:h,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:h,visitedSchemaIds:a,depth:n+1,options:{...o,name:_},skipReadonly:c});y!=null&&(f[_]=y)}}return Sl.object({properties:f})}default:vt(i)}}mergeExampleWith(t,r){t._visit({array:Et,enum:Et,literal:Et,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Et,unknown:Et,null:Et,_other:Et})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){if(r==null){let a=t.schemas.find(c=>this.hasExample(c,0,new Set,{ignoreOptionals:!1,isParameter:!1}));if(a!=null)return a;let o=t.schemas.find(c=>this.hasInherentExample(c));return o??t.schemas[0]}return t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,o)=>o.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return lb_({schema:t,value:r})?5:0;case"object":{if(!Xc(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,o]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(o.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Xc(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,i,n);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let o of t.properties)if(this.hasExample(o.schema,r+1,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let o=this.hasExample(a,r,i,n);return i.delete(t.schema),o}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,i,n));default:return!1}}hasInherentExample(t){switch(t.type){case"literal":return!0;case"enum":return t.values.length>0;case"optional":case"nullable":return this.hasInherentExample(t.value);case"reference":{let r=this.schemas[t.schema];return r!=null?this.hasInherentExample(r):!1}default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}getSchemaExample(t){return t._visit({primitive:r=>r.schema.example,object:r=>r.fullExamples?.[0]?.value,array:r=>r.example,map:r=>r.example,optional:r=>this.getSchemaExample(r.value),enum:r=>r.example,reference:r=>{let i=this.schemas[r.schema];return i!=null?this.getSchemaExample(i):void 0},literal:()=>{},oneOf:()=>{},nullable:r=>this.getSchemaExample(r.value),unknown:r=>r.example,_other:()=>{}})}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?Ha.string(t):r.example!=null?Ha.string(r.example):Ha.string(i.name??cu.STRING);case"base64":return t!=null&&typeof t=="string"?Ha.base64(t):r.example!=null?Ha.base64(r.example):Ha.base64(cu.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?Ha.boolean(t):r.example!=null?Ha.boolean(r.example):Ha.boolean(cu.BOOLEAN);case"date":return t!=null&&typeof t=="string"?Ha.date(t):r.example!=null?Ha.date(r.example):Ha.date(cu.DATE);case"datetime":return t!=null&&typeof t=="string"?Ha.datetime(t):r.example!=null?Ha.datetime(r.example):Ha.datetime(cu.DATE_TIME);case"double":return t!=null&&typeof t=="number"?Ha.double(t):r.example!=null?Ha.double(r.example):Ha.double(cu.DOUBLE);case"float":return t!=null&&typeof t=="number"?Ha.float(t):r.example!=null?Ha.float(r.example):Ha.float(cu.FLOAT);case"int":return t!=null&&typeof t=="number"?Ha.int(t):r.example!=null?Ha.int(r.example):Ha.int(cu.INT);case"int64":return t!=null&&typeof t=="number"?Ha.int64(t):r.example!=null?Ha.int64(r.example):Ha.int64(cu.INT64);case"uint":return t!=null&&typeof t=="number"?Ha.uint(t):r.example!=null?Ha.uint(r.example):Ha.uint(cu.UINT);case"uint64":return t!=null&&typeof t=="number"?Ha.uint64(t):r.example!=null?Ha.uint64(r.example):Ha.uint64(cu.UINT64);default:vt(r)}}};function lb_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function gFt(e){switch(e.type){case"object":return ri.object({allOf:e.allOf,properties:e.properties.map(t=>diM(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 ri.array({description:e.description,availability:e.availability,value:gFt(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 ri.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 ri.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 ri.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gFt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return ri.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:gFt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return ri.primitive({description:e.description,availability:e.availability,schema:fb_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return ri.map({description:e.description,availability:e.availability,key:ri.primitive({description:e.key.description,availability:e.key.availability,schema:fb_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:gFt(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 ri.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 ri.oneOf(fiM(e.value));case"unknown":return ri.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:vt(e)}}function fiM(e){switch(e.type){case"discriminated":return Bhe.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:gFt(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,gFt(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return Bhe.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>gFt(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:vt(e)}}function fb_(e){switch(e.type){case"string":return Ln.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Ln.base64({example:void 0});case"boolean":return Ln.boolean({default:e.default,example:void 0});case"date":return Ln.date({example:void 0});case"datetime":return Ln.datetime({example:void 0});case"double":return Ln.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 Ln.float({example:void 0});case"int":return Ln.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 Ln.int64({default:e.default,example:void 0});case"uint":return Ln.uint({default:void 0,example:void 0});case"uint64":return Ln.uint64({default:void 0,example:void 0});default:vt(e)}}function diM(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:gFt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function tLo(e){return e.type!=="optional"&&e.type!=="nullable"}function qsc(e){return e==="POST"||e==="PUT"||e==="PATCH"}function vja(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 rLo=class{schemas;context;globalHeaders;exampleTypeFactory;logger;missingExamples=[];constructor(t,r,i){this.schemas=t,this.context=r,this.globalHeaders=i,this.schemas=t,this.exampleTypeFactory=new ZCi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}addMissingExampleRecord(t,r,i,n,a={}){this.missingExamples.push({endpoint:t.path,method:t.method.toUpperCase(),type:r,schemaType:i,reason:n,operationSummary:t.summary,operationDescription:t.description,schemaDescription:a.schemaDescription,autoGeneratedExample:a.autoGeneratedExample})}writeMissingExamplesLog(){if(this.missingExamples.length===0)return;let t;if(this.context.source.type==="openapi"){let a=this.context.source.file,o=FJi.dirname(a),c=o;for(;c!==FJi.dirname(c);){let f=FJi.join(c,"fern");if(AUn.existsSync(f)&&AUn.statSync(f).isDirectory()){t=f;break}c=FJi.dirname(c)}t||(t=o)}else t=process.cwd();let r=t??process.cwd(),i=FJi.join(r,"schemas_missing_examples.txt"),n=["# Schemas Missing Examples Report",`# Generated on: ${new Date().toISOString()}`,`# Total missing examples: ${this.missingExamples.length}`,"",...this.missingExamples.flatMap(a=>{let o=[];if(o.push(`${a.method} ${a.endpoint} - ${a.type.toUpperCase()} (${a.schemaType}): ${a.reason}`),a.operationSummary&&o.push(` Operation: ${a.operationSummary}`),a.operationDescription&&a.operationDescription!==a.operationSummary&&o.push(` Description: ${a.operationDescription}`),a.schemaDescription&&o.push(` ${a.type==="request"?"Request":"Response"} Schema: ${a.schemaDescription}`),a.autoGeneratedExample){o.push(" Auto-generated example:");let f=JSON.stringify(a.autoGeneratedExample,null,4).split(`
1418
1418
  `).map(s=>` ${s}`).join(`
1419
1419
  `);o.push(f)}return o.push(""),o}),""].join(`