fern-api 0.77.6 → 0.77.7

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
@@ -2163,7 +2163,7 @@ ${mzh.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&oUl(th
2163
2163
  `+xGi.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?xGi.default.cyan(Czh(t,this.opt.mask)):xGi.default.italic(xGi.default.dim("[hidden]")):this.opt.mask?Czh(t,this.opt.mask):xGi.default.italic(xGi.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 sis=$i(Xae(),1),t7h=$i(e7h(),1),r7h=$i(det(),1);var Kxo=class extends Zae{_run(t){this.done=t,this.editorResult=new r7h.Subject;let r=oye(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?sis.default.dim("Received"):sis.default.dim("Press <enter> to launch your preferred editor."),t&&(r=sis.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,t7h.editAsync)(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 u7h=require("stream");var a7h=$i(require("readline"),1),o7h=$i(i7h(),1),UGi=class{constructor(t){this.rl||=a7h.default.createInterface(s7S(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 s7S(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new o7h.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var $xo=class extends UGi{constructor(t={}){super(t),this.log=new u7h.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Ixo(this.rl,this.bottomBar.split(`
2164
2164
  `).length),this}updateBottomBar(t){return Ixo(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+`
2165
2165
  `}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&&Nns(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var O4=$i(det(),1),l7h=$i(Xqo(),1);var cis=$i(det(),1),s7h=$i(Xqo(),1),lis=function(e,t,r){return typeof e[t]!="function"?(0,cis.of)(e):(0,cis.from)((0,s7h.default)(e[t])(r).then(n=>(e[t]=n,e)))};var c7h={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,a,u)=>{i==="__proto__"||i==="constructor"||(a===u.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((u,c)=>u!=null?u[c]:u,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},Lza=class extends UGi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let n;return Array.isArray(t)?n=(0,O4.from)(t):(0,O4.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,O4.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,O4.from)([t]),this.process=n.pipe((0,O4.concatMap)(this.processQuestion.bind(this)),(0,O4.publish)()),this.process.connect(),this.process.pipe((0,O4.reduce)((i,a)=>(c7h.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,O4.defer)(()=>(0,O4.of)(t).pipe((0,O4.concatMap)(this.setDefaultType.bind(this)),(0,O4.concatMap)(this.filterIfRunnable.bind(this)),(0,O4.concatMap)(()=>lis(t,"message",this.answers)),(0,O4.concatMap)(()=>lis(t,"default",this.answers)),(0,O4.concatMap)(()=>lis(t,"choices",this.answers)),(0,O4.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,O4.defer)(()=>(0,O4.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,O4.defer)(()=>(0,O4.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&c7h.get(this.answers,t.name)!==void 0)return O4.EMPTY;if(t.when===!1)return O4.EMPTY;if(typeof t.when!="function")return(0,O4.of)(t);let{answers:r}=this;return(0,O4.defer)(()=>(0,O4.from)((0,l7h.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,O4.filter)(n=>n!=null)))}};function f7h(e){let t=function(r,n){let i;try{i=new Lza(t.prompts,e)}catch(u){return Promise.reject(u)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Bxo),this.registerPrompt("input",qGi),this.registerPrompt("number",Txo),this.registerPrompt("confirm",qxo),this.registerPrompt("rawlist",xxo),this.registerPrompt("expand",Nxo),this.registerPrompt("checkbox",Rxo),this.registerPrompt("password",Fxo),this.registerPrompt("editor",Kxo)},t.restoreDefaultPrompts(),t}var kUl=f7h();function l7S(e,t){kUl.registerPrompt(e,t)}function f7S(){kUl.restoreDefaultPrompts()}var d7S={prompt:kUl,ui:{BottomBar:$xo,Prompt:Lza},createPromptModule:f7h,registerPrompt:l7S,restoreDefaultPrompts:f7S,Separator:Qxe},fis=d7S;var e2a=require("path"),Z8h=require("fs"),k8h=require("readline"),P8h="posthog-node";function Z5S(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"]}={}){return a=>{if(!(i==="*"||i.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[qis.POSTHOG_ID_TAG];if(c===void 0)return a;let p=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,p).toString();a.tags["PostHog Person URL"]=s;let o=a.exception?.values||[],l=o.map(A=>({...A,stacktrace:A.stacktrace?{...A.stacktrace,type:"raw",frames:(A.stacktrace.frames||[]).map(E=>({...E,platform:"node:javascript"}))}:void 0})),O={$exception_message:o[0]?.value||a.message,$exception_type:o[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:o[0]?.value||a.message,$sentry_exception_type:o[0]?.type,$sentry_tags:a.tags};return t&&r&&(O.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:O}),a}}var qis=class{constructor(t,r,n,i){this.name=P8h,this.name=P8h,this.setupOnce=function(a,u){let c=u()?.getClient()?.getDsn()?.projectId;a(Z5S(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};qis.POSTHOG_ID_TAG="posthog_distinct_id";var Cis="0123456789abcdef",xis=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=Cis.charAt(this.bytes[r]>>>4),t+=Cis.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+=Cis.charAt(this.bytes[r]>>>4),t+=Cis.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},LVl=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??k5S()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return xis.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,xis.ofInner(t)}},k5S=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),w8h,UVl=()=>eQS().toString(),eQS=()=>(w8h||(w8h=new LVl)).generate();function tQS(e,t){let r=!1;return Object.assign(n=>{let a=global.process.listeners("uncaughtException").filter(u=>u.name!=="domainUncaughtExceptionClear"&&u._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function rQS(e,t){global.process.on("uncaughtException",tQS(e,t))}function nQS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var Iis,j8h,Mis;function iQS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return Mis&&r.length===j8h||(j8h=r.length,Mis=r.reduce((n,i)=>{Iis||(Iis={});let a=Iis[i];if(a)n[a[0]]=a[1];else{let u=e(i);for(let c=u.length-1;c>=0;c--){let s=u[c]?.filename,o=t[i];if(s&&o){n[s]=o,Iis[i]=[s,o];break}}}return n},{})),Mis}function aQS(e){return typeof Event<"u"&&e5h(e,Event)}function oQS(e){return t5h(e,"Object")}function YVl(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return e5h(e,Error)}}function e5h(e,t){try{return e instanceof t}catch{return!1}}function uQS(e){return t5h(e,"ErrorEvent")}function t5h(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function sQS(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},u=r5h(a,r,n);return{$exception_list:await Promise.all(u.map(async s=>{let o=await hQS(e,t,s);return o.value=o.value||"",o.type=o.type||"Error",o.mechanism=a,o}))}}function r5h(e,t,r){let n=cQS(e,t,r);return n.cause?[n,...r5h(e,n.cause,r)]:[n]}function cQS(e,t,r){if(YVl(t))return t;if(e.synthetic=!0,oQS(t)){let i=lQS(t);if(i)return i;let a=fQS(t),u=r?.syntheticException||new Error(a);return u.message=a,u}let n=r?.syntheticException||new Error(t);return n.message=`${t}`,n}function lQS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(YVl(r))return r}}function fQS(e){if("name"in e&&typeof e.name=="string"){let n=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(n+=` with message '${e.message}'`),n}else if("message"in e&&typeof e.message=="string")return e.message;let t=pQS(e);if(uQS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=dQS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function dQS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function pQS(e,t=40){let r=Object.keys(_QS(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return E8h(n,t);for(let i=r.length;i>0;i--){let a=r.slice(0,i).join(", ");if(!(a.length>t))return i===r.length?a:E8h(a,t)}return""}function E8h(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function _QS(e){return YVl(e)?{message:e.message,name:e.name,stack:e.stack,...S8h(e)}:aQS(e)?{type:e.type,target:D8h(e.target),currentTarget:D8h(e.currentTarget),...S8h(e)}:e}function S8h(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 D8h(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function hQS(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=yQS(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function yQS(e,t){return vQS(e(t.stack||"",1),e)}function vQS(e,t){let r=iQS(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var bQS=2e3,Xza=class e{static async captureException(t,r,n,i,a){let u={...a};i||(u.$process_person_profile=!1);let c=await sQS(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||UVl(),properties:{...c,...u}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(rQS(this.onException.bind(this),this.onFatalError.bind(this)),nQS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(bQS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function gQS(e=process.argv[1]?(0,e2a.dirname)(process.argv[1]):process.cwd(),t=e2a.sep==="\\"){let r=t?C8h(e):e;return n=>{if(!n)return;let i=t?C8h(n):n,{dir:a,base:u,ext:c}=e2a.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(u=u.slice(0,c.length*-1));let p=decodeURIComponent(u);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${p}`;if(a.startsWith(r)){let o=a.slice(r.length+1).replace(/\//g,".");return o?`${o}:${p}`:p}return p}}function C8h(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var Nis=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)}}},Tis=new Nis(25),n5h=new Nis(20),XVl=7,mQS=1e3,OQS=1e4;async function AQS(e){let t={};for(let i=e.length-1;i>=0;i--){let a=e[i],u=a?.filename;if(!a||typeof u!="string"||typeof a.lineno!="number"||EQS(u)||SQS(a))continue;t[u]||(t[u]=[]),t[u].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(n5h.get(i))continue;let a=t[i];if(!a)continue;a.sort((p,s)=>p-s);let u=CQS(a);if(u.every(p=>DQS(i,p)))continue;let c=IQS(Tis,i,{});n.push(PQS(i,u,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&wQS(e,Tis),Tis.reduce(),e}function PQS(e,t,r){return new Promise(n=>{let i=(0,Z8h.createReadStream)(e),a=(0,k8h.createInterface)({input:i});function u(){i.destroy(),n()}let c=0,p=0,s=t[p];if(s===void 0){u();return}let o=s[0],l=s[1];function O(){n5h.set(e,1),a.close(),a.removeAllListeners(),u()}i.on("error",O),a.on("error",O),a.on("close",u),a.on("line",A=>{if(c++,!(c<o)&&(r[c]=MQS(A,0),c>=l)){if(p===t.length-1){a.close(),a.removeAllListeners();return}p++;let E=t[p];if(E===void 0){a.close(),a.removeAllListeners();return}o=E[0],l=E[1]}})})}function wQS(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;jQS(r.lineno,r,n)}}function jQS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=i5h(e);i<e;i++){let a=r[i];if(a===void 0){I8h(t);return}t.pre_context.push(a)}if(r[e]===void 0){I8h(t);return}t.context_line=r[e];let n=a5h(e);t.post_context=[];for(let i=e+1;i<=n;i++){let a=r[i];if(a===void 0)break;t.post_context.push(a)}}function I8h(e){delete e.pre_context,delete e.context_line,delete e.post_context}function EQS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function SQS(e){return e.lineno!==void 0&&e.lineno>OQS||e.colno!==void 0&&e.colno>mQS}function DQS(e,t){let r=Tis.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function CQS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=M8h(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let a=e[t+1];if(typeof a!="number")break;a<=n[1]?n[1]=a+XVl:(i.push(n),n=M8h(a)),t++}return i}function M8h(e){return[i5h(e),a5h(e)]}function i5h(e){return Math.max(1,e-XVl)}function a5h(e){return e+XVl}function IQS(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function MQS(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,n);return a>n-5&&(a=n),a===n&&(i=Math.max(a-140,0)),r=r.slice(i,a),i>0&&(r=`...${r}`),a<n&&(r+="..."),r}var BQS="4.18.0",Gxe;(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"})(Gxe||(Gxe={}));var B8h;(function(e){e.Left="left",e.Right="right",e.Center="center"})(B8h||(B8h={}));var T8h;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(T8h||(T8h={}));var q8h;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(q8h||(q8h={}));var x8h;(function(e){e.Html="html",e.Text="text"})(x8h||(x8h={}));var N8h;(function(e){e.Number="number",e.Emoji="emoji"})(N8h||(N8h={}));var R8h;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(R8h||(R8h={}));var F8h;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(F8h||(F8h={}));var z8h;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(z8h||(z8h={}));var Q8h;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(Q8h||(Q8h={}));var TQS=e=>{if("flags"in e){let t=xQS(e.flags),r=NQS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,o5h(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,qQS(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function qQS(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 xQS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,ZVl(r)]).filter(([,t])=>t!==void 0)),NQS=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let n=t[r];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(r=>{let n=t[r].metadata?.payload;return[r,n?o5h(n):void 0]}))},ZVl=e=>e===void 0?void 0:e.variant??e.enabled,o5h=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},RQS=1,FQS=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"]),zQS="utf8";function QQS(e,t){if(!e||typeof e!="string"||LQS(e))throw new Error(t)}function LQS(e){return e.trim().length===0}function UQS(e){return e?.replace(/\/+$/,"")}async function VQS(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function L8h(){return new Date().getTime()}function zVl(){return new Date().toISOString()}function Ris(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function WQS(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function HQS(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 GQS(e,t=0,r){let n=HQS(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function U8h(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var aNo=String.fromCharCode,V8h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Bis={};function JQS(e,t){if(!Bis[e]){Bis[e]={};for(let r=0;r<e.length;r++)Bis[e][e.charAt(r)]=r}return Bis[e][t]}var $za={compressToBase64:function(e){if(e==null)return"";let t=$za._compress(e,6,function(r){return V8h.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:$za._decompress(e.length,32,function(t){return JQS(V8h,e.charAt(t))})},compress:function(e){return $za._compress(e,16,function(t){return aNo(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],u,c,p="",s="",o="",l=2,O=3,A=2,E=0,C=0,M;for(M=0;M<e.length;M+=1)if(p=e.charAt(M),Object.prototype.hasOwnProperty.call(n,p)||(n[p]=O++,i[p]=!0),s=o+p,Object.prototype.hasOwnProperty.call(n,s))o=s;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<A;u++)E=E<<1,C==t-1?(C=0,a.push(r(E)),E=0):C++;for(c=o.charCodeAt(0),u=0;u<8;u++)E=E<<1|c&1,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=c>>1}else{for(c=1,u=0;u<A;u++)E=E<<1|c,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=0;for(c=o.charCodeAt(0),u=0;u<16;u++)E=E<<1|c&1,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[o]}else for(c=n[o],u=0;u<A;u++)E=E<<1|c&1,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++),n[s]=O++,o=String(p)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<A;u++)E=E<<1,C==t-1?(C=0,a.push(r(E)),E=0):C++;for(c=o.charCodeAt(0),u=0;u<8;u++)E=E<<1|c&1,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=c>>1}else{for(c=1,u=0;u<A;u++)E=E<<1|c,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=0;for(c=o.charCodeAt(0),u=0;u<16;u++)E=E<<1|c&1,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[o]}else for(c=n[o],u=0;u<A;u++)E=E<<1|c&1,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++)}for(c=2,u=0;u<A;u++)E=E<<1|c&1,C==t-1?(C=0,a.push(r(E)),E=0):C++,c=c>>1;for(;;)if(E=E<<1,C==t-1){a.push(r(E));break}else C++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:$za._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},u=4,c=4,p=3,s="",o,l,O,A,E,C,M;for(o=0;o<3;o+=1)n[o]=o;for(O=0,E=Math.pow(2,2),C=1;C!=E;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),O|=(A>0?1:0)*C,C<<=1;switch(O){case 0:for(O=0,E=Math.pow(2,8),C=1;C!=E;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),O|=(A>0?1:0)*C,C<<=1;M=aNo(O);break;case 1:for(O=0,E=Math.pow(2,16),C=1;C!=E;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),O|=(A>0?1:0)*C,C<<=1;M=aNo(O);break;case 2:return""}for(n[3]=M,l=M,i.push(M);;){if(a.index>e)return"";for(O=0,E=Math.pow(2,p),C=1;C!=E;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),O|=(A>0?1:0)*C,C<<=1;switch(M=O){case 0:for(O=0,E=Math.pow(2,8),C=1;C!=E;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),O|=(A>0?1:0)*C,C<<=1;n[c++]=aNo(O),M=c-1,u--;break;case 1:for(O=0,E=Math.pow(2,16),C=1;C!=E;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),O|=(A>0?1:0)*C,C<<=1;n[c++]=aNo(O),M=c-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,p),p++),n[M])s=n[M];else if(M===c)s=l+l.charAt(0);else return null;i.push(s),n[c++]=l+s.charAt(0),u--,l=s,u==0&&(u=Math.pow(2,p),p++)}}},VVl=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}},Zza=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()}},oNo=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function W8h(e){if(e instanceof Zza){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 QVl(e){return typeof e=="object"&&(e instanceof Zza||e instanceof oNo)}function H8h(e){return typeof e=="object"&&e instanceof Zza&&e.status===413}var WVl;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(WVl||(WVl={}));var HVl=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new VVl,this._isInitialized=!1,QQS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=UQS(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:QVl},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(Gxe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(Gxe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(Gxe.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=UVl();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}async identifyStatelessImmediate(t,r,n){let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",i,n)}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}async captureStatelessImmediate(t,r,n,i){let a=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",a,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}async aliasStatelessImmediate(t,r,n,i){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,i)}groupIdentifyStateless(t,r,n,i,a,u){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...u||{}}});this.enqueue("capture",c,i)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(i=>i.json()).catch(i=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",i)),this._events.emit("error",i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let c=GQS(this.apiKey,RQS,FQS)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,p={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,p,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>TQS(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,n={},i={},a={},u){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,n,i,a,u);if(c===void 0)return{response:void 0,requestId:void 0};let p=ZVl(c.response);return p===void 0&&(p=!1),{response:p,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},a={},u){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,n,i,a,u,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},u){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,n,i,a,u,[t]);if(!c)return;let p=c[t];return p===void 0?null:p}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a,u){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,u)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},a,u){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,u)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a,u){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,n,i,a,u);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},a,u){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),u&&(c.flag_keys_to_evaluate=u);let p=await this.getDecide(t,r,n,i,c);if(p!==void 0)return p.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"),p.quotaLimited?.includes(WVl.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:p?.requestId}):p}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},i=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let u=`Surveys API could not be loaded: ${a.status}`,c=new Error(u);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(u));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return i&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(i))),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(Gxe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(Gxe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(Gxe.Props,this.props)})}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i=this.prepareMessage(t,r,n),a=this.getPersistedProperty(Gxe.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:i}),this.setPersistedProperty(Gxe.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Ris(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={api_key:this.apiKey,batch:[this.prepareMessage(t,r,n)],sent_at:zVl()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${L8h()}&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($za.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(u,c)}catch(p){this._events.emit("error",p)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:zVl(),uuid:n?.uuid?n.uuid:UVl()};return(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId),i}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await W8h(t)})}async flush(){let t=U8h([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),U8h([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(Gxe.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),a=i.map(O=>O.message),u=()=>{let A=(this.getPersistedProperty(Gxe.Queue)||[]).slice(i.length);this.setPersistedProperty(Gxe.Queue,A),t=A},c={api_key:this.apiKey,batch:a,sent_at:zVl()};this.historicalMigration&&(c.historical_migration=!0);let p=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${L8h()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,o=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent($za.compressToBase64(p))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:p},l={retryCheck:O=>H8h(O)?!1:QVl(O)};try{await this.fetchWithRetry(s,o,l)}catch(O){if(H8h(O)&&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 O instanceof oNo||u(),this._events.emit("error",O),O}u(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let o=new AbortController;return setTimeout(()=>o.abort(),s),o.signal});let u=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(u,zQS)}catch{c=new TextEncoder().encode(u).length}return await VQS(async()=>{let p=null;try{p=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(o){throw new oNo(o)}if(!(r.mode==="no-cors")&&(p.status<200||p.status>=400))throw new Zza(p,c);return p},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(Gxe.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!QVl(i))throw i;await W8h(i)}};return Promise.race([new Promise((i,a)=>{Ris(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},GVl=WQS();if(!GVl){let e=A8h();GVl=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var u5h=GVl,Fis=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()}},s5h=new Fis(async()=>{try{return await import("crypto")}catch{return}});async function KQS(){return await s5h.getValue()}var $QS=new Fis(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await s5h.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function YQS(){return await $QS.getValue()}async function XQS(e){let t=await KQS();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await YQS();if(r){let n=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var ZQS=60*1e3,kQS=1152921504606847e3,e9S=["is_not"],Yza=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},kae=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},JVl=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:u,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=c.fetch||u5h,this.onError=c.onError,this.customHeaders=u,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let u,c;if(!this.loadedSuccessfullyOnce)return u;for(let p of this.featureFlags)if(t===p.key){c=p;break}if(c!==void 0)try{u=await this.computeFlagLocally(c,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(p){p instanceof kae?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${p}`)):p instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${p}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},u={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async p=>{try{let s=await this.computeFlagLocally(p,t,r,n,i);a[p.key]=s;let o=await this.computeFeatureFlagPayloadLocally(p.key,s);o&&(u[p.key]=o)}catch(s){s instanceof kae||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${p.key}: ${s}`)),c=!0}})),{response:a,payloads:u,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new kae("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let p=this.groupTypeMapping[String(c)];if(!p)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new kae("Flag has unknown group type index");if(!(p in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[p];return await this.matchFeatureFlagProperties(t,n[p],s)}else return await this.matchFeatureFlagProperties(t,r,i)}async matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],u=!1,c,p=[...a].sort((s,o)=>{let l=!!s.variant,O=!!o.variant;return l&&O?0:l?-1:O?1:0});for(let s of p)try{if(await this.isConditionMatch(t,r,s,n)){let o=s.variant,l=i.multivariate?.variants||[];o&&l.some(O=>O.key===o)?c=o:c=await this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof kae)u=!0;else throw o}if(c!==void 0)return c;if(u)throw new kae("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i){let a=n.rollout_percentage,u=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let p=c.type,s=!1;if(p==="cohort"?s=l5h(c,i,this.cohorts,this.debugMode):s=c5h(c,i,u),!s)return!1}if(a==null)return!0}return!(a!=null&&await G8h(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await G8h(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{i=n+c.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:c.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(ZQS,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Yza(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Yza(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Yza(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof Yza&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=Ris(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,n=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;i=Ris(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function G8h(e,t,r=""){let n=await XQS(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/kQS}function c5h(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new kae("Operator is_not_set is not supported")}else throw new kae(`Property ${n} not found in propertyValues`);let u=t[n];if(u==null&&!e9S.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,o){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function p(s,o,l){if(l==="gt")return s>o;if(l==="gte")return s>=o;if(l==="lt")return s<o;if(l==="lte")return s<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(i,u);case"is_not":return!c(i,u);case"is_set":return n in t;case"icontains":return String(u).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(i).toLowerCase());case"regex":return J8h(String(i))&&String(u).match(String(i))!==null;case"not_regex":return J8h(String(i))&&String(u).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof i=="number"?i:null;if(typeof i=="string")try{s=parseFloat(i)}catch{}return s!=null&&u!=null?typeof u=="string"?p(u,String(i),a):p(u,s,a):p(String(u),String(i),a)}case"is_date_after":case"is_date_before":{let s=t9S(String(i));if(s==null&&(s=K8h(i)),s==null)throw new kae(`Invalid date: ${i}`);let o=K8h(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new kae(`Unknown operator: ${a}`)}}function l5h(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new kae("can't match cohort without a given cohort property value");let a=r[i];return f5h(a,t,r,n)}function f5h(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let c of a)try{let p=f5h(c,t,r,n);if(i==="AND"){if(!p)return!1}else if(p)return!0}catch(p){if(p instanceof kae)n&&console.debug(`Failed to compute property ${c} locally: ${p}`),u=!0;else throw p}if(u)throw new kae("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let c of a)try{let p;c.type==="cohort"?p=l5h(c,t,r,n):p=c5h(c,t);let s=c.negation||!1;if(i==="AND"){if(!p&&!s||p&&s)return!1}else if(p&&!s||!p&&s)return!0}catch(p){if(p instanceof kae)n&&console.debug(`Failed to compute property ${c} locally: ${p}`),u=!0;else throw p}if(u)throw new kae("can't match cohort without a given cohort property value");return i==="AND"}}function J8h(e){try{return new RegExp(e),!0}catch{return!1}}function K8h(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 kae(`${e} is in an invalid date format`)}else throw new kae(`The date provided ${e} must be a string, number, or date object`)}function t9S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var KVl=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},r9S=100,$8h=30*1e3,n9S=50*1e3,$Vl=class extends HVl{constructor(t,r={}){if(super(t,r),this._memoryStorage=new KVl,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,r9S):$8h,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 JVl({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new Xza(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||n9S}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):u5h(t,r)}getLibraryVersion(){return BQS}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:u,timestamp:c,disableGeoip:p,uuid:s}=t,o=A=>{super.captureStateless(r,n,A,{timestamp:c,disableGeoip:p,uuid:s})},l=async(A,E,C)=>(await super.getFeatureFlagsStateless(A,E,void 0,void 0,C)).flags,O=Promise.resolve().then(async()=>{if(u)return await l(r,a,p);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[E,C]of Object.entries(a||{}))A[E]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:p,onlyEvaluateLocally:!0})}return{}}).then(A=>{let E={};if(A)for(let[M,q]of Object.entries(A))E[`$feature/${M}`]=q;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(E.$active_feature_flags=C),E}).catch(()=>({})).then(A=>{o({...A,...i,$groups:a})});this.addPendingPromise(O)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:u,timestamp:c,disableGeoip:p,uuid:s}=t,o=A=>super.captureStatelessImmediate(r,n,A,{timestamp:c,disableGeoip:p,uuid:s}),l=async(A,E,C)=>(await super.getFeatureFlagsStateless(A,E,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(u)return await l(r,a,p);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[E,C]of Object.entries(a||{}))A[E]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:p,onlyEvaluateLocally:!0})}return{}}).then(A=>{let E={};if(A)for(let[M,q]of Object.entries(A))E[`$feature/${M}`]=q;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(E.$active_feature_flags=C),E}).catch(()=>({})).then(A=>{o({...A,...i,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:i},{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=$8h){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(n),i(),r(a>0)})})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:c,personProperties:p,groupProperties:s}=n||{},o=this.addLocalPersonAndGroupProperties(r,i,p,s);p=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,p,s),O=l!==void 0,A,E;if(!O&&!u){let M=await super.getFeatureFlagDetailStateless(t,r,i,p,s,a);if(M===void 0)return;E=M.response,l=ZVl(E),A=M?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:E?.metadata?.id,$feature_flag_version:E?.metadata?.version,$feature_flag_reason:E?.reason?.description??E?.reason?.code,locally_evaluated:O,[`$feature/${t}`]:l,$feature_flag_request_id:A},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:u}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:p,personProperties:s,groupProperties:o}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,s,o);s=l.allPersonProperties,o=l.allGroupProperties;let O;return this.featureFlagsPoller!==void 0&&(n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),n&&(O=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n))),c==null&&(c=!1),p==null&&(p=!0),c==null&&(c=!1),!(O!==void 0)&&!c&&(O=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),O}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:c}=r||{},p=this.addLocalPersonAndGroupProperties(t,n,u,c);u=p.allPersonProperties,c=p.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,u,c),o={},l={},O=!0;if(s&&(o=s.response,l=s.payloads,O=s.fallbackToDecide),O&&!a){let A=await super.getFeatureFlagsAndPayloadsStateless(t,n,u,c,i);o={...o,...A.flags||{}},l={...l,...A.payloads||{}}}return{featureFlags:o,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},u={};if(r)for(let c of Object.keys(r))u[c]={$group_key:r[c],...i?.[c]||{}};return{allPersonProperties:a,allGroupProperties:u}}captureException(t,r,n){let i=new Error("PostHog syntheticException");Xza.captureException(this,t,{syntheticException:i},r,n)}},Y8h=/\(error: (.*)\)/,d5h=50,p5h="?";function i9S(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return n=>{let i=n.match(r);if(i){let a,u,c,p,s;if(i[1]){c=i[1];let O=c.lastIndexOf(".");if(c[O-1]==="."&&O--,O>0){a=c.slice(0,O),u=c.slice(O+1);let A=a.indexOf(".Module");A>0&&(c=c.slice(A+1),a=a.slice(0,A))}p=void 0}u&&(p=a,s=u),u==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||p5h,c=p?`${p}.${s}`:s);let o=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return o?.match(/\/[A-Z]:/)&&(o=o.slice(1)),!o&&i[5]&&!l&&(o=i[5]),{filename:o?decodeURI(o):void 0,module:e?e(o):void 0,function:c,lineno:X8h(i[3]),colno:X8h(i[4]),in_app:a9S(o||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function a9S(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 X8h(e){return parseInt(e||"",10)||void 0}function o9S(e){return[90,i9S(e)]}function u9S(e){let r=[o9S(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],u=n.split(`
2166
- `);for(let c=i;c<u.length;c++){let p=u[c];if(p.length>1024)continue;let s=Y8h.test(p)?p.replace(Y8h,"$1"):p;if(!s.match(/\S*Error: /)){for(let o of r){let l=o(s);if(l){a.push(l);break}}if(a.length>=d5h)break}}return s9S(a)}}function s9S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,d5h).map(r=>({...r,filename:r.filename||c9S(t).filename,function:r.function||p5h}))}function c9S(e){return e[e.length-1]||{}}Xza.stackParser=u9S(gQS());Xza.frameModifiers=[AQS];var kza=class extends $Vl{getLibraryId(){return"posthog-node"}};var zis=class{posthog;constructor({posthogApiKey:t}){this.posthog=new kza(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.77.6",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var uNo=class{async sendEvent(){}async identify(){}async flush(){}};var t2a=require("fs/promises"),v5h=require("os"),b5h=require("path");var _5h=$i(require("crypto")),Lis=new Uint8Array(256),Qis=Lis.length;function kVl(){return Qis>Lis.length-16&&(_5h.default.randomFillSync(Lis),Qis=0),Lis.slice(Qis,Qis+=16)}var cye=[];for(let e=0;e<256;++e)cye.push((e+256).toString(16).slice(1));function h5h(e,t=0){return cye[e[t+0]]+cye[e[t+1]]+cye[e[t+2]]+cye[e[t+3]]+"-"+cye[e[t+4]]+cye[e[t+5]]+"-"+cye[e[t+6]]+cye[e[t+7]]+"-"+cye[e[t+8]]+cye[e[t+9]]+"-"+cye[e[t+10]]+cye[e[t+11]]+cye[e[t+12]]+cye[e[t+13]]+cye[e[t+14]]+cye[e[t+15]]}var y5h=$i(require("crypto")),eWl={randomUUID:y5h.default.randomUUID};function l9S(e,t,r){if(eWl.randomUUID&&!t&&!e)return eWl.randomUUID();e=e||{};let n=e.random||(e.rng||kVl)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return h5h(n)}var Jxe=l9S;var f9S="id",d9S=".fern",sNo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new kza(r),this.userId=t==null?void 0:U7l(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.77.6",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Jl(D_.of((0,v5h.homedir)()),ds.of(d9S),ds.of(f9S));await ov(t)||(await(0,t2a.mkdir)((0,b5h.dirname)(t),{recursive:!0}),await(0,t2a.writeFile)(t,Jxe())),this.persistedDistinctId=(await(0,t2a.readFile)(t)).toString()}return this.persistedDistinctId}};var tWl;async function r2a(){return tWl==null&&(tWl=await p9S()),tWl}async function p9S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new uNo;let r=await nZu();return r!=null?new sNo({token:r,posthogApiKey:e}):await X4a()!=null?new zis({posthogApiKey:e}):new sNo({token:void 0,posthogApiKey:e})}catch{return new uNo}}function cNo(e,t){return function(){return e.apply(t,arguments)}}var{toString:_9S}=Object.prototype,{getPrototypeOf:nWl}=Object,{iterator:Vis,toStringTag:m5h}=Symbol,Wis=(e=>t=>{let r=_9S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),$Dr=e=>(e=e.toLowerCase(),t=>Wis(t)===e),His=e=>t=>typeof t===e,{isArray:i2a}=Array,n2a=His("undefined");function lNo(e){return e!==null&&!n2a(e)&&e.constructor!==null&&!n2a(e.constructor)&&Kxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var O5h=$Dr("ArrayBuffer");function h9S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&O5h(e.buffer),t}var y9S=His("string"),Kxe=His("function"),A5h=His("number"),fNo=e=>e!==null&&typeof e=="object",v9S=e=>e===!0||e===!1,Uis=e=>{if(Wis(e)!=="object")return!1;let t=nWl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(m5h in e)&&!(Vis in e)},b9S=e=>{if(!fNo(e)||lNo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},g9S=$Dr("Date"),m9S=$Dr("File"),O9S=$Dr("Blob"),A9S=$Dr("FileList"),P9S=e=>fNo(e)&&Kxe(e.pipe),w9S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Kxe(e.append)&&((t=Wis(e))==="formdata"||t==="object"&&Kxe(e.toString)&&e.toString()==="[object FormData]"))},j9S=$Dr("URLSearchParams"),[E9S,S9S,D9S,C9S]=["ReadableStream","Request","Response","Headers"].map($Dr),I9S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function dNo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),i2a(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(lNo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,c;for(n=0;n<u;n++)c=a[n],t.call(null,e[c],c,e)}}function P5h(e,t){if(lNo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var KGi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,w5h=e=>!n2a(e)&&e!==KGi;function rWl(){let{caseless:e,skipUndefined:t}=w5h(this)&&this||{},r={},n=(i,a)=>{let u=e&&P5h(r,a)||a;Uis(r[u])&&Uis(i)?r[u]=rWl(r[u],i):Uis(i)?r[u]=rWl({},i):i2a(i)?r[u]=i.slice():(!t||!n2a(i))&&(r[u]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&dNo(arguments[i],n);return r}var M9S=(e,t,r,{allOwnKeys:n}={})=>(dNo(t,(i,a)=>{r&&Kxe(i)?e[a]=cNo(i,r):e[a]=i},{allOwnKeys:n}),e),B9S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),T9S=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},q9S=(e,t,r,n)=>{let i,a,u,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!c[u]&&(t[u]=e[u],c[u]=!0);e=r!==!1&&nWl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},x9S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},N9S=e=>{if(!e)return null;if(i2a(e))return e;let t=e.length;if(!A5h(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},R9S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&nWl(Uint8Array)),F9S=(e,t)=>{let n=(e&&e[Vis]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},z9S=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Q9S=$Dr("HTMLFormElement"),L9S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),g5h=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),U9S=$Dr("RegExp"),j5h=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};dNo(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},V9S=e=>{j5h(e,(t,r)=>{if(Kxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Kxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},W9S=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return i2a(e)?n(e):n(String(e).split(t)),r},H9S=()=>{},G9S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function J9S(e){return!!(e&&Kxe(e.append)&&e[m5h]==="FormData"&&e[Vis])}var K9S=e=>{let t=new Array(10),r=(n,i)=>{if(fNo(n)){if(t.indexOf(n)>=0)return;if(lNo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=i2a(n)?[]:{};return dNo(n,(u,c)=>{let p=r(u,i+1);!n2a(p)&&(a[c]=p)}),t[i]=void 0,a}}return n};return r(e,0)},$9S=$Dr("AsyncFunction"),Y9S=e=>e&&(fNo(e)||Kxe(e))&&Kxe(e.then)&&Kxe(e.catch),E5h=((e,t)=>e?setImmediate:t?((r,n)=>(KGi.addEventListener("message",({source:i,data:a})=>{i===KGi&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),KGi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Kxe(KGi.postMessage)),X9S=typeof queueMicrotask<"u"?queueMicrotask.bind(KGi):typeof process<"u"&&process.nextTick||E5h,Z9S=e=>e!=null&&Kxe(e[Vis]),Hf={isArray:i2a,isArrayBuffer:O5h,isBuffer:lNo,isFormData:w9S,isArrayBufferView:h9S,isString:y9S,isNumber:A5h,isBoolean:v9S,isObject:fNo,isPlainObject:Uis,isEmptyObject:b9S,isReadableStream:E9S,isRequest:S9S,isResponse:D9S,isHeaders:C9S,isUndefined:n2a,isDate:g9S,isFile:m9S,isBlob:O9S,isRegExp:U9S,isFunction:Kxe,isStream:P9S,isURLSearchParams:j9S,isTypedArray:R9S,isFileList:A9S,forEach:dNo,merge:rWl,extend:M9S,trim:I9S,stripBOM:B9S,inherits:T9S,toFlatObject:q9S,kindOf:Wis,kindOfTest:$Dr,endsWith:x9S,toArray:N9S,forEachEntry:F9S,matchAll:z9S,isHTMLForm:Q9S,hasOwnProperty:g5h,hasOwnProp:g5h,reduceDescriptors:j5h,freezeMethods:V9S,toObjectSet:W9S,toCamelCase:L9S,noop:H9S,toFiniteNumber:G9S,findKey:P5h,global:KGi,isContextDefined:w5h,isSpecCompliantForm:J9S,toJSONObject:K9S,isAsyncFn:$9S,isThenable:Y9S,setImmediate:E5h,asap:X9S,isIterable:Z9S};function a2a(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Hf.inherits(a2a,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:Hf.toJSONObject(this.config),code:this.code,status:this.status}}});var S5h=a2a.prototype,D5h={};["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=>{D5h[e]={value:e}});Object.defineProperties(a2a,D5h);Object.defineProperty(S5h,"isAxiosError",{value:!0});a2a.from=(e,t,r,n,i,a)=>{let u=Object.create(S5h);Hf.toFlatObject(e,u,function(o){return o!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",p=t==null&&e?e.code:t;return a2a.call(u,c,p,r,n,i),e&&u.cause==null&&Object.defineProperty(u,"cause",{value:e,configurable:!0}),u.name=e&&e.name||"Error",a&&Object.assign(u,a),u};var T0=a2a;var C5h=$i(_is(),1),Gis=C5h.default;function iWl(e){return Hf.isPlainObject(e)||Hf.isArray(e)}function M5h(e){return Hf.endsWith(e,"[]")?e.slice(0,-2):e}function I5h(e,t,r){return e?e.concat(t).map(function(i,a){return i=M5h(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function k9S(e){return Hf.isArray(e)&&!e.some(iWl)}var eLS=Hf.toFlatObject(Hf,{},null,function(t){return/^is[A-Z]/.test(t)});function tLS(e,t,r){if(!Hf.isObject(e))throw new TypeError("target must be an object");t=t||new(Gis||FormData),r=Hf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Hf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,p=(r.Blob||typeof Blob<"u"&&Blob)&&Hf.isSpecCompliantForm(t);if(!Hf.isFunction(i))throw new TypeError("visitor must be a function");function s(E){if(E===null)return"";if(Hf.isDate(E))return E.toISOString();if(Hf.isBoolean(E))return E.toString();if(!p&&Hf.isBlob(E))throw new T0("Blob is not supported. Use a Buffer instead.");return Hf.isArrayBuffer(E)||Hf.isTypedArray(E)?p&&typeof Blob=="function"?new Blob([E]):Buffer.from(E):E}function o(E,C,M){let q=E;if(E&&!M&&typeof E=="object"){if(Hf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),E=JSON.stringify(E);else if(Hf.isArray(E)&&k9S(E)||(Hf.isFileList(E)||Hf.endsWith(C,"[]"))&&(q=Hf.toArray(E)))return C=M5h(C),q.forEach(function(U,Q){!(Hf.isUndefined(U)||U===null)&&t.append(u===!0?I5h([C],Q,a):u===null?C:C+"[]",s(U))}),!1}return iWl(E)?!0:(t.append(I5h(M,C,a),s(E)),!1)}let l=[],O=Object.assign(eLS,{defaultVisitor:o,convertValue:s,isVisitable:iWl});function A(E,C){if(!Hf.isUndefined(E)){if(l.indexOf(E)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(E),Hf.forEach(E,function(q,L){(!(Hf.isUndefined(q)||q===null)&&i.call(t,q,Hf.isString(L)?L.trim():L,C,O))===!0&&A(q,C?C.concat(L):[L])}),l.pop()}}if(!Hf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var nSi=tLS;function B5h(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function T5h(e,t){this._pairs=[],e&&nSi(e,this,t)}var q5h=T5h.prototype;q5h.append=function(t,r){this._pairs.push([t,r])};q5h.toString=function(t){let r=t?function(n){return t.call(this,n,B5h)}:B5h;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var x5h=T5h;function rLS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function $Gi(e,t,r){if(!t)return e;let n=r&&r.encode||rLS;Hf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Hf.isURLSearchParams(t)?t.toString():new x5h(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var aWl=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Hf.forEach(this.handlers,function(n){n!==null&&t(n)})}},oWl=aWl;var o2a={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var z5h=$i(require("crypto"),1);var N5h=$i(require("url"),1),R5h=N5h.default.URLSearchParams;var uWl="abcdefghijklmnopqrstuvwxyz",F5h="0123456789",Q5h={DIGIT:F5h,ALPHA:uWl,ALPHA_DIGIT:uWl+uWl.toUpperCase()+F5h},nLS=(e=16,t=Q5h.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);z5h.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},L5h={isNode:!0,classes:{URLSearchParams:R5h,FormData:Gis,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Q5h,generateString:nLS,protocols:["http","https","file","data"]};var lWl={};hs(lWl,{hasBrowserEnv:()=>cWl,hasStandardBrowserEnv:()=>iLS,hasStandardBrowserWebWorkerEnv:()=>aLS,navigator:()=>sWl,origin:()=>oLS});var cWl=typeof window<"u"&&typeof document<"u",sWl=typeof navigator=="object"&&navigator||void 0,iLS=cWl&&(!sWl||["ReactNative","NativeScript","NS"].indexOf(sWl.product)<0),aLS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",oLS=cWl&&window.location.href||"http://localhost";var bz={...lWl,...L5h};function fWl(e,t){return nSi(e,new bz.classes.URLSearchParams,{visitor:function(r,n,i,a){return bz.isNode&&Hf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function uLS(e){return Hf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function sLS(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function cLS(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let c=Number.isFinite(+u),p=a>=r.length;return u=!u&&Hf.isArray(i)?i.length:u,p?(Hf.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!c):((!i[u]||!Hf.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Hf.isArray(i[u])&&(i[u]=sLS(i[u])),!c)}if(Hf.isFormData(e)&&Hf.isFunction(e.entries)){let r={};return Hf.forEachEntry(e,(n,i)=>{t(uLS(n),i,r,0)}),r}return null}var Jis=cLS;function lLS(e,t,r){if(Hf.isString(e))try{return(t||JSON.parse)(e),Hf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var dWl={transitional:o2a,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Hf.isObject(t);if(a&&Hf.isHTMLForm(t)&&(t=new FormData(t)),Hf.isFormData(t))return i?JSON.stringify(Jis(t)):t;if(Hf.isArrayBuffer(t)||Hf.isBuffer(t)||Hf.isStream(t)||Hf.isFile(t)||Hf.isBlob(t)||Hf.isReadableStream(t))return t;if(Hf.isArrayBufferView(t))return t.buffer;if(Hf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return fWl(t,this.formSerializer).toString();if((c=Hf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let p=this.env&&this.env.FormData;return nSi(c?{"files[]":t}:t,p&&new p,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),lLS(t)):t}],transformResponse:[function(t){let r=this.transitional||dWl.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Hf.isResponse(t)||Hf.isReadableStream(t))return t;if(t&&Hf.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(u)throw c.name==="SyntaxError"?T0.from(c,T0.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:bz.classes.FormData,Blob:bz.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Hf.forEach(["delete","get","head","post","put","patch"],e=>{dWl.headers[e]={}});var u2a=dWl;var fLS=Hf.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"]),U5h=e=>{let t={},r,n,i;return e&&e.split(`
2166
+ `);for(let c=i;c<u.length;c++){let p=u[c];if(p.length>1024)continue;let s=Y8h.test(p)?p.replace(Y8h,"$1"):p;if(!s.match(/\S*Error: /)){for(let o of r){let l=o(s);if(l){a.push(l);break}}if(a.length>=d5h)break}}return s9S(a)}}function s9S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,d5h).map(r=>({...r,filename:r.filename||c9S(t).filename,function:r.function||p5h}))}function c9S(e){return e[e.length-1]||{}}Xza.stackParser=u9S(gQS());Xza.frameModifiers=[AQS];var kza=class extends $Vl{getLibraryId(){return"posthog-node"}};var zis=class{posthog;constructor({posthogApiKey:t}){this.posthog=new kza(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.77.7",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var uNo=class{async sendEvent(){}async identify(){}async flush(){}};var t2a=require("fs/promises"),v5h=require("os"),b5h=require("path");var _5h=$i(require("crypto")),Lis=new Uint8Array(256),Qis=Lis.length;function kVl(){return Qis>Lis.length-16&&(_5h.default.randomFillSync(Lis),Qis=0),Lis.slice(Qis,Qis+=16)}var cye=[];for(let e=0;e<256;++e)cye.push((e+256).toString(16).slice(1));function h5h(e,t=0){return cye[e[t+0]]+cye[e[t+1]]+cye[e[t+2]]+cye[e[t+3]]+"-"+cye[e[t+4]]+cye[e[t+5]]+"-"+cye[e[t+6]]+cye[e[t+7]]+"-"+cye[e[t+8]]+cye[e[t+9]]+"-"+cye[e[t+10]]+cye[e[t+11]]+cye[e[t+12]]+cye[e[t+13]]+cye[e[t+14]]+cye[e[t+15]]}var y5h=$i(require("crypto")),eWl={randomUUID:y5h.default.randomUUID};function l9S(e,t,r){if(eWl.randomUUID&&!t&&!e)return eWl.randomUUID();e=e||{};let n=e.random||(e.rng||kVl)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return h5h(n)}var Jxe=l9S;var f9S="id",d9S=".fern",sNo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new kza(r),this.userId=t==null?void 0:U7l(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.77.7",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Jl(D_.of((0,v5h.homedir)()),ds.of(d9S),ds.of(f9S));await ov(t)||(await(0,t2a.mkdir)((0,b5h.dirname)(t),{recursive:!0}),await(0,t2a.writeFile)(t,Jxe())),this.persistedDistinctId=(await(0,t2a.readFile)(t)).toString()}return this.persistedDistinctId}};var tWl;async function r2a(){return tWl==null&&(tWl=await p9S()),tWl}async function p9S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new uNo;let r=await nZu();return r!=null?new sNo({token:r,posthogApiKey:e}):await X4a()!=null?new zis({posthogApiKey:e}):new sNo({token:void 0,posthogApiKey:e})}catch{return new uNo}}function cNo(e,t){return function(){return e.apply(t,arguments)}}var{toString:_9S}=Object.prototype,{getPrototypeOf:nWl}=Object,{iterator:Vis,toStringTag:m5h}=Symbol,Wis=(e=>t=>{let r=_9S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),$Dr=e=>(e=e.toLowerCase(),t=>Wis(t)===e),His=e=>t=>typeof t===e,{isArray:i2a}=Array,n2a=His("undefined");function lNo(e){return e!==null&&!n2a(e)&&e.constructor!==null&&!n2a(e.constructor)&&Kxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var O5h=$Dr("ArrayBuffer");function h9S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&O5h(e.buffer),t}var y9S=His("string"),Kxe=His("function"),A5h=His("number"),fNo=e=>e!==null&&typeof e=="object",v9S=e=>e===!0||e===!1,Uis=e=>{if(Wis(e)!=="object")return!1;let t=nWl(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(m5h in e)&&!(Vis in e)},b9S=e=>{if(!fNo(e)||lNo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},g9S=$Dr("Date"),m9S=$Dr("File"),O9S=$Dr("Blob"),A9S=$Dr("FileList"),P9S=e=>fNo(e)&&Kxe(e.pipe),w9S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Kxe(e.append)&&((t=Wis(e))==="formdata"||t==="object"&&Kxe(e.toString)&&e.toString()==="[object FormData]"))},j9S=$Dr("URLSearchParams"),[E9S,S9S,D9S,C9S]=["ReadableStream","Request","Response","Headers"].map($Dr),I9S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function dNo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),i2a(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(lNo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,c;for(n=0;n<u;n++)c=a[n],t.call(null,e[c],c,e)}}function P5h(e,t){if(lNo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var KGi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,w5h=e=>!n2a(e)&&e!==KGi;function rWl(){let{caseless:e,skipUndefined:t}=w5h(this)&&this||{},r={},n=(i,a)=>{let u=e&&P5h(r,a)||a;Uis(r[u])&&Uis(i)?r[u]=rWl(r[u],i):Uis(i)?r[u]=rWl({},i):i2a(i)?r[u]=i.slice():(!t||!n2a(i))&&(r[u]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&dNo(arguments[i],n);return r}var M9S=(e,t,r,{allOwnKeys:n}={})=>(dNo(t,(i,a)=>{r&&Kxe(i)?e[a]=cNo(i,r):e[a]=i},{allOwnKeys:n}),e),B9S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),T9S=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},q9S=(e,t,r,n)=>{let i,a,u,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)u=i[a],(!n||n(u,e,t))&&!c[u]&&(t[u]=e[u],c[u]=!0);e=r!==!1&&nWl(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},x9S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},N9S=e=>{if(!e)return null;if(i2a(e))return e;let t=e.length;if(!A5h(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},R9S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&nWl(Uint8Array)),F9S=(e,t)=>{let n=(e&&e[Vis]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},z9S=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Q9S=$Dr("HTMLFormElement"),L9S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),g5h=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),U9S=$Dr("RegExp"),j5h=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};dNo(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},V9S=e=>{j5h(e,(t,r)=>{if(Kxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Kxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},W9S=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return i2a(e)?n(e):n(String(e).split(t)),r},H9S=()=>{},G9S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function J9S(e){return!!(e&&Kxe(e.append)&&e[m5h]==="FormData"&&e[Vis])}var K9S=e=>{let t=new Array(10),r=(n,i)=>{if(fNo(n)){if(t.indexOf(n)>=0)return;if(lNo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=i2a(n)?[]:{};return dNo(n,(u,c)=>{let p=r(u,i+1);!n2a(p)&&(a[c]=p)}),t[i]=void 0,a}}return n};return r(e,0)},$9S=$Dr("AsyncFunction"),Y9S=e=>e&&(fNo(e)||Kxe(e))&&Kxe(e.then)&&Kxe(e.catch),E5h=((e,t)=>e?setImmediate:t?((r,n)=>(KGi.addEventListener("message",({source:i,data:a})=>{i===KGi&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),KGi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Kxe(KGi.postMessage)),X9S=typeof queueMicrotask<"u"?queueMicrotask.bind(KGi):typeof process<"u"&&process.nextTick||E5h,Z9S=e=>e!=null&&Kxe(e[Vis]),Hf={isArray:i2a,isArrayBuffer:O5h,isBuffer:lNo,isFormData:w9S,isArrayBufferView:h9S,isString:y9S,isNumber:A5h,isBoolean:v9S,isObject:fNo,isPlainObject:Uis,isEmptyObject:b9S,isReadableStream:E9S,isRequest:S9S,isResponse:D9S,isHeaders:C9S,isUndefined:n2a,isDate:g9S,isFile:m9S,isBlob:O9S,isRegExp:U9S,isFunction:Kxe,isStream:P9S,isURLSearchParams:j9S,isTypedArray:R9S,isFileList:A9S,forEach:dNo,merge:rWl,extend:M9S,trim:I9S,stripBOM:B9S,inherits:T9S,toFlatObject:q9S,kindOf:Wis,kindOfTest:$Dr,endsWith:x9S,toArray:N9S,forEachEntry:F9S,matchAll:z9S,isHTMLForm:Q9S,hasOwnProperty:g5h,hasOwnProp:g5h,reduceDescriptors:j5h,freezeMethods:V9S,toObjectSet:W9S,toCamelCase:L9S,noop:H9S,toFiniteNumber:G9S,findKey:P5h,global:KGi,isContextDefined:w5h,isSpecCompliantForm:J9S,toJSONObject:K9S,isAsyncFn:$9S,isThenable:Y9S,setImmediate:E5h,asap:X9S,isIterable:Z9S};function a2a(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Hf.inherits(a2a,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:Hf.toJSONObject(this.config),code:this.code,status:this.status}}});var S5h=a2a.prototype,D5h={};["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=>{D5h[e]={value:e}});Object.defineProperties(a2a,D5h);Object.defineProperty(S5h,"isAxiosError",{value:!0});a2a.from=(e,t,r,n,i,a)=>{let u=Object.create(S5h);Hf.toFlatObject(e,u,function(o){return o!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",p=t==null&&e?e.code:t;return a2a.call(u,c,p,r,n,i),e&&u.cause==null&&Object.defineProperty(u,"cause",{value:e,configurable:!0}),u.name=e&&e.name||"Error",a&&Object.assign(u,a),u};var T0=a2a;var C5h=$i(_is(),1),Gis=C5h.default;function iWl(e){return Hf.isPlainObject(e)||Hf.isArray(e)}function M5h(e){return Hf.endsWith(e,"[]")?e.slice(0,-2):e}function I5h(e,t,r){return e?e.concat(t).map(function(i,a){return i=M5h(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function k9S(e){return Hf.isArray(e)&&!e.some(iWl)}var eLS=Hf.toFlatObject(Hf,{},null,function(t){return/^is[A-Z]/.test(t)});function tLS(e,t,r){if(!Hf.isObject(e))throw new TypeError("target must be an object");t=t||new(Gis||FormData),r=Hf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Hf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,p=(r.Blob||typeof Blob<"u"&&Blob)&&Hf.isSpecCompliantForm(t);if(!Hf.isFunction(i))throw new TypeError("visitor must be a function");function s(E){if(E===null)return"";if(Hf.isDate(E))return E.toISOString();if(Hf.isBoolean(E))return E.toString();if(!p&&Hf.isBlob(E))throw new T0("Blob is not supported. Use a Buffer instead.");return Hf.isArrayBuffer(E)||Hf.isTypedArray(E)?p&&typeof Blob=="function"?new Blob([E]):Buffer.from(E):E}function o(E,C,M){let q=E;if(E&&!M&&typeof E=="object"){if(Hf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),E=JSON.stringify(E);else if(Hf.isArray(E)&&k9S(E)||(Hf.isFileList(E)||Hf.endsWith(C,"[]"))&&(q=Hf.toArray(E)))return C=M5h(C),q.forEach(function(U,Q){!(Hf.isUndefined(U)||U===null)&&t.append(u===!0?I5h([C],Q,a):u===null?C:C+"[]",s(U))}),!1}return iWl(E)?!0:(t.append(I5h(M,C,a),s(E)),!1)}let l=[],O=Object.assign(eLS,{defaultVisitor:o,convertValue:s,isVisitable:iWl});function A(E,C){if(!Hf.isUndefined(E)){if(l.indexOf(E)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(E),Hf.forEach(E,function(q,L){(!(Hf.isUndefined(q)||q===null)&&i.call(t,q,Hf.isString(L)?L.trim():L,C,O))===!0&&A(q,C?C.concat(L):[L])}),l.pop()}}if(!Hf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var nSi=tLS;function B5h(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function T5h(e,t){this._pairs=[],e&&nSi(e,this,t)}var q5h=T5h.prototype;q5h.append=function(t,r){this._pairs.push([t,r])};q5h.toString=function(t){let r=t?function(n){return t.call(this,n,B5h)}:B5h;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var x5h=T5h;function rLS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function $Gi(e,t,r){if(!t)return e;let n=r&&r.encode||rLS;Hf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Hf.isURLSearchParams(t)?t.toString():new x5h(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var aWl=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Hf.forEach(this.handlers,function(n){n!==null&&t(n)})}},oWl=aWl;var o2a={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var z5h=$i(require("crypto"),1);var N5h=$i(require("url"),1),R5h=N5h.default.URLSearchParams;var uWl="abcdefghijklmnopqrstuvwxyz",F5h="0123456789",Q5h={DIGIT:F5h,ALPHA:uWl,ALPHA_DIGIT:uWl+uWl.toUpperCase()+F5h},nLS=(e=16,t=Q5h.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);z5h.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},L5h={isNode:!0,classes:{URLSearchParams:R5h,FormData:Gis,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:Q5h,generateString:nLS,protocols:["http","https","file","data"]};var lWl={};hs(lWl,{hasBrowserEnv:()=>cWl,hasStandardBrowserEnv:()=>iLS,hasStandardBrowserWebWorkerEnv:()=>aLS,navigator:()=>sWl,origin:()=>oLS});var cWl=typeof window<"u"&&typeof document<"u",sWl=typeof navigator=="object"&&navigator||void 0,iLS=cWl&&(!sWl||["ReactNative","NativeScript","NS"].indexOf(sWl.product)<0),aLS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",oLS=cWl&&window.location.href||"http://localhost";var bz={...lWl,...L5h};function fWl(e,t){return nSi(e,new bz.classes.URLSearchParams,{visitor:function(r,n,i,a){return bz.isNode&&Hf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function uLS(e){return Hf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function sLS(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function cLS(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let c=Number.isFinite(+u),p=a>=r.length;return u=!u&&Hf.isArray(i)?i.length:u,p?(Hf.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!c):((!i[u]||!Hf.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Hf.isArray(i[u])&&(i[u]=sLS(i[u])),!c)}if(Hf.isFormData(e)&&Hf.isFunction(e.entries)){let r={};return Hf.forEachEntry(e,(n,i)=>{t(uLS(n),i,r,0)}),r}return null}var Jis=cLS;function lLS(e,t,r){if(Hf.isString(e))try{return(t||JSON.parse)(e),Hf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var dWl={transitional:o2a,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Hf.isObject(t);if(a&&Hf.isHTMLForm(t)&&(t=new FormData(t)),Hf.isFormData(t))return i?JSON.stringify(Jis(t)):t;if(Hf.isArrayBuffer(t)||Hf.isBuffer(t)||Hf.isStream(t)||Hf.isFile(t)||Hf.isBlob(t)||Hf.isReadableStream(t))return t;if(Hf.isArrayBufferView(t))return t.buffer;if(Hf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return fWl(t,this.formSerializer).toString();if((c=Hf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let p=this.env&&this.env.FormData;return nSi(c?{"files[]":t}:t,p&&new p,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),lLS(t)):t}],transformResponse:[function(t){let r=this.transitional||dWl.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Hf.isResponse(t)||Hf.isReadableStream(t))return t;if(t&&Hf.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(u)throw c.name==="SyntaxError"?T0.from(c,T0.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:bz.classes.FormData,Blob:bz.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Hf.forEach(["delete","get","head","post","put","patch"],e=>{dWl.headers[e]={}});var u2a=dWl;var fLS=Hf.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"]),U5h=e=>{let t={},r,n,i;return e&&e.split(`
2167
2167
  `).forEach(function(u){i=u.indexOf(":"),r=u.substring(0,i).trim().toLowerCase(),n=u.substring(i+1).trim(),!(!r||t[r]&&fLS[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var V5h=Symbol("internals");function pNo(e){return e&&String(e).trim().toLowerCase()}function Kis(e){return e===!1||e==null?e:Hf.isArray(e)?e.map(Kis):String(e)}function dLS(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var pLS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function pWl(e,t,r,n,i){if(Hf.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Hf.isString(t)){if(Hf.isString(n))return t.indexOf(n)!==-1;if(Hf.isRegExp(n))return n.test(t)}}function _LS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function hLS(e,t){let r=Hf.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,u){return this[n].call(this,t,i,a,u)},configurable:!0})})}var s2a=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,p,s){let o=pNo(p);if(!o)throw new Error("header name must be a non-empty string");let l=Hf.findKey(i,o);(!l||i[l]===void 0||s===!0||s===void 0&&i[l]!==!1)&&(i[l||p]=Kis(c))}let u=(c,p)=>Hf.forEach(c,(s,o)=>a(s,o,p));if(Hf.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(Hf.isString(t)&&(t=t.trim())&&!pLS(t))u(U5h(t),r);else if(Hf.isObject(t)&&Hf.isIterable(t)){let c={},p,s;for(let o of t){if(!Hf.isArray(o))throw TypeError("Object iterator must return a key-value pair");c[s=o[0]]=(p=c[s])?Hf.isArray(p)?[...p,o[1]]:[p,o[1]]:o[1]}u(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=pNo(t),t){let n=Hf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return dLS(i);if(Hf.isFunction(r))return r.call(this,i,n);if(Hf.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=pNo(t),t){let n=Hf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||pWl(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(u){if(u=pNo(u),u){let c=Hf.findKey(n,u);c&&(!r||pWl(n,n[c],c,r))&&(delete n[c],i=!0)}}return Hf.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||pWl(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Hf.forEach(this,(i,a)=>{let u=Hf.findKey(n,a);if(u){r[u]=Kis(i),delete r[a];return}let c=t?_LS(a):String(a).trim();c!==a&&delete r[a],r[c]=Kis(i),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Hf.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Hf.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
2168
2168
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[V5h]=this[V5h]={accessors:{}}).accessors,i=this.prototype;function a(u){let c=pNo(u);n[c]||(hLS(i,u),n[c]=!0)}return Hf.isArray(t)?t.forEach(a):a(t),this}};s2a.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Hf.reduceDescriptors(s2a.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Hf.freezeMethods(s2a);var DJ=s2a;function _No(e,t){let r=this||u2a,n=t||r,i=DJ.from(n.headers),a=n.data;return Hf.forEach(e,function(c){a=c.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function hNo(e){return!!(e&&e.__CANCEL__)}function W5h(e,t,r){T0.call(this,e??"canceled",T0.ERR_CANCELED,t,r),this.name="CanceledError"}Hf.inherits(W5h,T0,{__CANCEL__:!0});var _et=W5h;function z7r(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new T0("Request failed with status code "+r.status,[T0.ERR_BAD_REQUEST,T0.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function _Wl(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function hWl(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function YGi(e,t,r){let n=!_Wl(t);return e&&(n||r==!1)?hWl(e,t):t}var oQh=$i(his(),1),uQh=$i(require("http"),1),sQh=$i(require("https"),1),cQh=$i(require("util"),1),lQh=$i(yVl(),1),rci=$i(require("zlib"),1);var XGi="1.12.0";function yNo(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var yLS=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function yWl(e,t,r){let n=r&&r.Blob||bz.classes.Blob,i=yNo(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=yLS.exec(e);if(!a)throw new T0("Invalid URL",T0.ERR_INVALID_URL);let u=a[1],c=a[2],p=a[3],s=Buffer.from(decodeURIComponent(p),c?"base64":"utf8");if(t){if(!n)throw new T0("Blob is not supported",T0.ERR_NOT_SUPPORT);return new n([s],{type:u})}return s}throw new T0("Unsupported protocol "+i,T0.ERR_NOT_SUPPORT)}var kGi=$i(require("stream"),1);var H5h=$i(require("stream"),1);var vWl=Symbol("internals"),bWl=class extends H5h.default.Transform{constructor(t){t=Hf.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Hf.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[vWl]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[vWl];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[vWl],a=i.maxRate,u=this.readableHighWaterMark,c=i.timeWindow,p=1e3/c,s=a/p,o=i.minChunkSize!==!1?Math.max(i.minChunkSize,s*.01):0,l=(A,E)=>{let C=Buffer.byteLength(A);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(A)?process.nextTick(E):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(E)}},O=(A,E)=>{let C=Buffer.byteLength(A),M=null,q=u,L,U=0;if(a){let Q=Date.now();(!i.ts||(U=Q-i.ts)>=c)&&(i.ts=Q,L=s-i.bytes,i.bytes=L<0?-L:0,U=0),L=s-i.bytes}if(a){if(L<=0)return setTimeout(()=>{E(null,A)},c-U);L<q&&(q=L)}q&&C>q&&C-q>o&&(M=A.subarray(q),A=A.subarray(0,q)),l(A,M?()=>{process.nextTick(E,null,M)}:E)};O(t,function A(E,C){if(E)return n(E);C?O(C,A):n(null)})}},gWl=bWl;var fQh=require("events");var J5h=$i(require("util"),1),K5h=require("stream");var{asyncIterator:G5h}=Symbol,vLS=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[G5h]?yield*e[G5h]():yield e},$is=vLS;var bLS=bz.ALPHABET.ALPHA_DIGIT+"-_",vNo=typeof TextEncoder=="function"?new TextEncoder:new J5h.default.TextEncoder,ZGi=`\r
2169
2169
  `,gLS=vNo.encode(ZGi),mLS=2,mWl=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Hf.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${ZGi}`;i?r=vNo.encode(String(r).replace(/\r?\n|\r\n?/g,ZGi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${ZGi}`,this.headers=vNo.encode(a+ZGi),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+mLS,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Hf.isTypedArray(t)?yield t:yield*$is(t),yield gLS}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},OLS=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+bz.generateString(i,bLS)}=r||{};if(!Hf.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=vNo.encode("--"+a+ZGi),c=vNo.encode("--"+a+"--"+ZGi),p=c.byteLength,s=Array.from(e.entries()).map(([l,O])=>{let A=new mWl(l,O);return p+=A.size,A});p+=u.byteLength*s.length,p=Hf.toFiniteNumber(p);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(p)&&(o["Content-Length"]=p),t&&t(o),K5h.Readable.from((async function*(){for(let l of s)yield u,yield*l.encode();yield c})())},$5h=OLS;var Y5h=$i(require("stream"),1),OWl=class extends Y5h.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},X5h=OWl;var ALS=(e,t)=>Hf.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,Z5h=ALS;function PLS(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,u;return t=t!==void 0?t:1e3,function(p){let s=Date.now(),o=n[a];u||(u=s),r[i]=p,n[i]=s;let l=a,O=0;for(;l!==i;)O+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),s-u<t)return;let A=o&&s-o;return A?Math.round(O*1e3/A):void 0}}var k5h=PLS;function wLS(e,t){let r=0,n=1e3/t,i,a,u=(s,o=Date.now())=>{r=o,i=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let o=Date.now(),l=o-r;l>=n?u(s,o):(i=s,a||(a=setTimeout(()=>{a=null,u(i)},n-l)))},()=>i&&u(i)]}var eQh=wLS;var tci=(e,t,r=3)=>{let n=0,i=k5h(50,250);return eQh(a=>{let u=a.loaded,c=a.lengthComputable?a.total:void 0,p=u-n,s=i(p),o=u<=c;n=u;let l={loaded:u,total:c,progress:c?u/c:void 0,bytes:p,rate:s||void 0,estimated:s&&c&&o?(c-u)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},c2a=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},l2a=e=>(...t)=>Hf.asap(()=>e(...t));function AWl(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,u=n.length;for(let O=0;O<u;O++)if(n.charCodeAt(O)===37&&O+2<u){let A=n.charCodeAt(O+1),E=n.charCodeAt(O+2);(A>=48&&A<=57||A>=65&&A<=70||A>=97&&A<=102)&&(E>=48&&E<=57||E>=65&&E<=70||E>=97&&E<=102)&&(a-=2,O+=2)}let c=0,p=u-1,s=O=>O>=2&&n.charCodeAt(O-2)===37&&n.charCodeAt(O-1)===51&&(n.charCodeAt(O)===68||n.charCodeAt(O)===100);p>=0&&(n.charCodeAt(p)===61?(c++,p--):s(p)&&(c++,p-=3)),c===1&&p>=0&&(n.charCodeAt(p)===61||s(p))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var tQh={flush:rci.default.constants.Z_SYNC_FLUSH,finishFlush:rci.default.constants.Z_SYNC_FLUSH},jLS={flush:rci.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:rci.default.constants.BROTLI_OPERATION_FLUSH},rQh=Hf.isFunction(rci.default.createBrotliDecompress),{http:ELS,https:SLS}=lQh.default,DLS=/https:?/,nQh=bz.protocols.map(e=>e+":"),iQh=(e,[t,r])=>(e.on("end",r).on("error",r),t);function CLS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function dQh(e,t,r){let n=t;if(!n&&n!==!1){let i=oQh.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){dQh(a,t,a.href)}}var ILS=typeof process<"u"&&Hf.kindOf(process)==="process",MLS=e=>new Promise((t,r)=>{let n,i,a=(p,s)=>{i||(i=!0,n&&n(p,s))},u=p=>{a(p),t(p)},c=p=>{a(p,!0),r(p)};e(u,c,p=>n=p).catch(c)}),BLS=({address:e,family:t})=>{if(!Hf.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},aQh=(e,t)=>BLS(Hf.isObject(e)?e:{address:e,family:t}),pQh=ILS&&function(t){return MLS(async function(n,i,a){let{data:u,lookup:c,family:p}=t,{responseType:s,responseEncoding:o}=t,l=t.method.toUpperCase(),O,A=!1,E;if(c){let Be=Z5h(c,Bt=>Hf.isArray(Bt)?Bt:[Bt]);c=(Bt,Qt,Ke)=>{Be(Bt,Qt,(ze,Dr,ut)=>{if(ze)return Ke(ze);let br=Hf.isArray(Dr)?Dr.map(Xt=>aQh(Xt)):[aQh(Dr,ut)];Qt.all?Ke(ze,br):Ke(ze,br[0].address,br[0].family)})}}let C=new fQh.EventEmitter,M=()=>{t.cancelToken&&t.cancelToken.unsubscribe(q),t.signal&&t.signal.removeEventListener("abort",q),C.removeAllListeners()};a((Be,Bt)=>{O=!0,Bt&&(A=!0,M())});function q(Be){C.emit("abort",!Be||Be.type?new _et(null,t,E):Be)}C.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(q),t.signal&&(t.signal.aborted?q():t.signal.addEventListener("abort",q)));let L=YGi(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(L,bz.hasBrowserEnv?bz.origin:void 0),Q=U.protocol||nQh[0];if(Q==="data:"){if(t.maxContentLength>-1){let Bt=String(t.url||L||"");if(AWl(Bt)>t.maxContentLength)return i(new T0("maxContentLength size of "+t.maxContentLength+" exceeded",T0.ERR_BAD_RESPONSE,t))}let Be;if(l!=="GET")return z7r(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Be=yWl(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Bt){throw T0.from(Bt,T0.ERR_BAD_REQUEST,t)}return s==="text"?(Be=Be.toString(o),(!o||o==="utf8")&&(Be=Hf.stripBOM(Be))):s==="stream"&&(Be=kGi.default.Readable.from(Be)),z7r(n,i,{data:Be,status:200,statusText:"OK",headers:new DJ,config:t})}if(nQh.indexOf(Q)===-1)return i(new T0("Unsupported protocol "+Q,T0.ERR_BAD_REQUEST,t));let J=DJ.from(t.headers).normalize();J.set("User-Agent","axios/"+XGi,!1);let{onUploadProgress:X,onDownloadProgress:te}=t,k=t.maxRate,re,ue;if(Hf.isSpecCompliantForm(u)){let Be=J.getContentType(/boundary=([-_\w\d]{10,70})/i);u=$5h(u,Bt=>{J.set(Bt)},{tag:`axios-${XGi}-boundary`,boundary:Be&&Be[1]||void 0})}else if(Hf.isFormData(u)&&Hf.isFunction(u.getHeaders)){if(J.set(u.getHeaders()),!J.hasContentLength())try{let Be=await cQh.default.promisify(u.getLength).call(u);Number.isFinite(Be)&&Be>=0&&J.setContentLength(Be)}catch{}}else if(Hf.isBlob(u)||Hf.isFile(u))u.size&&J.setContentType(u.type||"application/octet-stream"),J.setContentLength(u.size||0),u=kGi.default.Readable.from($is(u));else if(u&&!Hf.isStream(u)){if(!Buffer.isBuffer(u))if(Hf.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(Hf.isString(u))u=Buffer.from(u,"utf-8");else return i(new T0("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",T0.ERR_BAD_REQUEST,t));if(J.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return i(new T0("Request body larger than maxBodyLength limit",T0.ERR_BAD_REQUEST,t))}let Oe=Hf.toFiniteNumber(J.getContentLength());Hf.isArray(k)?(re=k[0],ue=k[1]):re=ue=k,u&&(X||re)&&(Hf.isStream(u)||(u=kGi.default.Readable.from(u,{objectMode:!1})),u=kGi.default.pipeline([u,new gWl({maxRate:Hf.toFiniteNumber(re)})],Hf.noop),X&&u.on("progress",iQh(u,c2a(Oe,tci(l2a(X),!1,3)))));let me;if(t.auth){let Be=t.auth.username||"",Bt=t.auth.password||"";me=Be+":"+Bt}if(!me&&U.username){let Be=U.username,Bt=U.password;me=Be+":"+Bt}me&&J.delete("authorization");let Ee;try{Ee=$Gi(U.pathname+U.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Be){let Bt=new Error(Be.message);return Bt.config=t,Bt.url=t.url,Bt.exists=!0,i(Bt)}J.set("Accept-Encoding","gzip, compress, deflate"+(rQh?", br":""),!1);let Pe={path:Ee,method:l,headers:J.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:me,protocol:Q,family:p,beforeRedirect:CLS,beforeRedirects:{}};!Hf.isUndefined(c)&&(Pe.lookup=c),t.socketPath?Pe.socketPath=t.socketPath:(Pe.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,Pe.port=U.port,dQh(Pe,t.proxy,Q+"//"+U.hostname+(U.port?":"+U.port:"")+Pe.path));let Me,Ue=DLS.test(Pe.protocol);if(Pe.agent=Ue?t.httpsAgent:t.httpAgent,t.transport?Me=t.transport:t.maxRedirects===0?Me=Ue?sQh.default:uQh.default:(t.maxRedirects&&(Pe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(Pe.beforeRedirects.config=t.beforeRedirect),Me=Ue?SLS:ELS),t.maxBodyLength>-1?Pe.maxBodyLength=t.maxBodyLength:Pe.maxBodyLength=1/0,t.insecureHTTPParser&&(Pe.insecureHTTPParser=t.insecureHTTPParser),E=Me.request(Pe,function(Bt){if(E.destroyed)return;let Qt=[Bt],Ke=+Bt.headers["content-length"];if(te||ue){let Xt=new gWl({maxRate:Hf.toFiniteNumber(ue)});te&&Xt.on("progress",iQh(Xt,c2a(Ke,tci(l2a(te),!0,3)))),Qt.push(Xt)}let ze=Bt,Dr=Bt.req||E;if(t.decompress!==!1&&Bt.headers["content-encoding"])switch((l==="HEAD"||Bt.statusCode===204)&&delete Bt.headers["content-encoding"],(Bt.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Qt.push(rci.default.createUnzip(tQh)),delete Bt.headers["content-encoding"];break;case"deflate":Qt.push(new X5h),Qt.push(rci.default.createUnzip(tQh)),delete Bt.headers["content-encoding"];break;case"br":rQh&&(Qt.push(rci.default.createBrotliDecompress(jLS)),delete Bt.headers["content-encoding"])}ze=Qt.length>1?kGi.default.pipeline(Qt,Hf.noop):Qt[0];let ut=kGi.default.finished(ze,()=>{ut(),M()}),br={status:Bt.statusCode,statusText:Bt.statusMessage,headers:new DJ(Bt.headers),config:t,request:Dr};if(s==="stream")br.data=ze,z7r(n,i,br);else{let Xt=[],Ze=0;ze.on("data",function(wr){Xt.push(wr),Ze+=wr.length,t.maxContentLength>-1&&Ze>t.maxContentLength&&(A=!0,ze.destroy(),i(new T0("maxContentLength size of "+t.maxContentLength+" exceeded",T0.ERR_BAD_RESPONSE,t,Dr)))}),ze.on("aborted",function(){if(A)return;let wr=new T0("stream has been aborted",T0.ERR_BAD_RESPONSE,t,Dr);ze.destroy(wr),i(wr)}),ze.on("error",function(wr){E.destroyed||i(T0.from(wr,null,t,Dr))}),ze.on("end",function(){try{let wr=Xt.length===1?Xt[0]:Buffer.concat(Xt);s!=="arraybuffer"&&(wr=wr.toString(o),(!o||o==="utf8")&&(wr=Hf.stripBOM(wr))),br.data=wr}catch(wr){return i(T0.from(wr,null,t,br.request,br))}z7r(n,i,br)})}C.once("abort",Xt=>{ze.destroyed||(ze.emit("error",Xt),ze.destroy())})}),C.once("abort",Be=>{i(Be),E.destroy(Be)}),E.on("error",function(Bt){i(T0.from(Bt,null,t,E))}),E.on("socket",function(Bt){Bt.setKeepAlive(!0,1e3*60)}),t.timeout){let Be=parseInt(t.timeout,10);if(Number.isNaN(Be)){i(new T0("error trying to parse `config.timeout` to int",T0.ERR_BAD_OPTION_VALUE,t,E));return}E.setTimeout(Be,function(){if(O)return;let Qt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Ke=t.transitional||o2a;t.timeoutErrorMessage&&(Qt=t.timeoutErrorMessage),i(new T0(Qt,Ke.clarifyTimeoutError?T0.ETIMEDOUT:T0.ECONNABORTED,t,E)),q()})}if(Hf.isStream(u)){let Be=!1,Bt=!1;u.on("end",()=>{Be=!0}),u.once("error",Qt=>{Bt=!0,E.destroy(Qt)}),u.on("close",()=>{!Be&&!Bt&&q(new _et("Request stream has been aborted",t,E))}),u.pipe(E)}else E.end(u)})};var _Qh=bz.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,bz.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(bz.origin),bz.navigator&&/(msie|trident)/i.test(bz.navigator.userAgent)):()=>!0;var hQh=bz.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let u=[e+"="+encodeURIComponent(t)];Hf.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),Hf.isString(n)&&u.push("path="+n),Hf.isString(i)&&u.push("domain="+i),a===!0&&u.push("secure"),document.cookie=u.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 yQh=e=>e instanceof DJ?{...e}:e;function YDr(e,t){t=t||{};let r={};function n(s,o,l,O){return Hf.isPlainObject(s)&&Hf.isPlainObject(o)?Hf.merge.call({caseless:O},s,o):Hf.isPlainObject(o)?Hf.merge({},o):Hf.isArray(o)?o.slice():o}function i(s,o,l,O){if(Hf.isUndefined(o)){if(!Hf.isUndefined(s))return n(void 0,s,l,O)}else return n(s,o,l,O)}function a(s,o){if(!Hf.isUndefined(o))return n(void 0,o)}function u(s,o){if(Hf.isUndefined(o)){if(!Hf.isUndefined(s))return n(void 0,s)}else return n(void 0,o)}function c(s,o,l){if(l in t)return n(s,o);if(l in e)return n(void 0,s)}let p={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:c,headers:(s,o,l)=>i(yQh(s),yQh(o),l,!0)};return Hf.forEach(Object.keys({...e,...t}),function(o){let l=p[o]||i,O=l(e[o],t[o],o);Hf.isUndefined(O)&&l!==c||(r[o]=O)}),r}var Yis=e=>{let t=YDr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:u,auth:c}=t;if(t.headers=u=DJ.from(u),t.url=$Gi(YGi(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&u.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Hf.isFormData(r)){if(bz.hasStandardBrowserEnv||bz.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if(Hf.isFunction(r.getHeaders)){let p=r.getHeaders(),s=["content-type","content-length"];Object.entries(p).forEach(([o,l])=>{s.includes(o.toLowerCase())&&u.set(o,l)})}}if(bz.hasStandardBrowserEnv&&(n&&Hf.isFunction(n)&&(n=n(t)),n||n!==!1&&_Qh(t.url))){let p=i&&a&&hQh.read(a);p&&u.set(i,p)}return t};var TLS=typeof XMLHttpRequest<"u",vQh=TLS&&function(e){return new Promise(function(r,n){let i=Yis(e),a=i.data,u=DJ.from(i.headers).normalize(),{responseType:c,onUploadProgress:p,onDownloadProgress:s}=i,o,l,O,A,E;function C(){A&&A(),E&&E(),i.cancelToken&&i.cancelToken.unsubscribe(o),i.signal&&i.signal.removeEventListener("abort",o)}let M=new XMLHttpRequest;M.open(i.method.toUpperCase(),i.url,!0),M.timeout=i.timeout;function q(){if(!M)return;let U=DJ.from("getAllResponseHeaders"in M&&M.getAllResponseHeaders()),J={data:!c||c==="text"||c==="json"?M.responseText:M.response,status:M.status,statusText:M.statusText,headers:U,config:e,request:M};z7r(function(te){r(te),C()},function(te){n(te),C()},J),M=null}"onloadend"in M?M.onloadend=q:M.onreadystatechange=function(){!M||M.readyState!==4||M.status===0&&!(M.responseURL&&M.responseURL.indexOf("file:")===0)||setTimeout(q)},M.onabort=function(){M&&(n(new T0("Request aborted",T0.ECONNABORTED,e,M)),M=null)},M.onerror=function(Q){let J=Q&&Q.message?Q.message:"Network Error",X=new T0(J,T0.ERR_NETWORK,e,M);X.event=Q||null,n(X),M=null},M.ontimeout=function(){let Q=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",J=i.transitional||o2a;i.timeoutErrorMessage&&(Q=i.timeoutErrorMessage),n(new T0(Q,J.clarifyTimeoutError?T0.ETIMEDOUT:T0.ECONNABORTED,e,M)),M=null},a===void 0&&u.setContentType(null),"setRequestHeader"in M&&Hf.forEach(u.toJSON(),function(Q,J){M.setRequestHeader(J,Q)}),Hf.isUndefined(i.withCredentials)||(M.withCredentials=!!i.withCredentials),c&&c!=="json"&&(M.responseType=i.responseType),s&&([O,E]=tci(s,!0),M.addEventListener("progress",O)),p&&M.upload&&([l,A]=tci(p),M.upload.addEventListener("progress",l),M.upload.addEventListener("loadend",A)),(i.cancelToken||i.signal)&&(o=U=>{M&&(n(!U||U.type?new _et(null,e,M):U),M.abort(),M=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));let L=yNo(i.url);if(L&&bz.protocols.indexOf(L)===-1){n(new T0("Unsupported protocol "+L+":",T0.ERR_BAD_REQUEST,e));return}M.send(a||null)})};var qLS=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(s){if(!i){i=!0,c();let o=s instanceof Error?s:this.reason;n.abort(o instanceof T0?o:new _et(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new T0(`timeout ${t} of ms exceeded`,T0.ETIMEDOUT))},t),c=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:p}=n;return p.unsubscribe=()=>Hf.asap(c),p}},bQh=qLS;var xLS=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},NLS=async function*(e,t){for await(let r of RLS(e))yield*xLS(r,t)},RLS=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},PWl=(e,t,r,n)=>{let i=NLS(e,t),a=0,u,c=p=>{u||(u=!0,n&&n(p))};return new ReadableStream({async pull(p){try{let{done:s,value:o}=await i.next();if(s){c(),p.close();return}let l=o.byteLength;if(r){let O=a+=l;r(O)}p.enqueue(new Uint8Array(o))}catch(s){throw c(s),s}},cancel(p){return c(p),i.return()}},{highWaterMark:2})};var gQh=64*1024,{isFunction:Xis}=Hf,PQh=(({fetch:e,Request:t,Response:r})=>({fetch:e,Request:t,Response:r}))(Hf.global),{ReadableStream:mQh,TextEncoder:OQh}=Hf.global,AQh=(e,...t)=>{try{return!!e(...t)}catch{return!1}},FLS=e=>{let{fetch:t,Request:r,Response:n}=Object.assign({},PQh,e),i=Xis(t),a=Xis(r),u=Xis(n);if(!i)return!1;let c=i&&Xis(mQh),p=i&&(typeof OQh=="function"?(E=>C=>E.encode(C))(new OQh):async E=>new Uint8Array(await new r(E).arrayBuffer())),s=a&&c&&AQh(()=>{let E=!1,C=new r(bz.origin,{body:new mQh,method:"POST",get duplex(){return E=!0,"half"}}).headers.has("Content-Type");return E&&!C}),o=u&&c&&AQh(()=>Hf.isReadableStream(new n("").body)),l={stream:o&&(E=>E.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(E=>{!l[E]&&(l[E]=(C,M)=>{let q=C&&C[E];if(q)return q.call(C);throw new T0(`Response type '${E}' is not supported`,T0.ERR_NOT_SUPPORT,M)})});let O=async E=>{if(E==null)return 0;if(Hf.isBlob(E))return E.size;if(Hf.isSpecCompliantForm(E))return(await new r(bz.origin,{method:"POST",body:E}).arrayBuffer()).byteLength;if(Hf.isArrayBufferView(E)||Hf.isArrayBuffer(E))return E.byteLength;if(Hf.isURLSearchParams(E)&&(E=E+""),Hf.isString(E))return(await p(E)).byteLength},A=async(E,C)=>{let M=Hf.toFiniteNumber(E.getContentLength());return M??O(C)};return async E=>{let{url:C,method:M,data:q,signal:L,cancelToken:U,timeout:Q,onDownloadProgress:J,onUploadProgress:X,responseType:te,headers:k,withCredentials:re="same-origin",fetchOptions:ue}=Yis(E);te=te?(te+"").toLowerCase():"text";let Oe=bQh([L,U&&U.toAbortSignal()],Q),me=null,Ee=Oe&&Oe.unsubscribe&&(()=>{Oe.unsubscribe()}),Pe;try{if(X&&s&&M!=="get"&&M!=="head"&&(Pe=await A(k,q))!==0){let Ke=new r(C,{method:"POST",body:q,duplex:"half"}),ze;if(Hf.isFormData(q)&&(ze=Ke.headers.get("content-type"))&&k.setContentType(ze),Ke.body){let[Dr,ut]=c2a(Pe,tci(l2a(X)));q=PWl(Ke.body,gQh,Dr,ut)}}Hf.isString(re)||(re=re?"include":"omit");let Me=a&&"credentials"in r.prototype,Ue={...ue,signal:Oe,method:M.toUpperCase(),headers:k.normalize().toJSON(),body:q,duplex:"half",credentials:Me?re:void 0};me=a&&new r(C,Ue);let Be=await(a?t(me,ue):t(C,Ue)),Bt=o&&(te==="stream"||te==="response");if(o&&(J||Bt&&Ee)){let Ke={};["status","statusText","headers"].forEach(br=>{Ke[br]=Be[br]});let ze=Hf.toFiniteNumber(Be.headers.get("content-length")),[Dr,ut]=J&&c2a(ze,tci(l2a(J),!0))||[];Be=new n(PWl(Be.body,gQh,Dr,()=>{ut&&ut(),Ee&&Ee()}),Ke)}te=te||"text";let Qt=await l[Hf.findKey(l,te)||"text"](Be,E);return!Bt&&Ee&&Ee(),await new Promise((Ke,ze)=>{z7r(Ke,ze,{data:Qt,headers:DJ.from(Be.headers),status:Be.status,statusText:Be.statusText,config:E,request:me})})}catch(Me){throw Ee&&Ee(),Me&&Me.name==="TypeError"&&/Load failed|fetch/i.test(Me.message)?Object.assign(new T0("Network Error",T0.ERR_NETWORK,E,me),{cause:Me.cause||Me}):T0.from(Me,Me&&Me.code,E,me)}}},zLS=new Map,wWl=e=>{let t=Hf.merge.call({skipUndefined:!0},PQh,e?e.env:null),{fetch:r,Request:n,Response:i}=t,a=[n,i,r],u=a.length,c=u,p,s,o=zLS;for(;c--;)p=a[c],s=o.get(p),s===void 0&&o.set(p,s=c?new Map:FLS(t)),o=s;return s},LQQ=wWl();var jWl={http:pQh,xhr:vQh,fetch:{get:wWl}};Hf.forEach(jWl,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var wQh=e=>`- ${e}`,LLS=e=>Hf.isFunction(e)||e===null||e===!1,Zis={getAdapter:(e,t)=>{e=Hf.isArray(e)?e:[e];let{length:r}=e,n,i,a={};for(let u=0;u<r;u++){n=e[u];let c;if(i=n,!LLS(n)&&(i=jWl[(c=String(n)).toLowerCase()],i===void 0))throw new T0(`Unknown adapter '${c}'`);if(i&&(Hf.isFunction(i)||(i=i.get(t))))break;a[c||"#"+u]=i}if(!i){let u=Object.entries(a).map(([p,s])=>`adapter ${p} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?u.length>1?`since :
@@ -2404,7 +2404,7 @@ ${Q}${L}${J}${vhy.default.cursorHide}`});function W_s({message:e,error:t,logger:
2404
2404
  Run ${yd.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
2405
2405
  Run ${yd.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),d2a(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Xof({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!Qhy(e))return;let i=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((c,p)=>c.generatorName.localeCompare(p.generatorName)||c.currentVersion.localeCompare(p.currentVersion));for(let c of u)i+=`
2406
2406
  ${await eID(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+yd.dim(c.currentVersion)+yd.reset(" \u2192 ")+yd.green(c.latestVersion);return i+=`
2407
- `,n?d2a(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function eID(e){let r=await new zhy.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 tID({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Uhy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(p,s,o,l)=>{c.versions[s]==null&&(c.versions[s]={});let O=Kji(o.name,l),A=await Bzr({generatorName:O,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][o.name]={previousVersion:o.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let u={type:"multiApi",versions:{}};return await Uhy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,p,s,o)=>{if(c==null)return;u.versions[c]==null&&(u.versions[c]={}),u.versions[c][p]==null&&(u.versions[c][p]={});let l=Kji(s.name,o),O=await Bzr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:o});O!=null&&(u.versions[c][p][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),u}async function Uhy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let c=await EDr({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(c==null||c.groups==null)){for(let p of c.groups)if(!(i!=null&&p.groupName!==i))for(let s of p.generators)n!=null&&s.name!==n||await r(a.workspaceName,p.groupName,s,u)}})}))}function Vhy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,c]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let p=dNe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(p?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:p,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function K_s({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let c=await tID({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[p,s]of Object.entries(c.versions))u.push(...Vhy(s,p,t.logger));else u.push(...Vhy(c.versions,void 0,t.logger))}return u}var _4o=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var aQa=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Zof=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),Why=typeof globalThis.AbortController=="function",Hhy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Ghy=typeof globalThis.ReadableStream=="function",Jhy=typeof globalThis.FormData=="function",$_s=["get","post","put","patch","head","delete"],rID=()=>{};rID();var Khy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Y_s=2147483647,$hy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,X_s=Symbol("stop"),Yhy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Xhy={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 nID=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=$hy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},Zhy=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,n=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:n},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(i){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:c,value:p}=await a.read();if(c){i.close();return}if(t){n+=p.byteLength;let s=r===0?0:n/r;t({percent:s,transferredBytes:n,totalBytes:r},p)}i.enqueue(p),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},khy=(e,t,r)=>{let n=nID(r??e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(a){let u=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function c(){let{done:p,value:s}=await u.read();if(p){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(n,i)},new Uint8Array),a.close();return}i+=s.byteLength;let o=n===0?0:i/n;(n<i||o===1)&&(o=.99),t&&t({percent:Number(o.toFixed(2)),transferredBytes:i,totalBytes:n},s),a.enqueue(s),await c()}await c()}})})};var oQa=e=>e!==null&&typeof e=="object";var h4o=(...e)=>{for(let t of e)if((!oQa(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return tuf({},...e)},kof=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Z_s(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:tuf(e[r]??[],t[r]??[])}var euf=(e={},t={})=>({beforeRequest:Z_s(e,t,"beforeRequest"),beforeRetry:Z_s(e,t,"beforeRetry"),afterResponse:Z_s(e,t,"afterResponse"),beforeError:Z_s(e,t,"beforeError")}),tuf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(oQa(i)){for(let[a,u]of Object.entries(i))oQa(u)&&a in t&&(u=tuf(t[a],u)),t={...t,[a]:u};oQa(i.hooks)&&(n=euf(n,i.hooks),t.hooks=n),oQa(i.headers)&&(r=kof(r,i.headers),t.headers=r)}return t};var tyy=e=>$_s.includes(e)?e.toUpperCase():e,iID=["get","put","head","delete","options","trace"],aID=[408,413,429,500,502,503,504],oID=[413,429,503],eyy={limit:2,methods:iID,statusCodes:aID,afterStatusCodes:oID,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},ryy=(e={})=>{if(typeof e=="number")return{...eyy,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{...eyy,...e}};async function ruf(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new aQa(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function nuf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var nyy=(e,t)=>{let r={};for(let n in t)!(n in Xhy)&&!(n in Yhy)&&!(n in e)&&(r[n]=t[n]);return r},iyy=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 y4o=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>Y_s)throw new RangeError(`The \`timeout\` option cannot be greater than ${Y_s}`);await Promise.resolve();let c=await n._fetch();for(let p of n._options.hooks.afterResponse){let s=await p(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let p=new _4o(c,n.request,n._options);for(let s of n._options.hooks.beforeError)p=await s(p);throw p}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Ghy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Zhy(c.clone(),n._options.onDownloadProgress)}return c},u=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{n.request.bodyUsed||await n.request.body?.cancel()});for(let[c,p]of Object.entries(Khy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(u[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||p);let s=await u;if(c==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[c]()});return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:kof(this._input.headers,r.headers),hooks:euf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:tyy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:ryy(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(Why&&Hhy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(Zof&&(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),iyy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(Jhy&&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(!Zof)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=khy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof aQa)throw t;if(t instanceof _4o){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),Y_s);if(this._retryCount<1)throw r;await nuf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===X_s)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=nyy(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):ruf(r,t,this.abortController,this._options)}};var iuf=e=>{let t=(r,n)=>y4o.create(r,h4o(e,n));for(let r of $_s)t[r]=(n,i)=>y4o.create(n,h4o(e,i,{method:r}));return t.create=r=>iuf(h4o(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),iuf(h4o(e,r))),t.stop=X_s,t},uID=iuf(),ayy=uID;var Dyy=$i(Syy(),1);function cuf(e){let t=(0,Dyy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Avy=$i(Ovy(),1),Pvy=$i(C4r(),1),Auf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Puf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function wuf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??cuf(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Avy.default)(a.toString(),{recursive:!0}),p={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete p.accept,c&&(p.authorization=`${c.type} ${c.token}`);let s;try{s=await ayy(u,{headers:p,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Auf(e):l}if(t.allVersions)return s;let o=new Puf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,E]of Object.entries(s.versions))E.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=Pvy.default.maxSatisfying(A,r),!r)throw o}let{time:O}=s;if(s=s.versions[r],s.time=O,!s)throw o}return s}async function A4o(e,t){let{version:r}=await wuf(e.toLowerCase(),t);return r}async function IDi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:A4o(e.packageName,{version:t?"prerelease":"latest"})}var wvy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],lhs=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=zj.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new J_s(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(i==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.77.6"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${yd.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qae}failWithoutThrowing(t,r){this.didSucceed=!1,W_s({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await r2a()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await Lhy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2407
+ `,n?d2a(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function eID(e){let r=await new zhy.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 tID({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Uhy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(p,s,o,l)=>{c.versions[s]==null&&(c.versions[s]={});let O=Kji(o.name,l),A=await Bzr({generatorName:O,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][o.name]={previousVersion:o.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let u={type:"multiApi",versions:{}};return await Uhy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,p,s,o)=>{if(c==null)return;u.versions[c]==null&&(u.versions[c]={}),u.versions[c][p]==null&&(u.versions[c][p]={});let l=Kji(s.name,o),O=await Bzr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:o});O!=null&&(u.versions[c][p][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),u}async function Uhy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let c=await EDr({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(c==null||c.groups==null)){for(let p of c.groups)if(!(i!=null&&p.groupName!==i))for(let s of p.generators)n!=null&&s.name!==n||await r(a.workspaceName,p.groupName,s,u)}})}))}function Vhy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,c]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let p=dNe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(p?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:p,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function K_s({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let c=await tID({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[p,s]of Object.entries(c.versions))u.push(...Vhy(s,p,t.logger));else u.push(...Vhy(c.versions,void 0,t.logger))}return u}var _4o=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${i} ${a}`.trim(),c=u?`status code ${u}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var aQa=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Zof=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),Why=typeof globalThis.AbortController=="function",Hhy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Ghy=typeof globalThis.ReadableStream=="function",Jhy=typeof globalThis.FormData=="function",$_s=["get","post","put","patch","head","delete"],rID=()=>{};rID();var Khy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Y_s=2147483647,$hy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,X_s=Symbol("stop"),Yhy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Xhy={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 nID=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=$hy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},Zhy=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,n=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:n},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(i){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:c,value:p}=await a.read();if(c){i.close();return}if(t){n+=p.byteLength;let s=r===0?0:n/r;t({percent:s,transferredBytes:n,totalBytes:r},p)}i.enqueue(p),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},khy=(e,t,r)=>{let n=nID(r??e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(a){let u=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function c(){let{done:p,value:s}=await u.read();if(p){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(n,i)},new Uint8Array),a.close();return}i+=s.byteLength;let o=n===0?0:i/n;(n<i||o===1)&&(o=.99),t&&t({percent:Number(o.toFixed(2)),transferredBytes:i,totalBytes:n},s),a.enqueue(s),await c()}await c()}})})};var oQa=e=>e!==null&&typeof e=="object";var h4o=(...e)=>{for(let t of e)if((!oQa(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return tuf({},...e)},kof=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,u]of i.entries())n&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Z_s(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:tuf(e[r]??[],t[r]??[])}var euf=(e={},t={})=>({beforeRequest:Z_s(e,t,"beforeRequest"),beforeRetry:Z_s(e,t,"beforeRetry"),afterResponse:Z_s(e,t,"afterResponse"),beforeError:Z_s(e,t,"beforeError")}),tuf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(oQa(i)){for(let[a,u]of Object.entries(i))oQa(u)&&a in t&&(u=tuf(t[a],u)),t={...t,[a]:u};oQa(i.hooks)&&(n=euf(n,i.hooks),t.hooks=n),oQa(i.headers)&&(r=kof(r,i.headers),t.headers=r)}return t};var tyy=e=>$_s.includes(e)?e.toUpperCase():e,iID=["get","put","head","delete","options","trace"],aID=[408,413,429,500,502,503,504],oID=[413,429,503],eyy={limit:2,methods:iID,statusCodes:aID,afterStatusCodes:oID,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},ryy=(e={})=>{if(typeof e=="number")return{...eyy,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{...eyy,...e}};async function ruf(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new aQa(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function nuf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var nyy=(e,t)=>{let r={};for(let n in t)!(n in Xhy)&&!(n in Yhy)&&!(n in e)&&(r[n]=t[n]);return r},iyy=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 y4o=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>Y_s)throw new RangeError(`The \`timeout\` option cannot be greater than ${Y_s}`);await Promise.resolve();let c=await n._fetch();for(let p of n._options.hooks.afterResponse){let s=await p(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let p=new _4o(c,n.request,n._options);for(let s of n._options.hooks.beforeError)p=await s(p);throw p}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Ghy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Zhy(c.clone(),n._options.onDownloadProgress)}return c},u=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{n.request.bodyUsed||await n.request.body?.cancel()});for(let[c,p]of Object.entries(Khy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(u[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||p);let s=await u;if(c==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[c]()});return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:kof(this._input.headers,r.headers),hooks:euf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:tyy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:ryy(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(Why&&Hhy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(Zof&&(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),iyy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(Jhy&&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(!Zof)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=khy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof aQa)throw t;if(t instanceof _4o){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),Y_s);if(this._retryCount<1)throw r;await nuf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===X_s)return;return this._retry(t)}}async _fetch(){for(let n of this._options.hooks.beforeRequest){let i=await n(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=nyy(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):ruf(r,t,this.abortController,this._options)}};var iuf=e=>{let t=(r,n)=>y4o.create(r,h4o(e,n));for(let r of $_s)t[r]=(n,i)=>y4o.create(n,h4o(e,i,{method:r}));return t.create=r=>iuf(h4o(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),iuf(h4o(e,r))),t.stop=X_s,t},uID=iuf(),ayy=uID;var Dyy=$i(Syy(),1);function cuf(e){let t=(0,Dyy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Avy=$i(Ovy(),1),Pvy=$i(C4r(),1),Auf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},Puf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function wuf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??cuf(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Avy.default)(a.toString(),{recursive:!0}),p={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete p.accept,c&&(p.authorization=`${c.type} ${c.token}`);let s;try{s=await ayy(u,{headers:p,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Auf(e):l}if(t.allVersions)return s;let o=new Puf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,E]of Object.entries(s.versions))E.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=Pvy.default.maxSatisfying(A,r),!r)throw o}let{time:O}=s;if(s=s.versions[r],s.time=O,!s)throw o}return s}async function A4o(e,t){let{version:r}=await wuf(e.toLowerCase(),t);return r}async function IDi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:A4o(e.packageName,{version:t?"prerelease":"latest"})}var wvy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],lhs=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=zj.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new J_s(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(i==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.77.7"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${yd.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qae}failWithoutThrowing(t,r){this.didSucceed=!1,W_s({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await r2a()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await Lhy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2408
2408
  `)||(r+=`
2409
2409
  `),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=gCl(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new s4o(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new qae}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await r2a()).sendEvent(t)}logger=J4r((t,...r)=>this.log(t,...r));stderr=J4r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=jvy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?jvy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=wvy[this.numTasks++%wvy.length],u=yd.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===BL.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let n=t.filter(i=>oji.indexOf(i.level)>=oji.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===zj.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 IDi({cliEnvironment:this.environment,includePreReleases:t}),n=dNe(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await K_s({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await Nof({message:t,default:r})}async getInput(t){return await Rof({message:t.message,default:t.default})}};function jvy(e){return`[${e}]:`}var OCr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};var Uet=class extends OCr{definition;sources;type="fern";constructor({definition:t,sources:r,...n}){super(n),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var rli={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1};function P4o({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??rli.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??rli.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??rli.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??rli.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??rli.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??rli.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??rli.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??rli.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??rli.respectForwardCompatibleEnums}}var HOe={openapi:e=>({...e,type:"openapi",_visit:function(t){return HOe._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return HOe._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 pQa={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return pQa._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Wle={basic:e=>({...e,type:"basic",_visit:function(t){return Wle._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Wle._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Wle._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Wle._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Wle._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var FS={primitive:e=>({value:e,type:"primitive",_visit:function(t){return FS._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return FS._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return FS._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return FS._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return FS._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return FS._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return FS._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return FS._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var Mm={int:e=>({value:e,type:"int",_visit:function(t){return Mm._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return Mm._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return Mm._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return Mm._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return Mm._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return Mm._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return Mm._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return Mm._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return Mm._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return Mm._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return Mm._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 MDi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return MDi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return MDi._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 BDi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return BDi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return BDi._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 vye={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case vye.GenerallyAvailable:return t.generallyAvailable();case vye.Beta:return t.beta();case vye.Deprecated:return t.deprecated();default:return t._other()}}};var Idt={cursor:e=>({...e,type:"cursor",_visit:function(t){return Idt._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Idt._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Idt._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 nli={language:e=>({...e,type:"language",_visit:function(t){return nli._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return nli._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 bye={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 bye.Curl:return t.curl();case bye.Python:return t.python();case bye.Javascript:return t.javascript();case bye.Typescript:return t.typescript();case bye.Go:return t.go();case bye.Ruby:return t.ruby();case bye.Csharp:return t.csharp();case bye.Java:return t.java();case bye.Js:return t.js();case bye.Node:return t.node();case bye.Ts:return t.ts();case bye.Nodets:return t.nodets();case bye.Golang:return t.golang();case bye.Dotnet:return t.dotnet();case bye.Jvm:return t.jvm();default:return t._other()}}};var ACr={unknown:e=>({value:e,type:"unknown",_visit:function(t){return ACr._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return ACr._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 PCr={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return PCr._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return PCr._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 gye={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case gye.Get:return t.get();case gye.Post:return t.post();case gye.Put:return t.put();case gye.Patch:return t.patch();case gye.Delete:return t.delete();case gye.Head:return t.head();case gye.Options:return t.options();case gye.Trace:return t.trace();default:return t._other()}}};var F8r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return F8r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return F8r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return F8r._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return F8r._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 ili={file:e=>({...e,type:"file",_visit:function(t){return ili._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return ili._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 GOe={file:e=>({...e,type:"file",_visit:function(t){return GOe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return GOe._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return GOe._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return GOe._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return GOe._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return GOe._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return GOe._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 aw={primitive:e=>({...e,type:"primitive",_visit:function(t){return aw._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return aw._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return aw._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return aw._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return aw._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return aw._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return aw._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return aw._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return aw._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return aw._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return aw._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 zT={int:e=>({...e,type:"int",_visit:function(t){return zT._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return zT._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return zT._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return zT._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return zT._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return zT._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return zT._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return zT._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return zT._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return zT._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return zT._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 LV={boolean:e=>({value:e,type:"boolean",_visit:function(t){return LV._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return LV._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 ali={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return ali._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return ali._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 ASe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return ASe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return ASe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return ASe._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return ASe._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 vQ={file:e=>({...e,type:"file",_visit:function(t){return vQ._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return vQ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return vQ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return vQ._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return vQ._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return vQ._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return vQ._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 Uh={primitive:e=>({...e,type:"primitive",_visit:function(t){return Uh._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Uh._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Uh._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Uh._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Uh._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Uh._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Uh._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Uh._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Uh._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Uh._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Uh._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 PSe={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return PSe._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return PSe._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 kg={int:e=>({...e,type:"int",_visit:function(t){return kg._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return kg._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return kg._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return kg._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return kg._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return kg._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return kg._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return kg._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return kg._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return kg._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return kg._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 Pw={};hs(Pw,{AllOfPropertyConflict:()=>NQa,ArraySchema:()=>Sys,ArraySchemaWithExample:()=>ivs,Availability:()=>mhs,Base64WithExample:()=>kys,BasicSecurityScheme:()=>Phs,BearerSecurityScheme:()=>whs,BooleanSchema:()=>Oys,BooleanWithExample:()=>evs,BytesResponse:()=>SQa,CasingOverrides:()=>Shs,CommonProperty:()=>xys,CommonPropertyWithExample:()=>pvs,CursorPagination:()=>iys,CustomCodeSample:()=>rys,CustomCodeSampleLanguage:()=>khs,CustomCodeSampleSdk:()=>tys,CustomPagination:()=>oys,DateWithExample:()=>Zys,DatetimeWithExample:()=>Xys,DiscriminatedOneOfSchema:()=>Tys,DiscriminatedOneOfSchemaWithExample:()=>fvs,DoubleSchema:()=>gys,DoubleWithExample:()=>$ys,Encoding:()=>ghs,Endpoint:()=>uys,EndpointExample:()=>MQa,EndpointResponseExample:()=>Zhs,EndpointSdkName:()=>L8r,EndpointWithExample:()=>tby,EnumSchema:()=>vQa,EnumSchemaWithExample:()=>rvs,EnumValue:()=>xDi,ErrorExample:()=>Jhs,FernExample:()=>$hs,FileResponse:()=>jQa,FileSchema:()=>zhs,FloatWithExample:()=>Kys,FormUrlEncodedRequest:()=>Whs,FullEndpointExample:()=>nys,FullExample:()=>U7,FullObjectExample:()=>qhs,FullOneOfExample:()=>Nhs,GlobalHeader:()=>Pys,Header:()=>RDi,HeaderExample:()=>IQa,HeaderSecurityScheme:()=>jhs,HeaderWithExample:()=>QDi,HttpEndpointServer:()=>DQa,HttpError:()=>Khs,HttpErrorWithExample:()=>Vys,HttpMethod:()=>mQa,IdempotencyHeader:()=>wys,Int64WithExample:()=>Hys,IntSchema:()=>vys,IntWithExample:()=>Wys,JsonRequest:()=>Vhs,JsonRequestWithExample:()=>zys,JsonResponse:()=>EQa,JsonResponseWithExample:()=>zQa,KeyValuePair:()=>xhs,LiteralExample:()=>Ths,LiteralSchema:()=>xQa,LiteralSchemaValue:()=>jys,LongSchema:()=>bys,MapSchema:()=>Dys,MapSchemaWithExample:()=>avs,MultipartRequest:()=>wQa,MultipartRequestProperty:()=>Uhs,MultipartRequestPropertyEncoding:()=>Lhs,MultipartSchema:()=>Qhs,NamedFullExample:()=>Bdt,Namespace:()=>Dhs,NamespaceId:()=>Bhs,NullableSchema:()=>Iys,NullableSchemaWithExample:()=>uvs,OauthSecurityScheme:()=>Ihs,ObjectProperty:()=>Bys,ObjectPropertyConflictInfo:()=>RQa,ObjectPropertyWithExample:()=>lvs,ObjectSchema:()=>Eys,ObjectSchemaWithExample:()=>svs,OctetStreamRequest:()=>PQa,OffsetPagination:()=>ays,OneOfSchema:()=>Mys,OneOfSchemaWithExample:()=>cvs,OpenApiIntermediateRepresentation:()=>kvy,OpenApiSource:()=>hhs,OptionalSchema:()=>Cys,OptionalSchemaWithExample:()=>ovs,Pagination:()=>BQa,ParseFormUrlEncodedRequest:()=>Qys,ParseMultipartRequest:()=>Fys,ParseOctetStreamRequest:()=>Rys,PathParameter:()=>OQa,PathParameterExample:()=>Yhs,PathParameterWithExample:()=>Nys,PrimitiveExample:()=>gQa,PrimitiveSchema:()=>zDi,PrimitiveSchemaValue:()=>Ays,PrimitiveSchemaValueWithExample:()=>tvs,PrimitiveSchemaWithExample:()=>QQa,PropertyKey:()=>bQa,ProtobufEncoding:()=>bhs,ProtobufSource:()=>yhs,QueryParameter:()=>AQa,QueryParameterExample:()=>CQa,QueryParameterWithExample:()=>FQa,QuerySecurityScheme:()=>Ehs,ReferencedSchema:()=>U8r,Request:()=>Hhs,RequestWithExample:()=>Lys,Response:()=>Ghs,ResponseWithExample:()=>Uys,Schema:()=>fC,SchemaId:()=>wSe,SchemaWithExample:()=>j4,Schemas:()=>yys,SdkGroup:()=>Chs,SdkGroupInfo:()=>Rhs,SdkGroupName:()=>NDi,SecurityScheme:()=>Mhs,SecuritySchemeId:()=>Ahs,Server:()=>S4o,Source:()=>vhs,StatusCode:()=>z8r,StreamingResponseExample:()=>Xhs,StringSchema:()=>mys,StringSchemaWithExample:()=>Yys,SupportedSdkLanguage:()=>eys,Tag:()=>Ohs,TagId:()=>jSe,Tags:()=>Fhs,TextResponse:()=>FDi,Uint64WithExample:()=>Jys,UintWithExample:()=>Gys,UnDiscriminatedOneOfSchema:()=>qys,UnDiscriminatedOneOfSchemaWithExample:()=>dvs,UnknownSchemaWithExample:()=>nvs,Webhook:()=>sys,WebhookExampleCall:()=>qQa,WebhookHttpMethod:()=>TQa,WebhookWithExample:()=>rby,WebsocketChannel:()=>hys,WebsocketHandshake:()=>cys,WebsocketHandshakeWithExample:()=>eby,WebsocketMessageExample:()=>pys,WebsocketMessageOrigin:()=>lys,WebsocketMessageSchema:()=>fys,WebsocketServer:()=>dys,WebsocketSessionExample:()=>_ys,WithAvailability:()=>xA,WithDescription:()=>By,WithEncoding:()=>hNe,WithInline:()=>w4,WithName:()=>XE,WithNamespace:()=>fE,WithSdkGroupName:()=>aI,WithSdkMethodName:()=>Q8r,WithSource:()=>tA,WithStatusCode:()=>Mdt,WithTitle:()=>iI,commons:()=>Cuf,example:()=>Iuf,finalIr:()=>Muf,parseIr:()=>Buf});var Cuf={};hs(Cuf,{BasicSecurityScheme:()=>Phs,BearerSecurityScheme:()=>whs,Encoding:()=>ghs,HeaderSecurityScheme:()=>jhs,Namespace:()=>Dhs,NamespaceId:()=>Bhs,OauthSecurityScheme:()=>Ihs,OpenApiSource:()=>hhs,ProtobufEncoding:()=>bhs,ProtobufSource:()=>yhs,QuerySecurityScheme:()=>Ehs,SchemaId:()=>wSe,SdkGroup:()=>Chs,SdkGroupName:()=>NDi,SecurityScheme:()=>Mhs,SecuritySchemeId:()=>Ahs,Server:()=>S4o,Source:()=>vhs,StatusCode:()=>z8r,Tag:()=>Ohs,TagId:()=>jSe,WithAvailability:()=>xA,WithDescription:()=>By,WithEncoding:()=>hNe,WithInline:()=>w4,WithName:()=>XE,WithNamespace:()=>fE,WithSdkGroupName:()=>aI,WithSdkMethodName:()=>Q8r,WithSource:()=>tA,WithStatusCode:()=>Mdt,WithTitle:()=>iI});var Wr={};hs(Wr,{JsonError:()=>_Qa,ParseError:()=>hQa,any:()=>Qvy,bigint:()=>Svy,boolean:()=>Lvy,booleanLiteral:()=>zvy,date:()=>Dvy,discriminant:()=>Yvy,enum_:()=>dhs,getObjectLikeUtils:()=>wCr,getObjectUtils:()=>v$i,getSchemaUtils:()=>L7,isProperty:()=>qDi,lazy:()=>Cvy,lazyObject:()=>Nvy,list:()=>_hs,number:()=>Uvy,object:()=>phs,objectWithoutOptionalProperties:()=>xvy,optional:()=>juf,property:()=>Mvy,record:()=>Gvy,set:()=>Jvy,string:()=>Vvy,stringLiteral:()=>Fvy,transform:()=>Euf,undiscriminatedUnion:()=>$vy,union:()=>Zvy,unknown:()=>Wvy,withParsedProperties:()=>Duf});var iT={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 Pz(e,t){return`Expected ${t}. Received ${pMD(e)}.`}function pMD(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 Hle(e){return{...e,json:Evy(e.json),parse:Evy(e.parse)}}function Evy(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
2410
2410
  `)),{ok:!0,value:t}):n}}function fhs(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var _Qa=class e extends Error{errors;constructor(t){super(t.map(fhs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var hQa=class e extends Error{errors;constructor(t){super(t.map(fhs).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function L7(e){return{optional:()=>juf(e),transform:t=>Euf(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new hQa(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new _Qa(n.errors)}}}function juf(e){let t={parse:(r,n)=>r==null?{ok:!0,value:void 0}:e.parse(r,n),json:(r,n)=>n?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,n),getType:()=>iT.OPTIONAL};return{...t,...L7(t)}}function Euf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(n,i)=>{let a=t.untransform(n);return e.json(a,i)},getType:()=>e.getType()};return{...r,...L7(r)}}function Svy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Pz(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:Pz(t,"bigint")}]},getType:()=>iT.BIGINT};return{...Hle(e),...L7(e)}}var _MD=/^([+-]?\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 Dvy(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Pz(t,"string")}]}:_MD.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Pz(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Pz(t,"Date object")}]},getType:()=>iT.DATE};return{...Hle(e),...L7(e)}}function JOe(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...Hle(r),...L7(r)}}}function dhs(e){let t=new Set(e);return JOe(iT.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Pz(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Pz(n,"enum")}]}:{ok:!0,value:n})()}function Cvy(e){let t=Suf(e);return{...t,...L7(t)}}function Suf(e){return{parse:(t,r)=>yQa(e).parse(t,r),json:(t,r)=>yQa(e).json(t,r),getType:()=>yQa(e).getType()}}function yQa(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function w4o(e){return Object.entries(e)}function j4o(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function TDi(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 E4o(e){return Object.keys(e)}function Ivy(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function wCr(e){return{withParsedProperties:t=>Duf(e,t)}}function Duf(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((c,[p,s])=>({...c,[p]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!TDi(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Pz(n,"object")}]};let a=new Set(Object.keys(t)),u=j4o(n,Object.keys(n).filter(c=>!a.has(c)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...L7(r),...wCr(r)}}function Mvy(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function qDi(e){return e.isProperty}function phs(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>qDi(n)?n.rawKey:r),_getParsedProperties:()=>E4o(e),parse:(r,n)=>{let i={},a=[];for(let[u,c]of w4o(e)){let p=qDi(c)?c.rawKey:u,s=qDi(c)?c.valueSchema:c,o={rawKey:p,parsedKey:u,valueSchema:s};i[p]=o,qvy(s)&&a.push(p)}return Bvy({value:r,requiredKeys:a,getProperty:u=>{let c=i[u];if(c!=null)return{transformedKey:c.parsedKey,transform:p=>c.valueSchema.parse(p,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},json:(r,n)=>{let i=[];for(let[a,u]of w4o(e)){let c=qDi(u)?u.valueSchema:u;qvy(c)&&i.push(a)}return Bvy({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return qDi(u)?{transformedKey:u.rawKey,transform:c=>u.valueSchema.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>u.json(c,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>iT.OBJECT};return{...Hle(t),...L7(t),...wCr(t),...v$i(t)}}function Bvy({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!TDi(e))return{ok:!1,errors:[{path:a,message:Pz(e,"object")}]};let u=new Set(t),c=[],p={};for(let[s,o]of Object.entries(e)){let l=r(s);if(l!=null){u.delete(s);let O=l.transform(o);O.ok?p[l.transformedKey]=O.value:(p[s]=o,c.push(...O.errors))}else switch(n){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":p[s]=o;break}}return c.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||i?{ok:!0,value:p}:{ok:!1,errors:c}}function v$i(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>Tvy({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>Tvy({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>iT.OBJECT};return{...r,...L7(r),...wCr(r),...v$i(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,n)=>{let i=e.parse(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},json:(r,n)=>{let i=e.json(r,{...n,unrecognizedObjectKeys:"passthrough"});return i.ok?{ok:!0,value:{...r,...i.value}}:i},getType:()=>iT.OBJECT};return{...t,...L7(t),...wCr(t),...v$i(t)}}}}function Tvy({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=Ivy(E4o(t),s=>i.has(s)),c=r(j4o(t,u)),p=n(j4o(t,a));return c.ok&&p.ok?{ok:!0,value:{...c.value,...p.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...p.ok?[]:p.errors]}}function qvy(e){return!hMD(e)}function hMD(e){switch(e.getType()){case iT.ANY:case iT.UNKNOWN:case iT.OPTIONAL:return!0;default:return!1}}function xvy(e){return phs(e)}function Nvy(e){let t={...Suf(e),_getRawProperties:()=>yQa(e)._getRawProperties(),_getParsedProperties:()=>yQa(e)._getParsedProperties()};return{...t,...L7(t),...wCr(t),...v$i(t)}}function _hs(e){let t={parse:(r,n)=>Rvy(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>Rvy(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>iT.LIST};return{...Hle(t),...L7(t)}}function Rvy(e,t){return Array.isArray(e)?e.map((n,i)=>t(n,i)).reduce((n,i)=>{if(n.ok&&i.ok)return{ok:!0,value:[...n.value,i.value]};let a=[];return n.ok||a.push(...n.errors),i.ok||a.push(...i.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:Pz(e,"list"),path:[]}]}}function Fvy(e){return JOe(iT.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Pz(r,`"${e}"`)}]})()}function zvy(e){return JOe(iT.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Pz(r,`${e.toString()}`)}]})()}var Qvy=JOe(iT.ANY,e=>({ok:!0,value:e}));var Lvy=JOe(iT.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Pz(e,"boolean")}]});var Uvy=JOe(iT.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Pz(e,"number")}]});var Vvy=JOe(iT.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Pz(e,"string")}]});var Wvy=JOe(iT.UNKNOWN,e=>({ok:!0,value:e}));function Gvy(e,t){let r={parse:(n,i)=>Hvy({value:n,isKeyNumeric:e.getType()===iT.NUMBER,transformKey:a=>e.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),json:(n,i)=>Hvy({value:n,isKeyNumeric:e.getType()===iT.NUMBER,transformKey:a=>e.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:i?.breadcrumbsPrefix}),getType:()=>iT.RECORD};return{...Hle(r),...L7(r)}}function Hvy({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return TDi(e)?w4o(e).reduce((a,[u,c])=>{if(c==null)return a;let p=a,s=u;if(t){let A=u.length>0?Number(u):NaN;isNaN(A)||(s=A)}let o=r(s),l=n(c,s);if(p.ok&&o.ok&&l.ok)return{ok:!0,value:{...p.value,[o.value]:l.value}};let O=[];return p.ok||O.push(...p.errors),o.ok||O.push(...o.errors),l.ok||O.push(...l.errors),{ok:!1,errors:O}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Pz(e,"object")}]}}function Jvy(e){let t=_hs(e),r={parse:(n,i)=>{let a=t.parse(n,i);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(n,i)=>n instanceof Set?t.json([...n],i):{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Pz(n,"Set")}]},getType:()=>iT.SET};return{...Hle(r),...L7(r)}}function $vy(e){let t={parse:(r,n)=>Kvy((i,a)=>i.parse(r,a),e,n),json:(r,n)=>Kvy((i,a)=>i.json(r,a),e,n),getType:()=>iT.UNDISCRIMINATED_UNION};return{...Hle(t),...L7(t)}}function Kvy(e,t,r){let n=[];for(let[i,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let c of u.errors)n.push({path:c.path,message:`[Variant ${i}] ${c.message}`})}return{ok:!1,errors:n}}function Yvy(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Zvy(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=dhs(E4o(t)),a={parse:(u,c)=>Xvy({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:p=>i.parse(p,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:p=>t[p],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(p,s)=>s.parse(p,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(u,c)=>Xvy({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:p=>i.json(p,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:p=>t[p],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(p,s)=>s.json(p,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>iT.UNION};return{...Hle(a),...L7(a),...wCr(a)}}function Xvy({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:c=[]}){if(!TDi(e))return{ok:!1,errors:[{path:c,message:Pz(e,"object")}]};let{[t]:p,...s}=e;if(p==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let o=n(p);if(!o.ok)return{ok:!1,errors:o.errors};let l=i(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let O=u(s,l);return O.ok?{ok:!0,value:{[r]:p,...O.value}}:O}var iI=Wr.objectWithoutOptionalProperties({title:Wr.string().optional()});var hhs=Wr.objectWithoutOptionalProperties({file:Wr.string()});var yhs=Wr.objectWithoutOptionalProperties({file:Wr.string()});var vhs=Wr.union("type",{openapi:hhs,protobuf:yhs}).transform({transform:e=>{switch(e.type){case"openapi":return HOe.openapi(e);case"protobuf":return HOe.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var tA=Wr.objectWithoutOptionalProperties({source:vhs.optional()});var bhs=Wr.objectWithoutOptionalProperties({typeName:Wr.string()});var ghs=Wr.union("type",{protobuf:bhs}).transform({transform:e=>{switch(e.type){case"protobuf":return pQa.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var hNe=Wr.objectWithoutOptionalProperties({encoding:ghs.optional()});var By=Wr.objectWithoutOptionalProperties({description:Wr.string().optional()});var mhs=Wr.enum_(["GenerallyAvailable","Beta","Deprecated"]);var xA=Wr.objectWithoutOptionalProperties({availability:mhs.optional()});var z8r=Wr.number();var Mdt=Wr.objectWithoutOptionalProperties({statusCode:z8r.optional()});var XE=Wr.objectWithoutOptionalProperties({nameOverride:Wr.string().optional(),generatedName:Wr.string()});var w4=Wr.objectWithoutOptionalProperties({inline:Wr.boolean().optional()});var wSe=Wr.string();var jSe=Wr.string();var Ohs=Wr.objectWithoutOptionalProperties({id:jSe}).extend(By);var Ahs=Wr.string();var Phs=Wr.objectWithoutOptionalProperties({usernameVariableName:Wr.string().optional(),usernameEnvVar:Wr.string().optional(),passwordVariableName:Wr.string().optional(),passwordEnvVar:Wr.string().optional()});var whs=Wr.objectWithoutOptionalProperties({tokenVariableName:Wr.string().optional(),tokenEnvVar:Wr.string().optional()});var jhs=Wr.objectWithoutOptionalProperties({headerName:Wr.string(),prefix:Wr.string().optional(),headerVariableName:Wr.string().optional(),headerEnvVar:Wr.string().optional()});var Ehs=Wr.objectWithoutOptionalProperties({queryParameterName:Wr.string()});var Shs=Wr.objectWithoutOptionalProperties({snake:Wr.string().optional(),camel:Wr.string().optional(),screamingSnake:Wr.string().optional(),pascal:Wr.string().optional()});var xDi=Wr.objectWithoutOptionalProperties({nameOverride:Wr.string().optional(),generatedName:Wr.string(),value:Wr.string(),casing:Shs.optional()}).extend(By).extend(xA);var Dhs=Wr.objectWithoutOptionalProperties({type:Wr.stringLiteral("namespace"),name:Wr.string()});var Chs=Wr.undiscriminatedUnion([Wr.string(),Dhs]);var NDi=Wr.list(Chs);var aI=Wr.objectWithoutOptionalProperties({groupName:NDi.optional()});var fE=Wr.objectWithoutOptionalProperties({namespace:Wr.string().optional()});var vQa=Wr.objectWithoutOptionalProperties({default:xDi.optional(),values:Wr.list(xDi)}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(tA).extend(iI).extend(w4);var Ihs=Wr.objectWithoutOptionalProperties({scopesEnum:vQa.optional()});var Mhs=Wr.union("type",{basic:Phs,bearer:whs,header:jhs,query:Ehs,oauth:Ihs}).transform({transform:e=>{switch(e.type){case"basic":return Wle.basic(e);case"bearer":return Wle.bearer(e);case"header":return Wle.header(e);case"query":return Wle.query(e);case"oauth":return Wle.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var S4o=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),url:Wr.string(),audiences:Wr.list(Wr.string()).optional()}).extend(By);var Bhs=Wr.string();var Q8r=Wr.objectWithoutOptionalProperties({sdkMethodName:Wr.string().optional()});var Iuf={};hs(Iuf,{FullExample:()=>U7,FullObjectExample:()=>qhs,FullOneOfExample:()=>Nhs,KeyValuePair:()=>xhs,LiteralExample:()=>Ths,PrimitiveExample:()=>gQa,PropertyKey:()=>bQa});var bQa=Wr.string();var gQa=Wr.union("type",{int:Wr.object({value:Wr.number()}),int64:Wr.object({value:Wr.number()}),uint:Wr.object({value:Wr.number()}),uint64:Wr.object({value:Wr.number()}),float:Wr.object({value:Wr.number()}),double:Wr.object({value:Wr.number()}),string:Wr.object({value:Wr.string()}),datetime:Wr.object({value:Wr.string()}),date:Wr.object({value:Wr.string()}),base64:Wr.object({value:Wr.string()}),boolean:Wr.object({value:Wr.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return Mm.int(e.value);case"int64":return Mm.int64(e.value);case"uint":return Mm.uint(e.value);case"uint64":return Mm.uint64(e.value);case"float":return Mm.float(e.value);case"double":return Mm.double(e.value);case"string":return Mm.string(e.value);case"datetime":return Mm.datetime(e.value);case"date":return Mm.date(e.value);case"base64":return Mm.base64(e.value);case"boolean":return Mm.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Ths=Wr.union("type",{boolean:Wr.object({value:Wr.boolean()}),string:Wr.object({value:Wr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return MDi.boolean(e.value);case"string":return MDi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var U7=Wr.union("type",{primitive:Wr.object({value:gQa}),object:Wr.lazyObject(()=>qhs),array:Wr.object({value:Wr.list(Wr.lazy(()=>U7))}),map:Wr.object({value:Wr.list(Wr.lazyObject(()=>xhs))}),enum:Wr.object({value:Wr.string()}),literal:Wr.object({value:Ths}),oneOf:Wr.object({value:Wr.lazy(()=>Nhs)}),unknown:Wr.object({value:Wr.lazy(()=>U7)})}).transform({transform:e=>{switch(e.type){case"primitive":return FS.primitive(e.value);case"object":return FS.object(e);case"array":return FS.array(e.value);case"map":return FS.map(e.value);case"enum":return FS.enum(e.value);case"literal":return FS.literal(e.value);case"oneOf":return FS.oneOf(e.value);case"unknown":return FS.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var qhs=Wr.objectWithoutOptionalProperties({properties:Wr.record(bQa,Wr.lazy(()=>U7))});var xhs=Wr.objectWithoutOptionalProperties({key:gQa,value:Wr.lazy(()=>U7)});var Nhs=Wr.union("type",{discriminated:Wr.object({value:Wr.record(bQa,Wr.lazy(()=>U7))}),undiscriminated:Wr.object({value:Wr.lazy(()=>U7)})}).transform({transform:e=>{switch(e.type){case"discriminated":return BDi.discriminated(e.value);case"undiscriminated":return BDi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Muf={};hs(Muf,{AllOfPropertyConflict:()=>NQa,ArraySchema:()=>Sys,Availability:()=>mhs,BooleanSchema:()=>Oys,BytesResponse:()=>SQa,CasingOverrides:()=>Shs,CommonProperty:()=>xys,CursorPagination:()=>iys,CustomCodeSample:()=>rys,CustomCodeSampleLanguage:()=>khs,CustomCodeSampleSdk:()=>tys,CustomPagination:()=>oys,DiscriminatedOneOfSchema:()=>Tys,DoubleSchema:()=>gys,Endpoint:()=>uys,EndpointExample:()=>MQa,EndpointResponseExample:()=>Zhs,EndpointSdkName:()=>L8r,EnumSchema:()=>vQa,EnumValue:()=>xDi,ErrorExample:()=>Jhs,FernExample:()=>$hs,FileResponse:()=>jQa,FileSchema:()=>zhs,FormUrlEncodedRequest:()=>Whs,FullEndpointExample:()=>nys,GlobalHeader:()=>Pys,Header:()=>RDi,HeaderExample:()=>IQa,HttpEndpointServer:()=>DQa,HttpError:()=>Khs,HttpMethod:()=>mQa,IdempotencyHeader:()=>wys,IntSchema:()=>vys,JsonRequest:()=>Vhs,JsonResponse:()=>EQa,LiteralSchema:()=>xQa,LiteralSchemaValue:()=>jys,LongSchema:()=>bys,MapSchema:()=>Dys,MultipartRequest:()=>wQa,MultipartRequestProperty:()=>Uhs,MultipartRequestPropertyEncoding:()=>Lhs,MultipartSchema:()=>Qhs,NullableSchema:()=>Iys,ObjectProperty:()=>Bys,ObjectPropertyConflictInfo:()=>RQa,ObjectSchema:()=>Eys,OctetStreamRequest:()=>PQa,OffsetPagination:()=>ays,OneOfSchema:()=>Mys,OpenApiIntermediateRepresentation:()=>kvy,OptionalSchema:()=>Cys,Pagination:()=>BQa,PathParameter:()=>OQa,PathParameterExample:()=>Yhs,PrimitiveSchema:()=>zDi,PrimitiveSchemaValue:()=>Ays,QueryParameter:()=>AQa,QueryParameterExample:()=>CQa,ReferencedSchema:()=>U8r,Request:()=>Hhs,Response:()=>Ghs,Schema:()=>fC,Schemas:()=>yys,SdkGroupInfo:()=>Rhs,StreamingResponseExample:()=>Xhs,StringSchema:()=>mys,SupportedSdkLanguage:()=>eys,Tags:()=>Fhs,TextResponse:()=>FDi,UnDiscriminatedOneOfSchema:()=>qys,Webhook:()=>sys,WebhookExampleCall:()=>qQa,WebhookHttpMethod:()=>TQa,WebsocketChannel:()=>hys,WebsocketHandshake:()=>cys,WebsocketMessageExample:()=>pys,WebsocketMessageOrigin:()=>lys,WebsocketMessageSchema:()=>fys,WebsocketServer:()=>dys,WebsocketSessionExample:()=>_ys});var Rhs=Wr.objectWithoutOptionalProperties({summary:Wr.string().optional(),description:Wr.string().optional()});var Fhs=Wr.objectWithoutOptionalProperties({tagsById:Wr.record(jSe,Ohs),orderedTagIds:Wr.list(jSe).optional()});var mQa=Wr.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var OQa=Wr.objectWithoutOptionalProperties({name:Wr.string(),schema:Wr.lazy(()=>fC),variableReference:Wr.string().optional(),parameterNameOverride:Wr.string().optional()}).extend(By).extend(xA).extend(tA);var AQa=Wr.objectWithoutOptionalProperties({name:Wr.string(),schema:Wr.lazy(()=>fC),parameterNameOverride:Wr.string().optional()}).extend(By).extend(xA).extend(tA);var RDi=Wr.objectWithoutOptionalProperties({name:Wr.string(),schema:Wr.lazy(()=>fC),env:Wr.string().optional(),parameterNameOverride:Wr.string().optional()}).extend(By).extend(xA).extend(tA);var L8r=Wr.objectWithoutOptionalProperties({groupName:NDi,methodName:Wr.string()});var PQa=Wr.objectWithoutOptionalProperties({contentType:Wr.string().optional()}).extend(By).extend(tA);var zhs=Wr.objectWithoutOptionalProperties({isOptional:Wr.boolean(),isArray:Wr.boolean()}).extend(By);var Qhs=Wr.union("type",{file:zhs,json:Wr.object({value:Wr.lazy(()=>fC)})}).transform({transform:e=>{switch(e.type){case"file":return ili.file(e);case"json":return ili.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Lhs=Wr.enum_(["json","form"]);var Uhs=Wr.objectWithoutOptionalProperties({key:Wr.string(),schema:Qhs,contentType:Wr.string().optional(),exploded:Wr.boolean().optional(),encoding:Lhs.optional()}).extend(By);var wQa=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),properties:Wr.list(Uhs)}).extend(By).extend(tA);var Vhs=Wr.objectWithoutOptionalProperties({schema:Wr.lazy(()=>fC),contentType:Wr.string().optional(),additionalProperties:Wr.boolean()}).extend(By).extend(tA);var Whs=Wr.objectWithoutOptionalProperties({schema:Wr.lazy(()=>fC),contentType:Wr.string().optional(),additionalProperties:Wr.boolean()}).extend(By).extend(tA);var Hhs=Wr.union("type",{octetStream:PQa,multipart:wQa,json:Vhs,formUrlEncoded:Whs}).transform({transform:e=>{switch(e.type){case"octetStream":return F8r.octetStream(e);case"multipart":return F8r.multipart(e);case"json":return F8r.json(e);case"formUrlEncoded":return F8r.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var jQa=Wr.objectWithoutOptionalProperties({}).extend(By).extend(tA).extend(Mdt);var EQa=Wr.objectWithoutOptionalProperties({schema:Wr.lazy(()=>fC),responseProperty:Wr.string().optional()}).extend(By).extend(tA).extend(Mdt);var FDi=Wr.objectWithoutOptionalProperties({}).extend(By).extend(tA).extend(Mdt);var SQa=Wr.objectWithoutOptionalProperties({}).extend(By).extend(tA).extend(Mdt);var Ghs=Wr.union("type",{file:jQa,json:EQa,text:FDi,bytes:SQa,streamingSse:EQa,streamingText:FDi,streamingJson:EQa}).transform({transform:e=>{switch(e.type){case"file":return GOe.file(e);case"json":return GOe.json(e);case"text":return GOe.text(e);case"bytes":return GOe.bytes(e);case"streamingSse":return GOe.streamingSse(e);case"streamingText":return GOe.streamingText(e);case"streamingJson":return GOe.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jhs=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),description:Wr.string().optional(),example:Wr.lazy(()=>U7)});var Khs=Wr.objectWithoutOptionalProperties({schema:Wr.lazy(()=>fC).optional(),examples:Wr.list(Jhs).optional()}).extend(By).extend(XE).extend(tA);var DQa=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),url:Wr.string().optional(),audiences:Wr.list(Wr.string()).optional()});var $hs=Wr.unknown();var Yhs=Wr.objectWithoutOptionalProperties({name:Wr.string(),parameterNameOverride:Wr.string().optional(),value:Wr.lazy(()=>U7)});var CQa=Wr.objectWithoutOptionalProperties({name:Wr.string(),value:Wr.lazy(()=>U7)});var IQa=Wr.objectWithoutOptionalProperties({name:Wr.string(),value:Wr.lazy(()=>U7)});var Xhs=Wr.objectWithoutOptionalProperties({sse:Wr.boolean(),events:Wr.list(Wr.lazy(()=>U7))});var Zhs=Wr.union("type",{withStreaming:Xhs,withoutStreaming:Wr.object({value:Wr.lazy(()=>U7)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return PCr.withStreaming(e);case"withoutStreaming":return PCr.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var khs=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),language:Wr.string(),code:Wr.string(),install:Wr.string().optional()}).extend(By);var eys=Wr.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var tys=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),sdk:eys,code:Wr.string()}).extend(By);var rys=Wr.union("type",{language:khs,sdk:tys}).transform({transform:e=>{switch(e.type){case"language":return nli.language(e);case"sdk":return nli.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var nys=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),pathParameters:Wr.list(Yhs).optional(),queryParameters:Wr.list(CQa).optional(),headers:Wr.list(IQa).optional(),request:Wr.lazy(()=>U7).optional(),response:Zhs.optional(),codeSamples:Wr.list(rys)}).extend(By);var MQa=Wr.union("type",{unknown:Wr.object({value:$hs}),full:nys}).transform({transform:e=>{switch(e.type){case"unknown":return ACr.unknown(e.value);case"full":return ACr.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var iys=Wr.objectWithoutOptionalProperties({cursor:Wr.string(),nextCursor:Wr.property("next_cursor",Wr.string()),results:Wr.string()});var ays=Wr.objectWithoutOptionalProperties({offset:Wr.string(),results:Wr.string(),step:Wr.string().optional(),hasNextPage:Wr.string().optional()});var oys=Wr.objectWithoutOptionalProperties({results:Wr.string()});var BQa=Wr.union("type",{cursor:iys,offset:ays,custom:oys}).transform({transform:e=>{switch(e.type){case"cursor":return Idt.cursor(e);case"offset":return Idt.offset(e);case"custom":return Idt.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var uys=Wr.objectWithoutOptionalProperties({authed:Wr.boolean(),internal:Wr.boolean().optional(),idempotent:Wr.boolean().optional(),method:mQa,audiences:Wr.list(Wr.string()),path:Wr.string(),summary:Wr.string().optional(),operationId:Wr.string().optional(),tags:Wr.list(jSe),pathParameters:Wr.list(OQa),queryParameters:Wr.list(AQa),headers:Wr.list(RDi),sdkName:L8r.optional(),generatedRequestName:Wr.string(),requestNameOverride:Wr.string().optional(),request:Hhs.optional(),response:Ghs.optional(),errors:Wr.record(z8r,Khs),servers:Wr.list(DQa),examples:Wr.list(MQa),pagination:BQa.optional()}).extend(By).extend(xA).extend(tA).extend(fE);var TQa=Wr.enum_(["GET","POST"]);var qQa=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),payload:Wr.lazy(()=>U7)}).extend(By);var sys=Wr.objectWithoutOptionalProperties({audiences:Wr.list(Wr.string()),sdkName:L8r.optional(),method:TQa,summary:Wr.string().optional(),operationId:Wr.string(),tags:Wr.list(jSe),headers:Wr.list(RDi),generatedPayloadName:Wr.string(),payload:Wr.lazy(()=>fC),examples:Wr.list(qQa)}).extend(By).extend(tA).extend(fE);var cys=Wr.objectWithoutOptionalProperties({queryParameters:Wr.list(AQa),headers:Wr.list(RDi),pathParameters:Wr.list(OQa)});var lys=Wr.enum_(["client","server"]);var fys=Wr.objectWithoutOptionalProperties({name:Wr.string(),origin:lys,body:Wr.lazy(()=>fC)});var dys=Wr.objectWithoutOptionalProperties({name:Wr.string(),url:Wr.string()});var pys=Wr.objectWithoutOptionalProperties({messageType:Wr.string(),payload:Wr.lazy(()=>U7)}).extend(By);var _ys=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),queryParameters:Wr.list(CQa).optional(),headers:Wr.list(IQa).optional(),messages:Wr.list(pys)}).extend(By);var hys=Wr.objectWithoutOptionalProperties({audiences:Wr.list(Wr.string()),path:Wr.string(),groupName:NDi,summary:Wr.string().optional(),handshake:cys,messages:Wr.list(fys),servers:Wr.list(dys),examples:Wr.list(_ys)}).extend(By).extend(tA);var yys=Wr.objectWithoutOptionalProperties({rootSchemas:Wr.record(wSe,Wr.lazy(()=>fC)),namespacedSchemas:Wr.record(Bhs,Wr.record(wSe,Wr.lazy(()=>fC)))});var vys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional(),minimum:Wr.number().optional(),maximum:Wr.number().optional(),exclusiveMinimum:Wr.boolean().optional(),exclusiveMaximum:Wr.boolean().optional(),multipleOf:Wr.number().optional()});var bys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional()});var gys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional(),minimum:Wr.number().optional(),maximum:Wr.number().optional(),exclusiveMinimum:Wr.boolean().optional(),exclusiveMaximum:Wr.boolean().optional(),multipleOf:Wr.number().optional()});var mys=Wr.objectWithoutOptionalProperties({default:Wr.string().optional(),pattern:Wr.string().optional(),format:Wr.string().optional(),minLength:Wr.number().optional(),maxLength:Wr.number().optional()});var Oys=Wr.objectWithoutOptionalProperties({default:Wr.boolean().optional()});var Ays=Wr.union("type",{int:vys,int64:bys,uint:Wr.object({}),uint64:Wr.object({}),float:Wr.object({}),double:gys,string:mys,datetime:Wr.object({}),date:Wr.object({}),base64:Wr.object({}),boolean:Oys}).transform({transform:e=>{switch(e.type){case"int":return zT.int(e);case"int64":return zT.int64(e);case"uint":return zT.uint();case"uint64":return zT.uint64();case"float":return zT.float();case"double":return zT.double(e);case"string":return zT.string(e);case"datetime":return zT.datetime();case"date":return zT.date();case"base64":return zT.base64();case"boolean":return zT.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var zDi=Wr.objectWithoutOptionalProperties({schema:Ays}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI);var Pys=Wr.objectWithoutOptionalProperties({header:Wr.string(),name:Wr.string().optional(),optional:Wr.boolean().optional(),env:Wr.string().optional(),schema:Wr.lazy(()=>fC).optional()});var wys=Wr.objectWithoutOptionalProperties({header:Wr.string(),name:Wr.string().optional(),env:Wr.string().optional(),schema:Wr.lazy(()=>fC).optional()});var kvy=Wr.objectWithoutOptionalProperties({apiVersion:Wr.unknown().optional(),title:Wr.string().optional(),description:Wr.string().optional(),basePath:Wr.string().optional(),servers:Wr.list(S4o),websocketServers:Wr.list(S4o),groups:Wr.record(Wr.string(),Rhs),tags:Fhs,hasEndpointsMarkedInternal:Wr.boolean(),endpoints:Wr.list(uys),webhooks:Wr.list(sys),channels:Wr.record(Wr.string(),hys),groupedSchemas:yys,variables:Wr.record(Wr.string(),zDi),nonRequestReferencedSchemas:Wr.set(wSe),securitySchemes:Wr.record(Ahs,Mhs),globalHeaders:Wr.list(Pys).optional(),idempotencyHeaders:Wr.list(wys).optional()});var U8r=Wr.objectWithoutOptionalProperties({schema:wSe}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(tA).extend(iI);var jys=Wr.union("type",{boolean:Wr.object({value:Wr.boolean()}),string:Wr.object({value:Wr.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return LV.boolean(e.value);case"string":return LV.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var xQa=Wr.objectWithoutOptionalProperties({value:jys}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI);var fC=Wr.union("type",{primitive:zDi,object:Wr.lazyObject(()=>Eys),array:Wr.lazyObject(()=>Sys),map:Wr.lazyObject(()=>Dys),optional:Wr.lazyObject(()=>Cys),enum:vQa,reference:U8r,literal:xQa,oneOf:Wr.object({value:Wr.lazy(()=>Mys)}),nullable:Wr.lazyObject(()=>Iys),unknown:XE}).transform({transform:e=>{switch(e.type){case"primitive":return aw.primitive(e);case"object":return aw.object(e);case"array":return aw.array(e);case"map":return aw.map(e);case"optional":return aw.optional(e);case"enum":return aw.enum(e);case"reference":return aw.reference(e);case"literal":return aw.literal(e);case"oneOf":return aw.oneOf(e.value);case"nullable":return aw.nullable(e);case"unknown":return aw.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var NQa=Wr.objectWithoutOptionalProperties({propertyKey:Wr.string(),allOfSchemaIds:Wr.list(wSe),conflictingTypeSignatures:Wr.boolean()});var Eys=Wr.objectWithoutOptionalProperties({allOf:Wr.list(U8r),properties:Wr.list(Wr.lazyObject(()=>Bys)),allOfPropertyConflicts:Wr.list(NQa),additionalProperties:Wr.boolean()}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(tA).extend(iI).extend(w4);var RQa=Wr.objectWithoutOptionalProperties({differentSchema:Wr.boolean()});var Bys=Wr.objectWithoutOptionalProperties({key:Wr.string(),schema:Wr.lazy(()=>fC),readonly:Wr.boolean().optional(),writeonly:Wr.boolean().optional(),conflict:Wr.record(wSe,RQa),generatedName:Wr.string(),nameOverride:Wr.string().optional(),audiences:Wr.list(Wr.string())}).extend(xA);var Sys=Wr.objectWithoutOptionalProperties({value:Wr.lazy(()=>fC)}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI).extend(w4);var Dys=Wr.objectWithoutOptionalProperties({key:zDi,value:Wr.lazy(()=>fC)}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(hNe).extend(iI).extend(w4);var Cys=Wr.objectWithoutOptionalProperties({value:Wr.lazy(()=>fC)}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI).extend(w4);var Iys=Wr.objectWithoutOptionalProperties({value:Wr.lazy(()=>fC)}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI).extend(w4);var Mys=Wr.union("type",{discriminated:Wr.lazyObject(()=>Tys),undiscriminated:Wr.lazyObject(()=>qys)}).transform({transform:e=>{switch(e.type){case"discriminated":return ali.discriminated(e);case"undiscriminated":return ali.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Tys=Wr.objectWithoutOptionalProperties({discriminantProperty:Wr.string(),commonProperties:Wr.list(Wr.lazyObject(()=>xys)),schemas:Wr.record(Wr.string(),Wr.lazy(()=>fC))}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(hNe).extend(tA).extend(iI).extend(w4);var xys=Wr.objectWithoutOptionalProperties({key:Wr.string(),schema:Wr.lazy(()=>fC)});var qys=Wr.objectWithoutOptionalProperties({schemas:Wr.list(Wr.lazy(()=>fC))}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(hNe).extend(tA).extend(iI).extend(w4);var Buf={};hs(Buf,{ArraySchemaWithExample:()=>ivs,Base64WithExample:()=>kys,BooleanWithExample:()=>evs,CommonPropertyWithExample:()=>pvs,DateWithExample:()=>Zys,DatetimeWithExample:()=>Xys,DiscriminatedOneOfSchemaWithExample:()=>fvs,DoubleWithExample:()=>$ys,EndpointWithExample:()=>tby,EnumSchemaWithExample:()=>rvs,FloatWithExample:()=>Kys,HeaderWithExample:()=>QDi,HttpErrorWithExample:()=>Vys,Int64WithExample:()=>Hys,IntWithExample:()=>Wys,JsonRequestWithExample:()=>zys,JsonResponseWithExample:()=>zQa,MapSchemaWithExample:()=>avs,NamedFullExample:()=>Bdt,NullableSchemaWithExample:()=>uvs,ObjectPropertyWithExample:()=>lvs,ObjectSchemaWithExample:()=>svs,OneOfSchemaWithExample:()=>cvs,OptionalSchemaWithExample:()=>ovs,ParseFormUrlEncodedRequest:()=>Qys,ParseMultipartRequest:()=>Fys,ParseOctetStreamRequest:()=>Rys,PathParameterWithExample:()=>Nys,PrimitiveSchemaValueWithExample:()=>tvs,PrimitiveSchemaWithExample:()=>QQa,QueryParameterWithExample:()=>FQa,RequestWithExample:()=>Lys,ResponseWithExample:()=>Uys,SchemaWithExample:()=>j4,StringSchemaWithExample:()=>Yys,Uint64WithExample:()=>Jys,UintWithExample:()=>Gys,UnDiscriminatedOneOfSchemaWithExample:()=>dvs,UnknownSchemaWithExample:()=>nvs,WebhookWithExample:()=>rby,WebsocketHandshakeWithExample:()=>eby});var Bdt=Wr.objectWithoutOptionalProperties({name:Wr.string().optional(),value:Wr.unknown()}).extend(By);var FQa=Wr.objectWithoutOptionalProperties({name:Wr.string(),schema:Wr.lazy(()=>j4),parameterNameOverride:Wr.string().optional()}).extend(By).extend(xA).extend(tA);var QDi=Wr.objectWithoutOptionalProperties({name:Wr.string(),schema:Wr.lazy(()=>j4),env:Wr.string().optional(),parameterNameOverride:Wr.string().optional()}).extend(By).extend(xA).extend(tA);var eby=Wr.objectWithoutOptionalProperties({queryParameters:Wr.list(FQa),headers:Wr.list(QDi)});var Nys=Wr.objectWithoutOptionalProperties({name:Wr.string(),schema:Wr.lazy(()=>j4),variableReference:Wr.string().optional(),parameterNameOverride:Wr.string().optional()}).extend(By).extend(xA).extend(tA);var Rys=Wr.objectWithoutOptionalProperties({}).extend(PQa).extend(Q8r);var Fys=Wr.objectWithoutOptionalProperties({}).extend(wQa).extend(Q8r);var zys=Wr.objectWithoutOptionalProperties({schema:Wr.lazy(()=>j4),contentType:Wr.string().optional(),fullExamples:Wr.list(Bdt).optional(),additionalProperties:Wr.boolean()}).extend(By).extend(tA).extend(Q8r);var Qys=Wr.objectWithoutOptionalProperties({schema:Wr.lazy(()=>j4),contentType:Wr.string().optional(),fullExamples:Wr.list(Bdt).optional(),additionalProperties:Wr.boolean()}).extend(By).extend(tA).extend(Q8r);var Lys=Wr.union("type",{octetStream:Rys,multipart:Fys,json:zys,formUrlEncoded:Qys}).transform({transform:e=>{switch(e.type){case"octetStream":return ASe.octetStream(e);case"multipart":return ASe.multipart(e);case"json":return ASe.json(e);case"formUrlEncoded":return ASe.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var zQa=Wr.objectWithoutOptionalProperties({schema:Wr.lazy(()=>j4),responseProperty:Wr.string().optional(),fullExamples:Wr.list(Bdt).optional()}).extend(By).extend(tA).extend(Mdt);var Uys=Wr.union("type",{file:jQa,json:zQa,text:FDi,bytes:SQa,streamingSse:zQa,streamingText:FDi,streamingJson:zQa}).transform({transform:e=>{switch(e.type){case"file":return vQ.file(e);case"json":return vQ.json(e);case"text":return vQ.text(e);case"bytes":return vQ.bytes(e);case"streamingSse":return vQ.streamingSse(e);case"streamingText":return vQ.streamingText(e);case"streamingJson":return vQ.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Vys=Wr.objectWithoutOptionalProperties({statusCode:z8r,schema:Wr.lazy(()=>j4),fullExamples:Wr.list(Bdt).optional()}).extend(By).extend(XE).extend(tA);var tby=Wr.objectWithoutOptionalProperties({authed:Wr.boolean(),internal:Wr.boolean().optional(),idempotent:Wr.boolean().optional(),method:mQa,audiences:Wr.list(Wr.string()),path:Wr.string(),summary:Wr.string().optional(),operationId:Wr.string().optional(),tags:Wr.list(jSe),pathParameters:Wr.list(Nys),queryParameters:Wr.list(FQa),headers:Wr.list(QDi),sdkName:L8r.optional(),generatedRequestName:Wr.string(),requestNameOverride:Wr.string().optional(),request:Lys.optional(),response:Uys.optional(),errors:Wr.record(z8r,Vys),servers:Wr.list(DQa),examples:Wr.list(MQa),pagination:BQa.optional()}).extend(By).extend(xA).extend(tA).extend(fE);var rby=Wr.objectWithoutOptionalProperties({audiences:Wr.list(Wr.string()),sdkName:L8r.optional(),method:TQa,summary:Wr.string().optional(),operationId:Wr.string(),tags:Wr.list(jSe),headers:Wr.list(QDi),generatedPayloadName:Wr.string(),payload:Wr.lazy(()=>j4),examples:Wr.list(qQa)}).extend(By).extend(tA).extend(fE);var Wys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional(),minimum:Wr.number().optional(),maximum:Wr.number().optional(),exclusiveMinimum:Wr.boolean().optional(),exclusiveMaximum:Wr.boolean().optional(),multipleOf:Wr.number().optional(),example:Wr.number().optional()});var Hys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional(),example:Wr.number().optional()});var Gys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional(),example:Wr.number().optional()});var Jys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional(),example:Wr.number().optional()});var Kys=Wr.objectWithoutOptionalProperties({example:Wr.number().optional()});var $ys=Wr.objectWithoutOptionalProperties({default:Wr.number().optional(),minimum:Wr.number().optional(),maximum:Wr.number().optional(),exclusiveMinimum:Wr.boolean().optional(),exclusiveMaximum:Wr.boolean().optional(),multipleOf:Wr.number().optional(),example:Wr.number().optional()});var Yys=Wr.objectWithoutOptionalProperties({default:Wr.string().optional(),pattern:Wr.string().optional(),format:Wr.string().optional(),minLength:Wr.number().optional(),maxLength:Wr.number().optional(),example:Wr.string().optional()});var Xys=Wr.objectWithoutOptionalProperties({example:Wr.string().optional()});var Zys=Wr.objectWithoutOptionalProperties({example:Wr.string().optional()});var kys=Wr.objectWithoutOptionalProperties({example:Wr.string().optional()});var evs=Wr.objectWithoutOptionalProperties({default:Wr.boolean().optional(),example:Wr.boolean().optional()});var tvs=Wr.union("type",{int:Wys,int64:Hys,uint:Gys,uint64:Jys,float:Kys,double:$ys,string:Yys,datetime:Xys,date:Zys,base64:kys,boolean:evs}).transform({transform:e=>{switch(e.type){case"int":return kg.int(e);case"int64":return kg.int64(e);case"uint":return kg.uint(e);case"uint64":return kg.uint64(e);case"float":return kg.float(e);case"double":return kg.double(e);case"string":return kg.string(e);case"datetime":return kg.datetime(e);case"date":return kg.date(e);case"base64":return kg.base64(e);case"boolean":return kg.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var QQa=Wr.objectWithoutOptionalProperties({schema:tvs}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI);var rvs=Wr.objectWithoutOptionalProperties({default:xDi.optional(),values:Wr.list(xDi),example:Wr.string().optional()}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(tA).extend(iI).extend(w4);var nvs=Wr.objectWithoutOptionalProperties({example:Wr.unknown()}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI);var j4=Wr.union("type",{primitive:QQa,object:Wr.lazyObject(()=>svs),array:Wr.lazyObject(()=>ivs),map:Wr.lazyObject(()=>avs),optional:Wr.lazyObject(()=>ovs),enum:rvs,reference:U8r,literal:xQa,oneOf:Wr.object({value:Wr.lazy(()=>cvs)}),nullable:Wr.lazyObject(()=>uvs),unknown:nvs}).transform({transform:e=>{switch(e.type){case"primitive":return Uh.primitive(e);case"object":return Uh.object(e);case"array":return Uh.array(e);case"map":return Uh.map(e);case"optional":return Uh.optional(e);case"enum":return Uh.enum(e);case"reference":return Uh.reference(e);case"literal":return Uh.literal(e);case"oneOf":return Uh.oneOf(e.value);case"nullable":return Uh.nullable(e);case"unknown":return Uh.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var ivs=Wr.objectWithoutOptionalProperties({value:Wr.lazy(()=>j4),example:Wr.list(Wr.unknown()).optional()}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI).extend(w4);var avs=Wr.objectWithoutOptionalProperties({key:QQa,value:Wr.lazy(()=>j4),example:Wr.unknown().optional()}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(hNe).extend(iI).extend(w4);var ovs=Wr.objectWithoutOptionalProperties({value:Wr.lazy(()=>j4)}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI).extend(w4);var uvs=Wr.objectWithoutOptionalProperties({value:Wr.lazy(()=>j4)}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(iI).extend(w4);var svs=Wr.objectWithoutOptionalProperties({allOf:Wr.list(U8r),properties:Wr.list(Wr.lazyObject(()=>lvs)),allOfPropertyConflicts:Wr.list(NQa),fullExamples:Wr.list(Bdt).optional(),additionalProperties:Wr.boolean()}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(tA).extend(iI).extend(w4);var lvs=Wr.objectWithoutOptionalProperties({key:Wr.string(),schema:Wr.lazy(()=>j4),readonly:Wr.boolean().optional(),writeonly:Wr.boolean().optional(),audiences:Wr.list(Wr.string()),conflict:Wr.record(wSe,RQa),nameOverride:Wr.string().optional(),generatedName:Wr.string()}).extend(xA);var cvs=Wr.union("type",{discriminated:Wr.lazyObject(()=>fvs),undiscriminated:Wr.lazyObject(()=>dvs)}).transform({transform:e=>{switch(e.type){case"discriminated":return PSe.discriminated(e);case"undiscriminated":return PSe.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var fvs=Wr.objectWithoutOptionalProperties({discriminantProperty:Wr.string(),commonProperties:Wr.list(Wr.lazyObject(()=>pvs)),schemas:Wr.record(Wr.string(),Wr.lazy(()=>j4))}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(hNe).extend(tA).extend(iI).extend(w4);var pvs=Wr.objectWithoutOptionalProperties({key:Wr.string(),schema:Wr.lazy(()=>j4)});var dvs=Wr.objectWithoutOptionalProperties({schemas:Wr.list(Wr.lazy(()=>j4))}).extend(aI).extend(fE).extend(XE).extend(By).extend(xA).extend(hNe).extend(tA).extend(iI).extend(w4);var nby=/^(\d+)/,LQa=/^[a-zA-Z][a-zA-Z0-9_]*$/,iby={"<":"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 LDi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],n=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),c=e%10;return c===0?n[u]:`${n[u]}_${t[c]}`}if(e<1e3){let u=Math.floor(e/100),c=e%100;return c===0?`${t[u]}_hundred`:`${t[u]}_hundred_${LDi(c)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${LDi(a)}`}function D4o(e){let t=e.match(nby);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=LDi(i);return n.length>0?`${a}_${n}`:a}}}function UQa(e){let t=D4o(e),r=iby[e];return t!=null?P9(Um(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":P9(Um(e)))}function yNe(e,t){return e.type==="primitive"&&t.type==="primitive"?aby(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?yMD(e.values,t.values):e.type==="array"&&t.type==="array"?yNe(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"?yNe(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?vMD(e.value,t.value):e.type==="object"&&t.type==="object"?bMD(e,t):e.type==="map"&&t.type==="map"?aby(e.key.schema,t.key.schema)&&yNe(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function aby(e,t){return e.type===t.type}function yMD(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return Tae(r,n)}function vMD(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,n])=>{let i=t.schemas[r];return i==null?!1:yNe(n,i)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:yNe(r,i)}):!1}function bMD(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(n=>[n.key,n.schema]));return Object.entries(t.properties).every(([n,i])=>{let a=r[n];return a==null?!1:yNe(a,i.schema)})}function LH(e){switch(e){case vye.Deprecated:return"deprecated";case vye.Beta:return"pre-release";case vye.GenerallyAvailable:return"generally-available";default:return}}function gMD(e){let t=e.find(n=>typeof n=="object"&&n.type==="namespace"),r=e.filter(n=>typeof n=="string"||n.type!=="namespace");return t?[t,...r]:r}function oby(e){let t=e?gMD(e):void 0;if(t==null||t.length===0)return xVi;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(Um(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(Um(i.name)):r.push(i.name,xVi);break}default:lc(i.type)}else lc(i);return r.join("/")}function UDi(e){return oP.of(`${oby(e)}.yml`)}function Tuf({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?xVi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,oby(r))}function uby({sdkName:e,namespaceOverride:t}){return oP.of(`${Tuf({sdkName:e,namespaceOverride:t})}.yml`)}function sby({location:e,namespaceOverride:t}){return t!=null?V$(oP.of(t),e):e}function _vs(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:lc(e.type)}}function VQa(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:lc(e)}}function wz(e){return typeof e=="string"?e:e.type}function WQa(e){if(typeof e!="string")return e.docs}function C4o(e){if(typeof e!="string")return e.default}function quf(e){if(typeof e!="string")return e.validation}var mMD=-2147483648,OMD=2147483647,AMD=-17976931348623157e292,PMD=17976931348623157e292;function zS({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i,declarationDepth:a}){switch(n.shouldMarkSchemaAsReferenced()&&n.markSchemaAsReferenced(e,i),e.type){case"primitive":return hvs(e);case"array":return Ruf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"map":return Fuf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"reference":return Nuf({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return Quf();case"optional":return yvs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"nullable":return zuf({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"enum":return BMD({schema:e,fileContainingReference:t,context:n,declarationFile:r,declarationDepth:a});case"literal":return e.value,Luf(e);case"object":return TMD({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});case"oneOf":return qMD({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});default:lc(e)}}function hvs(e){switch(e.schema.type){case"string":return EMD({description:e.description,schema:e.schema});case"int":return SMD({description:e.description,schema:e.schema});case"float":return DMD({description:e.description,schema:e.schema});case"double":return CMD({description:e.description,schema:e.schema});case"boolean":return wMD({description:e.description,schema:e.schema});case"int64":return jMD({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:LH(e.availability)}:{}}}function wMD({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function jMD({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),n}function EMD({description:e,schema:t}){let r="string",n=IMD(t);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function SMD({description:e,schema:t}){let r="integer",n=lby(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function DMD({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function CMD({description:e,schema:t}){let r="double",n=lby(t,r);if(e==null&&t.default==null&&n==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),n!=null&&(i.validation=n),i}function IMD(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=MMD(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function MMD(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 lby(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=xuf(r,t),n=xuf(n,t),i=xuf(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function xuf(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[mMD,OMD]:[AMD,PMD];return e<r||e>n?void 0:e}function Nuf({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=xMD(i)??e.schema,u=VQa(i),c=NMD(i),p=vvs({context:r,fileContainingReference:t,declarationFile:UDi(u),type:a}),s=i.type==="nullable"?`optional<${p}>`:p;return e.description==null&&c==null?s:{type:i.type==="nullable"?`optional<${p}>`:p,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:LH(e.availability)}:{}}}function Ruf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let u=zS({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=`list<${wz(u)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:LH(e.availability)}:{},type:c}}function Fuf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let u=hvs(e.key),c=zS({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),p=e.encoding!=null?_vs(e.encoding):void 0,s=`map<${wz(u)}, ${wz(c)}>`;if(e.description==null&&p==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=p),e.availability!=null&&(o.availability=LH(e.availability)),o}function zuf({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){if(!n.respectNullableSchemas)return yvs({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i,declarationDepth:a});let u=zS({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=wz(u),p=WQa(u),s=C4o(u),o=quf(u),l=c.startsWith("nullable<")?c:`nullable<${c}>`;if(e.availability==null&&e.description==null&&p==null&&s==null&&o==null&&e.title==null)return cby({typeReference:l,itemType:c});let O={type:l};return(e.description!=null||p!=null)&&(O.docs=e.description??p),s!=null&&(O.default=s),o!=null&&(O.validation=o),e.availability!=null&&(O.availability=LH(e.availability)),cby({typeReference:O,itemType:c})}function yvs({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let u=zS({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=wz(u),p=WQa(u),s=C4o(u),o=quf(u),l=c.startsWith("optional<")?c:`optional<${c}>`;if(e.availability==null&&e.description==null&&p==null&&s==null&&o==null&&e.title==null)return l;let O={type:l};return(e.description!=null||p!=null)&&(O.docs=e.description??p),s!=null&&(O.default=s),o!=null&&(O.validation=o),e.availability!=null&&(O.availability=LH(e.availability)),O}function Quf(){return"unknown"}function Luf(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:lc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:LH(e.availability)}:{}}}function BMD({schema:e,fileContainingReference:t,declarationFile:r,context:n,declarationDepth:i}){let a=I4o(e,i),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let c=vvs({type:u,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return c;let p={type:c};return e.description!=null&&(p.docs=e.description),e.default!=null&&(p.default=e.default.value),e.availability!=null&&(p.availability=LH(e.availability)),p}function TMD({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let u=Uuf({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:u.schema});let p=vvs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?p:{type:p,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:LH(e.availability)}:{}}}function qMD({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i,declarationDepth:a}){let u=Vuf({schema:e,declarationFile:r,context:n,namespace:i,declarationDepth:a}),c=e.nameOverride??e.generatedName;n.builder.addType(r,{name:c,schema:u.schema});let p=vvs({type:c,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?p:{...e.title!=null?{"display-name":e.title}:{},type:p,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:LH(e.availability)}:{}}}function vvs({type:e,fileContainingReference:t,declarationFile:r,context:n}){if(r===t)return e;let i=n.builder.addImport({file:t,fileToImport:r});return i!=null?`${i}.${e}`:e}function xMD(e){return aw._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 NMD(e){return aw._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:()=>{}})}function cby({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var foe;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(foe||(foe={}));function oli(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:lc(e)}}function dby({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a;switch(e.type){case"primitive":a=zMD(e);break;case"array":a=RMD({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"map":a=FMD({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"reference":a=QMD({schema:e,context:t,declarationFile:r,namespace:n});break;case"unknown":a=UMD(e.nameOverride,e.generatedName);break;case"optional":a=pby({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"nullable":a=LMD({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"enum":a=I4o(e,i);break;case"literal":a=VMD(e,e.nameOverride,e.generatedName);break;case"object":a=Uuf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;case"oneOf":a=Vuf({schema:e.value,context:t,declarationFile:r,namespace:n,declarationDepth:i});break;default:lc(e)}return a}function Uuf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=t.isInState(foe.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,c={},p=new Set;for(let A of e.properties){if(A.readonly&&(u=!0),a&&A.readonly)continue;if(Object.keys(A.conflict).length>0){if(Object.entries(A.conflict).every(([Q,J])=>!J.differentSchema))continue;Object.entries(A.conflict).forEach(([Q])=>{Wuf({property:A.key,schemaId:Q,context:t,namespace:n}).forEach(X=>{p.add(X)})})}let E=zS({schema:A.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}),C=A.audiences,M=A.nameOverride,q=LH(A.availability),L=JMD(A);c[A.key]=GMD({typeReference:E,audiences:C,name:M,availability:q,propertyAccess:L})}let s=new Set;for(let A of e.allOfPropertyConflicts)A.allOfSchemaIds.forEach(E=>p.add(E)),A.conflictingTypeSignatures&&s.add(A.propertyKey);let o=[];for(let A of e.allOf){let E=_by({schema:A.schema,context:t,namespace:n});if(E==null||p.has(A.schema)||p.has(E))continue;let C=zS({schema:aw.reference(A),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});o.push(wz(C))}for(let A of p){let E=Huf(t,A,n);for(let C of E.properties)c[C.key]==null&&(s.has(C.key)&&(c[C.key]="unknown"),c[C.key]=zS({schema:C.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1}));for(let C of E.allOf){if(p.has(C.schema))continue;let M=zS({schema:aw.reference(C),context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});o.push(wz(M))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([A,E])=>HMD(A)?[A,typeof E=="string"?{type:E,name:`_${A}`}:{...E,name:`_${A}`}]:[A,E]))};o.length>0&&(l.extends=o),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=LH(e.availability)),e.source!=null&&(l.source=oli(e.source)),l.inline=Guf(e,i);let O=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${O}Read`:O,schema:l}}function Wuf({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return Wuf({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=Huf(r,t,n),c=a.some(s=>s.key===e),p=[...u.flatMap(s=>Wuf({property:e,context:r,schemaId:s.schema,namespace:n}))];if(c||p.length>0)return[t,...p]}return[]}function Huf(e,t,r){let n=e.getSchema(t,r);if(n==null)return{properties:[],allOf:[]};if(n.type==="object")return{properties:n.properties,allOf:n.allOf};if(n.type==="reference")return Huf(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function RMD({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:Ruf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function FMD({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:Fuf({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n,declarationDepth:i})}}function zMD(e){let t=hvs(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...n}=t;return{name:e.nameOverride??e.generatedName,schema:{...n}}}function fby(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function I4o(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,c=a.value;if(u===c&&a.description==null&&(a.casing==null||fby(a.casing)))return u;let p={value:a.value};if(u!==c&&(p.name=u),a.description!=null&&(p.docs=a.description),a.casing!=null&&!fby(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(p.casing=s)}return p})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=Guf(e,t);let n=new Set,i={...r,enum:[],source:e.source!=null?oli(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;n.has(u.toLowerCase())||(i.enum.push(a),n.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:i}}function QMD({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Nuf({schema:e,context:t,fileContainingReference:r,namespace:n})}}function LMD({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:zuf({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}:pby({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i})}function pby({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){return{name:e.nameOverride??e.generatedName,schema:yvs({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n,declarationDepth:i})}}function UMD(e,t){return{name:e??t,schema:Quf()}}function VMD(e,t,r){return{name:t??r,schema:Luf(e)}}function Vuf({schema:e,context:t,declarationFile:r,namespace:n,declarationDepth:i}){let a=e.encoding!=null?_vs(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=zS({schema:s.schema,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1});let p={};for(let[s,o]of Object.entries(e.schemas))p[s]=zS({schema:o,context:t,fileContainingReference:r,namespace:n,declarationDepth:i+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?LH(e.availability):void 0,union:p,encoding:a,source:e.source!=null?oli(e.source):void 0}}}let u=[];for(let c of e.schemas)u.push(zS({schema:c,fileContainingReference:r,context:t,namespace:n,declarationDepth:i+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?oli(e.source):void 0,inline:Guf(e,i)}}}var WMD=/^[0-9]/;function HMD(e){return WMD.test(e)}function _by({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?_by({context:t,schema:n.schema,namespace:r}):e}function GMD({typeReference:e,audiences:t,name:r,availability:n,propertyAccess:i}){return t.length===0&&r==null&&n==null&&i==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{},...i!=null?{access:i}:{}}}function Guf(e,t){return e.inline===!0||t>0?!0:void 0}function JMD(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return $$.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return $$.ObjectPropertyAccess.WriteOnly}}function hby(e){let t=e.replace(/^x-|^X-/,"");return Um(t)}var yby="BasicAuthScheme",bvs="BearerAuthScheme";function vby(e){if(e.authOverrides!=null){for(let[r,n]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:n});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,n]of Object.entries(e.ir.securitySchemes))if(n.type==="basic"){let i={scheme:"basic"};n.usernameVariableName!=null&&(i.username===void 0?i.username={name:n.usernameVariableName}:i.username.name=n.usernameVariableName),n.usernameEnvVar!=null&&(i.username===void 0?i.username={env:n.usernameEnvVar}:i.username.env=n.usernameEnvVar),n.passwordVariableName!=null&&(i.password===void 0?i.password={name:n.passwordVariableName}:i.password.name=n.passwordVariableName),n.passwordEnvVar!=null&&(i.password===void 0?i.password={env:n.passwordEnvVar}:i.password.env=n.passwordEnvVar),e.builder.addAuthScheme({name:yby,schema:i}),t||(e.builder.setAuth(yby),t=!0)}else if(n.type==="bearer"){let i={scheme:"bearer"};n.tokenVariableName!=null&&(i.token===void 0?i.token={name:n.tokenVariableName}:i.token.name=n.tokenVariableName),n.tokenEnvVar!=null&&(i.token===void 0?i.token={env:n.tokenEnvVar}:i.token.env=n.tokenEnvVar),e.builder.addAuthScheme({name:bvs,schema:i}),t||(e.builder.setAuth(bvs),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??hby(n.headerName),env:n.headerEnvVar}});else{let i={header:n.headerName,name:n.headerVariableName??"apiKey",type:"string"};n.headerEnvVar!=null&&(i.env=n.headerEnvVar),n.prefix!=null&&(i.prefix=n.prefix),e.builder.addAuthScheme({name:r,schema:i}),e.builder.setAuth(r),t=!0}else if(n.type==="oauth"){let i={scheme:"bearer"};e.builder.addAuthScheme({name:bvs,schema:i}),t||(e.builder.setAuth(bvs),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(oP.of("__package__.yml"),{name:"OauthScope",schema:I4o(n.scopesEnum,0).schema})}}function V8r({header:e,context:t,fileContainingReference:r,namespace:n}){let i=zS({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),a=wz(i),u=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:Um(u);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let p={type:a};return c!==e.name&&(p.name=c),e.description!=null&&(p.docs=e.description),e.env!=null&&(p.env=e.env),e.availability!=null&&(p.availability=LH(e.availability)),p}function gvs({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=zS({schema:e.schema,context:t,fileContainingReference:r,namespace:n,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return wz(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:wz(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=LH(e.availability)),a}function Ovs({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=Juf({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=wz(i.value),u=C4o(i.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return u!=null&&(c.default=u),i.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=LH(e.availability)),KMD(i.value)&&i.value.validation!==void 0&&(c.validation=i.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function Juf({schema:e,context:t,fileContainingReference:r,namespace:n}){if(e.type==="reference"){let i=t.getSchema(e.schema,n);if(i==null)return;if(i.type==="array")return{value:zS({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:oP.of(Jx),fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undiscriminated"){let a=[],u=!1;for(let[c,p]of Object.entries(i.value.schemas))p.type==="primitive"&&p.schema.type==="string"&&(u=!0),p.type==="literal"&&p.value.type==="string"&&(LQa.test(p.value.value)?a.push(p.value.value):a.push({value:p.value.value,name:UQa(p.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),u&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[c,p]=i.value.schemas;if(c!=null&&p!=null&&mvs({array:c,primitive:p}))return{value:zS({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:p,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(c!=null&&p!=null&&mvs({array:c,primitive:p}))return{value:zS({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}for(let[c,p]of Object.entries(i.value.schemas))return Juf({schema:p,context:t,fileContainingReference:r,namespace:n})}else if(t.objectQueryParameters)return{value:zS({schema:e,context:t,fileContainingReference:r,declarationFile:oP.of(Jx),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let i=t.getSchema(e.value.schema,n);if(i==null)return;if(i.type==="array")return{value:zS({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:oP.of(Jx),namespace:n,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:zS({schema:e,context:t,fileContainingReference:r,declarationFile:oP.of(Jx),namespace:n,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:zS({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let i=[],a=!1;for(let[u,c]of Object.entries(e.value.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(a=!0),c.type==="literal"&&c.value.type==="string"&&(LQa.test(c.value.value)?i.push(c.value.value):i.push({value:c.value.value,name:UQa(c.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),a&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[u,c]=e.value.value.schemas;if(u!=null&&c!=null&&mvs({array:u,primitive:c}))return{value:zS({schema:aw.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:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0};if(u!=null&&c!=null&&mvs({array:c,primitive:u}))return{value:zS({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}}if(t.objectQueryParameters)return{value:zS({schema:e,context:t,fileContainingReference:r,declarationFile:oP.of(Jx),namespace:n,declarationDepth:0}),allowMultiple:!1};for(let[u,c]of Object.entries(e.value.value.schemas))return Juf({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return t.objectQueryParameters?{value:zS({schema:e,context:t,fileContainingReference:r,declarationFile:oP.of(Jx),namespace:n,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:zS({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:zS({schema:aw.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!0}:{value:zS({schema:e,context:t,fileContainingReference:r,namespace:n,declarationDepth:0}),allowMultiple:!1}}function mvs({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function KMD(e){return e.type!=null}function bby({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"]=$MD(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=YMD({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=VDi(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function $MD(e){let t={};return e.forEach(r=>{let n=VDi(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function YMD({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=VDi(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function VDi(e){switch(e.type){case"primitive":return gby(e.value);case"object":return mby(e.properties);case"array":return XMD(e.value);case"map":return ZMD(e.value);case"oneOf":return kMD(e.value);case"enum":return e.value;case"literal":return eBD(e.value);case"unknown":return VDi(e.value);default:lc(e)}}function gby(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:lc(e)}}function mby(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,VDi(r)]))}function XMD(e){return e.map(t=>VDi(t))}function ZMD(e){return Object.fromEntries(e.map(t=>[gby(t.key),VDi(t.value)]))}function kMD(e){return e.type==="discriminated"?mby(e.value):VDi(e.value)}function eBD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:lc(e)}}function uli(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function Avs(e,t){return t??(e?.groupName!=null?uli(e.groupName):void 0)}function Oby({channel:e,context:t,declarationFile:r}){let n={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(n.audiences=e.audiences),e.summary!=null&&(n["display-name"]=e.summary),e.description!=null&&(n.docs=e.description);let i=uli(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let p of e.handshake.pathParameters)a[p.name]=gvs({pathParameter:p,context:t,fileContainingReference:r,namespace:i});Object.keys(a).length>0&&(n["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let p of e.handshake.queryParameters){let s=Ovs({queryParameter:p,context:t,fileContainingReference:r,namespace:i});s!=null&&(u[p.name]=s)}Object.keys(u).length>0&&(n["query-parameters"]=u);let c={};if(e.handshake.headers.length>0)for(let p of e.handshake.headers){let s=V8r({header:p,context:t,fileContainingReference:r,namespace:i});c[p.name]=s}Object.keys(c).length>0&&(n.headers=c),t.builder.addChannel(r,{channel:n});for(let p of e.messages)t.builder.addChannelMessage(r,{messageId:p.name,message:{origin:p.origin,body:zS({schema:p.body,context:t,fileContainingReference:r,namespace:i,declarationDepth:0})}});for(let p of e.examples){let s=bby({context:t,websocketExample:p});t.builder.addChannelExample(r,{example:s})}}function Aby(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="grouped"}var sli="Base",tBD="Default";function b$i(e){return Object.entries(e).reduce((t,[r,n])=>(net(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function Pby(e){if(e.environmentOverrides!=null){for(let[q,L]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:q,schema:L});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[],n=e.ir.servers.some(q=>Aby(q)),i=e.ir.servers;for(let q of i)if(Aby(q)){let L={urls:{}};for(let[U,Q]of Object.entries(q.urls))L.urls[U]=Q.url;q.name&&(t[q.name]=L)}else if("url"in q&&q.url){let L=q.audiences?{url:q.url,audiences:q.audiences}:q.url;if(q.name==null){r.push(L);continue}t[q.name]=L}let a={},u={},c=[];for(let q of e.ir.endpoints)for(let L of q.servers){if(L.url==null&&L.name!=null){a[L.name]||(a[L.name]=[]);continue}if(L.url==null)continue;let U=L.audiences?{url:L.url,audiences:L.audiences}:L.url;if(L.name==null){c.push(U);continue}a[L.name]||(a[L.name]=[]),a[L.name]?.push({url:L.url,audiences:L.audiences}),u[L.name]=U}let p={},s=[];for(let q of e.ir.websocketServers){let L=q.audiences?{url:q.url,audiences:q.audiences}:q.url;if(q.name==null){s.push(L);continue}p[q.name]=L}let o=Object.keys(t).length,l=o>0,O=Object.keys(u).length>0,A=Object.keys(a).some(q=>a[q]?.length===0),E=Object.keys(p).length>0;if(!l&&!O&&E&&e.ir.servers.length===0){for(let[q,L]of Object.entries(p))e.builder.addEnvironment({name:q,schema:L});e.builder.setDefaultEnvironment(Object.keys(p)[0]),e.builder.setDefaultUrl(sli);return}if(c.length>0&&e.logger.error(`Skipping endpoint level servers ${c.map(q=>typeof q=="string"?q:q.url).join(", ")} because x-fern-server-name was not provided.`),!l){let q=e.ir.servers[0]?.url,L=e.ir.servers[0]?.audiences;if(q!=null){let U=L?{url:q,audiences:L}:q;t[tBD]=U}}let C=Object.values(t).map(q=>typeof q=="string"?q:net(q)?Object.values(q.urls)[0]:q.url),M=r.filter(q=>{let L=typeof q=="string"?q:q.url;return!C.includes(L)});if(M.length>0&&e.logger.error(`Skipping top level servers ${M.map(q=>typeof q=="string"?q:q.url).join(", ")} because x-fern-server-name was not provided.`),n){let q=!0;for(let[L,U]of Object.entries(t))if(e.builder.addEnvironment({name:L,schema:U}),q){if(e.builder.setDefaultEnvironment(L),net(U)){let Q=Object.keys(U.urls)[0];Q&&e.builder.setDefaultUrl(Q)}q=!1}return}if(!O&&!A){let q=!0;for(let[L,U]of Object.entries(t))if(q){if(E){let Q=typeof U=="string"?U:net(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:L,schema:{urls:{[sli]:Q??"",...b$i(p)}}})}else e.builder.addEnvironment({name:L,schema:U});e.builder.setDefaultEnvironment(L),q=!1}else if(E){let Q=typeof U=="string"?U:net(U)?Object.values(U.urls)[0]:U.url;e.builder.addEnvironment({name:L,schema:{urls:{[sli]:Q??"",...b$i(p)}}})}else e.builder.addEnvironment({name:L,schema:U});E&&e.builder.setDefaultUrl(sli)}else if(o===1){let q=Object.keys(t)[0],L=Object.values(t)[0],U=typeof L=="string"?L:net(L)?Object.values(L.urls)[0]:L.url;e.builder.addEnvironment({name:q,schema:{urls:{[sli]:U??"",...b$i(u),...b$i(p)}}}),e.builder.setDefaultEnvironment(q),e.builder.setDefaultUrl(sli)}else{let q=new Map;for(let L of e.ir.endpoints)for(let U of L.servers)if(U.url!=null&&U.name!=null){q.has(U.name)||q.set(U.name,new Map);let Q=U.url.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",J=q.get(U.name);J&&J.set(Q,U.url)}if(q.size>0){let L=!0;for(let[U,Q]of Object.entries(t)){let J=typeof Q=="string"?Q:net(Q)?Object.values(Q.urls)[0]:Q.url;if(!J)continue;let X=J.match(/[-]([a-z0-9]+)\./i)?.[1]?.toLowerCase()||"production",te={[sli]:J};for(let[k,re]of q.entries()){let ue=re.get(X)||re.get("production")||re.values().next().value;ue&&(te[k]=ue)}E&&Object.assign(te,b$i(p)),Object.keys(te).length>1?e.builder.addEnvironment({name:U,schema:{urls:te}}):e.builder.addEnvironment({name:U,schema:J}),L&&(e.builder.setDefaultEnvironment(U),L=!1)}q.size>0&&e.builder.setDefaultUrl(sli)}else{let L=!0;for(let[U,Q]of Object.entries(t)){if(E||Object.keys(u).length>0){let J=typeof Q=="string"?Q:net(Q)?Object.values(Q.urls)[0]:Q.url;e.builder.addEnvironment({name:U,schema:{urls:{[sli]:J??"",...b$i(u),...b$i(p)}}})}else e.builder.addEnvironment({name:U,schema:Q});L&&(e.builder.setDefaultEnvironment(U),L=!1)}}}}function Pvs(e){return wz(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var Kuf=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},rBD=.75,nBD=new Set("authorization");function wby(e){if(e.globalHeaderOverrides!=null){for(let[r,n]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:n});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,n]of Object.entries(t)){let i="optional<string>";if(n.name==null&&n.env==null&&typeof n.schema=="string")i=n.schema;else if(n!=null){let a=n.schema?VQa(n.schema):void 0,u=a!=null?uli(a):void 0,c=oP.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?wz(zS({schema:n.schema,context:e,fileContainingReference:u?V$(oP.of(Um(u)),c):c,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:i})}if(e.detectGlobalHeaders){let r={};for(let i of e.ir.endpoints)for(let a of i.headers){if(nBD.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let c=t[a.name],p=V8r({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:oP.of(aZ),context:e,namespace:void 0});u=new Kuf(p),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*rBD;for(let[i,a]of Object.entries(r)){let u=t[i],c=a.count===e.ir.endpoints.length,p=a.count>=n;u==null&&(c?e.builder.addGlobalHeader({name:i,schema:a.schema}):p&&e.builder.addGlobalHeader({name:i,schema:Pvs(a.schema)}))}}}function jby(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?VQa(t.schema):void 0,n=r!=null?uli(r):void 0,i=V8r({header:{...t,schema:t.schema??aw.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:zT.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:oP.of(aZ),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:Pvs(i)})}}function KOe(e){switch(e.type){case"primitive":return Sby(e.value);case"object":return Dby(e.properties);case"array":return Cby(e.value);case"map":return aBD(e.value);case"oneOf":return oBD(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return uBD(e.value);case"unknown":return KOe(e.value);default:lc(e)}}function Eby(e){switch(e.type){case"withStreaming":return e.sse?{stream:iBD(e.events)}:{stream:Cby(e.events)};case"withoutStreaming":return{body:KOe(e.value)};default:lc(e)}}function Sby(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:lc(e)}}function Dby(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,KOe(r)]))}function iBD(e){return e.map(t=>({event:"",data:KOe(t)}))}function Cby(e){return e.map(t=>KOe(t))}function aBD(e){return Object.fromEntries(e.map(t=>[Sby(t.key),KOe(t.value)]))}function oBD(e){return e.type==="discriminated"?Dby(e.value):KOe(e.value)}function uBD(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:lc(e)}}function Iby({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"]=sBD(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=cBD(e.queryParameters));let n=e.headers!=null&&e.headers.length>0,i=t.builder.getGlobalHeaders(),a=Object.keys(i).length>0,u=new Set(e.headers?.map(c=>c.name)??[]);if(n||a){let c=[];if(e.headers!=null)for(let p of e.headers)p.name!==t.builder.getAuthHeaderName()&&c.push(p);for(let[p,s]of Object.entries(i))if(!u.has(p))if(s!=null&&typeof s=="object"&&s.type!=null){let o=gZ({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:Jc}});o!=null&&c.push({name:p,value:FS.literal(MDi.string(o))})}else c.push({name:p,value:FS.primitive(Mm.string(p))});r.headers=lBD({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=KOe(e.request)),e.response!=null&&(r.response=Eby(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(HA)),r}function sBD(e){let t={};return e.forEach(r=>{let n=KOe(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function cBD(e){let t={};return e.forEach(r=>{let n=KOe(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function lBD({context:e,namedFullExamples:t}){let r={};return t.forEach(n=>{let i=KOe(n.value);i!=null&&(r[n.name]=i)}),r}function Mby(e){return gye._visit(e,{get:()=>$$.HttpMethodSchema.Get,post:()=>$$.HttpMethodSchema.Post,put:()=>$$.HttpMethodSchema.Put,patch:()=>$$.HttpMethodSchema.Patch,delete:()=>$$.HttpMethodSchema.Delete,head:()=>$$.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 Bby(e){return e==="POST"||e==="PUT"||e==="PATCH"}function Tby({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,c=Avs(e.sdkName,e.namespace),p={};for(let M of e.pathParameters)M.parameterNameOverride&&(u=u.replace(M.name,M.parameterNameOverride)),p[M.parameterNameOverride??M.name]=gvs({pathParameter:M,context:r,fileContainingReference:t,namespace:c}),a.add(M.name);let s={};for(let M of e.queryParameters){let q=Ovs({queryParameter:M,context:r,fileContainingReference:t,namespace:c});q!=null&&(s[M.name]=q,a.add(M.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:lc(e.pagination)}let l={path:u,method:Mby(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?oli(e.source):void 0};!pBD({context:r,request:e.request})&&Object.keys(p).length>0&&(l["path-parameters"]=p),e.summary!=null&&(l["display-name"]=e.summary);let O={},A=r.builder.getGlobalHeaderNames(),E=r.builder.getAuthHeaderName();E!=null&&A.add(E);let C=e.headers.filter(M=>!A.has(M.name));for(let M of C){let q=V8r({header:M,context:r,fileContainingReference:t,namespace:c});O[M.name]=q,a.add(typeof q=="string"?M.name:q.name??M.name)}if(e.request!=null){r.setInState(foe.Request);let M=dBD({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(p).length>0?p:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(O).length>0?O:void 0,usedNames:a,namespace:c});l.request=M.value,i=[...i,...M.schemaIdsToExclude??[]],r.unsetInState(foe.Request)}else{let M=r.inlinePathParameters&&Object.keys(p).length>0,q=Object.keys(s).length>0,L=Object.keys(O).length>0,U={};(M||q||L)&&(U.name=e.requestNameOverride??e.generatedRequestName),M&&(U["path-parameters"]=p),q&&(U["query-parameters"]=s),L&&(U.headers=O),Object.keys(U).length>0&&(l.request=U)}if(e.response!=null&&e.response._visit({json:M=>{let q=zS({schema:M.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:M.description??void 0,type:wz(q)},M.statusCode!=null&&(l.response["status-code"]=M.statusCode),M.responseProperty!=null&&(l.response.property=M.responseProperty)},streamingJson:M=>{let q=zS({schema:M.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:M.description??void 0,type:wz(q),format:"json"}},streamingSse:M=>{let q=zS({schema:M.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:M.description??void 0,type:wz(q),format:"sse"}},file:M=>{l.response={docs:M.description??void 0,type:"file","status-code":M.statusCode}},bytes:M=>{l.response={docs:M.description??void 0,type:"bytes","status-code":M.statusCode}},streamingText:M=>{l["response-stream"]={docs:M.description??void 0,type:"text"}},text:M=>{l.response={docs:M.description??void 0,type:"text","status-code":M.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let M=r.getDefaultServerName(),q=e.servers[0];q==null?M!=null&&(l.url=M):l.url=q.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=LH(e.availability)),Object.entries(e.errors).forEach(([M,q])=>{let L=q.generatedName,U=oP.of(Jx);r.builder.enableUniqueErrorsPerEndpoint&&(L=`${e.generatedRequestName}${q.generatedName}`,q.schema!=null&&(q.schema.type!=="reference"&&q.schema.type!=="oneOf"?q.schema.generatedName=`${e.generatedRequestName}${q.schema.generatedName}`:q.schema.type==="oneOf"&&(q.schema.value.generatedName=`${e.generatedRequestName}${q.schema.value.generatedName}`)));let Q={"status-code":parseInt(M)},J=sby({location:qby,namespaceOverride:c});if(q.schema!=null){let k=zS({schema:q.schema,context:r,fileContainingReference:J,declarationFile:J,namespace:c,declarationDepth:0});Q.type=wz(k),Q.docs=q.description}r.builder.addError(J,{name:L,schema:r.isErrorUnknownSchema(parseInt(M))?{...Q,type:"unknown"}:Q}),l.errors==null&&(l.errors=[]);let X=r.builder.addImport({file:t,fileToImport:J});l.errors.push(X!=null?`${X}.${L}`:L),Q.type!=null&&q.examples?.forEach(k=>{let re={value:KOe(k.example),name:k.name,docs:k.description};r.builder.addErrorExample(J,{name:L,example:re})})}),e.examples.length>0&&(l.examples=fBD({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[$uf,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function fBD({endpointExamples:e,context:t}){return e.map(r=>{try{return Iby({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function dBD({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,pathParameters:u,queryParameters:c,nonRequestReferencedSchemas:p,headers:s,usedNames:o,namespace:l}){if(n.type==="json"||n.type==="formUrlEncoded"){let O=n.schema.type==="reference"?n.schema.schema:void 0,A=n.schema.type==="reference"?r.getSchema(n.schema.schema,l):n.schema;if(A?.type!=="object"||O!=null&&p.includes(O)){let L=zS({schema:n.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),U={schemaIdsToExclude:[],value:{body:L}},Q=Object.keys(u??{}).length>0,J=Object.keys(c??{}).length>0,X=Object.keys(s??{}).length>0;return Q&&(U.value["path-parameters"]=u),J&&(U.value["query-parameters"]=c),X&&(U.value.headers=s),(Q||J||X)&&(U.value.name=i??a),n.contentType!=null&&(U.value["content-type"]=n.contentType),n.description!=null&&(U.value.docs=n.description),U}let E=Object.fromEntries(A.properties.filter(L=>L.readonly==null?!0:!(Bby(e.method)&&L.readonly)).map(L=>{let U=zS({schema:L.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),Q=L.nameOverride??L.key,J=LH(L.availability);if(!o.has(Q)&&L.audiences.length<=0)return o.add(Q),L.nameOverride!=null?[L.key,{type:wz(U),docs:WQa(U),name:L.nameOverride,availability:J}]:[L.key,J?{...typeof U=="string"?{type:U}:U,availability:J}:U];let X={type:wz(U),docs:WQa(U)};return o.has(Q)&&(X.name=L.generatedName),L.audiences.length>0&&(X.audiences=L.audiences),J!=null&&(X.availability=J),o.add(Q),[L.key,X]})),C=A.allOf.map(L=>{let U=zS({schema:aw.reference(L),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return wz(U)}).filter(L=>L!=="unknown"),M={properties:E};C.length>0&&(M.extends=C),n.additionalProperties&&(M["extra-properties"]=!0);let q={name:i??A.nameOverride??A.generatedName,"path-parameters":u,"query-parameters":c,headers:s,body:M};return n.contentType!=null&&(q["content-type"]=n.contentType),n.description!=null&&(q.docs=n.description),{schemaIdsToExclude:O!=null?[O]:[],value:q}}else if(n.type==="octetStream"){let O={body:"bytes","content-type":n.contentType??f2.APPLICATION_OCTET_STREAM,"query-parameters":c};return c!=null&&(O.name=i??a),n.description!=null&&(O.docs=n.description),{schemaIdsToExclude:[],value:O}}else if(n.type==="multipart"){let O=Object.fromEntries(n.properties.map(A=>{if(A.schema.type==="file"){let E=A.schema.isArray?"list<file>":"file";if(E=A.schema.isOptional?`optional<${E}>`:E,A.description!=null||A.contentType!=null){let C={type:E};if(A.description!=null&&(C.docs=A.description),A.contentType!=null){let M=A.contentType.split(",")[0];C["content-type"]=M}return[A.key,C]}return[A.key,E]}else{let E=zS({schema:A.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(A.contentType||A.exploded||A.encoding){let C=typeof E=="string"?{type:E}:E;A.contentType!=null&&(C["content-type"]=A.contentType),A.encoding==="form"?C.style="form":A.encoding==="json"?C.style="json":A.exploded&&(C.style="exploded"),E=C}return[A.key,E]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"path-parameters":u,"query-parameters":c,headers:s,body:{properties:O},"content-type":f2.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else lc(n)}function pBD({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:lc(t)}}function _BD({location:e,namespaceOverride:t}){return t!=null?{...e,file:V$(oP.of(t),e.file)}:e}function hBD(e){let t=e.namespace,r=e.tags.filter(p=>p!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:oP.of(`${Um(r)}.yml`),endpointId:e.summary!=null?Um(e.summary):Um(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:oP.of(Jx),endpointId:Um(e.summary)}:{file:oP.of(Jx),endpointId:Um(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:oP.of(Jx),endpointId:n};let i=M4o(r),a=M4o(n);if(Tae(i,a))return{file:oP.of("__package__.yml"),endpointId:r};let u=bBD({operationId:n,tag:r,path:e.path,method:e.method});if(u!=null)return u;let c=[];for(let p=0;p<i.length;++p){let s=i[p];if(s!=null&&s===a[p])c.push(s);else{let o=Um(r);return{file:oP.of(`${o}.yml`),endpointId:n,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:oP.of(Um(c.join("_"))+".yml"),endpointId:Um(a.slice(c.length).join("_")),tag:r}}function B4o(e){let t=e.tags[0];if(e.sdkName!=null){let r=Tuf({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:oP.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return _BD({namespaceOverride:e.namespace,location:hBD(e)})}function M4o(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=Tct(t),t}var yBD=new RegExp("[^a-zA-Z0-9{}]+"),vBD=new RegExp("[{}]","g");function bBD({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(yBD).join("_").replaceAll(vBD,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:oP.of(Um(t)+".yml"),endpointId:Um(e.slice(0,-1*a.length)),tag:t}}function xby(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:c,tag:p}=B4o(a),s=c.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let A=e.ir.groups;for(let E of a.sdkName.groupName){let C=typeof E=="string"?E:E.name,M=A[C];if(M==null)break;if(M.summary!=null||M.description!=null){o=A[C];break}}}let l=p==null?void 0:n.tagsById[p];e.setInState(foe.Endpoint),e.setEndpointMethod(a.method);let O=Tby({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(foe.Endpoint),i=[...i,...O.schemaIdsToExclude],e.builder.addEndpoint(c,{name:u,schema:O.value,source:a.source!=null?oli(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function Nby(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?uli(r.groupName):void 0,i=zS({schema:aw.primitive(r),context:e,fileContainingReference:oP.of(Jx),namespace:n,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:wz(i),docs:r.description??void 0}})}}function Rby(e){for(let t of e.ir.webhooks){let r=OBD({webhook:t,context:e});if(r==null)continue;let n=Avs(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=V8r({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:i,payload:zS({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:KOe(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function gBD({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:V$(oP.of(t),e.file)}:e}function mBD({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:oP.of(Jx),endpointId:n};let i=M4o(r),a=M4o(n);if(Tae(i,a))return{file:oP.of("__package__.yml"),endpointId:r};let u=[];for(let c=0;c<i.length;++c){let p=i[c];if(p!=null&&p===a[c])u.push(p);else{let s=Um(r);return{file:oP.of(`${s}.yml`),endpointId:n,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:oP.of(Um(u.join("_"))+".yml"),endpointId:Um(a.slice(u.length).join("_")),tag:r}}function OBD({webhook:e,context:t}){return e.sdkName!=null?{file:uby({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:gBD({namespaceOverride:e.namespace,location:mBD({webhook:e,context:t})})}var ABD=oP.of(Jx);function zby(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return Fby({namespace:e.namespace,groupName:e.groupName});case"oneOf":return Fby({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return ABD;default:lc(e)}}function Fby({namespace:e,groupName:t}){return e!=null&&t!=null?UDi([{type:"namespace",name:e},...t]):e!=null?UDi([{type:"namespace",name:e}]):UDi(t)}var $uf="external",qby=oP.of(Jx);function Qby({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=zby(a),c=dby({schema:a,context:n,declarationFile:u,namespace:r,declarationDepth:0});if(B1i(c.schema)){let p=wz(c.schema);if(p===(c.name??i)||p===`optional<${c.name??i}>`||p===`optional<nullable<${c.name??i}>>`)continue}n.builder.addType(u,{name:c.name??i,schema:c.schema})}}function Lby(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),Pby(e),wby(e),jby(e),vby(e),Nby(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience($uf);let t=xby(e),r=t.sdkGroups;e.setInState(foe.Webhook),Rby(e),e.unsetInState(foe.Webhook),e.setInState(foe.Channel);for(let i of Object.values(e.ir.channels)){let a=UDi(i.groupName);Oby({channel:i,context:e,declarationFile:a})}e.unsetInState(foe.Channel);let n=PBD({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});Qby({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:n,namespace:void 0,context:e});for(let[i,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))Qby({schemas:a,schemaIdsToExclude:n,namespace:i,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function PBD({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let n=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),i=new Set(t);for(let a of n)r.includes(a)||i.add(a);return Array.from(i)}var T4o=class{context;constructor(t){this.context=t}};var wvs=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,c]of Object.entries(n.files)){let p=i!=null?oP.of(`${i}${"/"}${u}`):oP.of(u);t[p]=c}let a=Object.keys(n.directories).sort();for(let u of a){let c=i!=null?`${i}${"/"}${u}`:u,p=n.directories[u];r(p,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split("/"))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[oP.of(t[0])]??={};let[r,...n]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(n)}};var g$i=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new wvs,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":n,"display-name":i,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),n!=null&&(u.service["base-path"]=n),i!=null&&(u.service["display-name"]=i),a!=null&&(u.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 Jzr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let n of Object.values(this.rootApiFile["auth-schemes"]))Uby(n)&&t.push(n.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(Uby(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let n=this.getVersionHeader();n!=null&&n===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:n}){if(t===r)return;let i=n??Um((Gct(r)+"/"+rWi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===oP.of(aZ))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=s8u(Gct(dRa.of(`/${t}`)),dRa.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=s8u(Gct(dRa.of(`/${t}`)),dRa.of(`/${r}`)),i}addType(t,{name:r,schema:n}){if(t===oP.of(aZ))return;let i=this.getOrCreateFile(t);i.types==null&&(i.types={}),i.types[r]=n}addTypeExample(t,r,n){let i=this.getOrCreateFile(t);i.types==null&&(i.types={});let a=i.types[r];a!=null&&(typeof a=="string"?i.types[r]={type:a,examples:[n]}:(a.examples==null&&(a.examples=[]),a.examples.push(n)))}addError(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.errors==null&&(i.errors={}),i.errors[r]==null?i.errors[r]=n:i.errors[r]?.type!==n.type&&(i.errors[r]={"status-code":n["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:n}){let i=this.getOrCreateFile(t);if(i.errors==null)return;let a=i.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>Tae(c,n))??!1)||a.examples?.push(n)}addEndpoint(t,{name:r,schema:n,source:i}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),i!=null&&(a.service.source=i),a.service.endpoints[r]=n}addWebhook(t,{name:r,schema:n}){let i=this.getOrCreateFile(t);i.webhooks==null&&(i.webhooks={}),i.webhooks[r]=n}addChannel(t,{channel:r}){let n=this.getOrCreateFile(t);n.channel=r;let i=this.basePath;i!=null&&(n.channel.path=V$(i,r.path))}addChannelExample(t,{example:r}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.examples==null&&(n.channel.examples=[]),n.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:n}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.messages[r]=n}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([i,a])=>[i,{...a,path:V$(r,a.path)}]))});for(let i of Object.values(t))i.service!=null&&(i.service={...i.service,endpoints:Object.fromEntries(Object.entries(i.service.endpoints).map(([a,u])=>[a,{...u,path:V$(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===Jx?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 Uby(e){return e?.header!=null}var jvs=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:n,environmentOverrides:i,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=i,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=n?.detectGlobalHeaders??!0,this.objectQueryParameters=n?.objectQueryParameters??!1,this.respectReadonlySchemas=n?.respectReadonlySchemas??!1,this.respectNullableSchemas=n?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=n?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=n?.inlinePathParameters??!1,this.useBytesForBinaryResponse=n?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=n?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=n?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=n?.enableUniqueErrorsPerEndpoint??!1,this.builder=new g$i(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let p of r.endpoints)for(let[s,o]of Object.entries(p.errors)){let l=parseInt(s),O=c[l];O==null&&o.schema!=null?c[l]=o.schema:O!=null&&o.schema!=null&&yNe(O,o.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(foe.Channel,foe.Endpoint,foe.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:lc(t)}}markObjectSchemaAsReferenced(t,r){for(let n of t.allOf)this.markSchemaIdAsReferenced(n.schema,r);for(let n of t.properties)this.markSchemaAsReferenced(n.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let n of Object.values(t.schemas))this.markSchemaAsReferenced(n,r);return;case"undiscriminated":for(let n of t.schemas)this.markSchemaAsReferenced(n,r);return;default:lc(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let n=this.getSchema(t,r);n!=null&&this.markSchemaAsReferenced(n,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function Yuf(e){let t=new jvs(e);return Lby(t)}var Evs=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:n,absoluteFilePath:i}){let a=Yuf({taskContext:t,ir:r,options:P4o({overrides:{...n,respectReadonlySchemas:n?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:n?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:n?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:n?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:n?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:n?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:n?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:n?.auth!=null?{auth:n.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:i??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:lg.dump(a.rootApiFile)},namedDefinitionFiles:{...Rb(a.definitionFiles,u=>({absoluteFilepath:i??this.args.absoluteFilePath,rawContents:lg.dump(u),contents:u})),[oP.of(Jx)]:{absoluteFilepath:i??this.args.absoluteFilePath,rawContents:lg.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var q4o=class extends OCr{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;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.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.converter=new Evs(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:n},i){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:n},i);return this.converter.convert({context:t,ir:a,settings:i,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new Uet({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion})}};var mye={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 HQa={of(e){return e}};var Vby={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},Xuf={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:Vby,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},tb={SOURCE:HQa.of("source"),SDK_NAMESPACE:HQa.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:HQa.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:HQa.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:HQa.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",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated"};var xJ={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1,groupMultiApiEnvironments:!1};function Tdt({options:e,overrides:t}){return{disableExamples:t?.disableExamples??xJ.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??xJ.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??xJ.useTitlesAsName,audiences:t?.audiences??e?.audiences??xJ.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??xJ.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??xJ.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??xJ.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??xJ.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??xJ.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??xJ.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??xJ.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??xJ.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??xJ.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??xJ.objectQueryParameters,filter:t?.filter??e?.filter??xJ.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??xJ.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??xJ.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??xJ.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??xJ.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??xJ.typeDatesAsStrings,preserveSingleSchemaOneOf:t?.preserveSingleSchemaOneOf??e?.preserveSingleSchemaOneOf??xJ.preserveSingleSchemaOneOf,inlineAllOfSchemas:t?.inlineAllOfSchemas??e?.inlineAllOfSchemas??xJ.inlineAllOfSchemas,groupMultiApiEnvironments:t?.groupMultiApiEnvironments??e?.groupMultiApiEnvironments??xJ.groupMultiApiEnvironments}}var Wby={naming:"v1"};function Cy(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function x4o(e,t,r,n,i=[]){try{let a=Cy(e,t);if(a!=null)return r.parse(a)}catch{let u=Tct(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function m$i(e){let t=Cy(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 Hby({schema:e,logger:t}){return Cy(e,tb.ENCODING)??void 0}function Gby(e){return Cy(e,tb.FERN_ENUM)}function Jby({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=Cy(n,tb.SDK_NAMESPACE),c=Cy(n,tb.SDK_GROUP_NAME),p=Cy(n,tb.TYPE_DEFINITION);if(p!=null)return N4o({fernType:p,nameOverride:e,generatedName:t,title:r,description:i,availability:a,namespace:u,groupName:typeof c=="string"?[c]:c})}function N4o({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c}){return gZ({type:e,_default:void 0,validation:void 0,visitor:{primitive:p=>{switch(p.v1){case"BASE_64":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.base64({example:void 0})});case"BOOLEAN":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.boolean({default:void 0,example:void 0})});case"DATE":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.date({example:void 0})});case"DATE_TIME":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.datetime({example:void 0})});case"FLOAT":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.float({example:void 0})});case"DOUBLE":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.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 Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.uint({default:void 0,example:void 0})});case"INTEGER":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.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 Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.uint64({default:void 0,example:void 0})});case"LONG":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Uh.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,schema:kg.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:lc(p.v1)}},unknown:()=>Uh.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,namespace:u,groupName:c}),map:({keyType:p,valueType:s})=>p?.type==="primitive"&&s!=null?Uh.map({nameOverride:t,generatedName:r,title:n,key:p,value:s,description:i,availability:a,namespace:u,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:p=>p!=null?Uh.array({nameOverride:t,generatedName:r,title:n,value:p,description:i,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,optional:p=>p!=null?Uh.optional({nameOverride:t,generatedName:r,title:n,value:p,description:i,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,nullable:p=>p!=null?Uh.nullable({nameOverride:t,generatedName:r,title:n,value:p,description:i,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,set:p=>p!=null?Uh.array({nameOverride:t,generatedName:r,title:n,value:p,description:i,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,literal:p=>Uh.literal({nameOverride:t,generatedName:r,title:n,value:p._visit({string:s=>LV.string(s),boolean:s=>LV.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,namespace:u,groupName:c}),named:p=>Uh.reference({schema:p,nameOverride:t,generatedName:r,title:n,description:i,availability:a,namespace:u,groupName:c,source:HOe.openapi({file:"<memory>"})})}})}function Kby(e){let t=Cy(e,tb.SOURCE);if(t!=null)return t.endsWith(".proto")?HOe.protobuf({file:t}):HOe.openapi({file:t})}function O$i(e){if(e!=null&&typeof e=="boolean")return e}function Ig(e){return e?.$ref!=null}function $by({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:c,context:p,namespace:s,groupName:o,example:l,encoding:O,source:A}){return i===void 0&&(i=p.options.additionalPropertiesDefaultsTo),typeof i=="boolean"||GQa(i,p.options)?Svs({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:kg.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:Uh.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0}),namespace:s,groupName:o,example:l,encoding:O}):Svs({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:kg.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:Yby(S1(i,p.options.optionalAdditionalProperties?c:!1,p,[...n,"Value"],A,s,void 0,void 0,void 0)),namespace:s,groupName:o,example:l,encoding:O})}function Yby(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=Yby(e.value);break;case"oneOf":e.value.inline=!0;break;default:lc(e)}return e}function Svs({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:c,namespace:p,groupName:s,example:o,encoding:l}){return a?Uh.nullable({nameOverride:e,generatedName:t,title:r,value:Uh.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,namespace:p,groupName:s,encoding:l,example:o,inline:void 0}),description:u,availability:c,namespace:p,groupName:s,inline:void 0}):Uh.map({nameOverride:e,generatedName:t,title:r,description:u,availability:c,key:n,value:i,namespace:p,groupName:s,encoding:l,example:o,inline:void 0})}function GQa(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!Ig(e)&&Object.keys(e).length===0}function Xby({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:c,context:p,namespace:s,groupName:o,example:l,source:O}){let A=i==null?Uh.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:s,groupName:o}):S1(i,!1,p,[...n,"Item"],O,s);return wBD({nameOverride:e,generatedName:t,title:r,namespace:s,groupName:o,itemSchema:A,wrapAsNullable:c,description:a,availability:u,example:l})}function wBD({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,namespace:c,groupName:p,example:s}){return i?Uh.nullable({nameOverride:e,generatedName:t,title:r,value:Uh.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,namespace:c,groupName:p,example:s,inline:void 0}),description:a,availability:u,namespace:c,groupName:p,inline:void 0}):Uh.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,namespace:c,groupName:p,example:s,inline:void 0})}function $Oe(e){switch(Cy(e,tb.AVAILABILITY)){case"deprecated":return vye.Deprecated;case"beta":return vye.Beta;case"generally-available":return vye.GenerallyAvailable;default:break}if(!Ig(e)&&e.deprecated)return vye.Deprecated}function Zuf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:c,wrapAsNullable:p,discriminator:s,context:o,namespace:l,groupName:O,encoding:A,source:E}){let C=s.propertyName,M=Object.fromEntries(Object.entries(s.mapping??{}).map(([L,U])=>{let Q=cli({$ref:U},!1,o,[U],A,E,l);return o.markReferencedByDiscriminatedUnion({$ref:U},C,1),[L,Q]})),q=Object.entries(i).filter(([L])=>L!==C).map(([L,U])=>{let Q=c!=null&&c.includes(L),J=S1(U,!Q,o,[...n,L],E,l);return{key:L,schema:J}});return Zby({nameOverride:e,generatedName:t,title:r,wrapAsNullable:p,properties:q,description:a,availability:u,discriminant:C,subtypes:M,namespace:l,groupName:O,source:E})}function kuf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:c,wrapAsNullable:p,discriminant:s,variants:o,context:l,namespace:O,groupName:A,encoding:E,source:C}){let M=Object.fromEntries(Object.entries(o).map(([L,U])=>{if(Ig(U)){let Q=cli(U,!1,l,[U.$ref],E,C,O);return l.markReferencedByDiscriminatedUnion(U,s,1),[L,Q]}else{let Q=JQa(U,!1,l,[...n,L],E,C,O,new Set([s]));return[L,Q]}})),q=Object.entries(i).filter(([L])=>L!==s).map(([L,U])=>{let Q=c!=null&&c.includes(L),J=S1(U,!Q,l,[...n,L],C,O);return{key:L,schema:J}});return Zby({nameOverride:e,generatedName:t,title:r,wrapAsNullable:p,properties:q,description:a,availability:u,discriminant:s,subtypes:M,namespace:O,groupName:A,source:C})}function Zby({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:c,subtypes:p,namespace:s,groupName:o,source:l}){return n?Uh.nullable({nameOverride:e,generatedName:t,title:r,value:Uh.oneOf(PSe.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:p,commonProperties:i,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0})),namespace:s,groupName:o,description:a,availability:u,inline:void 0}):Uh.oneOf(PSe.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:p,commonProperties:i,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0}))}function kby(e){if(e.proto!=null)return pQa.protobuf({typeName:e.proto.type})}function WDi({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:c,availability:p,wrapAsNullable:s,namespace:o,groupName:l,context:O,source:A,inline:E}){let C=EBD(i??[]),M=new Set(a),q=Array.from(M).map((U,Q)=>{let J=n?.[U],X=C[Q],te=LQa.test(U),k=J?.name??X,re=te?U:UQa(U);return k!=null&&!LQa.test(k)&&(O?.logger.warn(`Enum name override ${k} is not a valid name. Falling back on ${re}.`),k=void 0),{nameOverride:k,generatedName:re,value:U,description:J?.description,availability:p,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}}}),L=u!=null?q.find(U=>U.value===u):void 0;return jBD({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:q,_default:L,description:c,availability:p,namespace:o,groupName:l,source:A,inline:E})}function jBD({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:c,namespace:p,groupName:s,source:o,inline:l}){return e?Uh.nullable({nameOverride:t,generatedName:r,title:n,value:Uh.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:c,example:void 0,namespace:p,groupName:s,source:o,inline:l}),description:u,availability:c,namespace:p,groupName:s,inline:l}):Uh.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:c,default:a,example:void 0,namespace:p,groupName:s,source:o,inline:l})}function EBD(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(n=>n[r]===t[r]);)r++;return e.map(n=>n.substring(r))}function egy({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:p,multipleOf:s,description:o,availability:l,wrapAsNullable:O,example:A,namespace:E,groupName:C}){return n==="int64"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.int64({default:i,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="uint32"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.uint({default:i,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="uint64"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.uint64({default:i,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):doe({nameOverride:e,generatedName:t,title:r,primitive:kg.int({default:i,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:p,multipleOf:s,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C})}function tgy(e){return typeof e=="string"?LV.string(e):typeof e=="boolean"?LV.boolean(e):LV.string(`${e}`)}function rgy({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,namespace:c,groupName:p}){return n?Uh.nullable({nameOverride:e,generatedName:t,title:r,value:Uh.literal({nameOverride:e,generatedName:t,title:r,value:tgy(i),description:a,availability:u,namespace:c,groupName:p}),description:a,availability:u,namespace:c,groupName:p,inline:void 0}):Uh.literal({nameOverride:e,generatedName:t,title:r,value:tgy(i),description:a,availability:u,namespace:c,groupName:p})}function esf({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:p,multipleOf:s,description:o,availability:l,wrapAsNullable:O,example:A,namespace:E,groupName:C}){return n==null||n==="double"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.double({default:i,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:p,multipleOf:s,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="float"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.float({example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="int32"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.int({default:i,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:p,multipleOf:s,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="int64"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.int64({default:i,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="uint32"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.uint({default:i,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="uint64"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.uint64({default:i,example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):n==="time-delta"?doe({nameOverride:e,generatedName:t,title:r,primitive:kg.float({example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C}):doe({nameOverride:e,generatedName:t,title:r,primitive:kg.float({example:A}),wrapAsNullable:O,description:o,availability:l,namespace:E,groupName:C})}var SBD={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},DBD={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}}},CBD={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}}},IBD={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},MBD={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},BBD={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},TBD={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},qBD={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function Dvs(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[SBD,DBD,CBD,IBD,MBD,BBD,TBD,qBD],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:c}=a.applyStrategy(t);t=u,r=[...r,...c]}}while(t.join("")!==i.join(""));return r}function poe(e,t){let n=e.map(i=>/^[^a-zA-Z0-9]+$/.test(i)?i:P9(Um(i))).join("");return/^\d/.test(n)?D4o(n)??n:n}function tsf(e){let t=e.join("_");return Um(t)}function b6(e){switch(e.type){case"object":return aw.object({allOf:e.allOf,properties:e.properties.map(t=>NBD(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 aw.array({description:e.description,availability:e.availability,value:b6(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return aw.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 aw.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 aw.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:b6(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return aw.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:b6(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return aw.primitive({description:e.description,availability:e.availability,schema:ngy(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return aw.map({description:e.description,availability:e.availability,key:aw.primitive({description:e.key.description,availability:e.key.availability,schema:ngy(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:b6(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 aw.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 aw.oneOf(xBD(e.value));case"unknown":return aw.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:lc(e)}}function xBD(e){switch(e.type){case"discriminated":return ali.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:b6(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,b6(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return ali.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>b6(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:lc(e)}}function ngy(e){switch(e.type){case"string":return zT.string(e);case"base64":return zT.base64();case"boolean":return zT.boolean(e);case"date":return zT.date();case"datetime":return zT.datetime();case"double":return zT.double(e);case"float":return zT.float();case"int":return zT.int(e);case"int64":return zT.int64(e);case"uint":return zT.uint();case"uint64":return zT.uint64();default:lc(e)}}function NBD(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:b6(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function Cvs(e,t){return yNe(b6(e),b6(t))}function igy({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:c,allOf:p,context:s,propertiesToExclude:o,namespace:l,groupName:O,fullExamples:A,additionalProperties:E,availability:C,source:M}){let q=[...u??[]],L={...i},U=[],Q=[];for(let re of p)if(!s.options.inlineAllOfSchemas&&Ig(re)){let ue=s.resolveSchemaReference(re);if(ue.discriminator!=null&&ue.discriminator.mapping!=null)continue;if(ue.oneOf!=null||ue.anyOf!=null){let me=ue.oneOf??ue.anyOf;if(me!=null){for(let Ee of me){let Pe=Ig(Ee)?s.resolveSchemaReference(Ee):Ee,Me=S1(Pe,!1,s.DUMMY,n,M,l);Me.type==="object"&&U.push(...Me.properties.map(Ue=>Ue.schema.type!=="optional"&&Ue.schema.type!=="nullable"?{...Ue,schema:Uh.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Ue.schema,description:void 0,availability:Ue.availability,namespace:void 0,groupName:void 0,inline:void 0})}:Ue))}continue}}let Oe=HDi(re);if(Oe==null)continue;Q.push({schemaId:Oe,convertedSchema:rsf(re,[Oe],M,s.options.preserveSchemaIds),properties:agy({schema:re,context:s,breadcrumbs:n,source:M,namespace:l})}),s.markSchemaAsReferencedByNonRequest(Oe)}else if(Ig(re)){let ue=s.resolveSchemaReference(re),Oe=S1(ue,!1,s,n,M,l);Oe.type==="object"&&U.push(...Oe.properties)}else{let ue=re.required??[];U=U.map(me=>(me.schema.type==="optional"||me.schema.type==="nullable")&&ue.includes(me.key)?{...me,schema:me.schema.value}:me);let Oe=S1(re,!1,s,n,M,l);Oe.type==="object"&&U.push(...Oe.properties)}let J={};for(let re of Q)for(let[ue,Oe]of Object.entries(re.properties)){let me=J[ue];me!=null?(me.schemaIds.push(re.schemaId),me.schemas.some(Pe=>Cvs(Pe,Oe))||me.schemas.push(Oe)):J[ue]={schemaIds:[re.schemaId],schemas:[Oe]}}let X=[];for(let[re,ue]of Object.entries(J))ue.schemaIds.length>1&&X.push({propertyKey:re,allOfSchemaIds:ue.schemaIds,conflictingTypeSignatures:ue.schemas.length>1});let te=Object.fromEntries(Object.entries(L).filter(([re,ue])=>!(!Ig(ue)&&ue.type==="null"))),k=Object.entries(te).map(([re,ue])=>{let Oe=Cy(ue,tb.AUDIENCES)??[],me=$Oe(ue),Ee=Ig(ue)?!1:ue.readOnly,Pe=Ig(ue)?!1:ue.writeOnly,Me=q.includes(re)&&!Ee,Ue=Cy(ue,tb.FERN_PROPERTY_NAME),Be=[...n,re],Bt=tsf(Be),Qt=Me?S1(ue,!1,s,Be,M,l):Uh.optional({nameOverride:e,generatedName:Bt,title:r,description:void 0,availability:me,value:S1(ue,!1,s,Be,M,l),namespace:l,groupName:O,inline:void 0}),Ke={};for(let ze of Q){let Dr=ze.properties[re];Dr!=null&&!Cvs(Qt,Dr)?Ke[ze.schemaId]={differentSchema:!0}:Dr!=null&&(Ke[ze.schemaId]={differentSchema:!1})}return{key:re,schema:Qt,nameOverride:Ue,audiences:Oe,conflict:Ke,generatedName:tsf([...n,re]),availability:me,readonly:Ee,writeonly:Pe}});return k.push(...U.map(re=>{let ue=re.conflict;for(let Oe of Q){let me=Oe.properties[re.key];me!=null&&!Cvs(re.schema,me)?ue[Oe.schemaId]={differentSchema:!0}:me!=null&&(ue[Oe.schemaId]={differentSchema:!1})}return{...re,conflict:ue}})),RBD({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,properties:k.filter(re=>!o.has(re.key)),description:a,allOf:Q.map(re=>re.convertedSchema),allOfPropertyConflicts:X,namespace:l,groupName:O,fullExamples:A,additionalProperties:E,availability:C,source:M,context:s})}function RBD({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:c,namespace:p,groupName:s,fullExamples:o,additionalProperties:l,availability:O,source:A,context:E}){return n?Uh.nullable({nameOverride:e,generatedName:t,title:r,value:Uh.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:p,groupName:s,fullExamples:o,additionalProperties:GQa(l,E.options),availability:void 0,source:A,inline:void 0}),description:a,availability:O,namespace:p,groupName:s,inline:void 0}):Uh.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:p,groupName:s,fullExamples:o,additionalProperties:GQa(l,E.options),availability:O,source:A,inline:void 0})}function agy({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,c]=Ig(e)?[t.resolveSchemaReference(e),Dvs(e.$ref)]:[e,r];for(let p of u.allOf??[])a={...a,...agy({schema:p,context:t,breadcrumbs:c,source:n,namespace:i})};for(let[p,s]of Object.entries(u.properties??{})){let o=S1(s,!1,t,[...c,p],n,i);a[p]=o}return a}function GDi({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:c,subtypes:p,namespace:s,groupName:o,encoding:l,source:O,subtypePrefixOverrides:A}){let E=QBD({schemas:p}),C=p.flatMap((q,L)=>{if(!Ig(q)&&q.enum!=null&&c.options.coerceEnumsToLiterals&&q.type==="string")return q.enum.map(Q=>Uh.literal({nameOverride:void 0,generatedName:poe([t,Q],c.options.preserveSchemaIds),title:void 0,value:LV.string(String(Q)),namespace:s,groupName:void 0,description:void 0,availability:Q.availability}));let U=E[L];if(A!=null){let Q=A[L];Q!=null&&"name"in Q&&(U=Q.name)}return[S1(q,!1,c,[...n,U??`${L}`],O,s)]}),M=FBD(C);return zBD({uniqueSubtypes:M,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,namespace:s,groupName:o,context:c,encoding:l,source:O})}function FBD(e){let t=[];for(let r=0;r<e.length;++r){let n=e[r],i=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(n!=null&&u!=null&&yNe(n,u)){i=!0;break}}n!=null&&!i&&t.push(n)}return t}function zBD({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:n,wrapAsNullable:i,description:a,availability:u,namespace:c,groupName:p,context:s,encoding:o,source:l}){if(Object.entries(e).every(([A,E])=>E.type==="literal")){let A={},E=[];return Object.entries(e).forEach(([C,M])=>{M.type==="literal"&&M.value.type==="string"&&(E.push(M.value.value),M.description!=null&&(A[M.value.value]={description:M.description}))}),WDi({nameOverride:t,generatedName:r,title:n,wrapAsNullable:i,description:a,availability:u,fernEnum:A,enumVarNames:void 0,enumValues:E,_default:void 0,namespace:c,groupName:p,context:s,source:l,inline:void 0})}return e.length===1&&e[0]!=null&&!s.options.preserveSingleSchemaOneOf?e[0]:ogy({nameOverride:t,generatedName:r,title:n,wrapAsNullable:i,description:a,availability:u,subtypes:e,namespace:c,groupName:p,encoding:o,source:l})}function nsf({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,namespace:c,groupName:p,discriminator:s,encoding:o,source:l}){let O=Object.entries(s.mapping??{}).map(([C,M],q)=>{let L={$ref:M},U=cli(L,!1,u,[M],o,l,c);return u.markSchemaWithDiscriminantValue(L,s.propertyName,C),U.type==="object"&&(U.properties={[s.propertyName]:Uh.literal({nameOverride:void 0,generatedName:poe([t,C],u.options.preserveSchemaIds),title:void 0,value:LV.string(C),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...U.properties.filter(Q=>Q.key!==s.propertyName)}),U}),A=[];for(let C=0;C<O.length;++C){let M=O[C],q=!1;for(let L=C+1;L<O.length;++L){let U=O[L];if(M!=null&&U!=null&&yNe(M,U)){q=!0;break}}M!=null&&!q&&A.push(M)}if(Object.entries(A).every(([C,M])=>M.type==="literal")){let C={},M=[];return Object.entries(A).forEach(([q,L])=>{L.type==="literal"&&L.value.type==="string"&&(M.push(L.value.value),L.description!=null&&(C[L.value.value]={description:L.description}))}),WDi({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:C,enumVarNames:void 0,enumValues:M,_default:void 0,namespace:c,groupName:p,context:u,source:l,inline:void 0})}return A.length===1&&A[0]!=null&&!u.options.preserveSingleSchemaOneOf?A[0]:ogy({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:A,namespace:c,groupName:p,encoding:o,source:l})}function QBD({schemas:e}){let t={},r=0;for(let a of e){if(!Ig(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),c={},p=u;for(let[s,o]of Object.entries(t)){let l=c6u(o,u);p=c6u(p,o),c[s]=l}c[r]=p,t=c}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let c=u.sort();if(c[0]!=null){n.push(c[0]),++i;continue}}Ig(a)?n.push(LDi(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(LDi(i)??`${i}`),++i}return n}function ogy({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,namespace:c,groupName:p,encoding:s,source:o}){return n?Uh.nullable({nameOverride:e,generatedName:t,title:r,value:Uh.oneOf(PSe.undiscriminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:p,encoding:s,source:o,inline:void 0})),description:i,availability:a,namespace:c,groupName:p,inline:void 0}):Uh.oneOf(PSe.undiscriminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:p,encoding:s,source:o,inline:void 0}))}function KQa(e){if(e.default!=null&&typeof e.default=="string")return e.default}function Ivs({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let n=m$i(e);for(let i of n??[])if(typeof i=="number")return i;if(r&&typeof r=="number")return r}function ugy({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let n=m$i(e);for(let i of n??[])if(typeof i=="boolean")return i;if(r&&typeof r=="boolean")return r}function W8r({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let n=m$i(e);for(let i of n??[])if(typeof i=="string")return i;if(r&&typeof r=="string")return r}function sgy({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let n=m$i(e);for(let i of n??[])if(Array.isArray(i))return i;if(r&&Array.isArray(r))return r}var A$i="#/components/schemas/";function S1(e,t,r,n,i,a,u=!1,c=new Set,p){let s=Kby(e)??i,o=KBD({schema:e,logger:r.logger});if(Ig(e)){let l=HDi(e);return l!=null?(u?r.markSchemaAsReferencedByRequest(l):r.markSchemaAsReferencedByNonRequest(l),cli(e,t,r,n,o,s,a)):JQa(r.resolveSchemaReference(e),t,r,Dvs(e.$ref),o,s,a,c,u,p)}return JQa(e,t,r,n,o,s,a,c,u,p)}function cli(e,t,r,n,i,a,u){let c=e.$ref.includes("properties")?JQa(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Uh.reference(rsf(e,n,a,r.options.preserveSchemaIds));return t?Uh.nullable({title:void 0,nameOverride:void 0,generatedName:poe(n,r.options.preserveSchemaIds),value:c,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0}):c}function LBD(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function JQa(e,t,r,n,i,a,u,c=new Set,p=!1,s){typeof e=="string"&&(e={type:e});let o=Cy(e,tb.TYPE_NAME)??(r.options.useTitlesAsName?LBD(e.title):void 0),l=Cy(e,tb.SDK_GROUP_NAME)??Cy(e,mye.TAGS)?.[0],O=(typeof l=="string"?[l]:l)??[];O=r.resolveGroupName(O);let A=poe(n,r.options.preserveSchemaIds),E=e.title,C=e.description,M=$Oe(e),q=[];e.example!=null&&q.push({name:void 0,value:e.example,description:void 0});let L=Cy(e,mye.EXAMPLES);L!=null&&Object.keys(L).length>0&&q.push(...Object.entries(L).map(([J,X])=>({name:X?.summary??J,value:X.value,description:X.description})));let U=m$i(e);U!=null&&Object.keys(U).length>0&&q.push(...U.map(J=>({name:void 0,value:J,description:void 0})));let Q=Jby({schema:e,description:C,title:E,nameOverride:o,generatedName:A,availability:M});if(Q!=null)return Q;try{if(Array.isArray(e.type)){let X=e.type.indexOf("null"),te=X!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&te)e.type.splice(X,1),e.type=e.type[0],e.nullable=!0;else if(te&&(e.type.splice(X,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let k=new Set([...e.oneOf,...e.type]);e.oneOf=[...k]}}if(!t&&e.nullable===!0)return JQa(e,!0,r,n,i,a,u,c,p,s);if("const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(!Tvs(e.enum))return doe({nameOverride:o,generatedName:A,title:E,primitive:kg.string({default:KQa(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:W8r({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:O,wrapAsNullable:t,description:C,availability:M});let X=Gby(e);return e.enum.length===1&&e.enum[0]!=null&&X==null?rgy({nameOverride:o,generatedName:A,title:E,wrapAsNullable:t,value:e.enum[0],description:C,availability:M,namespace:u,groupName:O}):WDi({nameOverride:o,generatedName:A,title:E,fernEnum:X,enumVarNames:Cy(e,[mye.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:C,availability:M,wrapAsNullable:t,namespace:u,groupName:O,context:r,source:a,inline:void 0})}if(Tvs(e.type)&&e.type.length>1){let X=e.type.includes("null"),te=e.type.filter(k=>k!=="null").map(k=>({type:k,nullable:X}));return GDi({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,description:C,availability:M,wrapAsNullable:t,context:r,subtypes:te,namespace:u,groupName:O,encoding:i,source:a})}if(e.type==="boolean"){let X=Cy(e,tb.BOOLEAN_LITERAL);return X!=null?cgy({nameOverride:o,generatedName:A,title:E,literal:LV.boolean(X),wrapAsNullable:t,description:C,availability:M,namespace:u,groupName:O}):doe({nameOverride:o,generatedName:A,title:E,primitive:kg.boolean({default:UBD(e.default),example:ugy({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:C,availability:M,namespace:u,groupName:O})}if(e.type==="number")return esf({nameOverride:o,generatedName:A,title:E,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:O$i(e.exclusiveMinimum),exclusiveMaximum:O$i(e.exclusiveMaximum),multipleOf:e.multipleOf,description:C,availability:M,wrapAsNullable:t,example:Ivs({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:O});if(e.type==="integer")return egy({nameOverride:o,generatedName:A,title:E,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:O$i(e.exclusiveMinimum),exclusiveMaximum:O$i(e.exclusiveMaximum),multipleOf:e.multipleOf,description:C,availability:M,wrapAsNullable:t,example:Ivs({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:O});if(e.type==="float")return esf({nameOverride:o,generatedName:A,title:E,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:O$i(e.exclusiveMinimum),exclusiveMaximum:O$i(e.exclusiveMaximum),multipleOf:e.multipleOf,description:C,availability:M,wrapAsNullable:t,example:Ivs({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:O});if(e.type==="string"){if(e.format==="date-time")return doe({nameOverride:o,generatedName:A,title:E,primitive:kg.datetime({example:W8r({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:C,availability:M,namespace:u,groupName:O});if(e.format==="date"&&r.options.typeDatesAsStrings===!1)return doe({nameOverride:o,generatedName:A,title:E,primitive:kg.date({example:W8r({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:C,availability:M,namespace:u,groupName:O});if(e.format==="json-string")return Uh.unknown({nameOverride:o,generatedName:A,title:E,description:C,availability:M,namespace:u,groupName:O,example:void 0});let X=dgy(e,"const");return X!=null?cgy({nameOverride:o,generatedName:A,title:E,literal:LV.string(X),wrapAsNullable:t,description:C,availability:M,namespace:u,groupName:O}):doe({nameOverride:o,generatedName:A,title:E,primitive:kg.string({default:KQa(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:W8r({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:O,wrapAsNullable:t,description:C,availability:M})}if(e.type==="array")return Xby({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,item:e.items,description:C,availability:M,wrapAsNullable:t,context:r,namespace:u,groupName:O,example:sgy({schema:e,logger:r.logger,fallback:s}),source:a});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&Mvs(e))return $by({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,additionalProperties:e.additionalProperties,description:C,availability:M,wrapAsNullable:t,context:r,namespace:u,groupName:O,encoding:i,example:e.example,source:a});if(e.oneOf!=null&&e.oneOf.length>0&&Cy(e,tb.IS_DISCRIMINATED)===!1)return GDi({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,description:C,availability:M,wrapAsNullable:t,context:r,subtypes:e.oneOf,namespace:u,groupName:O,encoding:i,source:a});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?nsf({nameOverride:o,generatedName:A,title:E,description:C,availability:M,wrapAsNullable:t,context:r,namespace:u,groupName:O,discriminator:e.discriminator,encoding:i,source:a}):Zuf({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,description:C,availability:M,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:O,encoding:i,source:a});if(e.oneOf!=null&&e.oneOf.length>0){let X=Cy(e,tb.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||X?nsf({nameOverride:o,generatedName:A,title:E,description:C,availability:M,wrapAsNullable:t,context:r,namespace:u,groupName:O,discriminator:e.discriminator,encoding:i,source:a}):Zuf({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,description:C,availability:M,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:O,encoding:i,source:a});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(r.options.preserveSingleSchemaOneOf)return GDi({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,description:C,availability:M,wrapAsNullable:t,context:r,subtypes:e.oneOf.filter(k=>Ig(k)||k.type!=="null"),encoding:i,namespace:u,groupName:O,source:a});let te=S1(e.oneOf[0],t,r,n,a,u,p);return $Qa(te,C,u,O)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let ue=e.oneOf[0],Oe=e.oneOf[1];if(!Ig(ue)&&ue.type==="null")return S1(Oe,!0,r,n,a,u);if(!Ig(Oe)&&Oe.type==="null")return S1(ue,!0,r,n,a,u)}let te=HBD({schemas:e.oneOf});if(te!=null)return WDi({nameOverride:o,generatedName:A,title:E,fernEnum:void 0,enumVarNames:void 0,enumValues:te,_default:e.default,description:C,availability:M,wrapAsNullable:t,namespace:u,groupName:O,context:r,source:a,inline:void 0});let k=lgy({schemas:e.oneOf,context:r});if(k!=null&&!r.options.discriminatedUnionV2&&!X)return kuf({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,properties:e.properties??{},required:e.required,description:C,availability:M,wrapAsNullable:t,discriminant:k.discriminant,variants:k.schemas,context:r,namespace:u,groupName:O,encoding:i,source:a});let re=e.oneOf.filter(ue=>!Ig(ue)&&ue.type==="null").length>0;return GDi({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,description:C,availability:M,wrapAsNullable:t||re,context:r,subtypes:e.oneOf.filter(ue=>Ig(ue)||ue.type!=="null"),encoding:i,namespace:u,groupName:O,source:a})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let k=S1(e.anyOf[0],t,r,n,a,u,p);return $Qa(k,C,u,O)}if(e.anyOf.length===2){let[k,re]=e.anyOf;if(k!=null&&re!=null){if(!Ig(k)&&k.type==="null"){let ue=S1(re,!0,r,n,a,u);return $Qa(ue,C,u,O)}else if(!Ig(re)&&re.type==="null"){let ue=S1(k,!0,r,n,a,u);return $Qa(ue,C,u,O)}}}let X=lgy({schemas:e.anyOf,context:r});if(X!=null&&!r.options.discriminatedUnionV2)return kuf({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,properties:e.properties??{},required:e.required,description:C,availability:M,wrapAsNullable:t,discriminant:X.discriminant,variants:X.schemas,context:r,namespace:u,groupName:O,encoding:i,source:a});let te=e.anyOf.filter(k=>!Ig(k)&&k.type==="null").length>0;return GDi({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,description:C,availability:M,wrapAsNullable:t||te,context:r,subtypes:e.anyOf.filter(k=>Ig(k)||k.type!=="null"),encoding:i,namespace:u,groupName:O,source:a})}if(e.allOf!=null||e.properties!=null){let X=[];for(let k of e.allOf??[])(Ig(k)||Object.keys(k).length>0)&&X.push(k);if((e.properties==null||Mvs(e))&&X.length===1&&X[0]!=null){let k=S1(X[0],t,r,n,a,u,p);return $Qa(k,C,u,O)}let te=X.filter(k=>{let re=Bvs(k);return re||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(k)}`),re});if((e.properties==null||Mvs(e))&&te.length===1&&te[0]!=null){let k=S1(te[0],t,r,n,a,u,p);return $Qa(k,C,u,O)}return igy({nameOverride:o,generatedName:A,title:E,breadcrumbs:n,properties:e.properties??{},description:C,required:e.required,wrapAsNullable:t,allOf:te,context:r,propertiesToExclude:c,namespace:u,groupName:O,fullExamples:q,additionalProperties:e.additionalProperties,availability:M,encoding:i,source:a})}if(e.type==="object"&&VBD(e)&&WBD(e)&&Mvs(e))return Svs({nameOverride:o,generatedName:A,title:E,description:C,availability:M,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${A}Key`,title:void 0,description:void 0,availability:void 0,schema:kg.string({default:KQa(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:W8r({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:O},valueSchema:Uh.unknown({nameOverride:void 0,generatedName:`${A}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:O}),namespace:u,groupName:O,encoding:i,example:e.example});e.type!=null&&r.logger.warn(`Failed to parse an OpenAPI schema at the following location: ${n.join("->")}. Coercing to unknown.`);let J=e.example??e.default;return Uh.unknown({nameOverride:o,generatedName:A,title:E,description:C,availability:M,namespace:u,groupName:O,example:J})}catch(J){return r.logger.debug(`Error converting schema: ${J.message}
@@ -2839,7 +2839,7 @@ ${l}`)}async function HBC(e){await VV(void 0,"docker",["pull",e],{all:!0,doNotPi
2839
2839
  ${JSON.stringify(me.error)}`):c.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com
2840
2840
  ${JSON.stringify(me.error)}`)}},async({api:J,snippetsConfig:X,apiName:te})=>{J.snippetsConfiguration=X;let k=await A.api.v1.register.registerApiDefinition({orgId:GPr.FernRegistry.OrgId(t),apiId:GPr.FernRegistry.ApiId(te??J.id),definition:void 0,definitionV2:{...J,snippetsConfiguration:p?void 0:J.snippetsConfiguration}});if(k.ok)return c.logger.debug(`Registered API Definition ${k.body.apiDefinitionId}`),k.body.apiDefinitionId;switch(k.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return te!=null?c.failAndThrow(`Failed to publish docs because API definition (${te}) could not be uploaded. Please contact support@buildwithfern.com
2841
2841
  ${JSON.stringify(k.error)}`):c.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com
2842
- ${JSON.stringify(k.error)}`)}}).resolve();if(C==null)return c.failAndThrow("Failed to publish docs.","Docs registration ID is missing.");c.logger.debug("Publishing docs...");let Q=await A.docs.v2.write.finishDocsRegister(GPr.FernRegistry.docs.v1.write.DocsRegistrationId(C),{docsDefinition:U});if(Q.ok){let J=LSe(M),X=lgi(J,J);c.logger.info(yd.green(`Published docs to ${X}`))}else switch(Q.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("Insufficient permissions. Failed to publish docs to "+n);case"DocsRegistrationIdNotFound":return c.failAndThrow("Failed to publish docs to "+n,`Docs registration ID ${C} does not exist.`);default:return c.failAndThrow("Failed to publish docs to "+n,Q.error)}}async function TM1(e,t,r,n){let i=Date.now(),a=Object.keys(e).length;r.logger.debug(`Start uploading ${a} files...`);let u=wIo(Object.entries(e),n),c=0;for(let s of u){await Promise.all(s.map(async([l,{uploadUrl:O}])=>{let A=ds.of(l),E=Ww(t,A);try{let C=wl_.lookup(E);await nY.put(O,await(0,NM1.readFile)(E),{headers:{"Content-Type":C===!1?"application/octet-stream":C}})}catch(C){r.failAndThrow(`Failed to upload ${E}`,C)}}));let o=Date.now();c+=s.length,r.logger.debug(`Uploaded ${c}/${a} files in ${o-i}ms`)}let p=Date.now();r.logger.debug(`Finished uploading ${a} files in ${p-i}ms`)}function qM1(e,t){let r=[];for(let[n,i]of Object.entries(e)){let a=ds.of(n),u=Ww(t,a);r.push({relativeFilePath:a,absoluteFilePath:u,fileId:i.fileId})}return r}async function xM1(e,t){switch(await t.instrumentPostHogEvent({command:"docs-generation",properties:{error:JSON.stringify(e)}}),e.error){case"InvalidCustomDomainError":return t.failAndThrow("Your docs domain should end with docs.buildwithfern.com");case"InvalidDomainError":return t.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)");case"UnauthorizedError":return t.failAndThrow("Please make sure that your FERN_TOKEN is set.");case"UserNotInOrgError":return t.failAndThrow("Please verify if you have access to the organization you are trying to publish the docs to. If you are not a member of the organization, please reach out to the organization owner.");case"UnavailableError":return t.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");default:return t.failAndThrow("Failed to publish docs.",e)}}function Jy8(e){try{return new URL(LSe(e)).pathname}catch{return}}async function Ky8({workspace:e,organization:t,context:r,snippetsConfig:n}){let i={};if(!e)return;let a={typescript:n.typescriptSdk?.package,python:n.pythonSdk?.package,java:n.javaSdk?.coordinate,go:n.goSdk?.githubRepo,csharp:n.csharpSdk?.package,ruby:n.rubySdk?.gem,php:n.phpSdk?.package,swift:n.swiftSdk?.package,rust:void 0};if(e.generatorsConfiguration?.groups)for(let u of e.generatorsConfiguration.groups)for(let c of u.generators){let p=KGc({apiName:e.workspaceName??"",organization:t,generatorInvocation:c}),s="";if(p?.outputConfig.type==="publish")switch(p.outputConfig.value.type){case"npm":case"nuget":case"pypi":case"rubygems":s=p.outputConfig.value.packageName;break;case"maven":s=p.outputConfig.value.coordinate;break;case"go":s=p.outputConfig.value.repoUrl;break}if(c.language==="php"&&(s=c.config.packageName??""),!!c.language&&c.language&&a[c.language]===s){let o=GV({workspace:e,generationLanguage:c.language,keywords:void 0,smartCasing:c.smartCasing,exampleGeneration:{disabled:!0,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},audiences:{type:"all"},readme:void 0,packageName:s,version:void 0,context:r,sourceResolver:new WV(r,e),dynamicGeneratorConfig:p}),l=T7o({ir:o,disableExamples:!0,smartCasing:c.smartCasing,generationLanguage:c.language,generatorConfig:p});l?i[c.language]={dynamicIR:l}:r.logger.debug(`Failed to create dynamic IR for ${c.language}`)}}if(Object.keys(i).length>0)return i}async function $y8({dynamicIRs:e,dynamicIRUploadUrls:t,context:r,apiId:n}){if(Object.keys(t).length>0)for(let[i,a]of Object.entries(t)){let u=e[i]?.dynamicIR;u?(await fetch(a.uploadUrl,{method:"PUT",body:JSON.stringify(u),headers:{"Content-Type":"application/octet-stream","Content-Length":JSON.stringify(u).length.toString()}})).ok?r.logger.debug(`Uploaded dynamic IR for ${n}:${i}`):r.logger.warn(`Failed to upload dynamic IR for ${n}:${i}`):r.logger.warn(`Could not find matching dynamic IR to upload for ${n}:${i}`)}}async function jl_({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:a,instanceUrl:u,preview:c,disableTemplates:p,disableDynamicSnippets:s}){let o=n.config.instances;if(n.config=Ewi(n.config,{onError:A=>i.failAndThrow(A)},{substituteAsEmpty:c}),o.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(o.length>1&&u==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${o[0]?.url})`);return}let l=o.find(A=>A.url===u)??o[0];if(l==null){i.failAndThrow(`No docs instance with url ${u}. Failed to register.`);return}let O=[];l.customDomain!=null&&(typeof l.customDomain=="string"?O.push(l.customDomain):Array.isArray(l.customDomain)&&O.push(...l.customDomain)),await i.runInteractiveTask({name:l.url},async()=>{await RM1({docsWorkspace:n,customDomains:O,domain:l.url,token:a,organization:e,context:i,apiWorkspaces:t,ossWorkspaces:r,preview:c,editThisPage:l.editThisPage,isPrivate:l.private,disableTemplates:p,disableDynamicSnippets:s})})}var FB1=$i(eEi(),1);var spe={RequestReference:"requestReference",InlinedRequestProperty:"inlinedRequestProperty",Response:"response",StreamingResponse:"streamingResponse"};function j5(e,t){return r=>{r!=null&&e.docs?.(r,[...t,"docs"])}}function JPr({example:e,visitor:t,nodePath:r}){if(typeof e=="string")e.startsWith("$")&&t.exampleTypeReference?.(e,r);else if(TT(e))for(let n of Object.values(e))JPr({example:n,visitor:t,nodePath:r});else if(Array.isArray(e))for(let n of e)JPr({example:n,visitor:t,nodePath:r})}function axr(e){return(t,r,{_default:n,validation:i,location:a}={})=>{e.typeReference?.({typeReference:t,_default:n,validation:i,location:a,nodePath:r},r)}}function FM1({service:e,visitor:t,nodePath:r}){t.httpService?.(e,r),xq(e,{url:n=>{t.serviceBaseUrl?.(n,[...r,"url"])},"base-path":Jc,"display-name":Jc,availability:Jc,headers:n=>{zM1({headers:n,visitor:t,nodePath:[...r,"headers"]})},audiences:Jc,auth:Jc,"path-parameters":n=>{Avu({pathParameters:n,visitor:t,nodePath:[...r,"path-parameters"]})},endpoints:n=>{for(let[i,a]of Object.entries(n)){let u=[...r,"endpoints",i];Yy8({endpointId:i,endpoint:a,service:e,visitor:t,nodePathForEndpoint:u})}},idempotent:Jc,transport:Jc,source:Jc})}function Yy8({endpointId:e,endpoint:t,service:r,visitor:n,nodePathForEndpoint:i}){let a=axr(n);n.httpEndpoint?.({endpointId:e,endpoint:t,service:r},i),xq(t,{docs:j5(n,i),"display-name":Jc,availability:Jc,"base-path":Jc,path:Jc,idempotent:Jc,url:u=>{n.endpointBaseUrl?.({baseUrl:u,service:r},[...i,"url"])},"path-parameters":u=>{Avu({pathParameters:u,visitor:n,nodePath:[...i,"path-parameters"]})},request:u=>{if(u==null)return;let c=[...i,"request"];if(typeof u=="string"){a(u,c,{location:"requestReference"});return}xq(u,{name:Jc,docs:j5(n,c),"path-parameters":p=>{Avu({pathParameters:p,visitor:n,nodePath:[...c,"path-parameters"]})},"query-parameters":p=>{if(p!=null)for(let[s,o]of Object.entries(p)){let l=[...c,"query-parameters",s];n.queryParameter?.({queryParameterKey:s,queryParameter:o},l),typeof o=="string"?a(o,l):xq(o,{name:Jc,docs:j5(n,l),availability:Jc,type:O=>{a(O,[...l,"type"],{_default:o.default,validation:o.validation})},"allow-multiple":Jc,audiences:Jc,encoding:Jc,default:Jc,validation:Jc})}},"content-type":Jc,headers:p=>{zM1({headers:p,visitor:n,nodePath:[...c,"headers"]})},body:p=>{if(p==null)return;let s=[...c,"body"];typeof p=="string"?a(p,s,{location:"requestReference"}):D9(p)?(n.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:p},s),xq(p,{extends:o=>{if(o==null)return;let l=typeof o=="string"?[o]:o;for(let O of l){let A=[...s,"extends",O];n.extension?.(O,A),a(O,A)}},properties:o=>{if(o!=null)for(let[l,O]of Object.entries(o)){let A=[...s,"properties",l];typeof O=="string"?a(O,A,{location:spe.InlinedRequestProperty}):xq(O,{name:Jc,docs:j5(n,A),availability:Jc,type:E=>{a(E,[...A,"type"],{location:spe.InlinedRequestProperty,_default:O.default,validation:O.validation})},style:Jc,"content-type":Jc,audiences:Jc,encoding:Jc,default:Jc,validation:Jc})}},"extra-properties":Jc})):(j5(n,s)(p.docs),a(p.type,s))}})},audiences:Jc,method:Jc,auth:Jc,"stream-condition":u=>{n.streamCondition?.({streamCondition:u,endpoint:t},[...i,"stream-condition"])},"response-stream":u=>{u!=null&&(typeof u=="string"?a(u,[...i,"response-stream"],{location:spe.StreamingResponse}):a(u.type,[...i,"response-stream"],{location:spe.StreamingResponse}))},response:u=>{if(u==null)return;let c=[...i,"response"];typeof u=="string"?a(u,c,{location:spe.Response}):xq(u,{docs:j5(n,c),type:p=>{p!=null&&a(p,[...c,"type"],{location:spe.Response})},property:Jc,"status-code":Jc})},errors:u=>{if(u!=null)for(let c of u){let p=[...i,"errors",typeof c=="string"?c:c.error];typeof c=="string"?n.errorReference?.(c,p):xq(c,{docs:j5(n,p),error:s=>{n.errorReference?.(s,[...p,"error"])}})}},examples:u=>{if(u!=null)for(let[c,p]of u.entries())Xy8({nodePathForExample:[...i,{key:"examples",arrayIndex:c}],visitor:n,service:r,endpoint:t,example:p})},pagination:Jc,source:Jc,transport:Jc})}function Xy8({nodePathForExample:e,visitor:t,service:r,endpoint:n,example:i}){if(i.headers==null&&i["path-parameters"]==null&&i["query-parameters"]==null&&i.request==null&&i.response==null&&i["code-samples"]!=null)return;t.exampleHttpEndpointCall?.({service:r,endpoint:n,example:i},e);let a=[...e,"headers"];if(t.exampleHeaders?.({service:r,endpoint:n,examples:i.headers},a),i.headers!=null)for(let o of Object.values(i.headers))JPr({example:o,visitor:t,nodePath:a});let u=[...e,"path-parameters"];if(t.examplePathParameters?.({service:r,endpoint:n,examples:i["path-parameters"]},u),i["path-parameters"]!=null)for(let o of Object.values(i["path-parameters"]))JPr({example:o,visitor:t,nodePath:u});let c=[...e,"query-parameters"];if(t.exampleQueryParameters?.({service:r,endpoint:n,examples:i["query-parameters"]},c),i["query-parameters"]!=null)for(let o of Object.values(i["query-parameters"]))JPr({example:o,visitor:t,nodePath:c});let p=[...e,"request"];t.exampleRequest?.({service:r,endpoint:n,example:i.request},p),i.request!=null&&JPr({example:i.request,visitor:t,nodePath:p});let s=[...e,"response"];if(t.exampleResponse?.({service:r,endpoint:n,example:i.response},s),i.response!=null&&SHi(n,i.response,{body:o=>{o.body!=null&&JPr({example:o.body,visitor:t,nodePath:s}),o.error!=null&&t.errorReference?.(o.error,[...s,"error"])},stream:o=>{for(let l of o.stream)JPr({example:l,visitor:t,nodePath:s})},events:o=>{for(let{data:l}of o.stream)JPr({example:l,visitor:t,nodePath:s})}}),i["code-samples"]!=null)for(let[o,l]of i["code-samples"].entries())t.exampleCodeSample?.({service:r,endpoint:n,example:i,sample:l},[...e,{key:"code-samples",arrayIndex:o}])}function Avu({pathParameters:e,visitor:t,nodePath:r}){if(e==null)return;let n=axr(t);for(let[i,a]of Object.entries(e)){let u=[...r,i];t.pathParameter?.({pathParameterKey:i,pathParameter:a},u),t4a(a)?typeof a=="string"?t.variableReference?.(a,u):xq(a,{docs:j5(t,u),variable:c=>t.variableReference?.(c,[...u,"variable"]),availability:Jc}):typeof a=="string"?n(a,u):xq(a,{docs:j5(t,u),type:c=>{n(c,[...u,"type"],{_default:a.default,validation:a.validation})},availability:Jc,encoding:Jc,default:Jc,validation:Jc,name:Jc,audiences:Jc})}}function zM1({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=axr(t);for(let[i,a]of Object.entries(e)){let u=[...r,i];t.header?.({headerKey:i,header:a},u),typeof a=="string"?n(a,u):xq(a,{name:Jc,availability:Jc,type:c=>{n(c,u,{_default:a.default,validation:a.validation})},docs:j5(t,u),audiences:Jc,encoding:Jc,env:Jc,default:Jc,validation:Jc})}}function QM1({typeDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.typeName?.(n,a),El_({typeName:n,declaration:i,visitor:t,nodePathForType:a})}}function El_({typeName:e,declaration:t,visitor:r,nodePathForType:n}){let i=axr(r);r.typeDeclaration?.({typeName:{isInlined:!1,name:e},declaration:t,nodePath:n},n);let a=u=>{if(u!=null)for(let[c,p]of u.entries()){let s=[...n,{key:"examples",arrayIndex:c}];r.exampleType?.({typeName:e,typeDeclaration:t,example:p},s),JPr({example:p.value,nodePath:s,visitor:r})}};mZ(t,{alias:u=>{typeof u=="string"?i(u,n):xq(u,{type:c=>{i(c,[...n,"type"])},docs:j5(r,n),availability:Jc,audiences:Jc,examples:a,validation:Jc,encoding:Jc,source:Jc,inline:Jc})},object:u=>{xq(u,{docs:j5(r,n),extends:c=>{if(c==null)return;let p=typeof c=="string"?[c]:c;for(let s of p){let o=[...n,"extends",s];r.extension?.(s,o),i(s,o)}},properties:c=>{if(c!=null)for(let[p,s]of Object.entries(c)){let o=[...n,"properties",p];typeof s=="string"?i(s,o):xq(s,{name:Jc,docs:j5(r,o),availability:Jc,type:l=>{i(l,[...o,"type"],{_default:s.default,validation:s.validation})},audiences:Jc,encoding:Jc,default:Jc,validation:Jc,access:Jc})}},"extra-properties":Jc,availability:Jc,audiences:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})},discriminatedUnion:u=>{xq(u,{docs:j5(r,n),discriminant:Jc,extends:c=>{if(c==null)return;let p=typeof c=="string"?[c]:c;for(let s of p){let o=[...n,"extends",s];r.extension?.(s,o),i(s,o)}},union:c=>{for(let[p,s]of Object.entries(c)){let o=[...n,"union",p];typeof s=="string"?i(s,o):xq(s,{docs:j5(r,o),name:Jc,key:Jc,type:l=>{typeof l=="string"&&i(l,[...n,"type"])},"display-name":Jc,availability:Jc})}},"base-properties":Jc,availability:Jc,audiences:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})},undiscriminatedUnion:u=>{xq(u,{docs:j5(r,n),discriminated:Jc,union:c=>{for(let[p,s]of c.entries()){let o=[...n,`union[${p}]`];typeof s!="string"&&xq(s,{docs:j5(r,o),type:l=>{i(l,[...n,"type"])},"display-name":Jc,validation:Jc})}},availability:Jc,audiences:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})},enum:u=>{xq(u,{docs:j5(r,n),enum:c=>{for(let p of c){let s=[...n,typeof p=="string"?p:p.name??p.value];typeof p!="string"&&xq(p,{docs:j5(r,s),name:Jc,value:Jc,casing:Jc})}},availability:Jc,audiences:Jc,default:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})}})}function LM1({errorDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.errorDeclaration?.({errorName:n,declaration:i},a),Zy8({errorName:n,declaration:i,visitor:t,nodePathForError:a})}}function Zy8({errorName:e,declaration:t,visitor:r,nodePathForError:n}){let i=axr(r);typeof t=="string"?i(t,n):xq(t,{docs:j5(r,n),"status-code":Jc,type:a=>{if(a==null)return;let u=[...n,"type"];typeof a=="string"?i(a,u):El_({typeName:e,declaration:a,visitor:r,nodePathForType:u})},examples:a=>{if(a!=null)for(let u of a){let c=[...n,"type"];r.exampleError?.({errorName:e,declaration:t,example:u},c)}}})}function UM1({imports:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e))t.import?.({importPath:i,importedAs:n},[...r,n])}function VM1({webhook:e,visitor:t,nodePathForWebhook:r}){let n=axr(t);xq(e,{"display-name":Jc,method:Jc,examples:Jc,headers:i=>{ky8({headers:i,visitor:t,nodePath:[...r,"headers"]})},payload:i=>{let a=[...r,"payload"];if(typeof i=="string"){n(i,a,{location:"requestReference"});return}if(ev8(i)){n(i.type,[...a,"type"],{location:"requestReference"});return}let u=[...a];t.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:i},u),xq(i,{name:Jc,extends:c=>{if(c==null)return;let p=typeof c=="string"?[c]:c;for(let s of p){let o=[...u,"extends",s];t.extension?.(s,o),n(s,o)}},properties:c=>{if(c!=null)for(let[p,s]of Object.entries(c)){let o=[...u,"properties",p];typeof s=="string"?n(s,o,{location:spe.InlinedRequestProperty}):xq(s,{name:Jc,docs:j5(t,o),availability:Jc,type:l=>{n(l,[...o,"type"],{_default:s.default,validation:s.validation,location:spe.InlinedRequestProperty})},audiences:Jc,encoding:Jc,default:Jc,validation:Jc,access:Jc})}}})},audiences:Jc,availability:Jc,docs:j5(t,r)})}function ky8({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=axr(t);for(let[i,a]of Object.entries(e)){let u=[...r,i];t.header?.({headerKey:i,header:a},u),typeof a=="string"?n(a,u):xq(a,{name:Jc,availability:Jc,type:c=>{n(c,u,{_default:a.default,validation:a.validation})},docs:j5(t,u),audiences:Jc,encoding:Jc,env:Jc,default:Jc,validation:Jc})}}function ev8(e){return e.type!=null}function Zbe(e,t){xq(e,{docs:j5(t,[]),imports:r=>{UM1({imports:r,visitor:t,nodePath:["imports"]})},types:r=>{QM1({typeDeclarations:r,visitor:t,nodePath:["types"]})},service:r=>{r!=null&&FM1({service:r,visitor:t,nodePath:["service"]})},webhooks:r=>{for(let[n,i]of Object.entries(r??{}))VM1({webhook:i,visitor:t,nodePathForWebhook:["webhooks",n]})},channel:Jc,errors:r=>{LM1({errorDeclarations:r,visitor:t,nodePath:["errors"]})}})}function Sl_(e,t){xq(e,{docs:Jc,imports:Jc,types:Jc,service:Jc,webhooks:Jc,errors:Jc,channel:Jc,export:r=>{t.export?.(typeof r=="string"?r:r?.dependency,["export"])},navigation:r=>{t.navigation?.(r,["navigation"])}})}function Dl_(e,t){t.file?.(e,[]),xq(e,{version:Jc,product:Jc,name:Jc,"default-url":Jc,"display-name":Jc,imports:Jc,auth:Jc,"idempotency-headers":Jc,"auth-schemes":r=>Object.entries(r??{}).map(([n,i])=>{e4l(i)&&t.oauth?.({name:n,oauth:i},["auth-scheme",n])}),pagination:Jc,"default-environment":r=>{t.defaultEnvironment?.(r,["default-environment"])},docs:Jc,headers:Jc,environments:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.environment?.({environmentId:n,environment:i},["environments",n])},"error-discrimination":r=>{t.errorDiscrimination?.(r,["error-discrimination"])},audiences:Jc,errors:r=>{if(r!=null)for(let n of r)t.errorReference?.(n,["errors",n])},"base-path":Jc,"path-parameters":r=>{Avu({pathParameters:r,visitor:t,nodePath:["path-parameters"]})},variables:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.variableDeclaration?.({variableId:n,variable:i},["variables",n])}})}var MJc=new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$");function WM1({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let u=(c,p)=>{for(let s of r){let o=s.definitionFile?.[a];if(o!=null){let l=o(c,{relativeFilepath:e,contents:t});n(l.map(O=>({severity:O.severity,relativeFilepath:e,nodePath:p,message:O.message})))}}};return{[a]:u}}return{...i("docs"),...i("import"),...i("typeReference"),...i("typeDeclaration"),...i("typeName"),...i("httpService"),...i("httpEndpoint"),...i("pathParameter"),...i("queryParameter"),...i("streamCondition"),...i("header"),...i("errorDeclaration"),...i("errorReference"),...i("exampleType"),...i("exampleTypeReference"),...i("exampleHttpEndpointCall"),...i("exampleCodeSample"),...i("exampleHeaders"),...i("examplePathParameters"),...i("exampleQueryParameters"),...i("exampleRequest"),...i("exampleResponse"),...i("variableReference"),...i("extension"),...i("serviceBaseUrl"),...i("endpointBaseUrl"),...i("exampleError")}}function HM1({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let u=(c,p)=>{for(let s of r){let o=s.packageMarker?.[a];if(o!=null){let l=o(c,{relativeFilepath:e,contents:t});n(l.map(O=>({severity:O.severity,relativeFilepath:e,nodePath:p,message:O.message})))}}};return{[a]:u}}return{...i("export"),...i("navigation")}}function GM1({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let u=(c,p)=>{for(let s of r){let o=s.rootApiFile?.[a];if(o!=null){let l=o(c,{relativeFilepath:e,contents:t});n(l.map(O=>({severity:O.severity,relativeFilepath:e,nodePath:p,message:O.message})))}}};return{[a]:u}}return{...i("file"),...i("oauth"),...i("defaultEnvironment"),...i("environment"),...i("errorDiscrimination"),...i("errorReference"),...i("variableDeclaration"),...i("variableReference"),...i("pathParameter")}}var Cl_={name:"content-type-only-for-multipart",DISABLE_RULE:!1,create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>{if(e.request==null)return[];if(EHi(e.request)!=null)return[];if(typeof e.request!="string"&&e.request.body!=null&&D9(e.request.body)){let r=[];for(let[n,i]of Object.entries(e.request.body.properties??{}))typeof i!="string"&&i["content-type"]!=null&&r.push({severity:"fatal",message:`${n} has content-type, but the request is not multipart`});return r}return[]}}})};var PR=mSe({generationLanguage:void 0,keywords:void 0,smartCasing:!1});var Il_={name:"exploded-form-data-is-array",create:({workspace:e})=>{let t=new rN(e);return{definitionFile:{httpEndpoint:({endpoint:r},{relativeFilepath:n,contents:i})=>{if(r.request==null||typeof r.request=="string"||r.request?.body==null||typeof r.request.body=="string")return[];if(!tv8(r.request.body))return[];let a=[];for(let[u,c]of Object.entries(r.request.body.properties??{})){if(typeof c=="string"||c.style!=="exploded")continue;let p=NE({relativeFilepath:n,definitionFile:i,casingsGenerator:PR,rootApiFile:e.definition.rootApiFile.contents}),s=t.resolveType({type:c.type,file:p});if(s==null)return[];JM1(s)||a.push({message:`${u} is exploded and must be a list. Did you mean list<${c.type}>?`,severity:"error"})}return a}}}}};function JM1(e){return e._type!=="container"?!1:e.container._type==="list"?!0:e.container._type==="optional"||e.container._type==="nullable"?JM1(e.container.itemType):!1}function tv8(e){return e?.properties!=null}var Ml_={name:"import-file-exists",create:({workspace:e})=>{let t=Object.keys(Dli(e.definition)),r=new Set;return t.forEach(n=>{let i=Jl(e.definition.absoluteFilePath,ds.of(n));r.add(i)}),{definitionFile:{import:({importedAs:n,importPath:i},{relativeFilepath:a})=>{let u=[],c=Jl(e.definition.absoluteFilePath,cg(a),ds.of(i));return r.has(c)||u.push({severity:"fatal",message:`Import ${yd.bold(n)} points to non-existent path ${yd.bold(i)}.`}),u}}}}};function BJc(e){return e.definition.rootApiFile.contents.environments==null?[]:Object.values(e.definition.rootApiFile.contents.environments).reduce((t,r)=>{if(net(r))for(let n of Object.keys(r.urls))t.includes(n)||t.push(n);return t},[])}var Bl_={name:"matching-environment-urls",create:({workspace:e})=>{let t=BJc(e);return t.length===0?{}:{rootApiFile:{environment:({environmentId:r,environment:n})=>{let i=[],a=u=>{i.push({severity:"fatal",message:`Environment ${r} is missing URL for ${yd.bold(u)}`})};return Jzr(n,{singleBaseUrl:()=>{for(let u of t)a(u)},multipleBaseUrls:u=>{for(let c of t)u.urls[c]==null&&a(c)}}),i}}}}};var Tl_={name:"no-circular-imports",DISABLE_RULE:!0,create:({workspace:e})=>{let t=rv8(e.definition.namedDefinitionFiles);return{definitionFile:{import:({importPath:r},{relativeFilepath:n})=>{let i=t[n];if(i==null)return[];let a=DIi({referencedIn:n,importPath:ds.of(r)});return i.filter(({chainWithoutStartingFilepath:c})=>c.length===0||c[0]===a).map(c=>({severity:"fatal",message:c.chainWithoutStartingFilepath.length===0?"A file cannot import itself":`Circular import detected: ${[c.startingFilepath,...c.chainWithoutStartingFilepath,c.startingFilepath].join(" -> ")}`}))}}}}};function rv8(e){let t={};for(let r of xSr(e))t[r]=KM1(r,[r],e);return t}function KM1(e,t,r){let n=[],i=r[e];if(i==null)return[];if(i.contents.imports!=null)for(let a of Object.values(i.contents.imports)){let u=DIi({referencedIn:e,importPath:ds.of(a)});t.includes(u)?t[0]===u&&t[0]===nv8(t)&&n.push({startingFilepath:u,chainWithoutStartingFilepath:t.slice(1)}):n.push(...KM1(u,[...t,u],r))}return n}function nv8(e){return e.reduce((t,r)=>r<t?r:t)}var TJc=class{workspace;typeResolver;constructor(t){this.workspace=t,this.typeResolver=new rN(t)}isTypeComplex(t,r){let n=NE({relativeFilepath:r.relativeFilepath,definitionFile:r.contents,casingsGenerator:PR,rootApiFile:this.workspace.definition.rootApiFile.contents}),i=this.typeResolver.resolveType({type:t,file:n});if(i==null)return;let a=new Set;return this.isResolvedReferenceComplex({type:i,file:n,visited:a})}isResolvedReferenceComplex({type:t,file:r,visited:n}){switch(t._type){case"container":return this.isResolvedContainerComplex({type:t.container,file:r,visited:n});case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":return!1;case"unknown":return!0;default:lc(t)}}isResolvedContainerComplex({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return(this.isResolvedReferenceComplex({type:t.keyType,file:r,visited:n})||this.isResolvedReferenceComplex({type:t.valueType,file:r,visited:n}))&&!(t.keyType._type==="primitive"&&t.keyType.primitive.v1==="STRING"&&t.valueType._type==="unknown");case"optional":case"nullable":case"list":case"set":return this.isResolvedReferenceComplex({type:t.itemType,file:r,visited:n});default:lc(t)}}isNamedTypeComplex({type:t,file:r,visited:n}){if(n.has(t.rawName))return!1;if(n.add(t.rawName),T1i(t.declaration))return!0;if(PDr(t.declaration))return!1;if(eR(t.declaration))return this.objectHasComplexProperties({typeName:t.rawName,objectDeclaration:t.declaration,file:r,visited:n});if(r4a(t.declaration)){for(let i of t.declaration.union){let a=typeof i=="string"?i:i.type,u=this.isTypeComplex(a,{contents:r.definitionFile,relativeFilepath:r.relativeFilepath});if(u!=null&&u)return!0}return!1}lc(t.declaration)}objectHasComplexProperties({typeName:t,objectDeclaration:r,file:n,visited:i}){return YCr({typeName:t,objectDeclaration:r,typeResolver:this.typeResolver,definitionFile:n.definitionFile,workspace:this.workspace,filepathOfDeclaration:n.relativeFilepath,smartCasing:!1}).some(u=>this.isComplex({type:u.resolvedPropertyType,file:n,visited:i}))}isComplex({type:t,file:r,visited:n}){switch(t._type){case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":case"unknown":return!1;case"container":return this.isComplexContainer({type:t.container,file:r,visited:n});default:lc(t)}}isComplexContainer({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return this.isComplex({type:t.keyType,file:r,visited:n})||this.isComplex({type:t.valueType,file:r,visited:n});case"optional":case"nullable":case"list":case"set":return this.isComplex({type:t.itemType,file:r,visited:n});default:lc(t)}}};var ql_={name:"no-complex-query-params",create:({workspace:e})=>{let t=new TJc(e);return{definitionFile:{queryParameter:({queryParameter:r},n)=>{let i=typeof r=="string"?r:r.type,a=t.isTypeComplex(i,n);return a!=null&&a?[{severity:"fatal",message:`${i} is not a valid type for a query parameter`}]:[]}}}}};var xl_={name:"no-conflicting-endpoint-parameters",create:()=>({definitionFile:{pathParameter:({pathParameterKey:e})=>e===k1s?[{severity:"fatal",message:`Path parameter ${yd.bold(e)} is not suitable for code generation, because it can conflict with the request body parameter.`}]:[]}})};function Pvu({service:e,endpoint:t}){return e["base-path"]+t.path}var qJc=class{root=new Nl_;registerEndpoint(t){this.root.insert(this.getPathPartsForEndpoint(t),t)}getConflictingEndpoints(t){return this.root.getMatchingEndpoints(this.getPathPartsForEndpoint(t)).filter(r=>!(r.relativeFilepath===t.relativeFilepath&&r.endpointId===t.endpointId)&&r.endpoint.method===t.endpoint.method)}getPathPartsForEndpoint(t){return Pvu({service:t.service,endpoint:t.endpoint}).split("/").filter(r=>r.length>0)}},Nl_=class e{childPaths={};childPathParam;endpointsThatEndWithThisNode=[];insert(t,r){let[n,...i]=t;if(n==null){this.endpointsThatEndWithThisNode.push(r);return}(this.isPathParam(n)?this.childPathParam??=new e:this.childPaths[n]??=new e).insert(i,r)}getMatchingEndpoints(t){let[r,...n]=t;if(r==null)return this.endpointsThatEndWithThisNode;let i=[];if(this.isPathParam(r))i.push(...Object.values(this.childPaths).flatMap(a=>a.getMatchingEndpoints(n)));else{let a=this.childPaths[r];a!=null&&i.push(...a.getMatchingEndpoints(n))}return this.childPathParam!=null&&i.push(...this.childPathParam.getMatchingEndpoints(n)),i}isPathParam(t){return t.startsWith("{")&&t.endsWith("}")}};var Rl_={name:"no-conflicting-endpoint-paths",create:({workspace:e})=>{let t=new qJc;return LZ(e,(r,n)=>{Zbe(n,{httpEndpoint:({service:i,endpointId:a,endpoint:u})=>{t.registerEndpoint({service:i,endpointId:a,endpoint:u,relativeFilepath:r})}})}),{definitionFile:{httpEndpoint:({service:r,endpoint:n,endpointId:i},{relativeFilepath:a})=>{let u=t.getConflictingEndpoints({service:r,endpointId:i,endpoint:n,relativeFilepath:a});return u.length===0?[]:[{severity:"warning",message:[`Endpoint path ${Pvu({service:r,endpoint:n})} conflicts with other endpoints:`,...u.map(c=>` - ${c.relativeFilepath} -> ${c.endpointId} ${yd.dim(Pvu({service:c.service,endpoint:c.endpoint}))}`)].join(`
2842
+ ${JSON.stringify(k.error)}`)}}).resolve();if(C==null)return c.failAndThrow("Failed to publish docs.","Docs registration ID is missing.");c.logger.debug("Publishing docs...");let Q=await A.docs.v2.write.finishDocsRegister(GPr.FernRegistry.docs.v1.write.DocsRegistrationId(C),{docsDefinition:U});if(Q.ok){let J=LSe(M),X=lgi(J,J);c.logger.info(yd.green(`Published docs to ${X}`))}else switch(Q.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("Insufficient permissions. Failed to publish docs to "+n);case"DocsRegistrationIdNotFound":return c.failAndThrow("Failed to publish docs to "+n,`Docs registration ID ${C} does not exist.`);default:return c.failAndThrow("Failed to publish docs to "+n,Q.error)}}async function TM1(e,t,r,n){let i=Date.now(),a=Object.keys(e).length;r.logger.debug(`Start uploading ${a} files...`);let u=wIo(Object.entries(e),n),c=0;for(let s of u){await Promise.all(s.map(async([l,{uploadUrl:O}])=>{let A=ds.of(l),E=Ww(t,A);try{let C=wl_.lookup(E);await nY.put(O,await(0,NM1.readFile)(E),{headers:{"Content-Type":C===!1?"application/octet-stream":C}})}catch(C){r.failAndThrow(`Failed to upload ${E}`,C)}}));let o=Date.now();c+=s.length,r.logger.debug(`Uploaded ${c}/${a} files in ${o-i}ms`)}let p=Date.now();r.logger.debug(`Finished uploading ${a} files in ${p-i}ms`)}function qM1(e,t){let r=[];for(let[n,i]of Object.entries(e)){let a=ds.of(n),u=Ww(t,a);r.push({relativeFilePath:a,absoluteFilePath:u,fileId:i.fileId})}return r}async function xM1(e,t){switch(await t.instrumentPostHogEvent({command:"docs-generation",properties:{error:JSON.stringify(e)}}),e.error){case"InvalidCustomDomainError":return t.failAndThrow("Your docs domain should end with docs.buildwithfern.com");case"InvalidDomainError":return t.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)");case"UnauthorizedError":return t.failAndThrow("Please make sure that your FERN_TOKEN is set.");case"UserNotInOrgError":return t.failAndThrow("Please verify if you have access to the organization you are trying to publish the docs to. If you are not a member of the organization, please reach out to the organization owner.");case"UnavailableError":return t.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");default:return t.failAndThrow("Failed to publish docs.",e)}}function Jy8(e){try{return new URL(LSe(e)).pathname}catch{return}}async function Ky8({workspace:e,organization:t,context:r,snippetsConfig:n}){let i={};if(!e)return;let a={typescript:n.typescriptSdk?.package,python:n.pythonSdk?.package,java:n.javaSdk?.coordinate,go:n.goSdk?.githubRepo,csharp:n.csharpSdk?.package,ruby:n.rubySdk?.gem,php:n.phpSdk?.package,swift:n.swiftSdk?.package,rust:void 0};if(e.generatorsConfiguration?.groups)for(let u of e.generatorsConfiguration.groups)for(let c of u.generators){let p=KGc({apiName:e.workspaceName??"",organization:t,generatorInvocation:c}),s="";if(p?.outputConfig.type==="publish")switch(p.outputConfig.value.type){case"npm":case"nuget":case"pypi":case"rubygems":s=p.outputConfig.value.packageName;break;case"maven":s=p.outputConfig.value.coordinate;break;case"go":s=p.outputConfig.value.repoUrl;break}if(c.language==="php"&&c.config&&typeof c.config=="object"&&"packageName"in c.config&&(s=c.config.packageName??""),!!c.language&&c.language&&a[c.language]===s){let o=GV({workspace:e,generationLanguage:c.language,keywords:void 0,smartCasing:c.smartCasing,exampleGeneration:{disabled:!0,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},audiences:{type:"all"},readme:void 0,packageName:s,version:void 0,context:r,sourceResolver:new WV(r,e),dynamicGeneratorConfig:p}),l=T7o({ir:o,disableExamples:!0,smartCasing:c.smartCasing,generationLanguage:c.language,generatorConfig:p});l?i[c.language]={dynamicIR:l}:r.logger.debug(`Failed to create dynamic IR for ${c.language}`)}}if(Object.keys(i).length>0)return i}async function $y8({dynamicIRs:e,dynamicIRUploadUrls:t,context:r,apiId:n}){if(Object.keys(t).length>0)for(let[i,a]of Object.entries(t)){let u=e[i]?.dynamicIR;u?(await fetch(a.uploadUrl,{method:"PUT",body:JSON.stringify(u),headers:{"Content-Type":"application/octet-stream","Content-Length":JSON.stringify(u).length.toString()}})).ok?r.logger.debug(`Uploaded dynamic IR for ${n}:${i}`):r.logger.warn(`Failed to upload dynamic IR for ${n}:${i}`):r.logger.warn(`Could not find matching dynamic IR to upload for ${n}:${i}`)}}async function jl_({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:a,instanceUrl:u,preview:c,disableTemplates:p,disableDynamicSnippets:s}){let o=n.config.instances;if(n.config=Ewi(n.config,{onError:A=>i.failAndThrow(A)},{substituteAsEmpty:c}),o.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(o.length>1&&u==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${o[0]?.url})`);return}let l=o.find(A=>A.url===u)??o[0];if(l==null){i.failAndThrow(`No docs instance with url ${u}. Failed to register.`);return}let O=[];l.customDomain!=null&&(typeof l.customDomain=="string"?O.push(l.customDomain):Array.isArray(l.customDomain)&&O.push(...l.customDomain)),await i.runInteractiveTask({name:l.url},async()=>{await RM1({docsWorkspace:n,customDomains:O,domain:l.url,token:a,organization:e,context:i,apiWorkspaces:t,ossWorkspaces:r,preview:c,editThisPage:l.editThisPage,isPrivate:l.private,disableTemplates:p,disableDynamicSnippets:s})})}var FB1=$i(eEi(),1);var spe={RequestReference:"requestReference",InlinedRequestProperty:"inlinedRequestProperty",Response:"response",StreamingResponse:"streamingResponse"};function j5(e,t){return r=>{r!=null&&e.docs?.(r,[...t,"docs"])}}function JPr({example:e,visitor:t,nodePath:r}){if(typeof e=="string")e.startsWith("$")&&t.exampleTypeReference?.(e,r);else if(TT(e))for(let n of Object.values(e))JPr({example:n,visitor:t,nodePath:r});else if(Array.isArray(e))for(let n of e)JPr({example:n,visitor:t,nodePath:r})}function axr(e){return(t,r,{_default:n,validation:i,location:a}={})=>{e.typeReference?.({typeReference:t,_default:n,validation:i,location:a,nodePath:r},r)}}function FM1({service:e,visitor:t,nodePath:r}){t.httpService?.(e,r),xq(e,{url:n=>{t.serviceBaseUrl?.(n,[...r,"url"])},"base-path":Jc,"display-name":Jc,availability:Jc,headers:n=>{zM1({headers:n,visitor:t,nodePath:[...r,"headers"]})},audiences:Jc,auth:Jc,"path-parameters":n=>{Avu({pathParameters:n,visitor:t,nodePath:[...r,"path-parameters"]})},endpoints:n=>{for(let[i,a]of Object.entries(n)){let u=[...r,"endpoints",i];Yy8({endpointId:i,endpoint:a,service:e,visitor:t,nodePathForEndpoint:u})}},idempotent:Jc,transport:Jc,source:Jc})}function Yy8({endpointId:e,endpoint:t,service:r,visitor:n,nodePathForEndpoint:i}){let a=axr(n);n.httpEndpoint?.({endpointId:e,endpoint:t,service:r},i),xq(t,{docs:j5(n,i),"display-name":Jc,availability:Jc,"base-path":Jc,path:Jc,idempotent:Jc,url:u=>{n.endpointBaseUrl?.({baseUrl:u,service:r},[...i,"url"])},"path-parameters":u=>{Avu({pathParameters:u,visitor:n,nodePath:[...i,"path-parameters"]})},request:u=>{if(u==null)return;let c=[...i,"request"];if(typeof u=="string"){a(u,c,{location:"requestReference"});return}xq(u,{name:Jc,docs:j5(n,c),"path-parameters":p=>{Avu({pathParameters:p,visitor:n,nodePath:[...c,"path-parameters"]})},"query-parameters":p=>{if(p!=null)for(let[s,o]of Object.entries(p)){let l=[...c,"query-parameters",s];n.queryParameter?.({queryParameterKey:s,queryParameter:o},l),typeof o=="string"?a(o,l):xq(o,{name:Jc,docs:j5(n,l),availability:Jc,type:O=>{a(O,[...l,"type"],{_default:o.default,validation:o.validation})},"allow-multiple":Jc,audiences:Jc,encoding:Jc,default:Jc,validation:Jc})}},"content-type":Jc,headers:p=>{zM1({headers:p,visitor:n,nodePath:[...c,"headers"]})},body:p=>{if(p==null)return;let s=[...c,"body"];typeof p=="string"?a(p,s,{location:"requestReference"}):D9(p)?(n.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:p},s),xq(p,{extends:o=>{if(o==null)return;let l=typeof o=="string"?[o]:o;for(let O of l){let A=[...s,"extends",O];n.extension?.(O,A),a(O,A)}},properties:o=>{if(o!=null)for(let[l,O]of Object.entries(o)){let A=[...s,"properties",l];typeof O=="string"?a(O,A,{location:spe.InlinedRequestProperty}):xq(O,{name:Jc,docs:j5(n,A),availability:Jc,type:E=>{a(E,[...A,"type"],{location:spe.InlinedRequestProperty,_default:O.default,validation:O.validation})},style:Jc,"content-type":Jc,audiences:Jc,encoding:Jc,default:Jc,validation:Jc})}},"extra-properties":Jc})):(j5(n,s)(p.docs),a(p.type,s))}})},audiences:Jc,method:Jc,auth:Jc,"stream-condition":u=>{n.streamCondition?.({streamCondition:u,endpoint:t},[...i,"stream-condition"])},"response-stream":u=>{u!=null&&(typeof u=="string"?a(u,[...i,"response-stream"],{location:spe.StreamingResponse}):a(u.type,[...i,"response-stream"],{location:spe.StreamingResponse}))},response:u=>{if(u==null)return;let c=[...i,"response"];typeof u=="string"?a(u,c,{location:spe.Response}):xq(u,{docs:j5(n,c),type:p=>{p!=null&&a(p,[...c,"type"],{location:spe.Response})},property:Jc,"status-code":Jc})},errors:u=>{if(u!=null)for(let c of u){let p=[...i,"errors",typeof c=="string"?c:c.error];typeof c=="string"?n.errorReference?.(c,p):xq(c,{docs:j5(n,p),error:s=>{n.errorReference?.(s,[...p,"error"])}})}},examples:u=>{if(u!=null)for(let[c,p]of u.entries())Xy8({nodePathForExample:[...i,{key:"examples",arrayIndex:c}],visitor:n,service:r,endpoint:t,example:p})},pagination:Jc,source:Jc,transport:Jc})}function Xy8({nodePathForExample:e,visitor:t,service:r,endpoint:n,example:i}){if(i.headers==null&&i["path-parameters"]==null&&i["query-parameters"]==null&&i.request==null&&i.response==null&&i["code-samples"]!=null)return;t.exampleHttpEndpointCall?.({service:r,endpoint:n,example:i},e);let a=[...e,"headers"];if(t.exampleHeaders?.({service:r,endpoint:n,examples:i.headers},a),i.headers!=null)for(let o of Object.values(i.headers))JPr({example:o,visitor:t,nodePath:a});let u=[...e,"path-parameters"];if(t.examplePathParameters?.({service:r,endpoint:n,examples:i["path-parameters"]},u),i["path-parameters"]!=null)for(let o of Object.values(i["path-parameters"]))JPr({example:o,visitor:t,nodePath:u});let c=[...e,"query-parameters"];if(t.exampleQueryParameters?.({service:r,endpoint:n,examples:i["query-parameters"]},c),i["query-parameters"]!=null)for(let o of Object.values(i["query-parameters"]))JPr({example:o,visitor:t,nodePath:c});let p=[...e,"request"];t.exampleRequest?.({service:r,endpoint:n,example:i.request},p),i.request!=null&&JPr({example:i.request,visitor:t,nodePath:p});let s=[...e,"response"];if(t.exampleResponse?.({service:r,endpoint:n,example:i.response},s),i.response!=null&&SHi(n,i.response,{body:o=>{o.body!=null&&JPr({example:o.body,visitor:t,nodePath:s}),o.error!=null&&t.errorReference?.(o.error,[...s,"error"])},stream:o=>{for(let l of o.stream)JPr({example:l,visitor:t,nodePath:s})},events:o=>{for(let{data:l}of o.stream)JPr({example:l,visitor:t,nodePath:s})}}),i["code-samples"]!=null)for(let[o,l]of i["code-samples"].entries())t.exampleCodeSample?.({service:r,endpoint:n,example:i,sample:l},[...e,{key:"code-samples",arrayIndex:o}])}function Avu({pathParameters:e,visitor:t,nodePath:r}){if(e==null)return;let n=axr(t);for(let[i,a]of Object.entries(e)){let u=[...r,i];t.pathParameter?.({pathParameterKey:i,pathParameter:a},u),t4a(a)?typeof a=="string"?t.variableReference?.(a,u):xq(a,{docs:j5(t,u),variable:c=>t.variableReference?.(c,[...u,"variable"]),availability:Jc}):typeof a=="string"?n(a,u):xq(a,{docs:j5(t,u),type:c=>{n(c,[...u,"type"],{_default:a.default,validation:a.validation})},availability:Jc,encoding:Jc,default:Jc,validation:Jc,name:Jc,audiences:Jc})}}function zM1({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=axr(t);for(let[i,a]of Object.entries(e)){let u=[...r,i];t.header?.({headerKey:i,header:a},u),typeof a=="string"?n(a,u):xq(a,{name:Jc,availability:Jc,type:c=>{n(c,u,{_default:a.default,validation:a.validation})},docs:j5(t,u),audiences:Jc,encoding:Jc,env:Jc,default:Jc,validation:Jc})}}function QM1({typeDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.typeName?.(n,a),El_({typeName:n,declaration:i,visitor:t,nodePathForType:a})}}function El_({typeName:e,declaration:t,visitor:r,nodePathForType:n}){let i=axr(r);r.typeDeclaration?.({typeName:{isInlined:!1,name:e},declaration:t,nodePath:n},n);let a=u=>{if(u!=null)for(let[c,p]of u.entries()){let s=[...n,{key:"examples",arrayIndex:c}];r.exampleType?.({typeName:e,typeDeclaration:t,example:p},s),JPr({example:p.value,nodePath:s,visitor:r})}};mZ(t,{alias:u=>{typeof u=="string"?i(u,n):xq(u,{type:c=>{i(c,[...n,"type"])},docs:j5(r,n),availability:Jc,audiences:Jc,examples:a,validation:Jc,encoding:Jc,source:Jc,inline:Jc})},object:u=>{xq(u,{docs:j5(r,n),extends:c=>{if(c==null)return;let p=typeof c=="string"?[c]:c;for(let s of p){let o=[...n,"extends",s];r.extension?.(s,o),i(s,o)}},properties:c=>{if(c!=null)for(let[p,s]of Object.entries(c)){let o=[...n,"properties",p];typeof s=="string"?i(s,o):xq(s,{name:Jc,docs:j5(r,o),availability:Jc,type:l=>{i(l,[...o,"type"],{_default:s.default,validation:s.validation})},audiences:Jc,encoding:Jc,default:Jc,validation:Jc,access:Jc})}},"extra-properties":Jc,availability:Jc,audiences:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})},discriminatedUnion:u=>{xq(u,{docs:j5(r,n),discriminant:Jc,extends:c=>{if(c==null)return;let p=typeof c=="string"?[c]:c;for(let s of p){let o=[...n,"extends",s];r.extension?.(s,o),i(s,o)}},union:c=>{for(let[p,s]of Object.entries(c)){let o=[...n,"union",p];typeof s=="string"?i(s,o):xq(s,{docs:j5(r,o),name:Jc,key:Jc,type:l=>{typeof l=="string"&&i(l,[...n,"type"])},"display-name":Jc,availability:Jc})}},"base-properties":Jc,availability:Jc,audiences:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})},undiscriminatedUnion:u=>{xq(u,{docs:j5(r,n),discriminated:Jc,union:c=>{for(let[p,s]of c.entries()){let o=[...n,`union[${p}]`];typeof s!="string"&&xq(s,{docs:j5(r,o),type:l=>{i(l,[...n,"type"])},"display-name":Jc,validation:Jc})}},availability:Jc,audiences:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})},enum:u=>{xq(u,{docs:j5(r,n),enum:c=>{for(let p of c){let s=[...n,typeof p=="string"?p:p.name??p.value];typeof p!="string"&&xq(p,{docs:j5(r,s),name:Jc,value:Jc,casing:Jc})}},availability:Jc,audiences:Jc,default:Jc,encoding:Jc,source:Jc,examples:a,inline:Jc})}})}function LM1({errorDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.errorDeclaration?.({errorName:n,declaration:i},a),Zy8({errorName:n,declaration:i,visitor:t,nodePathForError:a})}}function Zy8({errorName:e,declaration:t,visitor:r,nodePathForError:n}){let i=axr(r);typeof t=="string"?i(t,n):xq(t,{docs:j5(r,n),"status-code":Jc,type:a=>{if(a==null)return;let u=[...n,"type"];typeof a=="string"?i(a,u):El_({typeName:e,declaration:a,visitor:r,nodePathForType:u})},examples:a=>{if(a!=null)for(let u of a){let c=[...n,"type"];r.exampleError?.({errorName:e,declaration:t,example:u},c)}}})}function UM1({imports:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e))t.import?.({importPath:i,importedAs:n},[...r,n])}function VM1({webhook:e,visitor:t,nodePathForWebhook:r}){let n=axr(t);xq(e,{"display-name":Jc,method:Jc,examples:Jc,headers:i=>{ky8({headers:i,visitor:t,nodePath:[...r,"headers"]})},payload:i=>{let a=[...r,"payload"];if(typeof i=="string"){n(i,a,{location:"requestReference"});return}if(ev8(i)){n(i.type,[...a,"type"],{location:"requestReference"});return}let u=[...a];t.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:i},u),xq(i,{name:Jc,extends:c=>{if(c==null)return;let p=typeof c=="string"?[c]:c;for(let s of p){let o=[...u,"extends",s];t.extension?.(s,o),n(s,o)}},properties:c=>{if(c!=null)for(let[p,s]of Object.entries(c)){let o=[...u,"properties",p];typeof s=="string"?n(s,o,{location:spe.InlinedRequestProperty}):xq(s,{name:Jc,docs:j5(t,o),availability:Jc,type:l=>{n(l,[...o,"type"],{_default:s.default,validation:s.validation,location:spe.InlinedRequestProperty})},audiences:Jc,encoding:Jc,default:Jc,validation:Jc,access:Jc})}}})},audiences:Jc,availability:Jc,docs:j5(t,r)})}function ky8({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=axr(t);for(let[i,a]of Object.entries(e)){let u=[...r,i];t.header?.({headerKey:i,header:a},u),typeof a=="string"?n(a,u):xq(a,{name:Jc,availability:Jc,type:c=>{n(c,u,{_default:a.default,validation:a.validation})},docs:j5(t,u),audiences:Jc,encoding:Jc,env:Jc,default:Jc,validation:Jc})}}function ev8(e){return e.type!=null}function Zbe(e,t){xq(e,{docs:j5(t,[]),imports:r=>{UM1({imports:r,visitor:t,nodePath:["imports"]})},types:r=>{QM1({typeDeclarations:r,visitor:t,nodePath:["types"]})},service:r=>{r!=null&&FM1({service:r,visitor:t,nodePath:["service"]})},webhooks:r=>{for(let[n,i]of Object.entries(r??{}))VM1({webhook:i,visitor:t,nodePathForWebhook:["webhooks",n]})},channel:Jc,errors:r=>{LM1({errorDeclarations:r,visitor:t,nodePath:["errors"]})}})}function Sl_(e,t){xq(e,{docs:Jc,imports:Jc,types:Jc,service:Jc,webhooks:Jc,errors:Jc,channel:Jc,export:r=>{t.export?.(typeof r=="string"?r:r?.dependency,["export"])},navigation:r=>{t.navigation?.(r,["navigation"])}})}function Dl_(e,t){t.file?.(e,[]),xq(e,{version:Jc,product:Jc,name:Jc,"default-url":Jc,"display-name":Jc,imports:Jc,auth:Jc,"idempotency-headers":Jc,"auth-schemes":r=>Object.entries(r??{}).map(([n,i])=>{e4l(i)&&t.oauth?.({name:n,oauth:i},["auth-scheme",n])}),pagination:Jc,"default-environment":r=>{t.defaultEnvironment?.(r,["default-environment"])},docs:Jc,headers:Jc,environments:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.environment?.({environmentId:n,environment:i},["environments",n])},"error-discrimination":r=>{t.errorDiscrimination?.(r,["error-discrimination"])},audiences:Jc,errors:r=>{if(r!=null)for(let n of r)t.errorReference?.(n,["errors",n])},"base-path":Jc,"path-parameters":r=>{Avu({pathParameters:r,visitor:t,nodePath:["path-parameters"]})},variables:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.variableDeclaration?.({variableId:n,variable:i},["variables",n])}})}var MJc=new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$");function WM1({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let u=(c,p)=>{for(let s of r){let o=s.definitionFile?.[a];if(o!=null){let l=o(c,{relativeFilepath:e,contents:t});n(l.map(O=>({severity:O.severity,relativeFilepath:e,nodePath:p,message:O.message})))}}};return{[a]:u}}return{...i("docs"),...i("import"),...i("typeReference"),...i("typeDeclaration"),...i("typeName"),...i("httpService"),...i("httpEndpoint"),...i("pathParameter"),...i("queryParameter"),...i("streamCondition"),...i("header"),...i("errorDeclaration"),...i("errorReference"),...i("exampleType"),...i("exampleTypeReference"),...i("exampleHttpEndpointCall"),...i("exampleCodeSample"),...i("exampleHeaders"),...i("examplePathParameters"),...i("exampleQueryParameters"),...i("exampleRequest"),...i("exampleResponse"),...i("variableReference"),...i("extension"),...i("serviceBaseUrl"),...i("endpointBaseUrl"),...i("exampleError")}}function HM1({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let u=(c,p)=>{for(let s of r){let o=s.packageMarker?.[a];if(o!=null){let l=o(c,{relativeFilepath:e,contents:t});n(l.map(O=>({severity:O.severity,relativeFilepath:e,nodePath:p,message:O.message})))}}};return{[a]:u}}return{...i("export"),...i("navigation")}}function GM1({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let u=(c,p)=>{for(let s of r){let o=s.rootApiFile?.[a];if(o!=null){let l=o(c,{relativeFilepath:e,contents:t});n(l.map(O=>({severity:O.severity,relativeFilepath:e,nodePath:p,message:O.message})))}}};return{[a]:u}}return{...i("file"),...i("oauth"),...i("defaultEnvironment"),...i("environment"),...i("errorDiscrimination"),...i("errorReference"),...i("variableDeclaration"),...i("variableReference"),...i("pathParameter")}}var Cl_={name:"content-type-only-for-multipart",DISABLE_RULE:!1,create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>{if(e.request==null)return[];if(EHi(e.request)!=null)return[];if(typeof e.request!="string"&&e.request.body!=null&&D9(e.request.body)){let r=[];for(let[n,i]of Object.entries(e.request.body.properties??{}))typeof i!="string"&&i["content-type"]!=null&&r.push({severity:"fatal",message:`${n} has content-type, but the request is not multipart`});return r}return[]}}})};var PR=mSe({generationLanguage:void 0,keywords:void 0,smartCasing:!1});var Il_={name:"exploded-form-data-is-array",create:({workspace:e})=>{let t=new rN(e);return{definitionFile:{httpEndpoint:({endpoint:r},{relativeFilepath:n,contents:i})=>{if(r.request==null||typeof r.request=="string"||r.request?.body==null||typeof r.request.body=="string")return[];if(!tv8(r.request.body))return[];let a=[];for(let[u,c]of Object.entries(r.request.body.properties??{})){if(typeof c=="string"||c.style!=="exploded")continue;let p=NE({relativeFilepath:n,definitionFile:i,casingsGenerator:PR,rootApiFile:e.definition.rootApiFile.contents}),s=t.resolveType({type:c.type,file:p});if(s==null)return[];JM1(s)||a.push({message:`${u} is exploded and must be a list. Did you mean list<${c.type}>?`,severity:"error"})}return a}}}}};function JM1(e){return e._type!=="container"?!1:e.container._type==="list"?!0:e.container._type==="optional"||e.container._type==="nullable"?JM1(e.container.itemType):!1}function tv8(e){return e?.properties!=null}var Ml_={name:"import-file-exists",create:({workspace:e})=>{let t=Object.keys(Dli(e.definition)),r=new Set;return t.forEach(n=>{let i=Jl(e.definition.absoluteFilePath,ds.of(n));r.add(i)}),{definitionFile:{import:({importedAs:n,importPath:i},{relativeFilepath:a})=>{let u=[],c=Jl(e.definition.absoluteFilePath,cg(a),ds.of(i));return r.has(c)||u.push({severity:"fatal",message:`Import ${yd.bold(n)} points to non-existent path ${yd.bold(i)}.`}),u}}}}};function BJc(e){return e.definition.rootApiFile.contents.environments==null?[]:Object.values(e.definition.rootApiFile.contents.environments).reduce((t,r)=>{if(net(r))for(let n of Object.keys(r.urls))t.includes(n)||t.push(n);return t},[])}var Bl_={name:"matching-environment-urls",create:({workspace:e})=>{let t=BJc(e);return t.length===0?{}:{rootApiFile:{environment:({environmentId:r,environment:n})=>{let i=[],a=u=>{i.push({severity:"fatal",message:`Environment ${r} is missing URL for ${yd.bold(u)}`})};return Jzr(n,{singleBaseUrl:()=>{for(let u of t)a(u)},multipleBaseUrls:u=>{for(let c of t)u.urls[c]==null&&a(c)}}),i}}}}};var Tl_={name:"no-circular-imports",DISABLE_RULE:!0,create:({workspace:e})=>{let t=rv8(e.definition.namedDefinitionFiles);return{definitionFile:{import:({importPath:r},{relativeFilepath:n})=>{let i=t[n];if(i==null)return[];let a=DIi({referencedIn:n,importPath:ds.of(r)});return i.filter(({chainWithoutStartingFilepath:c})=>c.length===0||c[0]===a).map(c=>({severity:"fatal",message:c.chainWithoutStartingFilepath.length===0?"A file cannot import itself":`Circular import detected: ${[c.startingFilepath,...c.chainWithoutStartingFilepath,c.startingFilepath].join(" -> ")}`}))}}}}};function rv8(e){let t={};for(let r of xSr(e))t[r]=KM1(r,[r],e);return t}function KM1(e,t,r){let n=[],i=r[e];if(i==null)return[];if(i.contents.imports!=null)for(let a of Object.values(i.contents.imports)){let u=DIi({referencedIn:e,importPath:ds.of(a)});t.includes(u)?t[0]===u&&t[0]===nv8(t)&&n.push({startingFilepath:u,chainWithoutStartingFilepath:t.slice(1)}):n.push(...KM1(u,[...t,u],r))}return n}function nv8(e){return e.reduce((t,r)=>r<t?r:t)}var TJc=class{workspace;typeResolver;constructor(t){this.workspace=t,this.typeResolver=new rN(t)}isTypeComplex(t,r){let n=NE({relativeFilepath:r.relativeFilepath,definitionFile:r.contents,casingsGenerator:PR,rootApiFile:this.workspace.definition.rootApiFile.contents}),i=this.typeResolver.resolveType({type:t,file:n});if(i==null)return;let a=new Set;return this.isResolvedReferenceComplex({type:i,file:n,visited:a})}isResolvedReferenceComplex({type:t,file:r,visited:n}){switch(t._type){case"container":return this.isResolvedContainerComplex({type:t.container,file:r,visited:n});case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":return!1;case"unknown":return!0;default:lc(t)}}isResolvedContainerComplex({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return(this.isResolvedReferenceComplex({type:t.keyType,file:r,visited:n})||this.isResolvedReferenceComplex({type:t.valueType,file:r,visited:n}))&&!(t.keyType._type==="primitive"&&t.keyType.primitive.v1==="STRING"&&t.valueType._type==="unknown");case"optional":case"nullable":case"list":case"set":return this.isResolvedReferenceComplex({type:t.itemType,file:r,visited:n});default:lc(t)}}isNamedTypeComplex({type:t,file:r,visited:n}){if(n.has(t.rawName))return!1;if(n.add(t.rawName),T1i(t.declaration))return!0;if(PDr(t.declaration))return!1;if(eR(t.declaration))return this.objectHasComplexProperties({typeName:t.rawName,objectDeclaration:t.declaration,file:r,visited:n});if(r4a(t.declaration)){for(let i of t.declaration.union){let a=typeof i=="string"?i:i.type,u=this.isTypeComplex(a,{contents:r.definitionFile,relativeFilepath:r.relativeFilepath});if(u!=null&&u)return!0}return!1}lc(t.declaration)}objectHasComplexProperties({typeName:t,objectDeclaration:r,file:n,visited:i}){return YCr({typeName:t,objectDeclaration:r,typeResolver:this.typeResolver,definitionFile:n.definitionFile,workspace:this.workspace,filepathOfDeclaration:n.relativeFilepath,smartCasing:!1}).some(u=>this.isComplex({type:u.resolvedPropertyType,file:n,visited:i}))}isComplex({type:t,file:r,visited:n}){switch(t._type){case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":case"unknown":return!1;case"container":return this.isComplexContainer({type:t.container,file:r,visited:n});default:lc(t)}}isComplexContainer({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return this.isComplex({type:t.keyType,file:r,visited:n})||this.isComplex({type:t.valueType,file:r,visited:n});case"optional":case"nullable":case"list":case"set":return this.isComplex({type:t.itemType,file:r,visited:n});default:lc(t)}}};var ql_={name:"no-complex-query-params",create:({workspace:e})=>{let t=new TJc(e);return{definitionFile:{queryParameter:({queryParameter:r},n)=>{let i=typeof r=="string"?r:r.type,a=t.isTypeComplex(i,n);return a!=null&&a?[{severity:"fatal",message:`${i} is not a valid type for a query parameter`}]:[]}}}}};var xl_={name:"no-conflicting-endpoint-parameters",create:()=>({definitionFile:{pathParameter:({pathParameterKey:e})=>e===k1s?[{severity:"fatal",message:`Path parameter ${yd.bold(e)} is not suitable for code generation, because it can conflict with the request body parameter.`}]:[]}})};function Pvu({service:e,endpoint:t}){return e["base-path"]+t.path}var qJc=class{root=new Nl_;registerEndpoint(t){this.root.insert(this.getPathPartsForEndpoint(t),t)}getConflictingEndpoints(t){return this.root.getMatchingEndpoints(this.getPathPartsForEndpoint(t)).filter(r=>!(r.relativeFilepath===t.relativeFilepath&&r.endpointId===t.endpointId)&&r.endpoint.method===t.endpoint.method)}getPathPartsForEndpoint(t){return Pvu({service:t.service,endpoint:t.endpoint}).split("/").filter(r=>r.length>0)}},Nl_=class e{childPaths={};childPathParam;endpointsThatEndWithThisNode=[];insert(t,r){let[n,...i]=t;if(n==null){this.endpointsThatEndWithThisNode.push(r);return}(this.isPathParam(n)?this.childPathParam??=new e:this.childPaths[n]??=new e).insert(i,r)}getMatchingEndpoints(t){let[r,...n]=t;if(r==null)return this.endpointsThatEndWithThisNode;let i=[];if(this.isPathParam(r))i.push(...Object.values(this.childPaths).flatMap(a=>a.getMatchingEndpoints(n)));else{let a=this.childPaths[r];a!=null&&i.push(...a.getMatchingEndpoints(n))}return this.childPathParam!=null&&i.push(...this.childPathParam.getMatchingEndpoints(n)),i}isPathParam(t){return t.startsWith("{")&&t.endsWith("}")}};var Rl_={name:"no-conflicting-endpoint-paths",create:({workspace:e})=>{let t=new qJc;return LZ(e,(r,n)=>{Zbe(n,{httpEndpoint:({service:i,endpointId:a,endpoint:u})=>{t.registerEndpoint({service:i,endpointId:a,endpoint:u,relativeFilepath:r})}})}),{definitionFile:{httpEndpoint:({service:r,endpoint:n,endpointId:i},{relativeFilepath:a})=>{let u=t.getConflictingEndpoints({service:r,endpointId:i,endpoint:n,relativeFilepath:a});return u.length===0?[]:[{severity:"warning",message:[`Endpoint path ${Pvu({service:r,endpoint:n})} conflicts with other endpoints:`,...u.map(c=>` - ${c.relativeFilepath} -> ${c.endpointId} ${yd.dim(Pvu({service:c.service,endpoint:c.endpoint}))}`)].join(`
2843
2843
  `)}]}}}}};var Fl_={name:"no-conflicting-request-wrapper-properties",create:({workspace:e})=>({definitionFile:{httpEndpoint:({endpoint:t,service:r},{contents:n,relativeFilepath:i})=>{let a=iv8({endpoint:t,service:r,relativeFilepath:i,definitionFile:n,workspace:e}),u=[];for(let[c,p]of Object.entries(a))p.length<=1||u.push({severity:"fatal",message:`Multiple request properties have the name ${yd.bold(c)}. This is not suitable for code generation. Use the "name" property to deconflict.
2844
2844
  `+p.map(s=>` - ${av8(s)}`).join(`
2845
2845
  `)});return u}}})};function iv8({endpoint:e,service:t,relativeFilepath:r,definitionFile:n,workspace:i}){let a={},u=(c,p)=>{(a[c]??=[]).push(p)};if(e.request!=null&&typeof e.request!="string"&&e.request.body!=null&&!D9(e.request.body)&&eEs({request:e.request,file:NE({relativeFilepath:r,definitionFile:n,casingsGenerator:PR,rootApiFile:i.definition.rootApiFile.contents}),typeResolver:new rN(i)})&&u(C7o,{type:"referenced-body",propertyName:C7o}),t.headers!=null)for(let[c,p]of Object.entries(t.headers))u(x5r({headerKey:c,header:p}).name,{type:"service-header",headerKey:c,header:p});if(e.request!=null&&typeof e.request!="string"){if(e.request.headers!=null)for(let[c,p]of Object.entries(e.request.headers))u(x5r({headerKey:c,header:p}).name,{type:"endpoint-header",headerKey:c,header:p});if(e.request["query-parameters"]!=null)for(let[c,p]of Object.entries(e.request["query-parameters"]))u(vfi({queryParameterKey:c,queryParameter:p}).name,{type:"endpoint-query-parameter",queryParameterKey:c,queryParameter:p});if(e.request.body!=null&&D9(e.request.body)){let c=YCr({typeName:void 0,objectDeclaration:{extends:e.request.body.extends,properties:e.request.body.properties??{}},filepathOfDeclaration:r,definitionFile:n,workspace:i,typeResolver:new rN(i),smartCasing:!1});for(let p of c)u(p.name,{type:"inlined-body",property:p})}}return a}function av8(e){switch(e.type){case"service-header":return`Service header "${e.headerKey}"`;case"endpoint-header":return`Endpoint header "${e.headerKey}"`;case"endpoint-query-parameter":return`Query Parameter "${e.queryParameterKey}"`;case"inlined-body":return`Body property: ${qUa({property:e.property,prefixBreadcrumbs:["<Request Body>"]})}`;case"referenced-body":return`Body property "${e.propertyName}"`;default:lc(e)}}var zl_=$i(require("path"),1);var Ql_={name:"no-duplicate-declarations",create:({workspace:e,logger:t})=>{let r=ov8(e),n={},i=({declaredName:a,relativeFilepath:u})=>{let c=zl_.default.dirname(u),p=r[c]?.[a];if(p==null)return t.error(`Could not find declarations for name: ${a}. This is an error in the Fern validator.`),[];let s=n[c]??=new Set;if(!s.has(a))return s.add(a),[];let o=p.indexOf(u);return p.filter((O,A)=>A!==o).map(O=>({severity:"fatal",message:`${a} is already declared in ${O===u?"this file":O}`}))};return{definitionFile:{typeName:(a,{relativeFilepath:u})=>i({declaredName:a,relativeFilepath:u}),errorDeclaration:({errorName:a},{relativeFilepath:u})=>i({declaredName:a,relativeFilepath:u}),httpEndpoint:({endpoint:a},{relativeFilepath:u})=>typeof a.request!="string"&&a.request?.name!=null?i({declaredName:a.request.name,relativeFilepath:u}):[]}}}};function ov8(e){let t={};return LZ(e,(r,n)=>{let i=zl_.default.dirname(r),a=t[i]??={},u=c=>{(a[c]??=[]).push(r)};Zbe(n,{typeName:c=>{u(c)},errorDeclaration:({errorName:c})=>{u(c)},httpEndpoint:({endpoint:c})=>{typeof c.request!="string"&&c.request?.name!=null&&u(c.request.name)}})}),t}function wvu(e){let t=new Set,r=new Set,n=[];for(let i of e)t.has(i)&&!r.has(i)&&(r.add(i),n.push(i)),t.add(i);return n}var Ll_={name:"no-duplicate-enum-values",create:()=>({definitionFile:{typeDeclaration:({declaration:e})=>PDr(e)?wvu(e.enum.map(r=>typeof r=="string"?r:r.value)).map(r=>({severity:"fatal",message:`Duplicated enum value: ${yd.bold(r)}.`})):[]}})};var Ul_={name:"no-duplicate-example-names",create:()=>({definitionFile:{typeDeclaration:({declaration:e})=>{if(typeof e=="string"||e.examples==null)return[];let t=e.examples.map(r=>r.name).filter(HA);return wvu(t).map(r=>({severity:"fatal",message:`Duplicate example name: ${r}`}))},httpEndpoint:({endpoint:e})=>{if(e.examples==null)return[];let t=e.examples.map(r=>r.name).filter(HA);return wvu(t).map(r=>({severity:"fatal",message:`Duplicate example name: ${r}`}))}}})};function $M1(e){if(!e.isInlined)return e.name;switch(e.location){case"inlinedRequest":return"<Inlined Request>";default:lc(e.location)}}var Vl_={name:"no-duplicate-field-names",create:({workspace:e})=>{let t=new rN(e);return{definitionFile:{typeDeclaration:({typeName:r,declaration:n},{relativeFilepath:i,contents:a})=>{let u=[];return mZ(n,{alias:Bct,enum:c=>{let p=YM1(c.enum,s=>zUa(s).name);for(let s of p)u.push({severity:"fatal",message:`Name "${s}" is used by multiple values.`})},object:c=>{let p=$M1(r),s=YCr({typeName:p,objectDeclaration:c,filepathOfDeclaration:i,definitionFile:a,workspace:e,typeResolver:t,smartCasing:!1}),o=hCl(s,l=>l.name);for(let[l,O]of Object.entries(o))if(O.length>1){let A=[`Object has multiple properties named "${l}":`,...O.map(E=>` - ${qUa({property:E,prefixBreadcrumbs:[p]})}`)].join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.77.6",
3
+ "version": "0.77.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",