fern-api 0.45.0-rc15 → 0.45.0-rc16

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
@@ -1812,7 +1812,7 @@ ${l.indent}`:""}${zKc(o)}:${f.indent?" ":""}`;return u=!1,c=!0,f.objectItem=void
1812
1812
  `}),r.replaceAll(/\n$/g,"")}function lw1(e){return e?nl.green(qNr.radioOn):qNr.radioOff}var vva=tu(Lje(),1);function qyf(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Syi=class extends SF{_run(t){this.done=t;let r=wH(this.rl),n=r.line.pipe((0,vva.map)(this.filterInput.bind(this))),i=this.handleSubmitEvents(n);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,vva.takeUntil)(i.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),n="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(n=`
1813
1813
  `+nl.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?nl.cyan(qyf(t,this.opt.mask)):nl.italic.dim("[hidden]"):this.opt.mask?qyf(t,this.opt.mask):nl.italic.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 avf=tu(ivf(),1),ovf=tu(Lje(),1);var Nyi=class extends SF{_run(t){this.done=t,this.editorResult=new ovf.Subject;let r=wH(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"?nl.dim("Received"):nl.dim("Press <enter> to launch your preferred editor."),t&&(r=nl.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),(0,avf.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 _vf=tu(cvf(),1);var dvf=tu(require("readline"),1),pvf=tu(fvf(),1),Ftn=class{constructor(t){this.rl||=dvf.default.createInterface(ej1(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 ej1(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 pvf.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var zyi=class extends Ftn{constructor(t={}){super(t),this.log=(0,_vf.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return byi(this.rl,this.bottomBar.split(`
1814
1814
  `).length),this}updateBottomBar(t){return byi(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+`
1815
- `}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&&pva(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var jvf=tu(vvf(),1),Dvf=tu($fu(),1),Svf=tu(Pvf(),1),HC=tu(Lje(),1),Evf=tu(Shi(),1);var zva=tu(Lje(),1),wvf=tu(Shi(),1),Rva=function(e,t,r){return typeof e[t]!="function"?(0,zva.of)(e):(0,zva.from)((0,wvf.default)(e[t])(r).then(n=>(e[t]=n,e)))};var Ryi={isPlainObject:jvf.default,set:Svf.default,get:Dvf.default},Y4n=class extends Ftn{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=Ryi.isPlainObject(r)?{...r}:{},Ryi.isPlainObject(t)&&(t=Object.values(t).every(i=>Ryi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,HC.from)(t):t;return this.process=n.pipe((0,HC.concatMap)(this.processQuestion.bind(this)),(0,HC.publish)()),this.process.connect(),this.process.pipe((0,HC.reduce)((i,a)=>(Ryi.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,HC.defer)(()=>(0,HC.of)(t).pipe((0,HC.concatMap)(this.setDefaultType.bind(this)),(0,HC.concatMap)(this.filterIfRunnable.bind(this)),(0,HC.concatMap)(()=>Rva(t,"message",this.answers)),(0,HC.concatMap)(()=>Rva(t,"default",this.answers)),(0,HC.concatMap)(()=>Rva(t,"choices",this.answers)),(0,HC.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,HC.defer)(()=>(0,HC.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,HC.defer)(()=>(0,HC.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&Ryi.get(this.answers,t.name)!==void 0)return(0,HC.empty)();if(t.when===!1)return(0,HC.empty)();if(typeof t.when!="function")return(0,HC.of)(t);let{answers:r}=this;return(0,HC.defer)(()=>(0,HC.from)((0,Evf.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,HC.filter)(n=>n!=null)))}};function Avf(e){let t=function(r,n){let i;try{i=new Y4n(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",myi),this.registerPrompt("input",Ctn),this.registerPrompt("number",Oyi),this.registerPrompt("confirm",Pyi),this.registerPrompt("rawlist",wyi),this.registerPrompt("expand",jyi),this.registerPrompt("checkbox",Dyi),this.registerPrompt("password",Syi),this.registerPrompt("editor",Nyi)},t.restoreDefaultPrompts(),t}var Qpu=Avf();function bj1(e,t){Qpu.registerPrompt(e,t)}function gj1(){Qpu.restoreDefaultPrompts()}var mj1={prompt:Qpu,ui:{BottomBar:zyi,Prompt:Y4n},createPromptModule:Avf,registerPrompt:bj1,restoreDefaultPrompts:gj1,Separator:qie},Fva=mj1;var zvf=tu(Mvf()),Rvf=tu(aou()),Gpu=function(e,t){return Gpu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},Gpu(e,t)};function X4n(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Gpu(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Qg=function(){return Qg=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Qg.apply(this,arguments)};function Oj1(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function hC(e,t,r,n){function i(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function f(o){try{c(n.next(o))}catch(l){u(l)}}function d(o){try{c(n.throw(o))}catch(l){u(l)}}function c(o){o.done?a(o.value):i(o.value).then(f,d)}c((n=n.apply(e,t||[])).next())})}function yC(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,u;return u={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function f(c){return function(o){return d([c,o])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(c[0]===6&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r)}catch(o){c=[6,o],i=0}finally{n=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Fvf(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,a;n<i;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}var $pu="3.1.2",fw;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties"})(fw||(fw={}));function Pj1(e,t){if(!e)throw new Error(t)}function wj1(e){return e?.replace(/\/+$/,"")}function jj1(e,t){return t===void 0&&(t={}),hC(this,void 0,void 0,function(){var r,n,i,a,u,f,d,c,o,l;return yC(this,function(g){switch(g.label){case 0:r=t.retryCount,n=r===void 0?3:r,i=t.retryDelay,a=i===void 0?5e3:i,u=t.retryCheck,f=u===void 0?function(){return!0}:u,d=null,c=0,g.label=1;case 1:return c<n+1?c>0?[4,new Promise(function(O){return setTimeout(O,a)})]:[3,3]:[3,7];case 2:g.sent(),g.label=3;case 3:return g.trys.push([3,5,,6]),[4,e()];case 4:return o=g.sent(),[2,o];case 5:if(l=g.sent(),d=l,!f(l))throw l;return[3,6];case 6:return c++,[3,1];case 7:throw d}})})}function Kpu(e){var t=new Date().getTime(),r=e&&e.performance&&e.performance.now&&e.performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var i=Math.random()*16;return t>0?(i=(t+i)%16|0,t=Math.floor(t/16)):(i=(r+i)%16|0,r=Math.floor(r/16)),(n==="x"?i:i&3|8).toString(16)})}function Dj1(){return new Date().getTime()}function xvf(){return new Date().toISOString()}function Lvf(e,t){var r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Lyi=String.fromCharCode,Tvf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Lva={};function Sj1(e,t){if(!Lva[e]){Lva[e]={};for(var r=0;r<e.length;r++)Lva[e][e.charAt(r)]=r}return Lva[e][t]}var Uyi={compressToBase64:function(e){if(e==null)return"";var t=Uyi._compress(e,6,function(r){return Tvf.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:Uyi._decompress(e.length,32,function(t){return Sj1(Tvf,e.charAt(t))})},compress:function(e){return Uyi._compress(e,16,function(t){return Lyi(t)})},_compress:function(e,t,r){if(e==null)return"";var n={},i={},a=[],u,f,d="",c="",o="",l=2,g=3,O=2,w=0,j=0,M;for(M=0;M<e.length;M+=1)if(d=e.charAt(M),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=g++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)w=w<<1,j==t-1?(j=0,a.push(r(w)),w=0):j++;for(f=o.charCodeAt(0),u=0;u<8;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}else{for(f=1,u=0;u<O;u++)w=w<<1|f,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=g++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)w=w<<1,j==t-1?(j=0,a.push(r(w)),w=0):j++;for(f=o.charCodeAt(0),u=0;u<8;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}else{for(f=1,u=0;u<O;u++)w=w<<1|f,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1;for(;;)if(w=w<<1,j==t-1){a.push(r(w));break}else j++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Uyi._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){var n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,g,O,w,j,M;for(o=0;o<3;o+=1)n[o]=o;for(g=0,w=Math.pow(2,2),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;switch(g){case 0:for(g=0,w=Math.pow(2,8),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;M=Lyi(g);break;case 1:for(g=0,w=Math.pow(2,16),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;M=Lyi(g);break;case 2:return""}for(n[3]=M,l=M,i.push(M);;){if(a.index>e)return"";for(g=0,w=Math.pow(2,d),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;switch(M=g){case 0:for(g=0,w=Math.pow(2,8),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;n[f++]=Lyi(g),M=f-1,u--;break;case 1:for(g=0,w=Math.pow(2,16),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;n[f++]=Lyi(g),M=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[M])c=n[M];else if(M===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},Ej1=function(){function e(){this.events={},this.events={}}return e.prototype.on=function(t,r){var n=this;return this.events[t]||(this.events[t]=[]),this.events[t].push(r),function(){n.events[t]=n.events[t].filter(function(i){return i!==r})}},e.prototype.emit=function(t,r){for(var n=0,i=this.events[t]||[];n<i.length;n++){var a=i[n];a(r)}for(var u=0,f=this.events["*"]||[];u<f.length;u++){var a=f[u];a(t,r)}},e}(),Aj1=function(e){X4n(t,e);function t(r){var n=e.call(this,"HTTP error while fetching PostHog: "+r.status)||this;return n.response=r,n.name="PostHogFetchHttpError",n}return t}(Error),Mj1=function(e){X4n(t,e);function t(r){var n=e.call(this,"Network error while fetching PostHog",r instanceof Error?{cause:r}:{})||this;return n.error=r,n.name="PostHogFetchNetworkError",n}return t}(Error);function Cvf(e){return typeof e=="object"&&(e.name==="PostHogFetchHttpError"||e.name==="PostHogFetchNetworkError")}var Uvf=function(){function e(t,r){var n,i,a,u,f;this.debugMode=!1,this.pendingPromises={},this.disableGeoip=!0,this._events=new Ej1,Pj1(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=wj1(r?.host||"https://app.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.flushInterval=(n=r?.flushInterval)!==null&&n!==void 0?n:1e4,this.captureMode=r?.captureMode||"form",this._optoutOverride=r?.enable===!1,this._retryOptions={retryCount:(i=r?.fetchRetryCount)!==null&&i!==void 0?i:3,retryDelay:(a=r?.fetchRetryDelay)!==null&&a!==void 0?a:3e3,retryCheck:Cvf},this.requestTimeout=(u=r?.requestTimeout)!==null&&u!==void 0?u:1e4,this.disableGeoip=(f=r?.disableGeoip)!==null&&f!==void 0?f:!0}return e.prototype.getCommonEventProperties=function(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}},Object.defineProperty(e.prototype,"optedOut",{get:function(){var t,r;return(r=(t=this.getPersistedProperty(fw.OptedOut))!==null&&t!==void 0?t:this._optoutOverride)!==null&&r!==void 0?r:!1},enumerable:!1,configurable:!0}),e.prototype.optIn=function(){this.setPersistedProperty(fw.OptedOut,!1)},e.prototype.optOut=function(){this.setPersistedProperty(fw.OptedOut,!0)},e.prototype.on=function(t,r){return this._events.on(t,r)},e.prototype.debug=function(t){var r;t===void 0&&(t=!0),(r=this.removeDebugCallback)===null||r===void 0||r.call(this),this.debugMode=t,t&&(this.removeDebugCallback=this.on("*",function(n,i){return console.log("PostHog Debug",n,i)}))},e.prototype.buildPayload=function(t){return{distinct_id:t.distinct_id,event:t.event,properties:Qg(Qg({},t.properties||{}),this.getCommonEventProperties())}},e.prototype.identifyStateless=function(t,r,n){var i=Qg({},this.buildPayload({distinct_id:t,event:"$identify",properties:r}));return this.enqueue("identify",i,n),this},e.prototype.captureStateless=function(t,r,n,i){var a=this.buildPayload({distinct_id:t,event:r,properties:n});return this.enqueue("capture",a,i),this},e.prototype.aliasStateless=function(t,r,n,i){var a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:Qg(Qg({},n||{}),{distinct_id:r,alias:t})});return this.enqueue("alias",a,i),this},e.prototype.groupIdentifyStateless=function(t,r,n,i,a,u){var f=this.buildPayload({distinct_id:a||"$".concat(t,"_").concat(r),event:"$groupidentify",properties:Qg({$group_type:t,$group_key:r,$group_set:n||{}},u||{})});return this.enqueue("capture",f,i),this},e.prototype.getDecide=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var u,f;return yC(this,function(d){return u="".concat(this.host,"/decide/?v=3"),f={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qg({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i},a))},[2,this.fetchWithRetry(u,f).then(function(c){return c.json()}).catch(function(c){console.error("Error fetching feature flags",c)})]})})},e.prototype.getFeatureFlagStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var f,d;return yC(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0&&(d=!1),[2,d]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var f,d;return yC(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagPayloadsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0?[2,null]:[2,this._parsePayload(d)]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){var u,f=this;return yC(this,function(d){switch(d.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return u=d.sent().payloads,u?[2,Object.fromEntries(Object.entries(u).map(function(c){var o=c[0],l=c[1];return[o,f._parsePayload(l)]}))]:[2,u]}})})},e.prototype._parsePayload=function(t){try{return JSON.parse(t)}catch{return t}},e.prototype.getFeatureFlagsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){return yC(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return[2,u.sent().flags]}})})},e.prototype.getFeatureFlagsAndPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){var u,f,d,c;return yC(this,function(o){switch(o.label){case 0:return u={},(a??this.disableGeoip)&&(u.geoip_disable=!0),[4,this.getDecide(t,r,n,i,u)];case 1:return f=o.sent(),d=f?.featureFlags,c=f?.featureFlagPayloads,[2,{flags:d,payloads:c}]}})})},e.prototype.enqueue=function(t,r,n){var i=this,a;if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.enable()");return}var u=Qg(Qg({},r),{type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:xvf()}),f=(a=n?.disableGeoip)!==null&&a!==void 0?a:this.disableGeoip;f&&(u.properties||(u.properties={}),u.properties.$geoip_disable=!0),u.distinctId&&(u.distinct_id=u.distinctId,delete u.distinctId);var d=this.getPersistedProperty(fw.Queue)||[];d.push({message:u}),this.setPersistedProperty(fw.Queue,d),this._events.emit(t,u),d.length>=this.flushAt&&this.flush(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Lvf(function(){return i.flush()},this.flushInterval))},e.prototype.flushAsync=function(){var t=this;return new Promise(function(r,n){t.flush(function(i,a){return i?n(i):r(a)})})},e.prototype.flush=function(t){var r=this;this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=null);var n=this.getPersistedProperty(fw.Queue)||[];if(!n.length)return t?.();var i=n.splice(0,this.flushAt);this.setPersistedProperty(fw.Queue,n);var a=i.map(function(O){return O.message}),u={api_key:this.apiKey,batch:a,sent_at:xvf()},f=Kpu(),d=function(O){O&&r._events.emit("error",O),t?.(O,a),delete r.pendingPromises[f],r._events.emit("flush",a)};this.getCustomUserAgent();var c=JSON.stringify(u),o=this.captureMode==="form"?"".concat(this.host,"/e/?ip=1&_=").concat(Dj1(),"&v=").concat(this.getLibraryVersion()):"".concat(this.host,"/batch/"),l=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"data=".concat(encodeURIComponent(Uyi.compressToBase64(c)),"&compression=lz64")}:{method:"POST",headers:{"Content-Type":"application/json"},body:c},g=this.fetchWithRetry(o,l);this.pendingPromises[f]=g,g.then(function(){return d()}).catch(function(O){d(O)})},e.prototype.fetchWithRetry=function(t,r,n){var i,a;return hC(this,void 0,void 0,function(){var u=this;return yC(this,function(f){switch(f.label){case 0:return(i=(a=AbortSignal).timeout)!==null&&i!==void 0||(a.timeout=function(c){var o=new AbortController;return setTimeout(function(){return o.abort()},c),o.signal}),[4,jj1(function(){return hC(u,void 0,void 0,function(){var d,c;return yC(this,function(o){switch(o.label){case 0:d=null,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.fetch(t,Qg({signal:AbortSignal.timeout(this.requestTimeout)},r))];case 2:return d=o.sent(),[3,4];case 3:throw c=o.sent(),new Mj1(c);case 4:if(d.status<200||d.status>=400)throw new Aj1(d);return[2,d]}})})},Qg(Qg({},this._retryOptions),n))];case 1:return[2,f.sent()]}})})},e.prototype.shutdownAsync=function(){return hC(this,void 0,void 0,function(){var t;return yC(this,function(r){switch(r.label){case 0:clearTimeout(this._flushTimer),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.flushAsync()];case 2:return r.sent(),[4,Promise.all(Object.values(this.pendingPromises).map(function(n){return n.catch(function(){})}))];case 3:return r.sent(),[3,5];case 4:if(t=r.sent(),!Cvf(t))throw t;return console.error("Error while shutting down PostHog",t),[3,5];case 5:return[2]}})})},e.prototype.shutdown=function(){this.shutdownAsync()},e}();(function(e){X4n(t,e);function t(r,n){var i=this,a,u,f,d=(a=n?.disableGeoip)!==null&&a!==void 0?a:!1;return i=e.call(this,r,Qg(Qg({},n),{disableGeoip:d}))||this,i.flagCallReported={},i.sessionProps={},i.sendFeatureFlagEvent=(u=n?.sendFeatureFlagEvent)!==null&&u!==void 0?u:!0,i._sessionExpirationTimeSeconds=(f=n?.sessionExpirationTimeSeconds)!==null&&f!==void 0?f:1800,i}return t.prototype.setupBootstrap=function(r){var n,i,a,u;if(!((n=r?.bootstrap)===null||n===void 0)&&n.distinctId&&(!((i=r?.bootstrap)===null||i===void 0)&&i.isIdentifiedId?this.setPersistedProperty(fw.DistinctId,r.bootstrap.distinctId):this.setPersistedProperty(fw.AnonymousId,r.bootstrap.distinctId)),!((a=r?.bootstrap)===null||a===void 0)&&a.featureFlags){var f=Object.keys(((u=r.bootstrap)===null||u===void 0?void 0:u.featureFlags)||{}).filter(function(d){var c,o;return!!(!((o=(c=r.bootstrap)===null||c===void 0?void 0:c.featureFlags)===null||o===void 0)&&o[d])}).reduce(function(d,c){var o,l;return d[c]=((l=(o=r.bootstrap)===null||o===void 0?void 0:o.featureFlags)===null||l===void 0?void 0:l[c])||!1,d},{});this.setKnownFeatureFlags(f),r?.bootstrap.featureFlagPayloads&&this.setKnownFeatureFlagPayloads(r?.bootstrap.featureFlagPayloads)}},Object.defineProperty(t.prototype,"props",{get:function(){return this._props||(this._props=this.getPersistedProperty(fw.Props)),this._props||{}},set:function(r){this._props=r},enumerable:!1,configurable:!0}),t.prototype.clearProps=function(){this.props=void 0,this.sessionProps={}},t.prototype.on=function(r,n){return this._events.on(r,n)},t.prototype.reset=function(r){var n=Fvf([fw.Queue],r||[],!0);this.clearProps();for(var i=0,a=Object.keys(fw);i<a.length;i++){var u=a[i];n.includes(fw[u])||this.setPersistedProperty(fw[u],null)}},t.prototype.getCommonEventProperties=function(){var r=this.getFeatureFlags(),n={};if(r)for(var i=0,a=Object.entries(r);i<a.length;i++){var u=a[i],f=u[0],d=u[1];n["$feature/".concat(f)]=d}return Qg(Qg({$active_feature_flags:r?Object.keys(r):void 0},n),e.prototype.getCommonEventProperties.call(this))},t.prototype.enrichProperties=function(r){return Qg(Qg(Qg(Qg(Qg({},this.props),this.sessionProps),r||{}),this.getCommonEventProperties()),{$session_id:this.getSessionId()})},t.prototype.getSessionId=function(){var r=this.getPersistedProperty(fw.SessionId),n=this.getPersistedProperty(fw.SessionLastTimestamp)||0;return(!r||Date.now()-n>this._sessionExpirationTimeSeconds*1e3)&&(r=Kpu(globalThis),this.setPersistedProperty(fw.SessionId,r)),this.setPersistedProperty(fw.SessionLastTimestamp,Date.now()),r},t.prototype.resetSessionId=function(){this.setPersistedProperty(fw.SessionId,null)},t.prototype.getAnonymousId=function(){var r=this.getPersistedProperty(fw.AnonymousId);return r||(r=Kpu(globalThis),this.setPersistedProperty(fw.AnonymousId,r)),r},t.prototype.getDistinctId=function(){return this.getPersistedProperty(fw.DistinctId)||this.getAnonymousId()},t.prototype.unregister=function(r){delete this.props[r],this.setPersistedProperty(fw.Props,this.props)},t.prototype.register=function(r){this.props=Qg(Qg({},this.props),r),this.setPersistedProperty(fw.Props,this.props)},t.prototype.registerForSession=function(r){this.sessionProps=Qg(Qg({},this.sessionProps),r)},t.prototype.unregisterForSession=function(r){delete this.sessionProps[r]},t.prototype.identify=function(r,n,i){var a=this.getDistinctId();r=r||a,n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(Qg(Qg({},n),{$anon_distinct_id:this.getAnonymousId(),$set:n}));return r!==a&&(this.setPersistedProperty(fw.AnonymousId,a),this.setPersistedProperty(fw.DistinctId,r),this.reloadFeatureFlags()),e.prototype.identifyStateless.call(this,r,u,i),this},t.prototype.capture=function(r,n,i){var a=this.getDistinctId();n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(n);return e.prototype.captureStateless.call(this,a,r,u,i),this},t.prototype.alias=function(r){var n=this.getDistinctId(),i=this.enrichProperties({});return e.prototype.aliasStateless.call(this,r,n,i),this},t.prototype.autocapture=function(r,n,i,a){i===void 0&&(i={});var u=this.getDistinctId(),f={distinct_id:u,event:"$autocapture",properties:Qg(Qg({},this.enrichProperties(i)),{$event_type:r,$elements:n})};return this.enqueue("autocapture",f,a),this},t.prototype.groups=function(r){var n=this.props.$groups||{};return this.register({$groups:Qg(Qg({},n),r)}),Object.keys(r).find(function(i){return n[i]!==r[i]})&&this.reloadFeatureFlags(),this},t.prototype.group=function(r,n,i,a){var u;return this.groups((u={},u[r]=n,u)),i&&this.groupIdentify(r,n,i,a),this},t.prototype.groupIdentify=function(r,n,i,a){var u=this.getDistinctId(),f=this.enrichProperties({});return e.prototype.groupIdentifyStateless.call(this,r,n,i,a,u,f),this},t.prototype.personProperties=function(r){var n=this.getPersistedProperty(fw.PersonProperties)||{};return this.setPersistedProperty(fw.PersonProperties,Qg(Qg({},n),r)),this},t.prototype.groupProperties=function(r){var n=this.getPersistedProperty(fw.GroupProperties)||{};return Object.keys(n).length!==0&&Object.keys(n).forEach(function(i){n[i]=Qg(Qg({},n[i]),r[i]),delete r[i]}),this.setPersistedProperty(fw.GroupProperties,Qg(Qg({},n),r)),this},t.prototype.decideAsync=function(r){return r===void 0&&(r=!0),this._decideResponsePromise?this._decideResponsePromise:this._decideAsync(r)},t.prototype._decideAsync=function(r){return r===void 0&&(r=!0),hC(this,void 0,void 0,function(){var n,i,a,u,f,d=this;return yC(this,function(c){return n=this.getDistinctId(),i=this.props.$groups||{},a=this.getPersistedProperty(fw.PersonProperties)||{},u=this.getPersistedProperty(fw.GroupProperties)||{},f={$anon_distinct_id:r?this.getAnonymousId():void 0},this._decideResponsePromise=e.prototype.getDecide.call(this,n,i,a,u,f).then(function(o){if(o?.featureFlags){var l=o.featureFlags,g=o.featureFlagPayloads;if(o.errorsWhileComputingFlags){var O=d.getPersistedProperty(fw.FeatureFlags),w=d.getPersistedProperty(fw.FeatureFlagPayloads);l=Qg(Qg({},O),o.featureFlags),g=Qg(Qg({},w),o.featureFlagPayloads)}d.setKnownFeatureFlags(l),d.setKnownFeatureFlagPayloads(g)}return o}).finally(function(){d._decideResponsePromise=void 0}),[2,this._decideResponsePromise]})})},t.prototype.setKnownFeatureFlags=function(r){this.setPersistedProperty(fw.FeatureFlags,r),this._events.emit("featureflags",r)},t.prototype.setKnownFeatureFlagPayloads=function(r){this.setPersistedProperty(fw.FeatureFlagPayloads,r)},t.prototype.getFeatureFlag=function(r){var n=this.getFeatureFlags();if(n){var i=n[r];return i===void 0&&(i=!1),this.sendFeatureFlagEvent&&!this.flagCallReported[r]&&(this.flagCallReported[r]=!0,this.capture("$feature_flag_called",{$feature_flag:r,$feature_flag_response:i})),i}},t.prototype.getFeatureFlagPayload=function(r){var n=this.getFeatureFlagPayloads();if(n){var i=n[r];return i===void 0?null:this._parsePayload(i)}},t.prototype.getFeatureFlagPayloads=function(){var r=this,n=this.getPersistedProperty(fw.FeatureFlagPayloads);return n&&Object.fromEntries(Object.entries(n).map(function(i){var a=i[0],u=i[1];return[a,r._parsePayload(u)]}))},t.prototype.getFeatureFlags=function(){var r=this.getPersistedProperty(fw.FeatureFlags),n=this.getPersistedProperty(fw.OverrideFeatureFlags);if(!n)return r;r=r||{};for(var i in n)n[i]?r[i]=n[i]:delete r[i];return r},t.prototype.getFeatureFlagsAndPayloads=function(){var r=this.getFeatureFlags(),n=this.getFeatureFlagPayloads();return{flags:r,payloads:n}},t.prototype.isFeatureEnabled=function(r){var n=this.getFeatureFlag(r);if(n!==void 0)return!!n},t.prototype.reloadFeatureFlags=function(r){this.decideAsync().then(function(n){r?.(void 0,n?.featureFlags)}).catch(function(n){r?.(n,void 0),r||console.log("[PostHog] Error reloading feature flags",n)})},t.prototype.reloadFeatureFlagsAsync=function(r){var n;return r===void 0&&(r=!0),hC(this,void 0,void 0,function(){return yC(this,function(i){switch(i.label){case 0:return[4,this.decideAsync(r)];case 1:return[2,(n=i.sent())===null||n===void 0?void 0:n.featureFlags]}})})},t.prototype.onFeatureFlags=function(r){var n=this;return this.on("featureflags",function(){return hC(n,void 0,void 0,function(){var i;return yC(this,function(a){return i=this.getFeatureFlags(),i&&r(i),[2]})})})},t.prototype.onFeatureFlag=function(r,n){var i=this;return this.on("featureflags",function(){return hC(i,void 0,void 0,function(){var a;return yC(this,function(u){return a=this.getFeatureFlag(r),a!==void 0&&n(a),[2]})})})},t.prototype.overrideFeatureFlag=function(r){return r===null?this.setPersistedProperty(fw.OverrideFeatureFlags,null):this.setPersistedProperty(fw.OverrideFeatureFlags,r)},t})(Uvf);var xj1=function(){function e(){this._memoryStorage={}}return e.prototype.getProperty=function(t){return this._memoryStorage[t]},e.prototype.setProperty=function(t,r){this._memoryStorage[t]=r!==null?r:void 0},e}(),Vvf=function(e,t){return hC(void 0,void 0,void 0,function(){var r;return yC(this,function(n){switch(n.label){case 0:return[4,Rvf.default.request({url:e,headers:t.headers,method:t.method.toLowerCase(),data:t.body,signal:t.signal,validateStatus:function(){return!0}})];case 1:return r=n.sent(),[2,{status:r.status,text:function(){return hC(void 0,void 0,void 0,function(){return yC(this,function(i){return[2,r.data]})})},json:function(){return hC(void 0,void 0,void 0,function(){return yC(this,function(i){return[2,r.data]})})}}]}})})},Tj1=1152921504606847e3,qvf=function(e){X4n(t,e);function t(r){var n=e.call(this)||this;return Error.captureStackTrace(n,n.constructor),n.name="ClientError",n.message=r,Object.setPrototypeOf(n,t.prototype),n}return t}(Error),zZ=function(e){X4n(t,e);function t(r){var n=e.call(this,r)||this;return n.name=n.constructor.name,Error.captureStackTrace(n,n.constructor),Object.setPrototypeOf(n,t.prototype),n}return t}(Error),Cj1=function(){function e(t){var r=t.pollingInterval,n=t.personalApiKey,i=t.projectApiKey,a=t.timeout,u=t.host,f=Oj1(t,["pollingInterval","personalApiKey","projectApiKey","timeout","host"]);this.debugMode=!1,this.pollingInterval=r,this.personalApiKey=n,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=a,this.projectApiKey=i,this.host=u,this.poller=void 0,this.fetch=f.fetch||Vvf,this.loadFeatureFlags()}return e.prototype.debug=function(t){t===void 0&&(t=!0),this.debugMode=t},e.prototype.getFeatureFlag=function(t,r,n,i,a){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var u,f,d,c,o;return yC(this,function(l){switch(l.label){case 0:return[4,this.loadFeatureFlags()];case 1:if(l.sent(),u=void 0,f=void 0,!this.loadedSuccessfullyOnce)return[2,u];for(d=0,c=this.featureFlags;d<c.length;d++)if(o=c[d],t===o.key){f=o;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.debugMode&&console.debug("Successfully computed flag locally: ".concat(t," -> ").concat(u))}catch(g){g instanceof zZ?this.debugMode&&console.debug("InconclusiveMatchError when computing flag locally: ".concat(t,": ").concat(g)):g instanceof Error&&console.error("Error computing flag locally: ".concat(t,": ").concat(g))}return[2,u]}})})},e.prototype.computeFeatureFlagPayloadLocally=function(t,r){var n,i,a,u,f,d,c,o;return hC(this,void 0,void 0,function(){var l;return yC(this,function(g){switch(g.label){case 0:return[4,this.loadFeatureFlags()];case 1:return g.sent(),l=void 0,this.loadedSuccessfullyOnce?(typeof r=="boolean"?l=(u=(a=(i=(n=this.featureFlagsByKey)===null||n===void 0?void 0:n[t])===null||i===void 0?void 0:i.filters)===null||a===void 0?void 0:a.payloads)===null||u===void 0?void 0:u[r.toString()]:typeof r=="string"&&(l=(o=(c=(d=(f=this.featureFlagsByKey)===null||f===void 0?void 0:f[t])===null||d===void 0?void 0:d.filters)===null||c===void 0?void 0:c.payloads)===null||o===void 0?void 0:o[r]),l===void 0?[2,null]:[2,l]):[2,void 0]}})})},e.prototype.getAllFlagsAndPayloads=function(t,r,n,i){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){var a,u,f,d=this;return yC(this,function(c){switch(c.label){case 0:return[4,this.loadFeatureFlags()];case 1:return c.sent(),a={},u={},f=this.featureFlags.length==0,this.featureFlags.map(function(o){return hC(d,void 0,void 0,function(){var l,g,O;return yC(this,function(w){switch(w.label){case 0:return w.trys.push([0,2,,3]),l=this.computeFlagLocally(o,t,r,n,i),a[o.key]=l,[4,this.computeFeatureFlagPayloadLocally(o.key,l)];case 1:return g=w.sent(),g&&(u[o.key]=g),[3,3];case 2:return O=w.sent(),O instanceof zZ||O instanceof Error&&console.error("Error computing flag locally: ".concat(o.key,": ").concat(O)),f=!0,[3,3];case 3:return[2]}})})}),[2,{response:a,payloads:u,fallbackToDecide:f}]}})})},e.prototype.computeFlagLocally=function(t,r,n,i,a){if(n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),t.ensure_experience_continuity)throw new zZ("Flag has experience continuity enabled");if(!t.active)return!1;var u=t.filters||{},f=u.aggregation_group_type_index;if(f!=null){var d=this.groupTypeMapping[String(f)];if(!d)throw console.warn("[FEATURE FLAGS] Unknown group type index ".concat(f," for feature flag ").concat(t.key)),new zZ("Flag has unknown group type index");if(!(d in n))return console.warn("[FEATURE FLAGS] Can't compute group feature flag: ".concat(t.key," without group names passed in")),!1;var c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)},e.prototype.matchFeatureFlagProperties=function(t,r,n){for(var i,a=t.filters||{},u=a.groups||[],f=!1,d=void 0,c=Fvf([],u,!0).sort(function(M,q){var B=!!M.variant,I=!!q.variant;return B&&I?0:B?-1:I?1:0}),o=function(M){try{if(l.isConditionMatch(t,r,M,n)){var q=M.variant,B=((i=a.multivariate)===null||i===void 0?void 0:i.variants)||[];return q&&B.some(function(I){return I.key===q})?d=q:d=l.getMatchingVariant(t,r)||!0,"break"}}catch(I){if(I instanceof zZ)f=!0;else throw I}},l=this,g=0,O=c;g<O.length;g++){var w=O[g],j=o(w);if(j==="break")break}if(d!==void 0)return d;if(f)throw new zZ("Can't determine if feature flag is enabled or not with given properties");return!1},e.prototype.isConditionMatch=function(t,r,n,i){var a=n.rollout_percentage;if((n.properties||[]).length>0){for(var u=0,f=n.properties;u<f.length;u++){var d=f[u],c=d.type,o=!1;if(c==="cohort"?o=Hvf(d,i,this.cohorts):o=Wvf(d,i),!o)return!1}if(a==null)return!0}return!(a!=null&&Ivf(t.key,r)>a/100)},e.prototype.getMatchingVariant=function(t,r){var n=Ivf(t.key,r,"variant"),i=this.variantLookupTable(t).find(function(a){return n>=a.valueMin&&n<a.valueMax});if(i)return i.key},e.prototype.variantLookupTable=function(t){var r,n=[],i=0,a=0,u=t.filters||{},f=((r=u.multivariate)===null||r===void 0?void 0:r.variants)||[];return f.forEach(function(d){a=i+d.rollout_percentage/100,n.push({valueMin:i,valueMax:a,key:d.key}),i=a}),n},e.prototype.loadFeatureFlags=function(t){return t===void 0&&(t=!1),hC(this,void 0,void 0,function(){return yC(this,function(r){switch(r.label){case 0:return!this.loadedSuccessfullyOnce||t?[4,this._loadFeatureFlags()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},e.prototype._loadFeatureFlags=function(){return hC(this,void 0,void 0,function(){var t,r,n,i=this;return yC(this,function(a){switch(a.label){case 0:this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(function(){return i._loadFeatureFlags()},this.pollingInterval),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,this._requestFeatureFlagDefinitions()];case 2:if(t=a.sent(),t&&t.status===401)throw new qvf("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");return t&&t.status!==200?[2]:[4,t.json()];case 3:return r=a.sent(),"flags"in r||console.error("Invalid response when getting feature flags: ".concat(JSON.stringify(r))),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce(function(u,f){return u[f.key]=f,u},{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0,[3,5];case 4:if(n=a.sent(),n instanceof qvf)throw n;return[3,5];case 5:return[2]}})})},e.prototype._requestFeatureFlagDefinitions=function(){return hC(this,void 0,void 0,function(){var t,r,n,i,a;return yC(this,function(u){switch(u.label){case 0:t="".concat(this.host,"/api/feature_flag/local_evaluation?token=").concat(this.projectApiKey,"&send_cohorts"),r={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.personalApiKey),"user-agent":"posthog-node/".concat($pu)}},n=null,this.timeout&&typeof this.timeout=="number"&&(i=new AbortController,n=Lvf(function(){i.abort()},this.timeout),r.signal=i.signal),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,this.fetch(t,r)];case 2:return[2,u.sent()];case 3:throw a=u.sent(),a;case 4:return clearTimeout(n),[7];case 5:return[2]}})})},e.prototype.stopPoller=function(){clearTimeout(this.poller)},e}();function Ivf(e,t,r){r===void 0&&(r="");var n=(0,zvf.createHash)();return n.update("".concat(e,".").concat(t).concat(r)),parseInt(n.digest("hex").slice(0,15),16)/Tj1}function Wvf(e,t){var r=e.key,n=e.value,i=e.operator||"exact";if(r in t){if(i==="is_not_set")throw new zZ("Operator is_not_set is not supported")}else throw new zZ("Property ".concat(r," not found in propertyValues"));var a=t[r];switch(i){case"exact":return Array.isArray(n)?n.indexOf(a)!==-1:n===a;case"is_not":return Array.isArray(n)?n.indexOf(a)===-1:n!==a;case"is_set":return r in t;case"icontains":return String(a).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(a).toLowerCase().includes(String(n).toLowerCase());case"regex":return Bvf(String(n))&&String(a).match(String(n))!==null;case"not_regex":return Bvf(String(n))&&String(a).match(String(n))===null;case"gt":return typeof a==typeof n&&a>n;case"gte":return typeof a==typeof n&&a>=n;case"lt":return typeof a==typeof n&&a<n;case"lte":return typeof a==typeof n&&a<=n;case"is_date_after":case"is_date_before":var u=Nvf(n),f=Nvf(a);return i==="is_date_before"?f<u:f>u;default:return console.error("Unknown operator: ".concat(i)),!1}}function Hvf(e,t,r){var n=String(e.value);if(!(n in r))throw new zZ("can't match cohort without a given cohort property value");var i=r[n];return Qvf(i,t,r)}function Qvf(e,t,r){if(!e)return!0;var n=e.type,i=e.values;if(!i||i.length===0)return!0;var a=!1;if("values"in i[0]){for(var u=0,f=i;u<f.length;u++){var d=f[u];try{var c=Qvf(d,t,r);if(n==="AND"){if(!c)return!1}else if(c)return!0}catch(O){if(O instanceof zZ)console.debug("Failed to compute property ".concat(d," locally: ").concat(O)),a=!0;else throw O}}if(a)throw new zZ("Can't match cohort without a given cohort property value");return n==="AND"}else{for(var o=0,l=i;o<l.length;o++){var d=l[o];try{var c=void 0;d.type==="cohort"?c=Hvf(d,t,r):c=Wvf(d,t);var g=d.negation||!1;if(n==="AND"){if(!c&&!g||c&&g)return!1}else if(c&&!g||!c&&g)return!0}catch(w){if(w instanceof zZ)console.debug("Failed to compute property ".concat(d," locally: ").concat(w)),a=!0;else throw w}}if(a)throw new zZ("can't match cohort without a given cohort property value");return n==="AND"}}function Bvf(e){try{return new RegExp(e),!0}catch{return!1}}function Nvf(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){var t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new zZ("".concat(e," is in an invalid date format"))}else throw new zZ("The date provided ".concat(e," must be a string, number, or date object"))}var qj1=30*1e3,Ij1=50*1e3,Uva=function(e){X4n(t,e);function t(r,n){n===void 0&&(n={});var i=this,a;return n.captureMode=n?.captureMode||"json",i=e.call(this,r,n)||this,i._memoryStorage=new xj1,i.options=n,n.personalApiKey&&(i.featureFlagsPoller=new Cj1({pollingInterval:typeof n.featureFlagsPollingInterval=="number"?n.featureFlagsPollingInterval:qj1,personalApiKey:n.personalApiKey,projectApiKey:r,timeout:(a=n.requestTimeout)!==null&&a!==void 0?a:1e4,host:i.host,fetch:n.fetch})),i.distinctIdHasSentFlagCalls={},i.maxCacheSize=n.maxCacheSize||Ij1,i}return t.prototype.getPersistedProperty=function(r){return this._memoryStorage.getProperty(r)},t.prototype.setPersistedProperty=function(r,n){return this._memoryStorage.setProperty(r,n)},t.prototype.fetch=function(r,n){return this.options.fetch?this.options.fetch(r,n):Vvf(r,n)},t.prototype.getLibraryId=function(){return"posthog-node"},t.prototype.getLibraryVersion=function(){return $pu},t.prototype.getCustomUserAgent=function(){return"posthog-node/".concat($pu)},t.prototype.enable=function(){return e.prototype.optIn.call(this)},t.prototype.disable=function(){return e.prototype.optOut.call(this)},t.prototype.debug=function(r){var n;r===void 0&&(r=!0),e.prototype.debug.call(this,r),(n=this.featureFlagsPoller)===null||n===void 0||n.debug(r)},t.prototype.capture=function(r){var n=this,i=r.distinctId,a=r.event,u=r.properties,f=r.groups,d=r.sendFeatureFlags,c=r.timestamp,o=r.disableGeoip,l=function(g){e.prototype.captureStateless.call(n,i,a,g,{timestamp:c,disableGeoip:o})};d?e.prototype.getFeatureFlagsStateless.call(this,i,f,void 0,void 0,o).then(function(g){var O={};if(g)for(var w=0,j=Object.entries(g);w<j.length;w++){var M=j[w],q=M[0],B=M[1];B!==!1&&(O["$feature/".concat(q)]=B)}var I=Object.keys(g||{}).filter(function(L){return g?.[L]!==!1}),C=Qg({$active_feature_flags:I||void 0},O);l(Qg(Qg(Qg({},u),{$groups:f}),C))}):l(Qg(Qg({},u),{$groups:f}))},t.prototype.identify=function(r){var n=r.distinctId,i=r.properties,a=r.disableGeoip,u=i?.$set||i;e.prototype.identifyStateless.call(this,n,{$set:u},{disableGeoip:a})},t.prototype.alias=function(r){e.prototype.aliasStateless.call(this,r.alias,r.distinctId,void 0,{disableGeoip:r.disableGeoip})},t.prototype.getFeatureFlag=function(r,n,i){var a;return hC(this,void 0,void 0,function(){var u,f,d,c,o,l,g,O,w,j,M,q;return yC(this,function(B){switch(B.label){case 0:return u=i||{},f=u.groups,d=u.personProperties,c=u.groupProperties,o=u.disableGeoip,l=i||{},g=l.onlyEvaluateLocally,O=l.sendFeatureFlagEvents,g==null&&(g=!1),O==null&&(O=!0),[4,(a=this.featureFlagsPoller)===null||a===void 0?void 0:a.getFeatureFlag(r,n,f,d,c)];case 1:return w=B.sent(),j=w!==void 0,!j&&!g?[4,e.prototype.getFeatureFlagStateless.call(this,r,n,f,d,c,o)]:[3,3];case 2:w=B.sent(),B.label=3;case 3:return M="".concat(r,"_").concat(w),O&&(!(n in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[n].includes(M))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[n])?this.distinctIdHasSentFlagCalls[n].push(M):this.distinctIdHasSentFlagCalls[n]=[M],this.capture({distinctId:n,event:"$feature_flag_called",properties:(q={$feature_flag:r,$feature_flag_response:w,locally_evaluated:j},q["$feature/".concat(r)]=w,q),groups:f,disableGeoip:o})),[2,w]}})})},t.prototype.getFeatureFlagPayload=function(r,n,i,a){var u;return hC(this,void 0,void 0,function(){var f,d,c,o,l,g,O,w,j;return yC(this,function(M){switch(M.label){case 0:return f=a||{},d=f.groups,c=f.personProperties,o=f.groupProperties,l=f.disableGeoip,g=a||{},O=g.onlyEvaluateLocally,g.sendFeatureFlagEvents,w=void 0,i?[3,2]:[4,this.getFeatureFlag(r,n,Qg(Qg({},a),{onlyEvaluateLocally:!0}))];case 1:i=M.sent(),M.label=2;case 2:return i?[4,(u=this.featureFlagsPoller)===null||u===void 0?void 0:u.computeFeatureFlagPayloadLocally(r,i)]:[3,4];case 3:w=M.sent(),M.label=4;case 4:return O==null&&(O=!1),O==null&&(O=!1),j=w!==void 0,!j&&!O?[4,e.prototype.getFeatureFlagPayloadStateless.call(this,r,n,d,c,o,l)]:[3,6];case 5:w=M.sent(),M.label=6;case 6:try{return[2,JSON.parse(w)]}catch{return[2,w]}return[2]}})})},t.prototype.isFeatureEnabled=function(r,n,i){return hC(this,void 0,void 0,function(){var a;return yC(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlag(r,n,i)];case 1:return a=u.sent(),a===void 0?[2,void 0]:[2,!!a||!1]}})})},t.prototype.getAllFlags=function(r,n){return hC(this,void 0,void 0,function(){var i;return yC(this,function(a){switch(a.label){case 0:return[4,this.getAllFlagsAndPayloads(r,n)];case 1:return i=a.sent(),[2,i.featureFlags]}})})},t.prototype.getAllFlagsAndPayloads=function(r,n){var i;return hC(this,void 0,void 0,function(){var a,u,f,d,c,o,l,g,O,w,j;return yC(this,function(M){switch(M.label){case 0:return a=n||{},u=a.groups,f=a.personProperties,d=a.groupProperties,c=a.disableGeoip,o=(n||{}).onlyEvaluateLocally,o==null&&(o=!1),[4,(i=this.featureFlagsPoller)===null||i===void 0?void 0:i.getAllFlagsAndPayloads(r,u,f,d)];case 1:return l=M.sent(),g={},O={},w=!0,l&&(g=l.response,O=l.payloads,w=l.fallbackToDecide),w&&!o?[4,e.prototype.getFeatureFlagsAndPayloadsStateless.call(this,r,u,f,d,c)]:[3,3];case 2:j=M.sent(),g=Qg(Qg({},g),j.flags||{}),O=Qg(Qg({},O),j.payloads||{}),M.label=3;case 3:return[2,{featureFlags:g,featureFlagPayloads:O}]}})})},t.prototype.groupIdentify=function(r){var n=r.groupType,i=r.groupKey,a=r.properties,u=r.distinctId,f=r.disableGeoip;e.prototype.groupIdentifyStateless.call(this,n,i,a,{disableGeoip:f},u)},t.prototype.reloadFeatureFlags=function(){var r;return hC(this,void 0,void 0,function(){return yC(this,function(n){switch(n.label){case 0:return[4,(r=this.featureFlagsPoller)===null||r===void 0?void 0:r.loadFeatureFlags(!0)];case 1:return n.sent(),[2]}})})},t.prototype.shutdown=function(){this.shutdownAsync()},t.prototype.shutdownAsync=function(){var r;return hC(this,void 0,void 0,function(){return yC(this,function(n){return(r=this.featureFlagsPoller)===null||r===void 0||r.stopPoller(),[2,e.prototype.shutdownAsync.call(this)]})})},t}(Uvf);var Vva=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Uva(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc15",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var Vyi=class{async sendEvent(){}async identify(){}async flush(){}};var Z4n=require("fs/promises"),Kvf=require("os"),Yvf=require("path");var Jvf=tu(require("crypto")),Hva=new Uint8Array(256),Wva=Hva.length;function Ypu(){return Wva>Hva.length-16&&(Jvf.default.randomFillSync(Hva),Wva=0),Hva.slice(Wva,Wva+=16)}var SH=[];for(let e=0;e<256;++e)SH.push((e+256).toString(16).slice(1));function Gvf(e,t=0){return SH[e[t+0]]+SH[e[t+1]]+SH[e[t+2]]+SH[e[t+3]]+"-"+SH[e[t+4]]+SH[e[t+5]]+"-"+SH[e[t+6]]+SH[e[t+7]]+"-"+SH[e[t+8]]+SH[e[t+9]]+"-"+SH[e[t+10]]+SH[e[t+11]]+SH[e[t+12]]+SH[e[t+13]]+SH[e[t+14]]+SH[e[t+15]]}var $vf=tu(require("crypto")),Xpu={randomUUID:$vf.default.randomUUID};function Bj1(e,t,r){if(Xpu.randomUUID&&!t&&!e)return Xpu.randomUUID();e=e||{};let n=e.random||(e.rng||Ypu)();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 Gvf(n)}var _8r=Bj1;var Nj1="id",zj1=".fern",Wyi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Uva(r),this.userId=t==null?void 0:auu(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.45.0-rc15",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=yf(j_.of((0,Kvf.homedir)()),Ms.of(zj1),Ms.of(Nj1));await Vh(t)||(await(0,Z4n.mkdir)((0,Yvf.dirname)(t),{recursive:!0}),await(0,Z4n.writeFile)(t,_8r())),this.persistedDistinctId=(await(0,Z4n.readFile)(t)).toString()}return this.persistedDistinctId}};var Zpu;async function k4n(){return Zpu==null&&(Zpu=await Rj1()),Zpu}async function Rj1(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Vyi;let r=await vda();return r!=null?new Wyi({token:r,posthogApiKey:e}):await yda()!=null?new Vva({posthogApiKey:e}):new Wyi({token:void 0,posthogApiKey:e})}catch{return new Vyi}}function Hyi(e,t){return function(){return e.apply(t,arguments)}}var{toString:Fj1}=Object.prototype,{getPrototypeOf:t_u}=Object,Jva=(e=>t=>{let r=Fj1.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),L6t=e=>(e=e.toLowerCase(),t=>Jva(t)===e),Gva=e=>t=>typeof t===e,{isArray:eBn}=Array,Qyi=Gva("undefined");function Lj1(e){return e!==null&&!Qyi(e)&&e.constructor!==null&&!Qyi(e.constructor)&&Uje(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var kvf=L6t("ArrayBuffer");function Uj1(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&kvf(e.buffer),t}var Vj1=Gva("string"),Uje=Gva("function"),ebf=Gva("number"),$va=e=>e!==null&&typeof e=="object",Wj1=e=>e===!0||e===!1,Qva=e=>{if(Jva(e)!=="object")return!1;let t=t_u(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Hj1=L6t("Date"),Qj1=L6t("File"),Jj1=L6t("Blob"),Gj1=L6t("FileList"),$j1=e=>$va(e)&&Uje(e.pipe),Kj1=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Uje(e.append)&&((t=Jva(e))==="formdata"||t==="object"&&Uje(e.toString)&&e.toString()==="[object FormData]"))},Yj1=L6t("URLSearchParams"),[Xj1,Zj1,kj1,eD1]=["ReadableStream","Request","Response","Headers"].map(L6t),tD1=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Jyi(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),eBn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function tbf(e,t){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 Ltn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rbf=e=>!Qyi(e)&&e!==Ltn;function e_u(){let{caseless:e}=rbf(this)&&this||{},t={},r=(n,i)=>{let a=e&&tbf(t,i)||i;Qva(t[a])&&Qva(n)?t[a]=e_u(t[a],n):Qva(n)?t[a]=e_u({},n):eBn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Jyi(arguments[n],r);return t}var rD1=(e,t,r,{allOwnKeys:n}={})=>(Jyi(t,(i,a)=>{r&&Uje(i)?e[a]=Hyi(i,r):e[a]=i},{allOwnKeys:n}),e),nD1=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),iD1=(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)},aD1=(e,t,r,n)=>{let i,a,u,f={};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))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&t_u(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},oD1=(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},uD1=e=>{if(!e)return null;if(eBn(e))return e;let t=e.length;if(!ebf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},sD1=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&t_u(Uint8Array)),cD1=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},lD1=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},fD1=L6t("HTMLFormElement"),dD1=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),Xvf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),pD1=L6t("RegExp"),nbf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};Jyi(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},_D1=e=>{nbf(e,(t,r)=>{if(Uje(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Uje(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+"'")})}})},hD1=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return eBn(e)?n(e):n(String(e).split(t)),r},yD1=()=>{},vD1=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,kpu="abcdefghijklmnopqrstuvwxyz",Zvf="0123456789",ibf={DIGIT:Zvf,ALPHA:kpu,ALPHA_DIGIT:kpu+kpu.toUpperCase()+Zvf},bD1=(e=16,t=ibf.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function gD1(e){return!!(e&&Uje(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var mD1=e=>{let t=new Array(10),r=(n,i)=>{if($va(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=eBn(n)?[]:{};return Jyi(n,(u,f)=>{let d=r(u,i+1);!Qyi(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},OD1=L6t("AsyncFunction"),PD1=e=>e&&($va(e)||Uje(e))&&Uje(e.then)&&Uje(e.catch),abf=((e,t)=>e?setImmediate:t?((r,n)=>(Ltn.addEventListener("message",({source:i,data:a})=>{i===Ltn&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Ltn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Uje(Ltn.postMessage)),wD1=typeof queueMicrotask<"u"?queueMicrotask.bind(Ltn):typeof process<"u"&&process.nextTick||abf,Jl={isArray:eBn,isArrayBuffer:kvf,isBuffer:Lj1,isFormData:Kj1,isArrayBufferView:Uj1,isString:Vj1,isNumber:ebf,isBoolean:Wj1,isObject:$va,isPlainObject:Qva,isReadableStream:Xj1,isRequest:Zj1,isResponse:kj1,isHeaders:eD1,isUndefined:Qyi,isDate:Hj1,isFile:Qj1,isBlob:Jj1,isRegExp:pD1,isFunction:Uje,isStream:$j1,isURLSearchParams:Yj1,isTypedArray:sD1,isFileList:Gj1,forEach:Jyi,merge:e_u,extend:rD1,trim:tD1,stripBOM:nD1,inherits:iD1,toFlatObject:aD1,kindOf:Jva,kindOfTest:L6t,endsWith:oD1,toArray:uD1,forEachEntry:cD1,matchAll:lD1,isHTMLForm:fD1,hasOwnProperty:Xvf,hasOwnProp:Xvf,reduceDescriptors:nbf,freezeMethods:_D1,toObjectSet:hD1,toCamelCase:dD1,noop:yD1,toFiniteNumber:vD1,findKey:tbf,global:Ltn,isContextDefined:rbf,ALPHABET:ibf,generateString:bD1,isSpecCompliantForm:gD1,toJSONObject:mD1,isAsyncFn:OD1,isThenable:PD1,setImmediate:abf,asap:wD1};function tBn(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)}Jl.inherits(tBn,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:Jl.toJSONObject(this.config),code:this.code,status:this.status}}});var obf=tBn.prototype,ubf={};["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=>{ubf[e]={value:e}});Object.defineProperties(tBn,ubf);Object.defineProperty(obf,"isAxiosError",{value:!0});tBn.from=(e,t,r,n,i,a)=>{let u=Object.create(obf);return Jl.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),tBn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var By=tBn;var sbf=tu(sen(),1),Kva=sbf.default;function r_u(e){return Jl.isPlainObject(e)||Jl.isArray(e)}function lbf(e){return Jl.endsWith(e,"[]")?e.slice(0,-2):e}function cbf(e,t,r){return e?e.concat(t).map(function(i,a){return i=lbf(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function jD1(e){return Jl.isArray(e)&&!e.some(r_u)}var DD1=Jl.toFlatObject(Jl,{},null,function(t){return/^is[A-Z]/.test(t)});function SD1(e,t,r){if(!Jl.isObject(e))throw new TypeError("target must be an object");t=t||new(Kva||FormData),r=Jl.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,M){return!Jl.isUndefined(M[j])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Jl.isSpecCompliantForm(t);if(!Jl.isFunction(i))throw new TypeError("visitor must be a function");function c(w){if(w===null)return"";if(Jl.isDate(w))return w.toISOString();if(!d&&Jl.isBlob(w))throw new By("Blob is not supported. Use a Buffer instead.");return Jl.isArrayBuffer(w)||Jl.isTypedArray(w)?d&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function o(w,j,M){let q=w;if(w&&!M&&typeof w=="object"){if(Jl.endsWith(j,"{}"))j=n?j:j.slice(0,-2),w=JSON.stringify(w);else if(Jl.isArray(w)&&jD1(w)||(Jl.isFileList(w)||Jl.endsWith(j,"[]"))&&(q=Jl.toArray(w)))return j=lbf(j),q.forEach(function(I,C){!(Jl.isUndefined(I)||I===null)&&t.append(u===!0?cbf([j],C,a):u===null?j:j+"[]",c(I))}),!1}return r_u(w)?!0:(t.append(cbf(M,j,a),c(w)),!1)}let l=[],g=Object.assign(DD1,{defaultVisitor:o,convertValue:c,isVisitable:r_u});function O(w,j){if(!Jl.isUndefined(w)){if(l.indexOf(w)!==-1)throw Error("Circular reference detected in "+j.join("."));l.push(w),Jl.forEach(w,function(q,B){(!(Jl.isUndefined(q)||q===null)&&i.call(t,q,Jl.isString(B)?B.trim():B,j,g))===!0&&O(q,j?j.concat(B):[B])}),l.pop()}}if(!Jl.isObject(e))throw new TypeError("data must be an object");return O(e),t}var h8r=SD1;function fbf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function dbf(e,t){this._pairs=[],e&&h8r(e,this,t)}var pbf=dbf.prototype;pbf.append=function(t,r){this._pairs.push([t,r])};pbf.toString=function(t){let r=t?function(n){return t.call(this,n,fbf)}:fbf;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var _bf=dbf;function ED1(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Utn(e,t,r){if(!t)return e;let n=r&&r.encode||ED1,i=r&&r.serialize,a;if(i?a=i(t,r):a=Jl.isURLSearchParams(t)?t.toString():new _bf(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var n_u=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){Jl.forEach(this.handlers,function(n){n!==null&&t(n)})}},i_u=n_u;var rBn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var hbf=tu(require("url"),1),ybf=hbf.default.URLSearchParams;var vbf={isNode:!0,classes:{URLSearchParams:ybf,FormData:Kva,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var u_u={};_l(u_u,{hasBrowserEnv:()=>o_u,hasStandardBrowserEnv:()=>AD1,hasStandardBrowserWebWorkerEnv:()=>MD1,navigator:()=>a_u,origin:()=>xD1});var o_u=typeof window<"u"&&typeof document<"u",a_u=typeof navigator=="object"&&navigator||void 0,AD1=o_u&&(!a_u||["ReactNative","NativeScript","NS"].indexOf(a_u.product)<0),MD1=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",xD1=o_u&&window.location.href||"http://localhost";var p6={...u_u,...vbf};function s_u(e,t){return h8r(e,new p6.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return p6.isNode&&Jl.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function TD1(e){return Jl.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function CD1(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 qD1(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Jl.isArray(i)?i.length:u,d?(Jl.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Jl.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Jl.isArray(i[u])&&(i[u]=CD1(i[u])),!f)}if(Jl.isFormData(e)&&Jl.isFunction(e.entries)){let r={};return Jl.forEachEntry(e,(n,i)=>{t(TD1(n),i,r,0)}),r}return null}var Yva=qD1;function ID1(e,t,r){if(Jl.isString(e))try{return(t||JSON.parse)(e),Jl.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var c_u={transitional:rBn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Jl.isObject(t);if(a&&Jl.isHTMLForm(t)&&(t=new FormData(t)),Jl.isFormData(t))return i?JSON.stringify(Yva(t)):t;if(Jl.isArrayBuffer(t)||Jl.isBuffer(t)||Jl.isStream(t)||Jl.isFile(t)||Jl.isBlob(t)||Jl.isReadableStream(t))return t;if(Jl.isArrayBufferView(t))return t.buffer;if(Jl.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return s_u(t,this.formSerializer).toString();if((f=Jl.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return h8r(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),ID1(t)):t}],transformResponse:[function(t){let r=this.transitional||c_u.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Jl.isResponse(t)||Jl.isReadableStream(t))return t;if(t&&Jl.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?By.from(f,By.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:p6.classes.FormData,Blob:p6.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Jl.forEach(["delete","get","head","post","put","patch"],e=>{c_u.headers[e]={}});var nBn=c_u;var BD1=Jl.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"]),bbf=e=>{let t={},r,n,i;return e&&e.split(`
1815
+ `}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&&pva(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var jvf=tu(vvf(),1),Dvf=tu($fu(),1),Svf=tu(Pvf(),1),HC=tu(Lje(),1),Evf=tu(Shi(),1);var zva=tu(Lje(),1),wvf=tu(Shi(),1),Rva=function(e,t,r){return typeof e[t]!="function"?(0,zva.of)(e):(0,zva.from)((0,wvf.default)(e[t])(r).then(n=>(e[t]=n,e)))};var Ryi={isPlainObject:jvf.default,set:Svf.default,get:Dvf.default},Y4n=class extends Ftn{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=Ryi.isPlainObject(r)?{...r}:{},Ryi.isPlainObject(t)&&(t=Object.values(t).every(i=>Ryi.isPlainObject(i)&&i.name===void 0)?Object.entries(t).map(([i,a])=>({name:i,...a})):[t]);let n=Array.isArray(t)?(0,HC.from)(t):t;return this.process=n.pipe((0,HC.concatMap)(this.processQuestion.bind(this)),(0,HC.publish)()),this.process.connect(),this.process.pipe((0,HC.reduce)((i,a)=>(Ryi.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,HC.defer)(()=>(0,HC.of)(t).pipe((0,HC.concatMap)(this.setDefaultType.bind(this)),(0,HC.concatMap)(this.filterIfRunnable.bind(this)),(0,HC.concatMap)(()=>Rva(t,"message",this.answers)),(0,HC.concatMap)(()=>Rva(t,"default",this.answers)),(0,HC.concatMap)(()=>Rva(t,"choices",this.answers)),(0,HC.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,HC.defer)(()=>(0,HC.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,HC.defer)(()=>(0,HC.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&Ryi.get(this.answers,t.name)!==void 0)return(0,HC.empty)();if(t.when===!1)return(0,HC.empty)();if(typeof t.when!="function")return(0,HC.of)(t);let{answers:r}=this;return(0,HC.defer)(()=>(0,HC.from)((0,Evf.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,HC.filter)(n=>n!=null)))}};function Avf(e){let t=function(r,n){let i;try{i=new Y4n(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",myi),this.registerPrompt("input",Ctn),this.registerPrompt("number",Oyi),this.registerPrompt("confirm",Pyi),this.registerPrompt("rawlist",wyi),this.registerPrompt("expand",jyi),this.registerPrompt("checkbox",Dyi),this.registerPrompt("password",Syi),this.registerPrompt("editor",Nyi)},t.restoreDefaultPrompts(),t}var Qpu=Avf();function bj1(e,t){Qpu.registerPrompt(e,t)}function gj1(){Qpu.restoreDefaultPrompts()}var mj1={prompt:Qpu,ui:{BottomBar:zyi,Prompt:Y4n},createPromptModule:Avf,registerPrompt:bj1,restoreDefaultPrompts:gj1,Separator:qie},Fva=mj1;var zvf=tu(Mvf()),Rvf=tu(aou()),Gpu=function(e,t){return Gpu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},Gpu(e,t)};function X4n(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Gpu(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Qg=function(){return Qg=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Qg.apply(this,arguments)};function Oj1(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function hC(e,t,r,n){function i(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function f(o){try{c(n.next(o))}catch(l){u(l)}}function d(o){try{c(n.throw(o))}catch(l){u(l)}}function c(o){o.done?a(o.value):i(o.value).then(f,d)}c((n=n.apply(e,t||[])).next())})}function yC(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,u;return u={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function f(c){return function(o){return d([c,o])}}function d(c){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(c[0]===6&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r)}catch(o){c=[6,o],i=0}finally{n=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Fvf(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,a;n<i;n++)(a||!(n in t))&&(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}var $pu="3.1.2",fw;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties"})(fw||(fw={}));function Pj1(e,t){if(!e)throw new Error(t)}function wj1(e){return e?.replace(/\/+$/,"")}function jj1(e,t){return t===void 0&&(t={}),hC(this,void 0,void 0,function(){var r,n,i,a,u,f,d,c,o,l;return yC(this,function(g){switch(g.label){case 0:r=t.retryCount,n=r===void 0?3:r,i=t.retryDelay,a=i===void 0?5e3:i,u=t.retryCheck,f=u===void 0?function(){return!0}:u,d=null,c=0,g.label=1;case 1:return c<n+1?c>0?[4,new Promise(function(O){return setTimeout(O,a)})]:[3,3]:[3,7];case 2:g.sent(),g.label=3;case 3:return g.trys.push([3,5,,6]),[4,e()];case 4:return o=g.sent(),[2,o];case 5:if(l=g.sent(),d=l,!f(l))throw l;return[3,6];case 6:return c++,[3,1];case 7:throw d}})})}function Kpu(e){var t=new Date().getTime(),r=e&&e.performance&&e.performance.now&&e.performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var i=Math.random()*16;return t>0?(i=(t+i)%16|0,t=Math.floor(t/16)):(i=(r+i)%16|0,r=Math.floor(r/16)),(n==="x"?i:i&3|8).toString(16)})}function Dj1(){return new Date().getTime()}function xvf(){return new Date().toISOString()}function Lvf(e,t){var r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var Lyi=String.fromCharCode,Tvf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Lva={};function Sj1(e,t){if(!Lva[e]){Lva[e]={};for(var r=0;r<e.length;r++)Lva[e][e.charAt(r)]=r}return Lva[e][t]}var Uyi={compressToBase64:function(e){if(e==null)return"";var t=Uyi._compress(e,6,function(r){return Tvf.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:Uyi._decompress(e.length,32,function(t){return Sj1(Tvf,e.charAt(t))})},compress:function(e){return Uyi._compress(e,16,function(t){return Lyi(t)})},_compress:function(e,t,r){if(e==null)return"";var n={},i={},a=[],u,f,d="",c="",o="",l=2,g=3,O=2,w=0,j=0,M;for(M=0;M<e.length;M+=1)if(d=e.charAt(M),Object.prototype.hasOwnProperty.call(n,d)||(n[d]=g++,i[d]=!0),c=o+d,Object.prototype.hasOwnProperty.call(n,c))o=c;else{if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)w=w<<1,j==t-1?(j=0,a.push(r(w)),w=0):j++;for(f=o.charCodeAt(0),u=0;u<8;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}else{for(f=1,u=0;u<O;u++)w=w<<1|f,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[c]=g++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(i,o)){if(o.charCodeAt(0)<256){for(u=0;u<O;u++)w=w<<1,j==t-1?(j=0,a.push(r(w)),w=0):j++;for(f=o.charCodeAt(0),u=0;u<8;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}else{for(f=1,u=0;u<O;u++)w=w<<1|f,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=0;for(f=o.charCodeAt(0),u=0;u<16;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[o]}else for(f=n[o],u=0;u<O;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(f=2,u=0;u<O;u++)w=w<<1|f&1,j==t-1?(j=0,a.push(r(w)),w=0):j++,f=f>>1;for(;;)if(w=w<<1,j==t-1){a.push(r(w));break}else j++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Uyi._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){var n=[],i=[],a={val:r(0),position:t,index:1},u=4,f=4,d=3,c="",o,l,g,O,w,j,M;for(o=0;o<3;o+=1)n[o]=o;for(g=0,w=Math.pow(2,2),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;switch(g){case 0:for(g=0,w=Math.pow(2,8),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;M=Lyi(g);break;case 1:for(g=0,w=Math.pow(2,16),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;M=Lyi(g);break;case 2:return""}for(n[3]=M,l=M,i.push(M);;){if(a.index>e)return"";for(g=0,w=Math.pow(2,d),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;switch(M=g){case 0:for(g=0,w=Math.pow(2,8),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;n[f++]=Lyi(g),M=f-1,u--;break;case 1:for(g=0,w=Math.pow(2,16),j=1;j!=w;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),g|=(O>0?1:0)*j,j<<=1;n[f++]=Lyi(g),M=f-1,u--;break;case 2:return i.join("")}if(u==0&&(u=Math.pow(2,d),d++),n[M])c=n[M];else if(M===f)c=l+l.charAt(0);else return null;i.push(c),n[f++]=l+c.charAt(0),u--,l=c,u==0&&(u=Math.pow(2,d),d++)}}},Ej1=function(){function e(){this.events={},this.events={}}return e.prototype.on=function(t,r){var n=this;return this.events[t]||(this.events[t]=[]),this.events[t].push(r),function(){n.events[t]=n.events[t].filter(function(i){return i!==r})}},e.prototype.emit=function(t,r){for(var n=0,i=this.events[t]||[];n<i.length;n++){var a=i[n];a(r)}for(var u=0,f=this.events["*"]||[];u<f.length;u++){var a=f[u];a(t,r)}},e}(),Aj1=function(e){X4n(t,e);function t(r){var n=e.call(this,"HTTP error while fetching PostHog: "+r.status)||this;return n.response=r,n.name="PostHogFetchHttpError",n}return t}(Error),Mj1=function(e){X4n(t,e);function t(r){var n=e.call(this,"Network error while fetching PostHog",r instanceof Error?{cause:r}:{})||this;return n.error=r,n.name="PostHogFetchNetworkError",n}return t}(Error);function Cvf(e){return typeof e=="object"&&(e.name==="PostHogFetchHttpError"||e.name==="PostHogFetchNetworkError")}var Uvf=function(){function e(t,r){var n,i,a,u,f;this.debugMode=!1,this.pendingPromises={},this.disableGeoip=!0,this._events=new Ej1,Pj1(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=wj1(r?.host||"https://app.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.flushInterval=(n=r?.flushInterval)!==null&&n!==void 0?n:1e4,this.captureMode=r?.captureMode||"form",this._optoutOverride=r?.enable===!1,this._retryOptions={retryCount:(i=r?.fetchRetryCount)!==null&&i!==void 0?i:3,retryDelay:(a=r?.fetchRetryDelay)!==null&&a!==void 0?a:3e3,retryCheck:Cvf},this.requestTimeout=(u=r?.requestTimeout)!==null&&u!==void 0?u:1e4,this.disableGeoip=(f=r?.disableGeoip)!==null&&f!==void 0?f:!0}return e.prototype.getCommonEventProperties=function(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}},Object.defineProperty(e.prototype,"optedOut",{get:function(){var t,r;return(r=(t=this.getPersistedProperty(fw.OptedOut))!==null&&t!==void 0?t:this._optoutOverride)!==null&&r!==void 0?r:!1},enumerable:!1,configurable:!0}),e.prototype.optIn=function(){this.setPersistedProperty(fw.OptedOut,!1)},e.prototype.optOut=function(){this.setPersistedProperty(fw.OptedOut,!0)},e.prototype.on=function(t,r){return this._events.on(t,r)},e.prototype.debug=function(t){var r;t===void 0&&(t=!0),(r=this.removeDebugCallback)===null||r===void 0||r.call(this),this.debugMode=t,t&&(this.removeDebugCallback=this.on("*",function(n,i){return console.log("PostHog Debug",n,i)}))},e.prototype.buildPayload=function(t){return{distinct_id:t.distinct_id,event:t.event,properties:Qg(Qg({},t.properties||{}),this.getCommonEventProperties())}},e.prototype.identifyStateless=function(t,r,n){var i=Qg({},this.buildPayload({distinct_id:t,event:"$identify",properties:r}));return this.enqueue("identify",i,n),this},e.prototype.captureStateless=function(t,r,n,i){var a=this.buildPayload({distinct_id:t,event:r,properties:n});return this.enqueue("capture",a,i),this},e.prototype.aliasStateless=function(t,r,n,i){var a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:Qg(Qg({},n||{}),{distinct_id:r,alias:t})});return this.enqueue("alias",a,i),this},e.prototype.groupIdentifyStateless=function(t,r,n,i,a,u){var f=this.buildPayload({distinct_id:a||"$".concat(t,"_").concat(r),event:"$groupidentify",properties:Qg({$group_type:t,$group_key:r,$group_set:n||{}},u||{})});return this.enqueue("capture",f,i),this},e.prototype.getDecide=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var u,f;return yC(this,function(d){return u="".concat(this.host,"/decide/?v=3"),f={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qg({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i},a))},[2,this.fetchWithRetry(u,f).then(function(c){return c.json()}).catch(function(c){console.error("Error fetching feature flags",c)})]})})},e.prototype.getFeatureFlagStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var f,d;return yC(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0&&(d=!1),[2,d]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadStateless=function(t,r,n,i,a,u){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var f,d;return yC(this,function(c){switch(c.label){case 0:return[4,this.getFeatureFlagPayloadsStateless(r,n,i,a,u)];case 1:return f=c.sent(),f?(d=f[t],d===void 0?[2,null]:[2,this._parsePayload(d)]):[2,void 0]}})})},e.prototype.getFeatureFlagPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){var u,f=this;return yC(this,function(d){switch(d.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return u=d.sent().payloads,u?[2,Object.fromEntries(Object.entries(u).map(function(c){var o=c[0],l=c[1];return[o,f._parsePayload(l)]}))]:[2,u]}})})},e.prototype._parsePayload=function(t){try{return JSON.parse(t)}catch{return t}},e.prototype.getFeatureFlagsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){return yC(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a)];case 1:return[2,u.sent().flags]}})})},e.prototype.getFeatureFlagsAndPayloadsStateless=function(t,r,n,i,a){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){var u,f,d,c;return yC(this,function(o){switch(o.label){case 0:return u={},(a??this.disableGeoip)&&(u.geoip_disable=!0),[4,this.getDecide(t,r,n,i,u)];case 1:return f=o.sent(),d=f?.featureFlags,c=f?.featureFlagPayloads,[2,{flags:d,payloads:c}]}})})},e.prototype.enqueue=function(t,r,n){var i=this,a;if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.enable()");return}var u=Qg(Qg({},r),{type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:xvf()}),f=(a=n?.disableGeoip)!==null&&a!==void 0?a:this.disableGeoip;f&&(u.properties||(u.properties={}),u.properties.$geoip_disable=!0),u.distinctId&&(u.distinct_id=u.distinctId,delete u.distinctId);var d=this.getPersistedProperty(fw.Queue)||[];d.push({message:u}),this.setPersistedProperty(fw.Queue,d),this._events.emit(t,u),d.length>=this.flushAt&&this.flush(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Lvf(function(){return i.flush()},this.flushInterval))},e.prototype.flushAsync=function(){var t=this;return new Promise(function(r,n){t.flush(function(i,a){return i?n(i):r(a)})})},e.prototype.flush=function(t){var r=this;this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=null);var n=this.getPersistedProperty(fw.Queue)||[];if(!n.length)return t?.();var i=n.splice(0,this.flushAt);this.setPersistedProperty(fw.Queue,n);var a=i.map(function(O){return O.message}),u={api_key:this.apiKey,batch:a,sent_at:xvf()},f=Kpu(),d=function(O){O&&r._events.emit("error",O),t?.(O,a),delete r.pendingPromises[f],r._events.emit("flush",a)};this.getCustomUserAgent();var c=JSON.stringify(u),o=this.captureMode==="form"?"".concat(this.host,"/e/?ip=1&_=").concat(Dj1(),"&v=").concat(this.getLibraryVersion()):"".concat(this.host,"/batch/"),l=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"data=".concat(encodeURIComponent(Uyi.compressToBase64(c)),"&compression=lz64")}:{method:"POST",headers:{"Content-Type":"application/json"},body:c},g=this.fetchWithRetry(o,l);this.pendingPromises[f]=g,g.then(function(){return d()}).catch(function(O){d(O)})},e.prototype.fetchWithRetry=function(t,r,n){var i,a;return hC(this,void 0,void 0,function(){var u=this;return yC(this,function(f){switch(f.label){case 0:return(i=(a=AbortSignal).timeout)!==null&&i!==void 0||(a.timeout=function(c){var o=new AbortController;return setTimeout(function(){return o.abort()},c),o.signal}),[4,jj1(function(){return hC(u,void 0,void 0,function(){var d,c;return yC(this,function(o){switch(o.label){case 0:d=null,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.fetch(t,Qg({signal:AbortSignal.timeout(this.requestTimeout)},r))];case 2:return d=o.sent(),[3,4];case 3:throw c=o.sent(),new Mj1(c);case 4:if(d.status<200||d.status>=400)throw new Aj1(d);return[2,d]}})})},Qg(Qg({},this._retryOptions),n))];case 1:return[2,f.sent()]}})})},e.prototype.shutdownAsync=function(){return hC(this,void 0,void 0,function(){var t;return yC(this,function(r){switch(r.label){case 0:clearTimeout(this._flushTimer),r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.flushAsync()];case 2:return r.sent(),[4,Promise.all(Object.values(this.pendingPromises).map(function(n){return n.catch(function(){})}))];case 3:return r.sent(),[3,5];case 4:if(t=r.sent(),!Cvf(t))throw t;return console.error("Error while shutting down PostHog",t),[3,5];case 5:return[2]}})})},e.prototype.shutdown=function(){this.shutdownAsync()},e}();(function(e){X4n(t,e);function t(r,n){var i=this,a,u,f,d=(a=n?.disableGeoip)!==null&&a!==void 0?a:!1;return i=e.call(this,r,Qg(Qg({},n),{disableGeoip:d}))||this,i.flagCallReported={},i.sessionProps={},i.sendFeatureFlagEvent=(u=n?.sendFeatureFlagEvent)!==null&&u!==void 0?u:!0,i._sessionExpirationTimeSeconds=(f=n?.sessionExpirationTimeSeconds)!==null&&f!==void 0?f:1800,i}return t.prototype.setupBootstrap=function(r){var n,i,a,u;if(!((n=r?.bootstrap)===null||n===void 0)&&n.distinctId&&(!((i=r?.bootstrap)===null||i===void 0)&&i.isIdentifiedId?this.setPersistedProperty(fw.DistinctId,r.bootstrap.distinctId):this.setPersistedProperty(fw.AnonymousId,r.bootstrap.distinctId)),!((a=r?.bootstrap)===null||a===void 0)&&a.featureFlags){var f=Object.keys(((u=r.bootstrap)===null||u===void 0?void 0:u.featureFlags)||{}).filter(function(d){var c,o;return!!(!((o=(c=r.bootstrap)===null||c===void 0?void 0:c.featureFlags)===null||o===void 0)&&o[d])}).reduce(function(d,c){var o,l;return d[c]=((l=(o=r.bootstrap)===null||o===void 0?void 0:o.featureFlags)===null||l===void 0?void 0:l[c])||!1,d},{});this.setKnownFeatureFlags(f),r?.bootstrap.featureFlagPayloads&&this.setKnownFeatureFlagPayloads(r?.bootstrap.featureFlagPayloads)}},Object.defineProperty(t.prototype,"props",{get:function(){return this._props||(this._props=this.getPersistedProperty(fw.Props)),this._props||{}},set:function(r){this._props=r},enumerable:!1,configurable:!0}),t.prototype.clearProps=function(){this.props=void 0,this.sessionProps={}},t.prototype.on=function(r,n){return this._events.on(r,n)},t.prototype.reset=function(r){var n=Fvf([fw.Queue],r||[],!0);this.clearProps();for(var i=0,a=Object.keys(fw);i<a.length;i++){var u=a[i];n.includes(fw[u])||this.setPersistedProperty(fw[u],null)}},t.prototype.getCommonEventProperties=function(){var r=this.getFeatureFlags(),n={};if(r)for(var i=0,a=Object.entries(r);i<a.length;i++){var u=a[i],f=u[0],d=u[1];n["$feature/".concat(f)]=d}return Qg(Qg({$active_feature_flags:r?Object.keys(r):void 0},n),e.prototype.getCommonEventProperties.call(this))},t.prototype.enrichProperties=function(r){return Qg(Qg(Qg(Qg(Qg({},this.props),this.sessionProps),r||{}),this.getCommonEventProperties()),{$session_id:this.getSessionId()})},t.prototype.getSessionId=function(){var r=this.getPersistedProperty(fw.SessionId),n=this.getPersistedProperty(fw.SessionLastTimestamp)||0;return(!r||Date.now()-n>this._sessionExpirationTimeSeconds*1e3)&&(r=Kpu(globalThis),this.setPersistedProperty(fw.SessionId,r)),this.setPersistedProperty(fw.SessionLastTimestamp,Date.now()),r},t.prototype.resetSessionId=function(){this.setPersistedProperty(fw.SessionId,null)},t.prototype.getAnonymousId=function(){var r=this.getPersistedProperty(fw.AnonymousId);return r||(r=Kpu(globalThis),this.setPersistedProperty(fw.AnonymousId,r)),r},t.prototype.getDistinctId=function(){return this.getPersistedProperty(fw.DistinctId)||this.getAnonymousId()},t.prototype.unregister=function(r){delete this.props[r],this.setPersistedProperty(fw.Props,this.props)},t.prototype.register=function(r){this.props=Qg(Qg({},this.props),r),this.setPersistedProperty(fw.Props,this.props)},t.prototype.registerForSession=function(r){this.sessionProps=Qg(Qg({},this.sessionProps),r)},t.prototype.unregisterForSession=function(r){delete this.sessionProps[r]},t.prototype.identify=function(r,n,i){var a=this.getDistinctId();r=r||a,n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(Qg(Qg({},n),{$anon_distinct_id:this.getAnonymousId(),$set:n}));return r!==a&&(this.setPersistedProperty(fw.AnonymousId,a),this.setPersistedProperty(fw.DistinctId,r),this.reloadFeatureFlags()),e.prototype.identifyStateless.call(this,r,u,i),this},t.prototype.capture=function(r,n,i){var a=this.getDistinctId();n?.$groups&&this.groups(n.$groups);var u=this.enrichProperties(n);return e.prototype.captureStateless.call(this,a,r,u,i),this},t.prototype.alias=function(r){var n=this.getDistinctId(),i=this.enrichProperties({});return e.prototype.aliasStateless.call(this,r,n,i),this},t.prototype.autocapture=function(r,n,i,a){i===void 0&&(i={});var u=this.getDistinctId(),f={distinct_id:u,event:"$autocapture",properties:Qg(Qg({},this.enrichProperties(i)),{$event_type:r,$elements:n})};return this.enqueue("autocapture",f,a),this},t.prototype.groups=function(r){var n=this.props.$groups||{};return this.register({$groups:Qg(Qg({},n),r)}),Object.keys(r).find(function(i){return n[i]!==r[i]})&&this.reloadFeatureFlags(),this},t.prototype.group=function(r,n,i,a){var u;return this.groups((u={},u[r]=n,u)),i&&this.groupIdentify(r,n,i,a),this},t.prototype.groupIdentify=function(r,n,i,a){var u=this.getDistinctId(),f=this.enrichProperties({});return e.prototype.groupIdentifyStateless.call(this,r,n,i,a,u,f),this},t.prototype.personProperties=function(r){var n=this.getPersistedProperty(fw.PersonProperties)||{};return this.setPersistedProperty(fw.PersonProperties,Qg(Qg({},n),r)),this},t.prototype.groupProperties=function(r){var n=this.getPersistedProperty(fw.GroupProperties)||{};return Object.keys(n).length!==0&&Object.keys(n).forEach(function(i){n[i]=Qg(Qg({},n[i]),r[i]),delete r[i]}),this.setPersistedProperty(fw.GroupProperties,Qg(Qg({},n),r)),this},t.prototype.decideAsync=function(r){return r===void 0&&(r=!0),this._decideResponsePromise?this._decideResponsePromise:this._decideAsync(r)},t.prototype._decideAsync=function(r){return r===void 0&&(r=!0),hC(this,void 0,void 0,function(){var n,i,a,u,f,d=this;return yC(this,function(c){return n=this.getDistinctId(),i=this.props.$groups||{},a=this.getPersistedProperty(fw.PersonProperties)||{},u=this.getPersistedProperty(fw.GroupProperties)||{},f={$anon_distinct_id:r?this.getAnonymousId():void 0},this._decideResponsePromise=e.prototype.getDecide.call(this,n,i,a,u,f).then(function(o){if(o?.featureFlags){var l=o.featureFlags,g=o.featureFlagPayloads;if(o.errorsWhileComputingFlags){var O=d.getPersistedProperty(fw.FeatureFlags),w=d.getPersistedProperty(fw.FeatureFlagPayloads);l=Qg(Qg({},O),o.featureFlags),g=Qg(Qg({},w),o.featureFlagPayloads)}d.setKnownFeatureFlags(l),d.setKnownFeatureFlagPayloads(g)}return o}).finally(function(){d._decideResponsePromise=void 0}),[2,this._decideResponsePromise]})})},t.prototype.setKnownFeatureFlags=function(r){this.setPersistedProperty(fw.FeatureFlags,r),this._events.emit("featureflags",r)},t.prototype.setKnownFeatureFlagPayloads=function(r){this.setPersistedProperty(fw.FeatureFlagPayloads,r)},t.prototype.getFeatureFlag=function(r){var n=this.getFeatureFlags();if(n){var i=n[r];return i===void 0&&(i=!1),this.sendFeatureFlagEvent&&!this.flagCallReported[r]&&(this.flagCallReported[r]=!0,this.capture("$feature_flag_called",{$feature_flag:r,$feature_flag_response:i})),i}},t.prototype.getFeatureFlagPayload=function(r){var n=this.getFeatureFlagPayloads();if(n){var i=n[r];return i===void 0?null:this._parsePayload(i)}},t.prototype.getFeatureFlagPayloads=function(){var r=this,n=this.getPersistedProperty(fw.FeatureFlagPayloads);return n&&Object.fromEntries(Object.entries(n).map(function(i){var a=i[0],u=i[1];return[a,r._parsePayload(u)]}))},t.prototype.getFeatureFlags=function(){var r=this.getPersistedProperty(fw.FeatureFlags),n=this.getPersistedProperty(fw.OverrideFeatureFlags);if(!n)return r;r=r||{};for(var i in n)n[i]?r[i]=n[i]:delete r[i];return r},t.prototype.getFeatureFlagsAndPayloads=function(){var r=this.getFeatureFlags(),n=this.getFeatureFlagPayloads();return{flags:r,payloads:n}},t.prototype.isFeatureEnabled=function(r){var n=this.getFeatureFlag(r);if(n!==void 0)return!!n},t.prototype.reloadFeatureFlags=function(r){this.decideAsync().then(function(n){r?.(void 0,n?.featureFlags)}).catch(function(n){r?.(n,void 0),r||console.log("[PostHog] Error reloading feature flags",n)})},t.prototype.reloadFeatureFlagsAsync=function(r){var n;return r===void 0&&(r=!0),hC(this,void 0,void 0,function(){return yC(this,function(i){switch(i.label){case 0:return[4,this.decideAsync(r)];case 1:return[2,(n=i.sent())===null||n===void 0?void 0:n.featureFlags]}})})},t.prototype.onFeatureFlags=function(r){var n=this;return this.on("featureflags",function(){return hC(n,void 0,void 0,function(){var i;return yC(this,function(a){return i=this.getFeatureFlags(),i&&r(i),[2]})})})},t.prototype.onFeatureFlag=function(r,n){var i=this;return this.on("featureflags",function(){return hC(i,void 0,void 0,function(){var a;return yC(this,function(u){return a=this.getFeatureFlag(r),a!==void 0&&n(a),[2]})})})},t.prototype.overrideFeatureFlag=function(r){return r===null?this.setPersistedProperty(fw.OverrideFeatureFlags,null):this.setPersistedProperty(fw.OverrideFeatureFlags,r)},t})(Uvf);var xj1=function(){function e(){this._memoryStorage={}}return e.prototype.getProperty=function(t){return this._memoryStorage[t]},e.prototype.setProperty=function(t,r){this._memoryStorage[t]=r!==null?r:void 0},e}(),Vvf=function(e,t){return hC(void 0,void 0,void 0,function(){var r;return yC(this,function(n){switch(n.label){case 0:return[4,Rvf.default.request({url:e,headers:t.headers,method:t.method.toLowerCase(),data:t.body,signal:t.signal,validateStatus:function(){return!0}})];case 1:return r=n.sent(),[2,{status:r.status,text:function(){return hC(void 0,void 0,void 0,function(){return yC(this,function(i){return[2,r.data]})})},json:function(){return hC(void 0,void 0,void 0,function(){return yC(this,function(i){return[2,r.data]})})}}]}})})},Tj1=1152921504606847e3,qvf=function(e){X4n(t,e);function t(r){var n=e.call(this)||this;return Error.captureStackTrace(n,n.constructor),n.name="ClientError",n.message=r,Object.setPrototypeOf(n,t.prototype),n}return t}(Error),zZ=function(e){X4n(t,e);function t(r){var n=e.call(this,r)||this;return n.name=n.constructor.name,Error.captureStackTrace(n,n.constructor),Object.setPrototypeOf(n,t.prototype),n}return t}(Error),Cj1=function(){function e(t){var r=t.pollingInterval,n=t.personalApiKey,i=t.projectApiKey,a=t.timeout,u=t.host,f=Oj1(t,["pollingInterval","personalApiKey","projectApiKey","timeout","host"]);this.debugMode=!1,this.pollingInterval=r,this.personalApiKey=n,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=a,this.projectApiKey=i,this.host=u,this.poller=void 0,this.fetch=f.fetch||Vvf,this.loadFeatureFlags()}return e.prototype.debug=function(t){t===void 0&&(t=!0),this.debugMode=t},e.prototype.getFeatureFlag=function(t,r,n,i,a){return n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),hC(this,void 0,void 0,function(){var u,f,d,c,o;return yC(this,function(l){switch(l.label){case 0:return[4,this.loadFeatureFlags()];case 1:if(l.sent(),u=void 0,f=void 0,!this.loadedSuccessfullyOnce)return[2,u];for(d=0,c=this.featureFlags;d<c.length;d++)if(o=c[d],t===o.key){f=o;break}if(f!==void 0)try{u=this.computeFlagLocally(f,r,n,i,a),this.debugMode&&console.debug("Successfully computed flag locally: ".concat(t," -> ").concat(u))}catch(g){g instanceof zZ?this.debugMode&&console.debug("InconclusiveMatchError when computing flag locally: ".concat(t,": ").concat(g)):g instanceof Error&&console.error("Error computing flag locally: ".concat(t,": ").concat(g))}return[2,u]}})})},e.prototype.computeFeatureFlagPayloadLocally=function(t,r){var n,i,a,u,f,d,c,o;return hC(this,void 0,void 0,function(){var l;return yC(this,function(g){switch(g.label){case 0:return[4,this.loadFeatureFlags()];case 1:return g.sent(),l=void 0,this.loadedSuccessfullyOnce?(typeof r=="boolean"?l=(u=(a=(i=(n=this.featureFlagsByKey)===null||n===void 0?void 0:n[t])===null||i===void 0?void 0:i.filters)===null||a===void 0?void 0:a.payloads)===null||u===void 0?void 0:u[r.toString()]:typeof r=="string"&&(l=(o=(c=(d=(f=this.featureFlagsByKey)===null||f===void 0?void 0:f[t])===null||d===void 0?void 0:d.filters)===null||c===void 0?void 0:c.payloads)===null||o===void 0?void 0:o[r]),l===void 0?[2,null]:[2,l]):[2,void 0]}})})},e.prototype.getAllFlagsAndPayloads=function(t,r,n,i){return r===void 0&&(r={}),n===void 0&&(n={}),i===void 0&&(i={}),hC(this,void 0,void 0,function(){var a,u,f,d=this;return yC(this,function(c){switch(c.label){case 0:return[4,this.loadFeatureFlags()];case 1:return c.sent(),a={},u={},f=this.featureFlags.length==0,this.featureFlags.map(function(o){return hC(d,void 0,void 0,function(){var l,g,O;return yC(this,function(w){switch(w.label){case 0:return w.trys.push([0,2,,3]),l=this.computeFlagLocally(o,t,r,n,i),a[o.key]=l,[4,this.computeFeatureFlagPayloadLocally(o.key,l)];case 1:return g=w.sent(),g&&(u[o.key]=g),[3,3];case 2:return O=w.sent(),O instanceof zZ||O instanceof Error&&console.error("Error computing flag locally: ".concat(o.key,": ").concat(O)),f=!0,[3,3];case 3:return[2]}})})}),[2,{response:a,payloads:u,fallbackToDecide:f}]}})})},e.prototype.computeFlagLocally=function(t,r,n,i,a){if(n===void 0&&(n={}),i===void 0&&(i={}),a===void 0&&(a={}),t.ensure_experience_continuity)throw new zZ("Flag has experience continuity enabled");if(!t.active)return!1;var u=t.filters||{},f=u.aggregation_group_type_index;if(f!=null){var d=this.groupTypeMapping[String(f)];if(!d)throw console.warn("[FEATURE FLAGS] Unknown group type index ".concat(f," for feature flag ").concat(t.key)),new zZ("Flag has unknown group type index");if(!(d in n))return console.warn("[FEATURE FLAGS] Can't compute group feature flag: ".concat(t.key," without group names passed in")),!1;var c=a[d];return this.matchFeatureFlagProperties(t,n[d],c)}else return this.matchFeatureFlagProperties(t,r,i)},e.prototype.matchFeatureFlagProperties=function(t,r,n){for(var i,a=t.filters||{},u=a.groups||[],f=!1,d=void 0,c=Fvf([],u,!0).sort(function(M,q){var B=!!M.variant,I=!!q.variant;return B&&I?0:B?-1:I?1:0}),o=function(M){try{if(l.isConditionMatch(t,r,M,n)){var q=M.variant,B=((i=a.multivariate)===null||i===void 0?void 0:i.variants)||[];return q&&B.some(function(I){return I.key===q})?d=q:d=l.getMatchingVariant(t,r)||!0,"break"}}catch(I){if(I instanceof zZ)f=!0;else throw I}},l=this,g=0,O=c;g<O.length;g++){var w=O[g],j=o(w);if(j==="break")break}if(d!==void 0)return d;if(f)throw new zZ("Can't determine if feature flag is enabled or not with given properties");return!1},e.prototype.isConditionMatch=function(t,r,n,i){var a=n.rollout_percentage;if((n.properties||[]).length>0){for(var u=0,f=n.properties;u<f.length;u++){var d=f[u],c=d.type,o=!1;if(c==="cohort"?o=Hvf(d,i,this.cohorts):o=Wvf(d,i),!o)return!1}if(a==null)return!0}return!(a!=null&&Ivf(t.key,r)>a/100)},e.prototype.getMatchingVariant=function(t,r){var n=Ivf(t.key,r,"variant"),i=this.variantLookupTable(t).find(function(a){return n>=a.valueMin&&n<a.valueMax});if(i)return i.key},e.prototype.variantLookupTable=function(t){var r,n=[],i=0,a=0,u=t.filters||{},f=((r=u.multivariate)===null||r===void 0?void 0:r.variants)||[];return f.forEach(function(d){a=i+d.rollout_percentage/100,n.push({valueMin:i,valueMax:a,key:d.key}),i=a}),n},e.prototype.loadFeatureFlags=function(t){return t===void 0&&(t=!1),hC(this,void 0,void 0,function(){return yC(this,function(r){switch(r.label){case 0:return!this.loadedSuccessfullyOnce||t?[4,this._loadFeatureFlags()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[2]}})})},e.prototype._loadFeatureFlags=function(){return hC(this,void 0,void 0,function(){var t,r,n,i=this;return yC(this,function(a){switch(a.label){case 0:this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(function(){return i._loadFeatureFlags()},this.pollingInterval),a.label=1;case 1:return a.trys.push([1,4,,5]),[4,this._requestFeatureFlagDefinitions()];case 2:if(t=a.sent(),t&&t.status===401)throw new qvf("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");return t&&t.status!==200?[2]:[4,t.json()];case 3:return r=a.sent(),"flags"in r||console.error("Invalid response when getting feature flags: ".concat(JSON.stringify(r))),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce(function(u,f){return u[f.key]=f,u},{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0,[3,5];case 4:if(n=a.sent(),n instanceof qvf)throw n;return[3,5];case 5:return[2]}})})},e.prototype._requestFeatureFlagDefinitions=function(){return hC(this,void 0,void 0,function(){var t,r,n,i,a;return yC(this,function(u){switch(u.label){case 0:t="".concat(this.host,"/api/feature_flag/local_evaluation?token=").concat(this.projectApiKey,"&send_cohorts"),r={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(this.personalApiKey),"user-agent":"posthog-node/".concat($pu)}},n=null,this.timeout&&typeof this.timeout=="number"&&(i=new AbortController,n=Lvf(function(){i.abort()},this.timeout),r.signal=i.signal),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,this.fetch(t,r)];case 2:return[2,u.sent()];case 3:throw a=u.sent(),a;case 4:return clearTimeout(n),[7];case 5:return[2]}})})},e.prototype.stopPoller=function(){clearTimeout(this.poller)},e}();function Ivf(e,t,r){r===void 0&&(r="");var n=(0,zvf.createHash)();return n.update("".concat(e,".").concat(t).concat(r)),parseInt(n.digest("hex").slice(0,15),16)/Tj1}function Wvf(e,t){var r=e.key,n=e.value,i=e.operator||"exact";if(r in t){if(i==="is_not_set")throw new zZ("Operator is_not_set is not supported")}else throw new zZ("Property ".concat(r," not found in propertyValues"));var a=t[r];switch(i){case"exact":return Array.isArray(n)?n.indexOf(a)!==-1:n===a;case"is_not":return Array.isArray(n)?n.indexOf(a)===-1:n!==a;case"is_set":return r in t;case"icontains":return String(a).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(a).toLowerCase().includes(String(n).toLowerCase());case"regex":return Bvf(String(n))&&String(a).match(String(n))!==null;case"not_regex":return Bvf(String(n))&&String(a).match(String(n))===null;case"gt":return typeof a==typeof n&&a>n;case"gte":return typeof a==typeof n&&a>=n;case"lt":return typeof a==typeof n&&a<n;case"lte":return typeof a==typeof n&&a<=n;case"is_date_after":case"is_date_before":var u=Nvf(n),f=Nvf(a);return i==="is_date_before"?f<u:f>u;default:return console.error("Unknown operator: ".concat(i)),!1}}function Hvf(e,t,r){var n=String(e.value);if(!(n in r))throw new zZ("can't match cohort without a given cohort property value");var i=r[n];return Qvf(i,t,r)}function Qvf(e,t,r){if(!e)return!0;var n=e.type,i=e.values;if(!i||i.length===0)return!0;var a=!1;if("values"in i[0]){for(var u=0,f=i;u<f.length;u++){var d=f[u];try{var c=Qvf(d,t,r);if(n==="AND"){if(!c)return!1}else if(c)return!0}catch(O){if(O instanceof zZ)console.debug("Failed to compute property ".concat(d," locally: ").concat(O)),a=!0;else throw O}}if(a)throw new zZ("Can't match cohort without a given cohort property value");return n==="AND"}else{for(var o=0,l=i;o<l.length;o++){var d=l[o];try{var c=void 0;d.type==="cohort"?c=Hvf(d,t,r):c=Wvf(d,t);var g=d.negation||!1;if(n==="AND"){if(!c&&!g||c&&g)return!1}else if(c&&!g||!c&&g)return!0}catch(w){if(w instanceof zZ)console.debug("Failed to compute property ".concat(d," locally: ").concat(w)),a=!0;else throw w}}if(a)throw new zZ("can't match cohort without a given cohort property value");return n==="AND"}}function Bvf(e){try{return new RegExp(e),!0}catch{return!1}}function Nvf(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){var t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new zZ("".concat(e," is in an invalid date format"))}else throw new zZ("The date provided ".concat(e," must be a string, number, or date object"))}var qj1=30*1e3,Ij1=50*1e3,Uva=function(e){X4n(t,e);function t(r,n){n===void 0&&(n={});var i=this,a;return n.captureMode=n?.captureMode||"json",i=e.call(this,r,n)||this,i._memoryStorage=new xj1,i.options=n,n.personalApiKey&&(i.featureFlagsPoller=new Cj1({pollingInterval:typeof n.featureFlagsPollingInterval=="number"?n.featureFlagsPollingInterval:qj1,personalApiKey:n.personalApiKey,projectApiKey:r,timeout:(a=n.requestTimeout)!==null&&a!==void 0?a:1e4,host:i.host,fetch:n.fetch})),i.distinctIdHasSentFlagCalls={},i.maxCacheSize=n.maxCacheSize||Ij1,i}return t.prototype.getPersistedProperty=function(r){return this._memoryStorage.getProperty(r)},t.prototype.setPersistedProperty=function(r,n){return this._memoryStorage.setProperty(r,n)},t.prototype.fetch=function(r,n){return this.options.fetch?this.options.fetch(r,n):Vvf(r,n)},t.prototype.getLibraryId=function(){return"posthog-node"},t.prototype.getLibraryVersion=function(){return $pu},t.prototype.getCustomUserAgent=function(){return"posthog-node/".concat($pu)},t.prototype.enable=function(){return e.prototype.optIn.call(this)},t.prototype.disable=function(){return e.prototype.optOut.call(this)},t.prototype.debug=function(r){var n;r===void 0&&(r=!0),e.prototype.debug.call(this,r),(n=this.featureFlagsPoller)===null||n===void 0||n.debug(r)},t.prototype.capture=function(r){var n=this,i=r.distinctId,a=r.event,u=r.properties,f=r.groups,d=r.sendFeatureFlags,c=r.timestamp,o=r.disableGeoip,l=function(g){e.prototype.captureStateless.call(n,i,a,g,{timestamp:c,disableGeoip:o})};d?e.prototype.getFeatureFlagsStateless.call(this,i,f,void 0,void 0,o).then(function(g){var O={};if(g)for(var w=0,j=Object.entries(g);w<j.length;w++){var M=j[w],q=M[0],B=M[1];B!==!1&&(O["$feature/".concat(q)]=B)}var I=Object.keys(g||{}).filter(function(L){return g?.[L]!==!1}),C=Qg({$active_feature_flags:I||void 0},O);l(Qg(Qg(Qg({},u),{$groups:f}),C))}):l(Qg(Qg({},u),{$groups:f}))},t.prototype.identify=function(r){var n=r.distinctId,i=r.properties,a=r.disableGeoip,u=i?.$set||i;e.prototype.identifyStateless.call(this,n,{$set:u},{disableGeoip:a})},t.prototype.alias=function(r){e.prototype.aliasStateless.call(this,r.alias,r.distinctId,void 0,{disableGeoip:r.disableGeoip})},t.prototype.getFeatureFlag=function(r,n,i){var a;return hC(this,void 0,void 0,function(){var u,f,d,c,o,l,g,O,w,j,M,q;return yC(this,function(B){switch(B.label){case 0:return u=i||{},f=u.groups,d=u.personProperties,c=u.groupProperties,o=u.disableGeoip,l=i||{},g=l.onlyEvaluateLocally,O=l.sendFeatureFlagEvents,g==null&&(g=!1),O==null&&(O=!0),[4,(a=this.featureFlagsPoller)===null||a===void 0?void 0:a.getFeatureFlag(r,n,f,d,c)];case 1:return w=B.sent(),j=w!==void 0,!j&&!g?[4,e.prototype.getFeatureFlagStateless.call(this,r,n,f,d,c,o)]:[3,3];case 2:w=B.sent(),B.label=3;case 3:return M="".concat(r,"_").concat(w),O&&(!(n in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[n].includes(M))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[n])?this.distinctIdHasSentFlagCalls[n].push(M):this.distinctIdHasSentFlagCalls[n]=[M],this.capture({distinctId:n,event:"$feature_flag_called",properties:(q={$feature_flag:r,$feature_flag_response:w,locally_evaluated:j},q["$feature/".concat(r)]=w,q),groups:f,disableGeoip:o})),[2,w]}})})},t.prototype.getFeatureFlagPayload=function(r,n,i,a){var u;return hC(this,void 0,void 0,function(){var f,d,c,o,l,g,O,w,j;return yC(this,function(M){switch(M.label){case 0:return f=a||{},d=f.groups,c=f.personProperties,o=f.groupProperties,l=f.disableGeoip,g=a||{},O=g.onlyEvaluateLocally,g.sendFeatureFlagEvents,w=void 0,i?[3,2]:[4,this.getFeatureFlag(r,n,Qg(Qg({},a),{onlyEvaluateLocally:!0}))];case 1:i=M.sent(),M.label=2;case 2:return i?[4,(u=this.featureFlagsPoller)===null||u===void 0?void 0:u.computeFeatureFlagPayloadLocally(r,i)]:[3,4];case 3:w=M.sent(),M.label=4;case 4:return O==null&&(O=!1),O==null&&(O=!1),j=w!==void 0,!j&&!O?[4,e.prototype.getFeatureFlagPayloadStateless.call(this,r,n,d,c,o,l)]:[3,6];case 5:w=M.sent(),M.label=6;case 6:try{return[2,JSON.parse(w)]}catch{return[2,w]}return[2]}})})},t.prototype.isFeatureEnabled=function(r,n,i){return hC(this,void 0,void 0,function(){var a;return yC(this,function(u){switch(u.label){case 0:return[4,this.getFeatureFlag(r,n,i)];case 1:return a=u.sent(),a===void 0?[2,void 0]:[2,!!a||!1]}})})},t.prototype.getAllFlags=function(r,n){return hC(this,void 0,void 0,function(){var i;return yC(this,function(a){switch(a.label){case 0:return[4,this.getAllFlagsAndPayloads(r,n)];case 1:return i=a.sent(),[2,i.featureFlags]}})})},t.prototype.getAllFlagsAndPayloads=function(r,n){var i;return hC(this,void 0,void 0,function(){var a,u,f,d,c,o,l,g,O,w,j;return yC(this,function(M){switch(M.label){case 0:return a=n||{},u=a.groups,f=a.personProperties,d=a.groupProperties,c=a.disableGeoip,o=(n||{}).onlyEvaluateLocally,o==null&&(o=!1),[4,(i=this.featureFlagsPoller)===null||i===void 0?void 0:i.getAllFlagsAndPayloads(r,u,f,d)];case 1:return l=M.sent(),g={},O={},w=!0,l&&(g=l.response,O=l.payloads,w=l.fallbackToDecide),w&&!o?[4,e.prototype.getFeatureFlagsAndPayloadsStateless.call(this,r,u,f,d,c)]:[3,3];case 2:j=M.sent(),g=Qg(Qg({},g),j.flags||{}),O=Qg(Qg({},O),j.payloads||{}),M.label=3;case 3:return[2,{featureFlags:g,featureFlagPayloads:O}]}})})},t.prototype.groupIdentify=function(r){var n=r.groupType,i=r.groupKey,a=r.properties,u=r.distinctId,f=r.disableGeoip;e.prototype.groupIdentifyStateless.call(this,n,i,a,{disableGeoip:f},u)},t.prototype.reloadFeatureFlags=function(){var r;return hC(this,void 0,void 0,function(){return yC(this,function(n){switch(n.label){case 0:return[4,(r=this.featureFlagsPoller)===null||r===void 0?void 0:r.loadFeatureFlags(!0)];case 1:return n.sent(),[2]}})})},t.prototype.shutdown=function(){this.shutdownAsync()},t.prototype.shutdownAsync=function(){var r;return hC(this,void 0,void 0,function(){return yC(this,function(n){return(r=this.featureFlagsPoller)===null||r===void 0||r.stopPoller(),[2,e.prototype.shutdownAsync.call(this)]})})},t}(Uvf);var Vva=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Uva(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.45.0-rc16",usingAccessToken:!0}})}flush(){this.posthog.flush()}};var Vyi=class{async sendEvent(){}async identify(){}async flush(){}};var Z4n=require("fs/promises"),Kvf=require("os"),Yvf=require("path");var Jvf=tu(require("crypto")),Hva=new Uint8Array(256),Wva=Hva.length;function Ypu(){return Wva>Hva.length-16&&(Jvf.default.randomFillSync(Hva),Wva=0),Hva.slice(Wva,Wva+=16)}var SH=[];for(let e=0;e<256;++e)SH.push((e+256).toString(16).slice(1));function Gvf(e,t=0){return SH[e[t+0]]+SH[e[t+1]]+SH[e[t+2]]+SH[e[t+3]]+"-"+SH[e[t+4]]+SH[e[t+5]]+"-"+SH[e[t+6]]+SH[e[t+7]]+"-"+SH[e[t+8]]+SH[e[t+9]]+"-"+SH[e[t+10]]+SH[e[t+11]]+SH[e[t+12]]+SH[e[t+13]]+SH[e[t+14]]+SH[e[t+15]]}var $vf=tu(require("crypto")),Xpu={randomUUID:$vf.default.randomUUID};function Bj1(e,t,r){if(Xpu.randomUUID&&!t&&!e)return Xpu.randomUUID();e=e||{};let n=e.random||(e.rng||Ypu)();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 Gvf(n)}var _8r=Bj1;var Nj1="id",zj1=".fern",Wyi=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new Uva(r),this.userId=t==null?void 0:auu(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.45.0-rc16",...t,...t.properties}})}flush(){this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=yf(j_.of((0,Kvf.homedir)()),Ms.of(zj1),Ms.of(Nj1));await Vh(t)||(await(0,Z4n.mkdir)((0,Yvf.dirname)(t),{recursive:!0}),await(0,Z4n.writeFile)(t,_8r())),this.persistedDistinctId=(await(0,Z4n.readFile)(t)).toString()}return this.persistedDistinctId}};var Zpu;async function k4n(){return Zpu==null&&(Zpu=await Rj1()),Zpu}async function Rj1(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Vyi;let r=await vda();return r!=null?new Wyi({token:r,posthogApiKey:e}):await yda()!=null?new Vva({posthogApiKey:e}):new Wyi({token:void 0,posthogApiKey:e})}catch{return new Vyi}}function Hyi(e,t){return function(){return e.apply(t,arguments)}}var{toString:Fj1}=Object.prototype,{getPrototypeOf:t_u}=Object,Jva=(e=>t=>{let r=Fj1.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),L6t=e=>(e=e.toLowerCase(),t=>Jva(t)===e),Gva=e=>t=>typeof t===e,{isArray:eBn}=Array,Qyi=Gva("undefined");function Lj1(e){return e!==null&&!Qyi(e)&&e.constructor!==null&&!Qyi(e.constructor)&&Uje(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var kvf=L6t("ArrayBuffer");function Uj1(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&kvf(e.buffer),t}var Vj1=Gva("string"),Uje=Gva("function"),ebf=Gva("number"),$va=e=>e!==null&&typeof e=="object",Wj1=e=>e===!0||e===!1,Qva=e=>{if(Jva(e)!=="object")return!1;let t=t_u(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Hj1=L6t("Date"),Qj1=L6t("File"),Jj1=L6t("Blob"),Gj1=L6t("FileList"),$j1=e=>$va(e)&&Uje(e.pipe),Kj1=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Uje(e.append)&&((t=Jva(e))==="formdata"||t==="object"&&Uje(e.toString)&&e.toString()==="[object FormData]"))},Yj1=L6t("URLSearchParams"),[Xj1,Zj1,kj1,eD1]=["ReadableStream","Request","Response","Headers"].map(L6t),tD1=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Jyi(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),eBn(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,f;for(n=0;n<u;n++)f=a[n],t.call(null,e[f],f,e)}}function tbf(e,t){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 Ltn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,rbf=e=>!Qyi(e)&&e!==Ltn;function e_u(){let{caseless:e}=rbf(this)&&this||{},t={},r=(n,i)=>{let a=e&&tbf(t,i)||i;Qva(t[a])&&Qva(n)?t[a]=e_u(t[a],n):Qva(n)?t[a]=e_u({},n):eBn(n)?t[a]=n.slice():t[a]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Jyi(arguments[n],r);return t}var rD1=(e,t,r,{allOwnKeys:n}={})=>(Jyi(t,(i,a)=>{r&&Uje(i)?e[a]=Hyi(i,r):e[a]=i},{allOwnKeys:n}),e),nD1=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),iD1=(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)},aD1=(e,t,r,n)=>{let i,a,u,f={};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))&&!f[u]&&(t[u]=e[u],f[u]=!0);e=r!==!1&&t_u(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},oD1=(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},uD1=e=>{if(!e)return null;if(eBn(e))return e;let t=e.length;if(!ebf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},sD1=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&t_u(Uint8Array)),cD1=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},lD1=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},fD1=L6t("HTMLFormElement"),dD1=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),Xvf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),pD1=L6t("RegExp"),nbf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};Jyi(r,(i,a)=>{let u;(u=t(i,a,e))!==!1&&(n[a]=u||i)}),Object.defineProperties(e,n)},_D1=e=>{nbf(e,(t,r)=>{if(Uje(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(Uje(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+"'")})}})},hD1=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return eBn(e)?n(e):n(String(e).split(t)),r},yD1=()=>{},vD1=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,kpu="abcdefghijklmnopqrstuvwxyz",Zvf="0123456789",ibf={DIGIT:Zvf,ALPHA:kpu,ALPHA_DIGIT:kpu+kpu.toUpperCase()+Zvf},bD1=(e=16,t=ibf.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function gD1(e){return!!(e&&Uje(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var mD1=e=>{let t=new Array(10),r=(n,i)=>{if($va(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[i]=n;let a=eBn(n)?[]:{};return Jyi(n,(u,f)=>{let d=r(u,i+1);!Qyi(d)&&(a[f]=d)}),t[i]=void 0,a}}return n};return r(e,0)},OD1=L6t("AsyncFunction"),PD1=e=>e&&($va(e)||Uje(e))&&Uje(e.then)&&Uje(e.catch),abf=((e,t)=>e?setImmediate:t?((r,n)=>(Ltn.addEventListener("message",({source:i,data:a})=>{i===Ltn&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Ltn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Uje(Ltn.postMessage)),wD1=typeof queueMicrotask<"u"?queueMicrotask.bind(Ltn):typeof process<"u"&&process.nextTick||abf,Jl={isArray:eBn,isArrayBuffer:kvf,isBuffer:Lj1,isFormData:Kj1,isArrayBufferView:Uj1,isString:Vj1,isNumber:ebf,isBoolean:Wj1,isObject:$va,isPlainObject:Qva,isReadableStream:Xj1,isRequest:Zj1,isResponse:kj1,isHeaders:eD1,isUndefined:Qyi,isDate:Hj1,isFile:Qj1,isBlob:Jj1,isRegExp:pD1,isFunction:Uje,isStream:$j1,isURLSearchParams:Yj1,isTypedArray:sD1,isFileList:Gj1,forEach:Jyi,merge:e_u,extend:rD1,trim:tD1,stripBOM:nD1,inherits:iD1,toFlatObject:aD1,kindOf:Jva,kindOfTest:L6t,endsWith:oD1,toArray:uD1,forEachEntry:cD1,matchAll:lD1,isHTMLForm:fD1,hasOwnProperty:Xvf,hasOwnProp:Xvf,reduceDescriptors:nbf,freezeMethods:_D1,toObjectSet:hD1,toCamelCase:dD1,noop:yD1,toFiniteNumber:vD1,findKey:tbf,global:Ltn,isContextDefined:rbf,ALPHABET:ibf,generateString:bD1,isSpecCompliantForm:gD1,toJSONObject:mD1,isAsyncFn:OD1,isThenable:PD1,setImmediate:abf,asap:wD1};function tBn(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)}Jl.inherits(tBn,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:Jl.toJSONObject(this.config),code:this.code,status:this.status}}});var obf=tBn.prototype,ubf={};["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=>{ubf[e]={value:e}});Object.defineProperties(tBn,ubf);Object.defineProperty(obf,"isAxiosError",{value:!0});tBn.from=(e,t,r,n,i,a)=>{let u=Object.create(obf);return Jl.toFlatObject(e,u,function(d){return d!==Error.prototype},f=>f!=="isAxiosError"),tBn.call(u,e.message,t,r,n,i),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var By=tBn;var sbf=tu(sen(),1),Kva=sbf.default;function r_u(e){return Jl.isPlainObject(e)||Jl.isArray(e)}function lbf(e){return Jl.endsWith(e,"[]")?e.slice(0,-2):e}function cbf(e,t,r){return e?e.concat(t).map(function(i,a){return i=lbf(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function jD1(e){return Jl.isArray(e)&&!e.some(r_u)}var DD1=Jl.toFlatObject(Jl,{},null,function(t){return/^is[A-Z]/.test(t)});function SD1(e,t,r){if(!Jl.isObject(e))throw new TypeError("target must be an object");t=t||new(Kva||FormData),r=Jl.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(j,M){return!Jl.isUndefined(M[j])});let n=r.metaTokens,i=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&Jl.isSpecCompliantForm(t);if(!Jl.isFunction(i))throw new TypeError("visitor must be a function");function c(w){if(w===null)return"";if(Jl.isDate(w))return w.toISOString();if(!d&&Jl.isBlob(w))throw new By("Blob is not supported. Use a Buffer instead.");return Jl.isArrayBuffer(w)||Jl.isTypedArray(w)?d&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function o(w,j,M){let q=w;if(w&&!M&&typeof w=="object"){if(Jl.endsWith(j,"{}"))j=n?j:j.slice(0,-2),w=JSON.stringify(w);else if(Jl.isArray(w)&&jD1(w)||(Jl.isFileList(w)||Jl.endsWith(j,"[]"))&&(q=Jl.toArray(w)))return j=lbf(j),q.forEach(function(I,C){!(Jl.isUndefined(I)||I===null)&&t.append(u===!0?cbf([j],C,a):u===null?j:j+"[]",c(I))}),!1}return r_u(w)?!0:(t.append(cbf(M,j,a),c(w)),!1)}let l=[],g=Object.assign(DD1,{defaultVisitor:o,convertValue:c,isVisitable:r_u});function O(w,j){if(!Jl.isUndefined(w)){if(l.indexOf(w)!==-1)throw Error("Circular reference detected in "+j.join("."));l.push(w),Jl.forEach(w,function(q,B){(!(Jl.isUndefined(q)||q===null)&&i.call(t,q,Jl.isString(B)?B.trim():B,j,g))===!0&&O(q,j?j.concat(B):[B])}),l.pop()}}if(!Jl.isObject(e))throw new TypeError("data must be an object");return O(e),t}var h8r=SD1;function fbf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function dbf(e,t){this._pairs=[],e&&h8r(e,this,t)}var pbf=dbf.prototype;pbf.append=function(t,r){this._pairs.push([t,r])};pbf.toString=function(t){let r=t?function(n){return t.call(this,n,fbf)}:fbf;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var _bf=dbf;function ED1(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Utn(e,t,r){if(!t)return e;let n=r&&r.encode||ED1,i=r&&r.serialize,a;if(i?a=i(t,r):a=Jl.isURLSearchParams(t)?t.toString():new _bf(t,r).toString(n),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var n_u=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){Jl.forEach(this.handlers,function(n){n!==null&&t(n)})}},i_u=n_u;var rBn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var hbf=tu(require("url"),1),ybf=hbf.default.URLSearchParams;var vbf={isNode:!0,classes:{URLSearchParams:ybf,FormData:Kva,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var u_u={};_l(u_u,{hasBrowserEnv:()=>o_u,hasStandardBrowserEnv:()=>AD1,hasStandardBrowserWebWorkerEnv:()=>MD1,navigator:()=>a_u,origin:()=>xD1});var o_u=typeof window<"u"&&typeof document<"u",a_u=typeof navigator=="object"&&navigator||void 0,AD1=o_u&&(!a_u||["ReactNative","NativeScript","NS"].indexOf(a_u.product)<0),MD1=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",xD1=o_u&&window.location.href||"http://localhost";var p6={...u_u,...vbf};function s_u(e,t){return h8r(e,new p6.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,a){return p6.isNode&&Jl.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function TD1(e){return Jl.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function CD1(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 qD1(e){function t(r,n,i,a){let u=r[a++];if(u==="__proto__")return!0;let f=Number.isFinite(+u),d=a>=r.length;return u=!u&&Jl.isArray(i)?i.length:u,d?(Jl.hasOwnProp(i,u)?i[u]=[i[u],n]:i[u]=n,!f):((!i[u]||!Jl.isObject(i[u]))&&(i[u]=[]),t(r,n,i[u],a)&&Jl.isArray(i[u])&&(i[u]=CD1(i[u])),!f)}if(Jl.isFormData(e)&&Jl.isFunction(e.entries)){let r={};return Jl.forEachEntry(e,(n,i)=>{t(TD1(n),i,r,0)}),r}return null}var Yva=qD1;function ID1(e,t,r){if(Jl.isString(e))try{return(t||JSON.parse)(e),Jl.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var c_u={transitional:rBn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Jl.isObject(t);if(a&&Jl.isHTMLForm(t)&&(t=new FormData(t)),Jl.isFormData(t))return i?JSON.stringify(Yva(t)):t;if(Jl.isArrayBuffer(t)||Jl.isBuffer(t)||Jl.isStream(t)||Jl.isFile(t)||Jl.isBlob(t)||Jl.isReadableStream(t))return t;if(Jl.isArrayBufferView(t))return t.buffer;if(Jl.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let f;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return s_u(t,this.formSerializer).toString();if((f=Jl.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return h8r(f?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),ID1(t)):t}],transformResponse:[function(t){let r=this.transitional||c_u.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Jl.isResponse(t)||Jl.isReadableStream(t))return t;if(t&&Jl.isString(t)&&(n&&!this.responseType||i)){let u=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(f){if(u)throw f.name==="SyntaxError"?By.from(f,By.ERR_BAD_RESPONSE,this,null,this.response):f}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:p6.classes.FormData,Blob:p6.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Jl.forEach(["delete","get","head","post","put","patch"],e=>{c_u.headers[e]={}});var nBn=c_u;var BD1=Jl.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"]),bbf=e=>{let t={},r,n,i;return e&&e.split(`
1816
1816
  `).forEach(function(u){i=u.indexOf(":"),r=u.substring(0,i).trim().toLowerCase(),n=u.substring(i+1).trim(),!(!r||t[r]&&BD1[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var gbf=Symbol("internals");function Gyi(e){return e&&String(e).trim().toLowerCase()}function Xva(e){return e===!1||e==null?e:Jl.isArray(e)?e.map(Xva):String(e)}function ND1(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 zD1=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function l_u(e,t,r,n,i){if(Jl.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Jl.isString(t)){if(Jl.isString(n))return t.indexOf(n)!==-1;if(Jl.isRegExp(n))return n.test(t)}}function RD1(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function FD1(e,t){let r=Jl.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 iBn=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(f,d,c){let o=Gyi(d);if(!o)throw new Error("header name must be a non-empty string");let l=Jl.findKey(i,o);(!l||i[l]===void 0||c===!0||c===void 0&&i[l]!==!1)&&(i[l||d]=Xva(f))}let u=(f,d)=>Jl.forEach(f,(c,o)=>a(c,o,d));if(Jl.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(Jl.isString(t)&&(t=t.trim())&&!zD1(t))u(bbf(t),r);else if(Jl.isHeaders(t))for(let[f,d]of t.entries())a(d,f,n);else t!=null&&a(r,t,n);return this}get(t,r){if(t=Gyi(t),t){let n=Jl.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return ND1(i);if(Jl.isFunction(r))return r.call(this,i,n);if(Jl.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=Gyi(t),t){let n=Jl.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||l_u(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(u){if(u=Gyi(u),u){let f=Jl.findKey(n,u);f&&(!r||l_u(n,n[f],f,r))&&(delete n[f],i=!0)}}return Jl.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||l_u(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Jl.forEach(this,(i,a)=>{let u=Jl.findKey(n,a);if(u){r[u]=Xva(i),delete r[a];return}let f=t?RD1(a):String(a).trim();f!==a&&delete r[a],r[f]=Xva(i),n[f]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Jl.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Jl.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(`
1817
1817
  `)}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[gbf]=this[gbf]={accessors:{}}).accessors,i=this.prototype;function a(u){let f=Gyi(u);n[f]||(FD1(i,u),n[f]=!0)}return Jl.isArray(t)?t.forEach(a):a(t),this}};iBn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Jl.reduceDescriptors(iBn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Jl.freezeMethods(iBn);var j3=iBn;function $yi(e,t){let r=this||nBn,n=t||r,i=j3.from(n.headers),a=n.data;return Jl.forEach(e,function(f){a=f.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function Kyi(e){return!!(e&&e.__CANCEL__)}function mbf(e,t,r){By.call(this,e??"canceled",By.ERR_CANCELED,t,r),this.name="CanceledError"}Jl.inherits(mbf,By,{__CANCEL__:!0});var Vje=mbf;function zFt(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new By("Request failed with status code "+r.status,[By.ERR_BAD_REQUEST,By.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function f_u(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function d_u(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Vtn(e,t){return e&&!f_u(t)?d_u(e,t):t}var Rbf=tu(Pbf(),1),Fbf=tu(require("http"),1),Lbf=tu(require("https"),1),Ubf=tu(require("util"),1),Vbf=tu(kfa(),1),xEr=tu(require("zlib"),1);var Wtn="1.7.7";function Yyi(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var QD1=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function p_u(e,t,r){let n=r&&r.Blob||p6.classes.Blob,i=Yyi(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=QD1.exec(e);if(!a)throw new By("Invalid URL",By.ERR_INVALID_URL);let u=a[1],f=a[2],d=a[3],c=Buffer.from(decodeURIComponent(d),f?"base64":"utf8");if(t){if(!n)throw new By("Blob is not supported",By.ERR_NOT_SUPPORT);return new n([c],{type:u})}return c}throw new By("Unsupported protocol "+i,By.ERR_NOT_SUPPORT)}var Htn=tu(require("stream"),1);var wbf=tu(require("stream"),1);var __u=Symbol("internals"),h_u=class extends wbf.default.Transform{constructor(t){t=Jl.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Jl.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[__u]={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[__u];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[__u],a=i.maxRate,u=this.readableHighWaterMark,f=i.timeWindow,d=1e3/f,c=a/d,o=i.minChunkSize!==!1?Math.max(i.minChunkSize,c*.01):0,l=(O,w)=>{let j=Buffer.byteLength(O);i.bytesSeen+=j,i.bytes+=j,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(O)?process.nextTick(w):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(w)}},g=(O,w)=>{let j=Buffer.byteLength(O),M=null,q=u,B,I=0;if(a){let C=Date.now();(!i.ts||(I=C-i.ts)>=f)&&(i.ts=C,B=c-i.bytes,i.bytes=B<0?-B:0,I=0),B=c-i.bytes}if(a){if(B<=0)return setTimeout(()=>{w(null,O)},f-I);B<q&&(q=B)}q&&j>q&&j-q>o&&(M=O.subarray(q),O=O.subarray(0,q)),l(O,M?()=>{process.nextTick(w,null,M)}:w)};g(t,function O(w,j){if(w)return n(w);j?g(j,O):n(null)})}},y_u=h_u;var Wbf=require("events");var Dbf=require("util"),Sbf=require("stream");var{asyncIterator:jbf}=Symbol,JD1=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[jbf]?yield*e[jbf]():yield e},Zva=JD1;var GD1=Jl.ALPHABET.ALPHA_DIGIT+"-_",Xyi=new Dbf.TextEncoder,y8r=`\r
1818
1818
  `,$D1=Xyi.encode(y8r),KD1=2,v_u=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Jl.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${y8r}`;i?r=Xyi.encode(String(r).replace(/\r?\n|\r\n?/g,y8r)):a+=`Content-Type: ${r.type||"application/octet-stream"}${y8r}`,this.headers=Xyi.encode(a+y8r),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+KD1,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Jl.isTypedArray(t)?yield t:yield*Zva(t),yield $D1}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},YD1=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+Jl.generateString(i,GD1)}=r||{};if(!Jl.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=Xyi.encode("--"+a+y8r),f=Xyi.encode("--"+a+"--"+y8r+y8r),d=f.byteLength,c=Array.from(e.entries()).map(([l,g])=>{let O=new v_u(l,g);return d+=O.size,O});d+=u.byteLength*c.length,d=Jl.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),Sbf.Readable.from(async function*(){for(let l of c)yield u,yield*l.encode();yield f}())},Ebf=YD1;var Abf=tu(require("stream"),1),b_u=class extends Abf.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)}},Mbf=b_u;var XD1=(e,t)=>Jl.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,xbf=XD1;function ZD1(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(d){let c=Date.now(),o=n[a];u||(u=c),r[i]=d,n[i]=c;let l=a,g=0;for(;l!==i;)g+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-u<t)return;let O=o&&c-o;return O?Math.round(g*1e3/O):void 0}}var Tbf=ZD1;function kD1(e,t){let r=0,n=1e3/t,i,a,u=(c,o=Date.now())=>{r=o,i=null,a&&(clearTimeout(a),a=null),e.apply(null,c)};return[(...c)=>{let o=Date.now(),l=o-r;l>=n?u(c,o):(i=c,a||(a=setTimeout(()=>{a=null,u(i)},n-l)))},()=>i&&u(i)]}var Cbf=kD1;var MEr=(e,t,r=3)=>{let n=0,i=Tbf(50,250);return Cbf(a=>{let u=a.loaded,f=a.lengthComputable?a.total:void 0,d=u-n,c=i(d),o=u<=f;n=u;let l={loaded:u,total:f,progress:f?u/f:void 0,bytes:d,rate:c||void 0,estimated:c&&f&&o?(f-u)/c:void 0,event:a,lengthComputable:f!=null,[t?"download":"upload"]:!0};e(l)},r)},oBn=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},uBn=e=>(...t)=>Jl.asap(()=>e(...t));var qbf={flush:xEr.default.constants.Z_SYNC_FLUSH,finishFlush:xEr.default.constants.Z_SYNC_FLUSH},eS1={flush:xEr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:xEr.default.constants.BROTLI_OPERATION_FLUSH},Ibf=Jl.isFunction(xEr.default.createBrotliDecompress),{http:tS1,https:rS1}=Vbf.default,nS1=/https:?/,Bbf=p6.protocols.map(e=>e+":"),Nbf=(e,[t,r])=>(e.on("end",r).on("error",r),t);function iS1(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Hbf(e,t,r){let n=t;if(!n&&n!==!1){let i=(0,Rbf.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){Hbf(a,t,a.href)}}var aS1=typeof process<"u"&&Jl.kindOf(process)==="process",oS1=e=>new Promise((t,r)=>{let n,i,a=(d,c)=>{i||(i=!0,n&&n(d,c))},u=d=>{a(d),t(d)},f=d=>{a(d,!0),r(d)};e(u,f,d=>n=d).catch(f)}),uS1=({address:e,family:t})=>{if(!Jl.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},zbf=(e,t)=>uS1(Jl.isObject(e)?e:{address:e,family:t}),Qbf=aS1&&function(t){return oS1(async function(n,i,a){let{data:u,lookup:f,family:d}=t,{responseType:c,responseEncoding:o}=t,l=t.method.toUpperCase(),g,O=!1,w;if(f){let or=xbf(f,Pr=>Jl.isArray(Pr)?Pr:[Pr]);f=(Pr,Ur,It)=>{or(Pr,Ur,(cr,Wr,Gt)=>{if(cr)return It(cr);let wn=Jl.isArray(Wr)?Wr.map(An=>zbf(An)):[zbf(Wr,Gt)];Ur.all?It(cr,wn):It(cr,wn[0].address,wn[0].family)})}}let j=new Wbf.EventEmitter,M=()=>{t.cancelToken&&t.cancelToken.unsubscribe(q),t.signal&&t.signal.removeEventListener("abort",q),j.removeAllListeners()};a((or,Pr)=>{g=!0,Pr&&(O=!0,M())});function q(or){j.emit("abort",!or||or.type?new Vje(null,t,w):or)}j.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 B=Vtn(t.baseURL,t.url),I=new URL(B,p6.hasBrowserEnv?p6.origin:void 0),C=I.protocol||Bbf[0];if(C==="data:"){let or;if(l!=="GET")return zFt(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{or=p_u(t.url,c==="blob",{Blob:t.env&&t.env.Blob})}catch(Pr){throw By.from(Pr,By.ERR_BAD_REQUEST,t)}return c==="text"?(or=or.toString(o),(!o||o==="utf8")&&(or=Jl.stripBOM(or))):c==="stream"&&(or=Htn.default.Readable.from(or)),zFt(n,i,{data:or,status:200,statusText:"OK",headers:new j3,config:t})}if(Bbf.indexOf(C)===-1)return i(new By("Unsupported protocol "+C,By.ERR_BAD_REQUEST,t));let L=j3.from(t.headers).normalize();L.set("User-Agent","axios/"+Wtn,!1);let{onUploadProgress:K,onDownloadProgress:te}=t,J=t.maxRate,G,re;if(Jl.isSpecCompliantForm(u)){let or=L.getContentType(/boundary=([-_\w\d]{10,70})/i);u=Ebf(u,Pr=>{L.set(Pr)},{tag:`axios-${Wtn}-boundary`,boundary:or&&or[1]||void 0})}else if(Jl.isFormData(u)&&Jl.isFunction(u.getHeaders)){if(L.set(u.getHeaders()),!L.hasContentLength())try{let or=await Ubf.default.promisify(u.getLength).call(u);Number.isFinite(or)&&or>=0&&L.setContentLength(or)}catch{}}else if(Jl.isBlob(u))u.size&&L.setContentType(u.type||"application/octet-stream"),L.setContentLength(u.size||0),u=Htn.default.Readable.from(Zva(u));else if(u&&!Jl.isStream(u)){if(!Buffer.isBuffer(u))if(Jl.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(Jl.isString(u))u=Buffer.from(u,"utf-8");else return i(new By("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",By.ERR_BAD_REQUEST,t));if(L.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return i(new By("Request body larger than maxBodyLength limit",By.ERR_BAD_REQUEST,t))}let Xe=Jl.toFiniteNumber(L.getContentLength());Jl.isArray(J)?(G=J[0],re=J[1]):G=re=J,u&&(K||G)&&(Jl.isStream(u)||(u=Htn.default.Readable.from(u,{objectMode:!1})),u=Htn.default.pipeline([u,new y_u({maxRate:Jl.toFiniteNumber(G)})],Jl.noop),K&&u.on("progress",Nbf(u,oBn(Xe,MEr(uBn(K),!1,3)))));let Re;if(t.auth){let or=t.auth.username||"",Pr=t.auth.password||"";Re=or+":"+Pr}if(!Re&&I.username){let or=I.username,Pr=I.password;Re=or+":"+Pr}Re&&L.delete("authorization");let Dt;try{Dt=Utn(I.pathname+I.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(or){let Pr=new Error(or.message);return Pr.config=t,Pr.url=t.url,Pr.exists=!0,i(Pr)}L.set("Accept-Encoding","gzip, compress, deflate"+(Ibf?", br":""),!1);let Ct={path:Dt,method:l,headers:L.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:Re,protocol:C,family:d,beforeRedirect:iS1,beforeRedirects:{}};!Jl.isUndefined(f)&&(Ct.lookup=f),t.socketPath?Ct.socketPath=t.socketPath:(Ct.hostname=I.hostname.startsWith("[")?I.hostname.slice(1,-1):I.hostname,Ct.port=I.port,Hbf(Ct,t.proxy,C+"//"+I.hostname+(I.port?":"+I.port:"")+Ct.path));let Wt,Bt=nS1.test(Ct.protocol);if(Ct.agent=Bt?t.httpsAgent:t.httpAgent,t.transport?Wt=t.transport:t.maxRedirects===0?Wt=Bt?Lbf.default:Fbf.default:(t.maxRedirects&&(Ct.maxRedirects=t.maxRedirects),t.beforeRedirect&&(Ct.beforeRedirects.config=t.beforeRedirect),Wt=Bt?rS1:tS1),t.maxBodyLength>-1?Ct.maxBodyLength=t.maxBodyLength:Ct.maxBodyLength=1/0,t.insecureHTTPParser&&(Ct.insecureHTTPParser=t.insecureHTTPParser),w=Wt.request(Ct,function(Pr){if(w.destroyed)return;let Ur=[Pr],It=+Pr.headers["content-length"];if(te||re){let An=new y_u({maxRate:Jl.toFiniteNumber(re)});te&&An.on("progress",Nbf(An,oBn(It,MEr(uBn(te),!0,3)))),Ur.push(An)}let cr=Pr,Wr=Pr.req||w;if(t.decompress!==!1&&Pr.headers["content-encoding"])switch((l==="HEAD"||Pr.statusCode===204)&&delete Pr.headers["content-encoding"],(Pr.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Ur.push(xEr.default.createUnzip(qbf)),delete Pr.headers["content-encoding"];break;case"deflate":Ur.push(new Mbf),Ur.push(xEr.default.createUnzip(qbf)),delete Pr.headers["content-encoding"];break;case"br":Ibf&&(Ur.push(xEr.default.createBrotliDecompress(eS1)),delete Pr.headers["content-encoding"])}cr=Ur.length>1?Htn.default.pipeline(Ur,Jl.noop):Ur[0];let Gt=Htn.default.finished(cr,()=>{Gt(),M()}),wn={status:Pr.statusCode,statusText:Pr.statusMessage,headers:new j3(Pr.headers),config:t,request:Wr};if(c==="stream")wn.data=cr,zFt(n,i,wn);else{let An=[],Ht=0;cr.on("data",function(dn){An.push(dn),Ht+=dn.length,t.maxContentLength>-1&&Ht>t.maxContentLength&&(O=!0,cr.destroy(),i(new By("maxContentLength size of "+t.maxContentLength+" exceeded",By.ERR_BAD_RESPONSE,t,Wr)))}),cr.on("aborted",function(){if(O)return;let dn=new By("maxContentLength size of "+t.maxContentLength+" exceeded",By.ERR_BAD_RESPONSE,t,Wr);cr.destroy(dn),i(dn)}),cr.on("error",function(dn){w.destroyed||i(By.from(dn,null,t,Wr))}),cr.on("end",function(){try{let dn=An.length===1?An[0]:Buffer.concat(An);c!=="arraybuffer"&&(dn=dn.toString(o),(!o||o==="utf8")&&(dn=Jl.stripBOM(dn))),wn.data=dn}catch(dn){return i(By.from(dn,null,t,wn.request,wn))}zFt(n,i,wn)})}j.once("abort",An=>{cr.destroyed||(cr.emit("error",An),cr.destroy())})}),j.once("abort",or=>{i(or),w.destroy(or)}),w.on("error",function(Pr){i(By.from(Pr,null,t,w))}),w.on("socket",function(Pr){Pr.setKeepAlive(!0,1e3*60)}),t.timeout){let or=parseInt(t.timeout,10);if(Number.isNaN(or)){i(new By("error trying to parse `config.timeout` to int",By.ERR_BAD_OPTION_VALUE,t,w));return}w.setTimeout(or,function(){if(g)return;let Ur=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",It=t.transitional||rBn;t.timeoutErrorMessage&&(Ur=t.timeoutErrorMessage),i(new By(Ur,It.clarifyTimeoutError?By.ETIMEDOUT:By.ECONNABORTED,t,w)),q()})}if(Jl.isStream(u)){let or=!1,Pr=!1;u.on("end",()=>{or=!0}),u.once("error",Ur=>{Pr=!0,w.destroy(Ur)}),u.on("close",()=>{!or&&!Pr&&q(new Vje("Request stream has been aborted",t,w))}),u.pipe(w)}else w.end(u)})};var Jbf=p6.hasStandardBrowserEnv?function(){let t=p6.navigator&&/(msie|trident)/i.test(p6.navigator.userAgent),r=document.createElement("a"),n;function i(a){let u=a;return t&&(r.setAttribute("href",u),u=r.href),r.setAttribute("href",u),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=i(window.location.href),function(u){let f=Jl.isString(u)?i(u):u;return f.protocol===n.protocol&&f.host===n.host}}():function(){return function(){return!0}}();var Gbf=p6.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let u=[e+"="+encodeURIComponent(t)];Jl.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),Jl.isString(n)&&u.push("path="+n),Jl.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 $bf=e=>e instanceof j3?{...e}:e;function U6t(e,t){t=t||{};let r={};function n(c,o,l){return Jl.isPlainObject(c)&&Jl.isPlainObject(o)?Jl.merge.call({caseless:l},c,o):Jl.isPlainObject(o)?Jl.merge({},o):Jl.isArray(o)?o.slice():o}function i(c,o,l){if(Jl.isUndefined(o)){if(!Jl.isUndefined(c))return n(void 0,c,l)}else return n(c,o,l)}function a(c,o){if(!Jl.isUndefined(o))return n(void 0,o)}function u(c,o){if(Jl.isUndefined(o)){if(!Jl.isUndefined(c))return n(void 0,c)}else return n(void 0,o)}function f(c,o,l){if(l in t)return n(c,o);if(l in e)return n(void 0,c)}let d={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:f,headers:(c,o)=>i($bf(c),$bf(o),!0)};return Jl.forEach(Object.keys(Object.assign({},e,t)),function(o){let l=d[o]||i,g=l(e[o],t[o],o);Jl.isUndefined(g)&&l!==f||(r[o]=g)}),r}var kva=e=>{let t=U6t({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:u,auth:f}=t;t.headers=u=j3.from(u),t.url=Utn(Vtn(t.baseURL,t.url),e.params,e.paramsSerializer),f&&u.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):"")));let d;if(Jl.isFormData(r)){if(p6.hasStandardBrowserEnv||p6.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[c,...o]=d?d.split(";").map(l=>l.trim()).filter(Boolean):[];u.setContentType([c||"multipart/form-data",...o].join("; "))}}if(p6.hasStandardBrowserEnv&&(n&&Jl.isFunction(n)&&(n=n(t)),n||n!==!1&&Jbf(t.url))){let c=i&&a&&Gbf.read(a);c&&u.set(i,c)}return t};var sS1=typeof XMLHttpRequest<"u",Kbf=sS1&&function(e){return new Promise(function(r,n){let i=kva(e),a=i.data,u=j3.from(i.headers).normalize(),{responseType:f,onUploadProgress:d,onDownloadProgress:c}=i,o,l,g,O,w;function j(){O&&O(),w&&w(),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 I=j3.from("getAllResponseHeaders"in M&&M.getAllResponseHeaders()),L={data:!f||f==="text"||f==="json"?M.responseText:M.response,status:M.status,statusText:M.statusText,headers:I,config:e,request:M};zFt(function(te){r(te),j()},function(te){n(te),j()},L),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 By("Request aborted",By.ECONNABORTED,e,M)),M=null)},M.onerror=function(){n(new By("Network Error",By.ERR_NETWORK,e,M)),M=null},M.ontimeout=function(){let C=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",L=i.transitional||rBn;i.timeoutErrorMessage&&(C=i.timeoutErrorMessage),n(new By(C,L.clarifyTimeoutError?By.ETIMEDOUT:By.ECONNABORTED,e,M)),M=null},a===void 0&&u.setContentType(null),"setRequestHeader"in M&&Jl.forEach(u.toJSON(),function(C,L){M.setRequestHeader(L,C)}),Jl.isUndefined(i.withCredentials)||(M.withCredentials=!!i.withCredentials),f&&f!=="json"&&(M.responseType=i.responseType),c&&([g,w]=MEr(c,!0),M.addEventListener("progress",g)),d&&M.upload&&([l,O]=MEr(d),M.upload.addEventListener("progress",l),M.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(o=I=>{M&&(n(!I||I.type?new Vje(null,e,M):I),M.abort(),M=null)},i.cancelToken&&i.cancelToken.subscribe(o),i.signal&&(i.signal.aborted?o():i.signal.addEventListener("abort",o)));let B=Yyi(i.url);if(B&&p6.protocols.indexOf(B)===-1){n(new By("Unsupported protocol "+B+":",By.ERR_BAD_REQUEST,e));return}M.send(a||null)})};var cS1=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(c){if(!i){i=!0,f();let o=c instanceof Error?c:this.reason;n.abort(o instanceof By?o:new Vje(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new By(`timeout ${t} of ms exceeded`,By.ETIMEDOUT))},t),f=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(a):c.removeEventListener("abort",a)}),e=null)};e.forEach(c=>c.addEventListener("abort",a));let{signal:d}=n;return d.unsubscribe=()=>Jl.asap(f),d}},Ybf=cS1;var lS1=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},fS1=async function*(e,t){for await(let r of dS1(e))yield*lS1(r,t)},dS1=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()}},g_u=(e,t,r,n)=>{let i=fS1(e,t),a=0,u,f=d=>{u||(u=!0,n&&n(d))};return new ReadableStream({async pull(d){try{let{done:c,value:o}=await i.next();if(c){f(),d.close();return}let l=o.byteLength;if(r){let g=a+=l;r(g)}d.enqueue(new Uint8Array(o))}catch(c){throw f(c),c}},cancel(d){return f(d),i.return()}},{highWaterMark:2})};var tba=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Zbf=tba&&typeof ReadableStream=="function",pS1=tba&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),kbf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},_S1=Zbf&&kbf(()=>{let e=!1,t=new Request(p6.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Xbf=64*1024,m_u=Zbf&&kbf(()=>Jl.isReadableStream(new Response("").body)),eba={stream:m_u&&(e=>e.body)};tba&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!eba[t]&&(eba[t]=Jl.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new By(`Response type '${t}' is not supported`,By.ERR_NOT_SUPPORT,n)})})})(new Response);var hS1=async e=>{if(e==null)return 0;if(Jl.isBlob(e))return e.size;if(Jl.isSpecCompliantForm(e))return(await new Request(p6.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Jl.isArrayBufferView(e)||Jl.isArrayBuffer(e))return e.byteLength;if(Jl.isURLSearchParams(e)&&(e=e+""),Jl.isString(e))return(await pS1(e)).byteLength},yS1=async(e,t)=>{let r=Jl.toFiniteNumber(e.getContentLength());return r??hS1(t)},egf=tba&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:a,timeout:u,onDownloadProgress:f,onUploadProgress:d,responseType:c,headers:o,withCredentials:l="same-origin",fetchOptions:g}=kva(e);c=c?(c+"").toLowerCase():"text";let O=Ybf([i,a&&a.toAbortSignal()],u),w,j=O&&O.unsubscribe&&(()=>{O.unsubscribe()}),M;try{if(d&&_S1&&r!=="get"&&r!=="head"&&(M=await yS1(o,n))!==0){let L=new Request(t,{method:"POST",body:n,duplex:"half"}),K;if(Jl.isFormData(n)&&(K=L.headers.get("content-type"))&&o.setContentType(K),L.body){let[te,J]=oBn(M,MEr(uBn(d)));n=g_u(L.body,Xbf,te,J)}}Jl.isString(l)||(l=l?"include":"omit");let q="credentials"in Request.prototype;w=new Request(t,{...g,signal:O,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:n,duplex:"half",credentials:q?l:void 0});let B=await fetch(w),I=m_u&&(c==="stream"||c==="response");if(m_u&&(f||I&&j)){let L={};["status","statusText","headers"].forEach(G=>{L[G]=B[G]});let K=Jl.toFiniteNumber(B.headers.get("content-length")),[te,J]=f&&oBn(K,MEr(uBn(f),!0))||[];B=new Response(g_u(B.body,Xbf,te,()=>{J&&J(),j&&j()}),L)}c=c||"text";let C=await eba[Jl.findKey(eba,c)||"text"](B,e);return!I&&j&&j(),await new Promise((L,K)=>{zFt(L,K,{data:C,headers:j3.from(B.headers),status:B.status,statusText:B.statusText,config:e,request:w})})}catch(q){throw j&&j(),q&&q.name==="TypeError"&&/fetch/i.test(q.message)?Object.assign(new By("Network Error",By.ERR_NETWORK,e,w),{cause:q.cause||q}):By.from(q,q&&q.code,e,w)}});var O_u={http:Qbf,xhr:Kbf,fetch:egf};Jl.forEach(O_u,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var tgf=e=>`- ${e}`,vS1=e=>Jl.isFunction(e)||e===null||e===!1,rba={getAdapter:e=>{e=Jl.isArray(e)?e:[e];let{length:t}=e,r,n,i={};for(let a=0;a<t;a++){r=e[a];let u;if(n=r,!vS1(r)&&(n=O_u[(u=String(r)).toLowerCase()],n===void 0))throw new By(`Unknown adapter '${u}'`);if(n)break;i[u||"#"+a]=n}if(!n){let a=Object.entries(i).map(([f,d])=>`adapter ${f} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
@@ -1935,7 +1935,7 @@ errors:
1935
1935
  Run ${nl.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
1936
1936
  Run ${nl.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),cBn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function g0u({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!Uwf(e))return;let i=t??"",a=e.filter(f=>f.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((f,d)=>f.generatorName.localeCompare(d.generatorName)||f.currentVersion.localeCompare(d.currentVersion));for(let f of u)i+=`
1937
1937
  ${await II1(f.generatorName)} (${f.apiName!=null?"API: "+f.apiName+", ":""}Group: ${f.generatorGroup}) `+nl.dim(f.currentVersion)+nl.reset(" \u2192 ")+nl.green(f.latestVersion);return i+=`
1938
- `,n?cBn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function II1(e){let r=await new Lwf.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 BI1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await Wwf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=yP.getGeneratorNameOrThrow(o.name,l),O=await yP.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await Wwf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=yP.getGeneratorNameOrThrow(c.name,o),g=await yP.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function Wwf({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await yP.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function Hwf(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=Nie(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function dga({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await BI1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...Hwf(c,d,t.logger));else u.push(...Hwf(f.versions,void 0,t.logger))}return u}var N0i=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(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var zBn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var RBn=e=>e!==null&&typeof e=="object";var z0i=(...e)=>{for(let t of e)if((!RBn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return P0u({},...e)},m0u=(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 pga(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:P0u(e[r]??[],t[r]??[])}var O0u=(e={},t={})=>({beforeRequest:pga(e,t,"beforeRequest"),beforeRetry:pga(e,t,"beforeRetry"),afterResponse:pga(e,t,"afterResponse"),beforeError:pga(e,t,"beforeError")}),P0u=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(RBn(i)){for(let[a,u]of Object.entries(i))RBn(u)&&a in t&&(u=P0u(t[a],u)),t={...t,[a]:u};RBn(i.hooks)&&(n=O0u(n,i.hooks),t.hooks=n),RBn(i.headers)&&(r=m0u(r,i.headers),t.headers=r)}return t};var Qwf=(()=>{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})(),Jwf=typeof globalThis.AbortController=="function",Gwf=typeof globalThis.ReadableStream=="function",$wf=typeof globalThis.FormData=="function",_ga=["get","post","put","patch","head","delete"],NI1=()=>{};NI1();var Kwf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},hga=2147483647,yga=Symbol("stop"),Ywf={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Xwf={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 kwf=e=>_ga.includes(e)?e.toUpperCase():e,zI1=["get","put","head","delete","options","trace"],RI1=[408,413,429,500,502,503,504],FI1=[413,429,503],Zwf={limit:2,methods:zI1,statusCodes:RI1,afterStatusCodes:FI1,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},ejf=(e={})=>{if(typeof e=="number")return{...Zwf,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{...Zwf,...e}};async function w0u(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new zBn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function j0u(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 tjf=(e,t)=>{let r={};for(let n in t)!(n in Xwf)&&!(n in Ywf)&&!(n in e)&&(r[n]=t[n]);return r};var R0i=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>hga)throw new RangeError(`The \`timeout\` option cannot be greater than ${hga}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new N0i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Gwf)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(Kwf))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:m0u(this._input.headers,r.headers),hooks:O0u({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:kwf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:ejf(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(Jwf){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(Qwf&&(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),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);($wf&&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)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof zBn)throw t;if(t instanceof N0i){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),hga);if(this._retryCount<1)throw r;await j0u(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})===yga)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=tjf(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):w0u(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var D0u=e=>{let t=(r,n)=>R0i.create(r,z0i(e,n));for(let r of _ga)t[r]=(n,i)=>R0i.create(n,z0i(e,i,{method:r}));return t.create=r=>D0u(z0i(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),D0u(z0i(e,r))),t.stop=yga,t},LI1=D0u(),rjf=LI1;var Djf=tu(jjf(),1);function x0u(e){let t=(0,Djf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var lEf=tu(bDf(),1),fEf=tu(cEf(),1),svu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},cvu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function lvu(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??x0u(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,lEf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await rjf(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new svu(e):l}if(t.allVersions)return c;let o=new cvu(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,w]of Object.entries(c.versions))w.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=fEf.default.maxSatisfying(O,r),!r)throw o}let{time:g}=c;if(c=c.versions[r],c.time=g,!c)throw o}return c}async function X0i(e,t){let{version:r}=await lvu(e.toLowerCase(),t);return r}async function GBn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:X0i(e.packageName,{version:t?"prerelease":"latest"})}var dEf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Rga=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=JA.Info;constructor(t){this.ttyAwareLogger=new fga(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc15"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${nl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Cxe}failWithoutThrowing(t,r){this.didSucceed=!1,uga({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await k4n()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await Vwf({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1938
+ `,n?cBn(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function II1(e){let r=await new Lwf.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 BI1({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let f={type:"singleApi",versions:{}};return await Wwf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,c,o,l)=>{f.versions[c]==null&&(f.versions[c]={});let g=yP.getGeneratorNameOrThrow(o.name,l),O=await yP.getLatestGeneratorVersion({generatorName:g,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:i,includeMajor:a,context:l});O!=null&&(f.versions[c][o.name]={previousVersion:o.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),f}let u={type:"multiApi",versions:{}};return await Wwf({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,d,c,o)=>{if(f==null)return;u.versions[f]==null&&(u.versions[f]={}),u.versions[f][d]==null&&(u.versions[f][d]={});let l=yP.getGeneratorNameOrThrow(c.name,o),g=await yP.getLatestGeneratorVersion({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:c.version,channel:i,includeMajor:a,context:o});g!=null&&(u.versions[f][d][c.name]={previousVersion:c.version,latestVersion:g})},generatorFilter:r,groupFilter:n}),u}async function Wwf({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let f=await yP.loadGeneratorsConfiguration({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(f==null||f.groups==null)){for(let d of f.groups)if(!(i!=null&&d.groupName!==i))for(let c of d.generators)n!=null&&c.name!==n||await r(a.workspaceName,d.groupName,c,u)}})}))}function Hwf(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[u,f]of Object.entries(a)){r.debug(`Checking if ${u} in group ${i} has an upgrade available...`);let d=Nie(f.latestVersion,f.previousVersion);r.debug(`Latest version: ${f.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),n.push({generatorName:u,generatorGroup:i,apiName:t,isUpgradeAvailable:d,currentVersion:f.previousVersion,latestVersion:f.latestVersion})}return n}async function dga({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let u=[];if(e!=null){let f=await BI1({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(f.type==="multiApi")for(let[d,c]of Object.entries(f.versions))u.push(...Hwf(c,d,t.logger));else u.push(...Hwf(f.versions,void 0,t.logger))}return u}var N0i=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(),f=u?`status code ${u}`:"an unknown error";super(`Request failed with ${f}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var zBn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var RBn=e=>e!==null&&typeof e=="object";var z0i=(...e)=>{for(let t of e)if((!RBn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return P0u({},...e)},m0u=(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 pga(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:P0u(e[r]??[],t[r]??[])}var O0u=(e={},t={})=>({beforeRequest:pga(e,t,"beforeRequest"),beforeRetry:pga(e,t,"beforeRetry"),afterResponse:pga(e,t,"afterResponse"),beforeError:pga(e,t,"beforeError")}),P0u=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(RBn(i)){for(let[a,u]of Object.entries(i))RBn(u)&&a in t&&(u=P0u(t[a],u)),t={...t,[a]:u};RBn(i.hooks)&&(n=O0u(n,i.hooks),t.hooks=n),RBn(i.headers)&&(r=m0u(r,i.headers),t.headers=r)}return t};var Qwf=(()=>{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})(),Jwf=typeof globalThis.AbortController=="function",Gwf=typeof globalThis.ReadableStream=="function",$wf=typeof globalThis.FormData=="function",_ga=["get","post","put","patch","head","delete"],NI1=()=>{};NI1();var Kwf={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},hga=2147483647,yga=Symbol("stop"),Ywf={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},Xwf={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 kwf=e=>_ga.includes(e)?e.toUpperCase():e,zI1=["get","put","head","delete","options","trace"],RI1=[408,413,429,500,502,503,504],FI1=[413,429,503],Zwf={limit:2,methods:zI1,statusCodes:RI1,afterStatusCodes:FI1,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},ejf=(e={})=>{if(typeof e=="number")return{...Zwf,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{...Zwf,...e}};async function w0u(e,t,r,n){return new Promise((i,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new zBn(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(u)})})}async function j0u(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 tjf=(e,t)=>{let r={};for(let n in t)!(n in Xwf)&&!(n in Ywf)&&!(n in e)&&(r[n]=t[n]);return r};var R0i=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>hga)throw new RangeError(`The \`timeout\` option cannot be greater than ${hga}`);await Promise.resolve();let f=await n._fetch();for(let d of n._options.hooks.afterResponse){let c=await d(n.request,n._options,n._decorateResponse(f.clone()));c instanceof globalThis.Response&&(f=c)}if(n._decorateResponse(f),!f.ok&&n._options.throwHttpErrors){let d=new N0i(f,n.request,n._options);for(let c of n._options.hooks.beforeError)d=await c(d);throw d}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Gwf)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return n._stream(f.clone(),n._options.onDownloadProgress)}return f},u=n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i();for(let[f,d]of Object.entries(Kwf))u[f]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||d);let o=(await u).clone();if(f==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[f]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:m0u(this._input.headers,r.headers),hooks:O0u({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:kwf(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:ejf(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(Jwf){this.abortController=new globalThis.AbortController;let n=this._options.signal??this._input.signal;n?.addEventListener("abort",()=>{this.abortController.abort(n.reason)}),this._options.signal=this.abortController.signal}if(Qwf&&(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),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);($wf&&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)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof zBn)throw t;if(t instanceof N0i){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),hga);if(this._retryCount<1)throw r;await j0u(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})===yga)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=tjf(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):w0u(r,t,this.abortController,this._options)}_stream(t,r){let n=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(r&&r({percent:1,totalBytes:n,transferredBytes:i},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:n},new Uint8Array);async function f(){let{done:d,value:c}=await u.read();if(d){a.close();return}if(r){i+=c.byteLength;let o=n===0?0:i/n;r({percent:o,transferredBytes:i,totalBytes:n},c)}a.enqueue(c),await f()}await f()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var D0u=e=>{let t=(r,n)=>R0i.create(r,z0i(e,n));for(let r of _ga)t[r]=(n,i)=>R0i.create(n,z0i(e,i,{method:r}));return t.create=r=>D0u(z0i(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),D0u(z0i(e,r))),t.stop=yga,t},LI1=D0u(),rjf=LI1;var Djf=tu(jjf(),1);function x0u(e){let t=(0,Djf.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var lEf=tu(bDf(),1),fEf=tu(cEf(),1),svu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},cvu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function lvu(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??x0u(i),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),f=(0,lEf.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,f&&(d.authorization=`${f.type} ${f.token}`);let c;try{c=await rjf(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new svu(e):l}if(t.allVersions)return c;let o=new cvu(e,r);if(c["dist-tags"][r]){let{time:l}=c;c=c.versions[c["dist-tags"][r]],c.time=l}else if(r){let l=!!c.versions[r];if(n&&!l)for(let[O,w]of Object.entries(c.versions))w.deprecated&&delete c.versions[O];if(!l){let O=Object.keys(c.versions);if(r=fEf.default.maxSatisfying(O,r),!r)throw o}let{time:g}=c;if(c=c.versions[r],c.time=g,!c)throw o}return c}async function X0i(e,t){let{version:r}=await lvu(e.toLowerCase(),t);return r}async function GBn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:X0i(e.packageName,{version:t?"prerelease":"latest"})}var dEf=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Rga=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=JA.Info;constructor(t){this.ttyAwareLogger=new fga(t);let r=this.getPackageName(),n=this.getPackageVersion(),i=this.getCliName();(r==null||n==null||i==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:n,cliName:i}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.45.0-rc16"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${nl.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Cxe}failWithoutThrowing(t,r){this.didSucceed=!1,uga({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),(await k4n()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await Vwf({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1939
1939
  `)||(r+=`
1940
1940
  `),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=UQo(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 M0i(t);return this.ttyAwareLogger.registerTask(r),r}async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw n.failWithoutThrowing(void 0,a),new Cxe}finally{n.finish()}return i}async instrumentPostHogEvent(t){(await k4n()).sendEvent(t)}logger=idi(this.log.bind(this));constructTaskInitForWorkspace(t){let r=pEf(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?pEf(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=dEf[this.numTasks++%dEf.length],u=nl.hex(a)(i);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===OB.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}])}logImmediately(t){let r=t.filter(n=>UBr.indexOf(n.level)>=UBr.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===JA.Debug})}_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 GBn({cliEnvironment:this.environment,includePreReleases:t}),n=Nie(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await dga({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}};function pEf(e){return`[${e}]:`}var UAf=tu(LAf(),1);async function Xje(e,t,r=[],{doNotPipeOutput:n=!1,secrets:i=[],substitutions:a={},...u}={}){let f=i.reduce((o,l)=>({...o,[l]:"<redacted>"}),a),d=[t,...r].join(" ");for(let[o,l]of Object.entries(f))d=d.replaceAll(o,l);e?.debug(`+ ${d}`);let c=(0,UAf.default)(t,r,u);return n||(c.stdout?.pipe(process.stdout),c.stderr?.pipe(process.stderr)),c}function Jga(e,{logger:t,...r}={}){return(n,i)=>Xje(t,e,n,{...r,...i})}var $ga=require("fs/promises"),VAf=tu(hne(),1),T81="buf.gen.yaml",WAf="output",C81=`${WAf}/openapi.yaml`,q81=`
1941
1941
  version: v1
@@ -1948,7 +1948,7 @@ plugins:
1948
1948
  - default_response=false
1949
1949
  `,Gga=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,local:n}){return n?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}){let n=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}),i=mq(t,r);return this.doGenerateLocal({cwd:n,target:i})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}){let r=j_.of((await VAf.default.dir()).path);return await(0,$ga.cp)(t,r,{recursive:!0}),await(0,$ga.writeFile)(yf(r,Ms.of(T81)),q81),r}async doGenerateLocal({cwd:t,target:r}){let n=Jga("which",{cwd:t,logger:this.context.logger});try{await n(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await n(["protoc-gen-openapi"])}catch{this.context.failAndThrow("Missing required dependency; please install 'protoc-gen-openapi' to continue (e.g. 'brew install go && go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest').")}let i=Jga("buf",{cwd:t,logger:this.context.logger});return await i(["config","init"]),await i(["generate",r]),yf(t,Ms.of(C81))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};async function brn({context:e,specs:t,relativePathToDependency:r}){let n=new Gga({context:e}),i=t.filter(f=>f.type==="openapi").map(f=>({...f,relativePathToDependency:r})),a=t.filter(f=>f.type==="protobuf"),u=await Promise.all(a.map(async f=>I81({generator:n,protobufSpec:f,relativePathToDependency:r})));return[...i,...u]}async function I81({generator:e,protobufSpec:t,relativePathToDependency:r}){return{type:"openapi",absoluteFilepath:await e.generate({absoluteFilepathToProtobufRoot:t.absoluteFilepathToProtobufRoot,absoluteFilepathToProtobufTarget:t.absoluteFilepathToProtobufTarget,local:t.generateLocally}),absoluteFilepathToOverrides:t.absoluteFilepathToOverrides,settings:t.settings,source:{type:"protobuf",relativePathToDependency:r,root:t.absoluteFilepathToProtobufRoot,file:t.absoluteFilepathToProtobufTarget}}}var _gu=tu(Den(),1);var UTf=require("fs"),P3n=require("fs/promises");var VTf=require("os"),WTf=tu(require("path"),1),HTf=require("stream/promises"),QTf=tu(tOa(),1),JTf=tu(hne(),1);var wj;(function(e){e.FILE_READ="FILE_READ",e.FILE_PARSE="FILE_PARSE",e.FILE_MISSING="FILE_MISSING",e.STRUCTURE_VALIDATION="STRUCTURE_VALIDATION",e.JSONSCHEMA_VALIDATION="JSONSCHEMA_VALIDATION",e.DEPENDENCY_NOT_LISTED="DEPENDENCY_NOT_LISTED",e.FAILED_TO_LOAD_DEPENDENCY="FAILED_TO_LOAD_DEPENDENCY",e.EXPORTING_PACKAGE_MARKER_OTHER_KEYS="EXPORTING_PACKAGE_MARKER_OTHER_KEYS",e.EXPORT_PACKAGE_HAS_DEFINITIONS="EXPORT_PACKAGE_HAS_DEFINITIONS",e.MISCONFIGURED_DIRECTORY="MISCONFIGURED_DIRECTORY"})(wj||(wj={}));var lR1=aEr();async function GTf({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:n,cliVersion:i,settings:a,loadAPIWorkspace:u}){let f,d={type:wj.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},c=t.dependencies[e];return c==null?d={type:wj.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${vR1(c)}`},async o=>{switch(c.type){case"version":f=await hR1({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;case"local":f=await _R1({context:o,dependency:c,cliVersion:i,settings:a,loadAPIWorkspace:u});return;default:Kc(c)}}),f!=null?{didSucceed:!0,definition:f}:{didSucceed:!1,failure:d}}var $Tf="dependencies";var fR1="metadata.json",dR1=".fern";function pR1(e){return yf(j_.of((0,VTf.homedir)()),Ms.of(dR1),Ms.of($Tf),Ms.of(e.organization),Ms.of(e.apiName),Ms.of(e.version))}async function _R1({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){if(i==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await i({absolutePathToWorkspace:e.absoluteFilepath,context:t,cliVersion:r,workspaceName:void 0});if(!a.didSucceed){t.failWithoutThrowing("Failed to load api definition",a.failures);return}t.logger.info("Modifying source filepath ...");let u=await a.workspace.getDefinition({context:t,relativePathToDependency:Ms.of(e.path)},n);return t.logger.info("Loaded..."),u}async function hR1({dependency:e,context:t,cliVersion:r,settings:n,loadAPIWorkspace:i}){let a=pR1(e),u=yf(a,Ms.of($Tf)),f=yf(a,Ms.of(fR1)),d;if(!await Vh(u)||!await Vh(f)){t.logger.info("Downloading manifest...");let l=await lR1.definitionRegistry.get(_gu.FernFiddle.OrganizationId(e.organization),_gu.FernFiddle.ApiId(e.apiName),e.version);if(!l.ok){l.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:j=>{t.failWithoutThrowing("Failed to download API manifest",j)}});return}let g=l.body.yamlSchemaVersion!=null?parseInt(l.body.yamlSchemaVersion):void 0,O=srn(r),w=srn(l.body.cliVersion);if(g!=null){if(g>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${l.body.cliVersion}`);return}else if(g<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(O.major!==w.major||O.minor!==w.minor){t.failWithoutThrowing(`CLI version is ${l.body.cliVersion}. Expected ${O.major}.${O.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+l.body.definitionS3DownloadUrl),await(0,P3n.mkdir)(u,{recursive:!0});try{await yR1({s3PreSignedReadUrl:l.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(j){t.failWithoutThrowing("Failed to download API",j);return}d=l.body,await(0,P3n.writeFile)(f,JSON.stringify(d))}else d=JSON.parse((await(0,P3n.readFile)(f)).toString());if(t.logger.info("Parsing..."),i==null){t.failWithoutThrowing("Failed to load API");return}let c=await i({absolutePathToWorkspace:u,context:t,cliVersion:d.cliVersion,workspaceName:void 0});if(!c.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",c.failures);return}if(c.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await c.workspace.getDefinition({context:t},n)}async function yR1({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await aN.get(e,{responseType:"stream"}),n=await JTf.default.dir(),i=WTf.default.join(n.path,"api.tgz");await(0,HTf.pipeline)(r.data,(0,UTf.createWriteStream)(i)),await(0,QTf.extract)({file:i,cwd:t})}function vR1(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Kc(e)}}var uCf=tu(vgu(),1);function rOa(e,t){for(let[r,n]of o8(e))gR1({relativeFilepath:r,failure:n,logger:t})}function gR1({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case wj.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case wj.FILE_READ:r.error("Failed to open file: "+e);break;case wj.FILE_MISSING:r.error("Missing file: "+e);break;case wj.FILE_PARSE:t.error instanceof ddi?r.error(Nqt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case wj.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of mR1(n))r.error(Nqt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case wj.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case wj.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${KKi}: `+t.dependencyName);break;case wj.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case wj.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case wj.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Nqt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:Kc(t)}}function mR1(e){switch(e.code){case e_.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${nl.underline(e.expected)} but received ${nl.underline(e.received)}`}];case e_.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${nl.underline(t)}`}));case e_.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>nl.underline(t)).join(", ")}`}];case e_.invalid_union:case e_.invalid_arguments:case e_.invalid_return_type:case e_.invalid_date:case e_.invalid_string:case e_.too_small:case e_.too_big:case e_.invalid_intersection_types:case e_.not_multiple_of:case e_.custom:default:return[{title:e.message}]}}var eCf=require("fs/promises");async function tCf(e,t){let r=[];for(let n of await xxe(e,t))r.push(await OR1({relativeFilepath:mq(e,n),absoluteFilepath:n}));return r}async function OR1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,eCf.readFile)(t)).toString()}}async function rCf(e){let t={},r={};function n(i){try{t[i.relativeFilepath]={defaultUrl:void 0,contents:f0.load(i.fileContents,{schema:f0.CORE_SCHEMA}),rawContents:i.fileContents}}catch(a){r[i.relativeFilepath]={type:wj.FILE_PARSE,error:a}}}return await Promise.all(e.map(n)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function nCf({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:n,settings:i,loadAPIWorkspace:a}){let u={},f={},d={};return await Promise.all(o8(t.packageMarkers).map(async([c,o])=>{if(o.contents.export==null)u[c]=o;else{let{export:l,...g}=o.contents;if(y8t(g)>0)d[c]={type:wj.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:c};else{let O=ub(c);if(c8t(t.namedDefinitionFiles).some(j=>j!==c&&j.startsWith(O)))d[c]={type:wj.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:O};else{let j=await GTf({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:n,settings:i,loadAPIWorkspace:a});j.didSucceed?f[ub(c)]={definition:j.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:d[c]=j.failure}}}})),y8t(d)>0?{didSucceed:!1,failures:d}:{didSucceed:!0,packageMarkers:u,importedDefinitions:f}}var iCf=tu(require("path"),1);var bgu={};_l(bgu,{additionalProperties:()=>jR1,default:()=>SR1,definitions:()=>DR1,properties:()=>wR1,type:()=>PR1});var PR1="object",wR1={docs:{oneOf:[{type:"string"},{type:"null"}]},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]}},jR1=!1,DR1={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.TypeReferenceDeclarationWithName":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceDeclarationWithNameSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDeclarationWithName"}]},"types.ObjectPropertySchema":{$ref:"#/definitions/types.TypeReferenceDeclarationWithNameSchema"},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithContentTypeSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithContentTypeSchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1}},SR1={type:PR1,properties:wR1,additionalProperties:jR1,definitions:DR1};var ggu={};_l(ggu,{additionalProperties:()=>xR1,default:()=>CR1,definitions:()=>TR1,properties:()=>AR1,required:()=>MR1,type:()=>ER1});var ER1="object",AR1={docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},"default-url":{oneOf:[{type:"string"},{type:"null"}]},"default-environment":{oneOf:[{type:"string"},{type:"null"}]},environments:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/environments.EnvironmentSchema"}},{type:"null"}]},auth:{oneOf:[{$ref:"#/definitions/auth.ApiAuthSchema"},{type:"null"}]},"auth-schemes":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/auth.AuthSchemeDeclarationSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},name:{type:"string"},imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},"error-discrimination":{oneOf:[{$ref:"#/definitions/file.ErrorDiscriminationSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},errors:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"idempotency-headers":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},variables:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/variables.VariableDeclarationSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"null"}]},version:{oneOf:[{$ref:"#/definitions/versioning.VersionDeclarationSchema"},{type:"null"}]}},MR1=["name"],xR1=!1,TR1={"environments.SingleBaseUrlEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},url:{type:"string"}},required:["url"],additionalProperties:!1},"environments.MultipleBaseUrlsEnvironmentSchema":{type:"object",properties:{audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},urls:{type:"object",additionalProperties:{type:"string"}}},required:["urls"],additionalProperties:!1},"environments.EnvironmentSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/environments.SingleBaseUrlEnvironmentSchema"},{$ref:"#/definitions/environments.MultipleBaseUrlsEnvironmentSchema"}]},"auth.AuthSchemeReferenceSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{type:"string"}},required:["scheme"],additionalProperties:!1},"auth.AnyAuthItem":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"}]},"auth.AnyAuthSchemesSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},any:{type:"array",items:{$ref:"#/definitions/auth.AnyAuthItem"}}},required:["any"],additionalProperties:!1},"auth.ApiAuthSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/auth.AuthSchemeReferenceSchema"},{$ref:"#/definitions/auth.AnyAuthSchemesSchema"}]},"auth.OAuthAccessTokenRequestPropertiesSchema":{type:"object",properties:{"client-id":{oneOf:[{type:"string"},{type:"null"}]},"client-secret":{oneOf:[{type:"string"},{type:"null"}]},scopes:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthAccessTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthGetTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthAccessTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthRefreshTokenRequestPropertiesSchema":{type:"object",properties:{"refresh-token":{type:"string"}},required:["refresh-token"],additionalProperties:!1},"auth.OAuthRefreshTokenResponsePropertiesSchema":{type:"object",properties:{"access-token":{oneOf:[{type:"string"},{type:"null"}]},"expires-in":{oneOf:[{type:"string"},{type:"null"}]},"refresh-token":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.OAuthRefreshTokenEndpointSchema":{type:"object",properties:{endpoint:{type:"string"},"request-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenRequestPropertiesSchema"},{type:"null"}]},"response-properties":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenResponsePropertiesSchema"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"auth.OAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"oauth"},type:{const:"client-credentials"},scopes:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"client-id-env":{oneOf:[{type:"string"},{type:"null"}]},"client-secret-env":{oneOf:[{type:"string"},{type:"null"}]},"token-prefix":{oneOf:[{type:"string"},{type:"null"}]},"get-token":{$ref:"#/definitions/auth.OAuthGetTokenEndpointSchema"},"refresh-token":{oneOf:[{$ref:"#/definitions/auth.OAuthRefreshTokenEndpointSchema"},{type:"null"}]}},required:["scheme","type","get-token"],additionalProperties:!1},"auth.HeaderAuthSchemeSchema":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},header:{type:"string"},type:{oneOf:[{type:"string"},{type:"null"}]},prefix:{oneOf:[{type:"string"},{type:"null"}]}},required:["header"],additionalProperties:!1},"auth.AuthVariable":{type:"object",properties:{env:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"auth.BasicAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"basic"},username:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]},password:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.BearerAuthSchemeSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},scheme:{const:"bearer"},token:{oneOf:[{$ref:"#/definitions/auth.AuthVariable"},{type:"null"}]}},required:["scheme"],additionalProperties:!1},"auth.AuthSchemeDeclarationSchema":{anyOf:[{$ref:"#/definitions/auth.OAuthSchemeSchema"},{$ref:"#/definitions/auth.HeaderAuthSchemeSchema"},{$ref:"#/definitions/auth.BasicAuthSchemeSchema"},{$ref:"#/definitions/auth.BearerAuthSchemeSchema"}]},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"file.PropertyBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"property"},"property-name":{type:"string"}},required:["strategy","property-name"],additionalProperties:!1},"file.StatusCodeBasedErrorDiscrimination":{type:"object",properties:{strategy:{const:"status-code"}},required:["strategy"],additionalProperties:!1},"file.ErrorDiscriminationSchema":{anyOf:[{$ref:"#/definitions/file.PropertyBasedErrorDiscrimination"},{$ref:"#/definitions/file.StatusCodeBasedErrorDiscrimination"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"variables.VariableDeclarationDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"variables.VariableDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/variables.VariableDeclarationDetailed"}]},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"versioning.VersionValueDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionValue":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionValueDetailed"}]},"versioning.VersionDeclarationHeaderObjectSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"versioning.VersionDeclarationHeaderSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/versioning.VersionDeclarationHeaderObjectSchema"}]},"versioning.VersionDeclarationSchema":{type:"object",properties:{default:{oneOf:[{type:"string"},{type:"null"}]},values:{type:"array",items:{$ref:"#/definitions/versioning.VersionValue"}},header:{$ref:"#/definitions/versioning.VersionDeclarationHeaderSchema"}},required:["values","header"],additionalProperties:!1}},CR1={type:ER1,properties:AR1,required:MR1,additionalProperties:xR1,definitions:TR1};var mgu={};_l(mgu,{additionalProperties:()=>BR1,default:()=>zR1,definitions:()=>NR1,properties:()=>IR1,type:()=>qR1});var qR1="object",IR1={imports:{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},types:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeDeclarationSchema"}},{type:"null"}]},service:{oneOf:[{$ref:"#/definitions/service.HttpServiceSchema"},{type:"null"}]},errors:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/errors.ErrorDeclarationSchema"}},{type:"null"}]},webhooks:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/webhooks.WebhookSchema"}},{type:"null"}]},channel:{oneOf:[{$ref:"#/definitions/websocket.WebSocketChannelSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},navigation:{oneOf:[{$ref:"#/definitions/file.Navigation"},{type:"null"}]},export:{oneOf:[{$ref:"#/definitions/file.Export"},{type:"null"}]}},BR1=!1,NR1={"examples.ExampleTypeValueSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleTypeSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},value:{$ref:"#/definitions/examples.ExampleTypeValueSchema"}},required:["value"],additionalProperties:!1},"encoding.ProtobufTypeSchema":{type:"object",properties:{type:{type:"string"}},required:["type"],additionalProperties:!1},"encoding.EncodingSchema":{type:"object",properties:{proto:{oneOf:[{$ref:"#/definitions/encoding.ProtobufTypeSchema"},{type:"null"}]}},additionalProperties:!1},"source.OpenAPISourceSchema":{type:"object",properties:{openapi:{type:"string"}},required:["openapi"],additionalProperties:!1},"source.ProtobufSourceSchema":{type:"object",properties:{proto:{type:"string"}},required:["proto"],additionalProperties:!1},"source.SourceSchema":{anyOf:[{$ref:"#/definitions/source.OpenAPISourceSchema"},{$ref:"#/definitions/source.ProtobufSourceSchema"}]},"availability.AvailabilityStatusSchema":{type:"string",enum:["in-development","pre-release","deprecated","generally-available"]},"availability.AvailabilitySchema":{type:"object",properties:{status:{$ref:"#/definitions/availability.AvailabilityStatusSchema"},message:{oneOf:[{type:"string"},{type:"null"}]}},required:["status"],additionalProperties:!1},"availability.AvailabilityUnionSchema":{anyOf:[{$ref:"#/definitions/availability.AvailabilityStatusSchema"},{$ref:"#/definitions/availability.AvailabilitySchema"}]},"types.ObjectExtendsSchema":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"validation.StringValidationSchema":{type:"object",properties:{minLength:{oneOf:[{type:"integer"},{type:"null"}]},maxLength:{oneOf:[{type:"integer"},{type:"null"}]},pattern:{oneOf:[{type:"string"},{type:"null"}]},format:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"validation.NumberValidationSchema":{type:"object",properties:{min:{oneOf:[{type:"number"},{type:"null"}]},max:{oneOf:[{type:"number"},{type:"null"}]},exclusiveMin:{oneOf:[{type:"boolean"},{type:"null"}]},exclusiveMax:{oneOf:[{type:"boolean"},{type:"null"}]},multipleOf:{oneOf:[{type:"number"},{type:"null"}]}},additionalProperties:!1},"validation.ValidationSchema":{anyOf:[{$ref:"#/definitions/validation.StringValidationSchema"},{$ref:"#/definitions/validation.NumberValidationSchema"}]},"types.TypeReferenceDeclarationWithName":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceDeclarationWithNameSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDeclarationWithName"}]},"types.ObjectPropertySchema":{$ref:"#/definitions/types.TypeReferenceDeclarationWithNameSchema"},"types.ObjectSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]}},additionalProperties:!1},"types.CasingOverridesSchema":{type:"object",properties:{camel:{oneOf:[{type:"string"},{type:"null"}]},snake:{oneOf:[{type:"string"},{type:"null"}]},pascal:{oneOf:[{type:"string"},{type:"null"}]},"screaming-snake":{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"types.EnumValueSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"},casing:{oneOf:[{$ref:"#/definitions/types.CasingOverridesSchema"},{type:"null"}]}},required:["value"],additionalProperties:!1},"types.EnumValue":{anyOf:[{type:"string"},{$ref:"#/definitions/types.EnumValueSchema"}]},"types.EnumSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},default:{oneOf:[{type:"string"},{type:"null"}]},enum:{type:"array",items:{$ref:"#/definitions/types.EnumValue"}}},required:["enum"],additionalProperties:!1},"types.UnionDiscriminantSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.UnionDiscriminant":{anyOf:[{type:"string"},{$ref:"#/definitions/types.UnionDiscriminantSchema"}]},"types.TypeReferenceDetailedSchema":{type:"object",properties:{default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.TypeReferenceSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.TypeReferenceDetailedSchema"}]},"types.SingleUnionTypeKeySchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},value:{type:"string"}},required:["value"],additionalProperties:!1},"types.SingleUnionTypeKey":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeKeySchema"}]},"types.SingleUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{oneOf:[{type:"string"},{type:"null"}]},key:{oneOf:[{$ref:"#/definitions/types.SingleUnionTypeKey"},{type:"null"}]}},additionalProperties:!1},"types.SingleUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUnionTypeDetailedSchema"}]},"types.DiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminant:{oneOf:[{$ref:"#/definitions/types.UnionDiscriminant"},{type:"null"}]},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"base-properties":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},union:{type:"object",additionalProperties:{$ref:"#/definitions/types.SingleUnionTypeSchema"}}},required:["union"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeDetailedSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"types.SingleUndiscriminatedUnionTypeSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeDetailedSchema"}]},"types.UndiscriminatedUnionSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},discriminated:{const:!1},union:{type:"array",items:{$ref:"#/definitions/types.SingleUndiscriminatedUnionTypeSchema"}}},required:["discriminated","union"],additionalProperties:!1},"types.AliasSchema":{type:"object",properties:{examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},type:{type:"string"},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]}},required:["type"],additionalProperties:!1},"types.TypeDeclarationSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/types.ObjectSchema"},{$ref:"#/definitions/types.EnumSchema"},{$ref:"#/definitions/types.DiscriminatedUnionSchema"},{$ref:"#/definitions/types.UndiscriminatedUnionSchema"},{$ref:"#/definitions/types.AliasSchema"}]},"service.GrpcTransport":{type:"object",properties:{"service-name":{type:"string"}},required:["service-name"],additionalProperties:!1},"service.ServiceTransport":{type:"object",properties:{grpc:{oneOf:[{$ref:"#/definitions/service.GrpcTransport"},{type:"null"}]}},additionalProperties:!1},"service.HttpMethodSchema":{type:"string",enum:["GET","POST","PUT","PATCH","DELETE"]},"variables.VariableReferenceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},variable:{type:"string"}},required:["variable"],additionalProperties:!1},"service.HttpPathParameterSchema":{anyOf:[{$ref:"#/definitions/types.TypeReferenceSchema"},{$ref:"#/definitions/variables.VariableReferenceSchema"}]},"service.QueryParameterTypeReferenceDetailed":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"allow-multiple":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpQueryParameterSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.QueryParameterTypeReferenceDetailed"}]},"service.TypeReferenceDeclarationWithEnvOverrideSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},env:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithEnvOverride":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverrideSchema"}]},"service.HttpHeaderSchema":{$ref:"#/definitions/service.TypeReferenceDeclarationWithEnvOverride"},"service.HttpReferencedRequestBodySchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"service.TypeReferenceDeclarationWithContentTypeSchema":{type:"object",properties:{type:{type:"string"},default:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},encoding:{oneOf:[{$ref:"#/definitions/encoding.EncodingSchema"},{type:"null"}]},validation:{oneOf:[{$ref:"#/definitions/validation.ValidationSchema"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpInlineRequestBodyPropertySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.TypeReferenceDeclarationWithContentTypeSchema"}]},"service.HttpInlineRequestBodySchema":{type:"object",properties:{extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},"extra-properties":{oneOf:[{type:"boolean"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpInlineRequestBodyPropertySchema"}},{type:"null"}]}},additionalProperties:!1},"service.HttpRequestBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpReferencedRequestBodySchema"},{$ref:"#/definitions/service.HttpInlineRequestBodySchema"}]},"service.HttpRequestSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"content-type":{oneOf:[{type:"string"},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/service.HttpRequestBodySchema"},{type:"null"}]}},additionalProperties:!1},"service.HttpRequest":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpRequestSchema"}]},"service.HttpResponseSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},property:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{oneOf:[{type:"integer"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseSchemaDetailed"}]},"service.StreamFormat":{type:"string",enum:["sse","json"]},"service.HttpResponseStreamSchemaDetailed":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"},format:{oneOf:[{$ref:"#/definitions/service.StreamFormat"},{type:"null"}]},terminator:{oneOf:[{type:"string"},{type:"null"}]}},required:["type"],additionalProperties:!1},"service.HttpResponseStreamSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/service.HttpResponseStreamSchemaDetailed"}]},"service.ResponseErrorWithDocsSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},error:{type:"string"}},required:["error"],additionalProperties:!1},"service.ResponseError":{anyOf:[{type:"string"},{$ref:"#/definitions/service.ResponseErrorWithDocsSchema"}]},"service.ResponseErrorsSchema":{type:"array",items:{$ref:"#/definitions/service.ResponseError"}},"examples.ExampleTypeReferenceSchema":{type:["string","number","boolean","object","array","null"]},"examples.ExampleBodyResponseSchema":{type:"object",properties:{error:{oneOf:[{type:"string"},{type:"null"}]},body:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},additionalProperties:!1},"examples.ExampleStreamResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleSseEventSchema":{type:"object",properties:{event:{type:"string"},data:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]}},required:["event"],additionalProperties:!1},"examples.ExampleSseResponseSchema":{type:"object",properties:{stream:{type:"array",items:{$ref:"#/definitions/examples.ExampleSseEventSchema"}}},required:["stream"],additionalProperties:!1},"examples.ExampleResponseSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleBodyResponseSchema"},{$ref:"#/definitions/examples.ExampleStreamResponseSchema",description:"JSON Streams"},{$ref:"#/definitions/examples.ExampleSseResponseSchema",description:"Server-Sent Event streams"}]},"examples.SupportedSdkLanguageSchema":{type:"string",enum:["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]},"examples.ExampleCodeSampleSchemaSdk":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},sdk:{$ref:"#/definitions/examples.SupportedSdkLanguageSchema"},code:{type:"string"}},required:["sdk","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchemaLanguage":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},name:{oneOf:[{type:"string"},{type:"null"}]},language:{type:"string"},code:{type:"string"},install:{oneOf:[{type:"string"},{type:"null"}]}},required:["language","code"],additionalProperties:!1},"examples.ExampleCodeSampleSchema":{anyOf:[{$ref:"#/definitions/examples.ExampleCodeSampleSchemaSdk"},{$ref:"#/definitions/examples.ExampleCodeSampleSchemaLanguage"}]},"examples.ExampleEndpointCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/examples.ExampleResponseSchema"},{type:"null"}]},"code-samples":{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleCodeSampleSchema"}},{type:"null"}]}},additionalProperties:!1},"pagination.CursorPaginationSchema":{type:"object",properties:{cursor:{type:"string"},next_cursor:{type:"string"},results:{type:"string"}},required:["cursor","next_cursor","results"],additionalProperties:!1},"pagination.OffsetPaginationSchema":{type:"object",properties:{offset:{type:"string"},results:{type:"string"},step:{oneOf:[{type:"string"},{type:"null"}]},"has-next-page":{oneOf:[{type:"string"},{type:"null"}]}},required:["offset","results"],additionalProperties:!1},"pagination.PaginationSchema":{anyOf:[{$ref:"#/definitions/pagination.CursorPaginationSchema"},{$ref:"#/definitions/pagination.OffsetPaginationSchema"}]},"service.Pagination":{anyOf:[{$ref:"#/definitions/pagination.PaginationSchema"},{type:"boolean"}]},"service.HttpEndpointSchema":{type:"object",properties:{"display-name":{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},method:{oneOf:[{$ref:"#/definitions/service.HttpMethodSchema"},{type:"null"}]},"base-path":{oneOf:[{type:"string"},{type:"null"}]},path:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},auth:{oneOf:[{type:"boolean"},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},"stream-condition":{oneOf:[{type:"string"},{type:"null"}]},request:{oneOf:[{$ref:"#/definitions/service.HttpRequest"},{type:"null"}]},response:{oneOf:[{$ref:"#/definitions/service.HttpResponseSchema"},{type:"null"}]},"response-stream":{oneOf:[{$ref:"#/definitions/service.HttpResponseStreamSchema"},{type:"null"}]},errors:{oneOf:[{$ref:"#/definitions/service.ResponseErrorsSchema"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleEndpointCallSchema"}},{type:"null"}]},pagination:{oneOf:[{$ref:"#/definitions/service.Pagination"},{type:"null"}]}},required:["path"],additionalProperties:!1},"service.HttpServiceSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},url:{oneOf:[{type:"string"},{type:"null"}]},"base-path":{type:"string"},"path-parameters":{oneOf:[{type:"object",additionalProperties:{type:"string"}},{type:"null"}]},idempotent:{oneOf:[{type:"boolean"},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.TypeReferenceSchema"}},{type:"null"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{type:"null"}]},endpoints:{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpEndpointSchema"}}},required:["auth","base-path","endpoints"],additionalProperties:!1},"errors.ErrorDeclarationSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},"status-code":{type:"integer"},type:{oneOf:[{type:"string"},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleTypeSchema"}},{type:"null"}]}},required:["status-code"],additionalProperties:!1},"webhooks.WebhookMethodSchema":{type:"string",enum:["POST","GET"]},"webhooks.WebhookReferencedPayloadSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"webhooks.WebhookInlinedPayloadSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"webhooks.WebhookPayloadSchema":{anyOf:[{type:"string"},{$ref:"#/definitions/webhooks.WebhookReferencedPayloadSchema"},{$ref:"#/definitions/webhooks.WebhookInlinedPayloadSchema"}]},"examples.ExampleWebhookCallSchema":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},id:{oneOf:[{type:"string"},{type:"null"}]},payload:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},required:["payload"],additionalProperties:!1},"webhooks.WebhookSchema":{type:"object",properties:{availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},method:{$ref:"#/definitions/webhooks.WebhookMethodSchema"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},payload:{$ref:"#/definitions/webhooks.WebhookPayloadSchema"},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebhookCallSchema"}},{type:"null"}]}},required:["method","payload"],additionalProperties:!1},"websocket.WebSocketOrigin":{type:"string",enum:["client","server"]},"websocket.WebSocketChannelReferencedMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},type:{type:"string"}},required:["type"],additionalProperties:!1},"websocket.WebSocketChannelInlinedMessageSchema":{type:"object",properties:{name:{type:"string"},extends:{oneOf:[{$ref:"#/definitions/types.ObjectExtendsSchema"},{type:"null"}]},properties:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/types.ObjectPropertySchema"}},{type:"null"}]}},required:["name"],additionalProperties:!1},"websocket.WebSocketChannelMessageBodySchema":{anyOf:[{type:"string"},{$ref:"#/definitions/websocket.WebSocketChannelReferencedMessageSchema"},{$ref:"#/definitions/websocket.WebSocketChannelInlinedMessageSchema"}]},"websocket.WebSocketChannelMessageSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},origin:{$ref:"#/definitions/websocket.WebSocketOrigin"},body:{$ref:"#/definitions/websocket.WebSocketChannelMessageBodySchema"}},required:["origin","body"],additionalProperties:!1},"examples.ExampleWebSocketMessage":{type:"object",properties:{type:{type:"string"},body:{type:["string","number","boolean","object","array","null"]}},required:["type","body"],additionalProperties:!1},"examples.ExampleWebSocketSession":{type:"object",properties:{name:{oneOf:[{type:"string"},{type:"null"}]},docs:{oneOf:[{type:"string"},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/examples.ExampleTypeReferenceSchema"}},{type:"null"}]},messages:{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketMessage"}}},required:["messages"],additionalProperties:!1},"websocket.WebSocketChannelSchema":{type:"object",properties:{docs:{oneOf:[{type:"string"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/availability.AvailabilityUnionSchema"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},"display-name":{oneOf:[{type:"string"},{type:"null"}]},auth:{type:"boolean"},path:{type:"string"},headers:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpHeaderSchema"}},{type:"null"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{type:"null"}]},"query-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpQueryParameterSchema"}},{type:"null"}]},messages:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/websocket.WebSocketChannelMessageSchema"}},{type:"null"}]},examples:{oneOf:[{type:"array",items:{$ref:"#/definitions/examples.ExampleWebSocketSession"}},{type:"null"}]}},required:["auth","path"],additionalProperties:!1},"file.Navigation":{anyOf:[{type:"string"},{type:"array",items:{type:"string"}}]},"file.ExportDetailed":{type:"object",properties:{dependency:{type:"string"},url:{oneOf:[{type:"string"},{type:"null"}]}},required:["dependency"],additionalProperties:!1},"file.Export":{anyOf:[{type:"string"},{$ref:"#/definitions/file.ExportDetailed"}]}},zR1={type:qR1,properties:IR1,additionalProperties:BR1,definitions:NR1};function aCf({files:e,absolutePathToDefinition:t}){let r,n={},i={},a={};for(let[u,f]of o8(e)){let d=f.contents,c=o=>{a[u]={type:wj.JSONSCHEMA_VALIDATION,error:o}};if(u===u5){let o=Tfi(d,ggu);if(o.success){let l=hie.serialization.RootApiFileSchema.parseOrThrow(d);r={defaultUrl:l["default-url"],contents:l,rawContents:f.rawContents}}else c(o)}else if(iCf.default.basename(u)===QA){let o=Tfi(d,mgu);if(o.success){let l=hie.serialization.PackageMarkerFileSchema.parseOrThrow(d);i[u]={defaultUrl:typeof l.export=="object"?l.export.url:void 0,contents:l,rawContents:f.rawContents}}else c(o)}else{let o=Tfi(d,bgu);if(o.success){let l=hie.serialization.DefinitionFileSchema.parseOrThrow(d);n[u]={defaultUrl:void 0,contents:l,rawContents:f.rawContents,absoluteFilePath:yf(t,u)}}else c(o)}}return r==null?{didSucceed:!1,failures:{[Ms.of(u5)]:{type:wj.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:n,rootApiFile:r,packageMarkers:i}}var Z6t=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type="api";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 k6t=class extends Z6t{definition;sources;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]}};function H8r(e,t={}){return{...Object.fromEntries(o8(e.namedDefinitionFiles).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...o8(e.importedDefinitions).reduce((r,[n,i])=>({...r,...tfi(H8r(i.definition,{defaultURL:i.url}),(a,u)=>yf(n,Ms.of(u)))}),{})}}function Dvi(e,t={}){return{...Object.fromEntries(o8(e.packageMarkers).map(([r,n])=>[r,{...n,defaultUrl:t.defaultURL}])),...o8(e.importedDefinitions).reduce((r,[n,i])=>({...r,...tfi(Dvi(i.definition,{defaultURL:i.url}),(a,u)=>yf(n,Ms.of(u)))}),{})}}function YEr(e){return{...Dvi(e),...H8r(e)}}function Uie(e,t){return YEr(e.definition)[t]?.contents}var oCf=tu(require("path"),1);async function x8(e,t){for(let[r,n]of o8(YEr(e.definition)))await t(r,n.contents,{isPackageMarker:oCf.default.basename(r)===QA,defaultUrl:n.defaultUrl})}async function Trn(e,t){for(let[r,n]of o8(Dvi(e.definition)))await t(r,n.contents)}var D3n=class extends Z6t{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...n}){super(n),this.context=t,this.loadAPIWorkspace=r}async getDefinition({context:t},r){return(await this.toFernWorkspace({context:t},r)).definition}async toFernWorkspace({context:t},r){let n=(0,uCf.default)(r??{}),i=this.fernWorkspaces[n];if(i==null){let a=t||this.context,u=yf(this.absoluteFilePath,Ms.of(AL)),f=await KYi.loadDependenciesConfiguration({absolutePathToWorkspace:this.absoluteFilePath,context:a}),d=await tCf(u,"{yml,yaml}"),c=await rCf(d);if(!c.didSucceed)return rOa(c.failures,a.logger),a.failAndThrow();let o=aCf({files:c.files,absolutePathToDefinition:u});if(!o.didSucceed)return rOa(o.failures,a.logger),a.failAndThrow();let l=await nCf({dependenciesConfiguration:f,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!l.didSucceed)return rOa(l.failures,a.logger),a.failAndThrow();i=new k6t({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:f,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:l.packageMarkers,importedDefinitions:l.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[n]=i}return i}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var XEr={openapi:e=>({...e,type:"openapi",_visit:function(t){return XEr._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return XEr._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 S3n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return S3n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var aU={basic:e=>({...e,type:"basic",_visit:function(t){return aU._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return aU._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return aU._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return aU._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return aU._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 n1={primitive:e=>({value:e,type:"primitive",_visit:function(t){return n1._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return n1._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return n1._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return n1._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return n1._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return n1._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return n1._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return n1._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 _0={int:e=>({value:e,type:"int",_visit:function(t){return _0._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return _0._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return _0._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return _0._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return _0._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return _0._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return _0._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return _0._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return _0._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return _0._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return _0._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 E3n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return E3n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return E3n._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 Q8r={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return Q8r._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return Q8r._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undisciminated":return t.undisciminated(e.value);default:return t._other(e)}}};var xH={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case xH.GenerallyAvailable:return t.generallyAvailable();case xH.Beta:return t.beta();case xH.Deprecated:return t.deprecated();default:return t._other()}}};var ZEr={cursor:e=>({...e,type:"cursor",_visit:function(t){return ZEr._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return ZEr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);default:return t._other(e)}}};var kEr={language:e=>({...e,type:"language",_visit:function(t){return kEr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return kEr._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 TH={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 TH.Curl:return t.curl();case TH.Python:return t.python();case TH.Javascript:return t.javascript();case TH.Typescript:return t.typescript();case TH.Go:return t.go();case TH.Ruby:return t.ruby();case TH.Csharp:return t.csharp();case TH.Java:return t.java();case TH.Js:return t.js();case TH.Node:return t.node();case TH.Ts:return t.ts();case TH.Nodets:return t.nodets();case TH.Golang:return t.golang();case TH.Dotnet:return t.dotnet();case TH.Jvm:return t.jvm();default:return t._other()}}};var eIt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return eIt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return eIt._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 tIt={withStreaming:e=>({value:e,type:"withStreaming",_visit(t){return tIt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit(t){return tIt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e.value);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var h$={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case h$.Get:return t.get();case h$.Post:return t.post();case h$.Put:return t.put();case h$.Patch:return t.patch();case h$.Delete:return t.delete();case h$.Head:return t.head();case h$.Options:return t.options();case h$.Trace:return t.trace();default:return t._other()}}};var J8r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return J8r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return J8r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return J8r._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);default:return t._other(e)}}};var KCe={file:e=>({...e,type:"file",_visit:function(t){return KCe._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return KCe._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 Vie={file:e=>({...e,type:"file",_visit:function(t){return Vie._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Vie._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Vie._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Vie._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Vie._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Vie._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"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var vb={primitive:e=>({...e,type:"primitive",_visit:function(t){return vb._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return vb._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return vb._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return vb._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return vb._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return vb._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return vb._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return vb._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return vb._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return vb._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return vb._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 PD={int:e=>({...e,type:"int",_visit:function(t){return PD._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return PD._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return PD._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return PD._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return PD._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return PD._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return PD._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return PD._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return PD._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return PD._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return PD._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 O4={boolean:e=>({value:e,type:"boolean",_visit:function(t){return O4._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return O4._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 eAr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return eAr._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return eAr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var YCe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return YCe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return YCe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return YCe._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);default:return t._other(e)}}};var P4={file:e=>({...e,type:"file",_visit(t){return P4._visit(this,t)}}),json:e=>({...e,type:"json",_visit(t){return P4._visit(this,t)}}),text:e=>({...e,type:"text",_visit(t){return P4._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit(t){return P4._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit(t){return P4._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit(t){return P4._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"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Qp={primitive:e=>({...e,type:"primitive",_visit:function(t){return Qp._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Qp._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Qp._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Qp._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Qp._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Qp._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Qp._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Qp._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Qp._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Qp._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Qp._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 UZ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return UZ._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return UZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undisciminated":return t.undisciminated(e);default:return t._other(e)}}};var Ey={int:e=>({...e,type:"int",_visit:function(t){return Ey._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Ey._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Ey._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Ey._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Ey._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Ey._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Ey._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Ey._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Ey._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Ey._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Ey._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 Tg={};_l(Tg,{AllOfPropertyConflict:()=>G3n,ArraySchema:()=>hPa,ArraySchemaWithExample:()=>WPa,Availability:()=>dOa,Base64WithExample:()=>RPa,BasicSecurityScheme:()=>hOa,BearerSecurityScheme:()=>yOa,BooleanSchema:()=>cPa,BooleanWithExample:()=>FPa,CasingOverrides:()=>gOa,CommonProperty:()=>wPa,CommonPropertyWithExample:()=>ZPa,CursorPagination:()=>$Oa,CustomCodeSample:()=>JOa,CustomCodeSampleLanguage:()=>WOa,CustomCodeSampleSdk:()=>QOa,DateWithExample:()=>zPa,DatetimeWithExample:()=>NPa,DiscriminatedOneOfSchema:()=>OPa,DiscriminatedOneOfSchemaWithExample:()=>YPa,DoubleSchema:()=>uPa,DoubleWithExample:()=>IPa,Encoding:()=>fOa,Endpoint:()=>YOa,EndpointExample:()=>H3n,EndpointResponseExample:()=>VOa,EndpointSdkName:()=>ezr,EndpointWithExample:()=>NCf,EnumSchema:()=>C3n,EnumSchemaWithExample:()=>UPa,EnumValue:()=>K8r,ErrorExample:()=>ROa,FernExample:()=>LOa,FileResponse:()=>L3n,FileSchema:()=>COa,FloatWithExample:()=>qPa,FullEndpointExample:()=>GOa,FullExample:()=>J2,FullObjectExample:()=>EOa,FullOneOfExample:()=>MOa,GlobalHeader:()=>fPa,Header:()=>k8r,HeaderExample:()=>W3n,HeaderSecurityScheme:()=>vOa,HeaderWithExample:()=>Y3n,HttpEndpointServer:()=>U3n,HttpError:()=>FOa,HttpErrorWithExample:()=>APa,HttpMethod:()=>B3n,IdempotencyHeader:()=>dPa,Int64WithExample:()=>xPa,IntSchema:()=>aPa,IntWithExample:()=>MPa,JsonRequest:()=>BOa,JsonRequestWithExample:()=>DPa,JsonResponse:()=>tzr,JsonResponseWithExample:()=>Mvi,KeyValuePair:()=>AOa,LiteralExample:()=>SOa,LiteralSchema:()=>J3n,LiteralSchemaValue:()=>pPa,LongSchema:()=>oPa,MapSchema:()=>yPa,MapSchemaWithExample:()=>HPa,MultipartRequest:()=>F3n,MultipartRequestProperty:()=>IOa,MultipartSchema:()=>qOa,NamedFullExample:()=>kFt,Namespace:()=>mOa,NamespaceId:()=>DOa,NullableSchema:()=>bPa,NullableSchemaWithExample:()=>JPa,OauthSecurityScheme:()=>POa,ObjectProperty:()=>mPa,ObjectPropertyConflictInfo:()=>$3n,ObjectPropertyWithExample:()=>KPa,ObjectSchema:()=>_Pa,ObjectSchemaWithExample:()=>GPa,OctetStreamRequest:()=>R3n,OffsetPagination:()=>KOa,OneOfSchema:()=>gPa,OneOfSchemaWithExample:()=>$Pa,OpenApiIntermediateRepresentation:()=>ICf,OpenApiSource:()=>uOa,OptionalSchema:()=>vPa,OptionalSchemaWithExample:()=>QPa,Pagination:()=>Q3n,PathParameter:()=>N3n,PathParameterExample:()=>UOa,PathParameterWithExample:()=>jPa,PrimitiveExample:()=>I3n,PrimitiveSchema:()=>nzr,PrimitiveSchemaValue:()=>lPa,PrimitiveSchemaValueWithExample:()=>LPa,PrimitiveSchemaWithExample:()=>X3n,PropertyKey:()=>q3n,ProtobufEncoding:()=>lOa,ProtobufSource:()=>sOa,QueryParameter:()=>z3n,QueryParameterExample:()=>V3n,QueryParameterWithExample:()=>K3n,QuerySecurityScheme:()=>bOa,ReferencedSchema:()=>ZFt,Request:()=>NOa,RequestWithExample:()=>SPa,Response:()=>zOa,ResponseWithExample:()=>EPa,Schema:()=>Y1,SchemaId:()=>VZ,SchemaWithExample:()=>QC,Schemas:()=>iPa,SdkGroup:()=>OOa,SdkGroupInfo:()=>xOa,SdkGroupName:()=>Y8r,SecurityScheme:()=>wOa,SecuritySchemeId:()=>_Oa,Server:()=>jOa,Source:()=>cOa,StatusCode:()=>X8r,StringSchema:()=>sPa,StringSchemaWithExample:()=>BPa,SupportedSdkLanguage:()=>HOa,Tag:()=>pOa,TagId:()=>tDe,Tags:()=>TOa,TextResponse:()=>rzr,Uint64WithExample:()=>CPa,UintWithExample:()=>TPa,UnDiscriminatedOneOfSchema:()=>PPa,UnDiscriminatedOneOfSchemaWithExample:()=>XPa,UnknownSchemaWithExample:()=>VPa,Webhook:()=>kOa,WebhookExampleCall:()=>ZOa,WebhookHttpMethod:()=>XOa,WebsocketChannel:()=>nPa,WebsocketHandshake:()=>ePa,WebsocketHandshakeWithExample:()=>BCf,WebsocketMessageExample:()=>tPa,WebsocketSessionExample:()=>rPa,WithAvailability:()=>dv,WithDescription:()=>A_,WithEncoding:()=>Wie,WithName:()=>dO,WithNamespace:()=>Z8r,WithSdkGroupName:()=>K1,WithSource:()=>Ab,WithTitle:()=>$1,commons:()=>Dgu,example:()=>Sgu,finalIr:()=>Egu,parseIr:()=>Agu});var Dgu={};_l(Dgu,{BasicSecurityScheme:()=>hOa,BearerSecurityScheme:()=>yOa,Encoding:()=>fOa,HeaderSecurityScheme:()=>vOa,Namespace:()=>mOa,NamespaceId:()=>DOa,OauthSecurityScheme:()=>POa,OpenApiSource:()=>uOa,ProtobufEncoding:()=>lOa,ProtobufSource:()=>sOa,QuerySecurityScheme:()=>bOa,SchemaId:()=>VZ,SdkGroup:()=>OOa,SdkGroupName:()=>Y8r,SecurityScheme:()=>wOa,SecuritySchemeId:()=>_Oa,Server:()=>jOa,Source:()=>cOa,StatusCode:()=>X8r,Tag:()=>pOa,TagId:()=>tDe,WithAvailability:()=>dv,WithDescription:()=>A_,WithEncoding:()=>Wie,WithName:()=>dO,WithNamespace:()=>Z8r,WithSdkGroupName:()=>K1,WithSource:()=>Ab,WithTitle:()=>$1});var Fn={};_l(Fn,{JsonError:()=>A3n,ParseError:()=>M3n,any:()=>OCf,boolean:()=>PCf,booleanLiteral:()=>mCf,date:()=>cCf,discriminant:()=>TCf,enum_:()=>iOa,getObjectLikeUtils:()=>XFt,getObjectUtils:()=>T3n,getSchemaUtils:()=>_6,isProperty:()=>$8r,lazy:()=>lCf,lazyObject:()=>vCf,list:()=>oOa,number:()=>wCf,object:()=>aOa,objectWithoutOptionalProperties:()=>yCf,optional:()=>Ogu,property:()=>dCf,record:()=>ECf,set:()=>ACf,string:()=>jCf,stringLiteral:()=>gCf,transform:()=>Pgu,undiscriminatedUnion:()=>xCf,union:()=>qCf,unknown:()=>DCf,withParsedProperties:()=>jgu});var hE={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 Q2(e,t){return`Expected ${t}. Received ${RR1(e)}.`}function RR1(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function y$(e){return{...e,json:sCf(e.json),parse:sCf(e.parse)}}function sCf(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(`
1950
1950
  `)),{ok:!0,value:t}):n}}function nOa(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var A3n=class e extends Error{errors;constructor(t){super(t.map(nOa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var M3n=class e extends Error{errors;constructor(t){super(t.map(nOa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function _6(e){return{optional:()=>Ogu(e),transform:t=>Pgu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new M3n(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new A3n(n.errors)}}}function Ogu(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:()=>hE.OPTIONAL};return{...t,..._6(t)}}function Pgu(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,..._6(r)}}var FR1=/^([+-]?\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 cCf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:Q2(t,"string")}]}:FR1.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:Q2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:Q2(t,"Date object")}]},getType:()=>hE.DATE};return{...y$(e),..._6(e)}}function v$(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...y$(r),..._6(r)}}}function iOa(e){let t=new Set(e);return v$(hE.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:Q2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:Q2(n,"enum")}]}:{ok:!0,value:n})()}function lCf(e){let t=wgu(e);return{...t,..._6(t)}}function wgu(e){return{parse:(t,r)=>x3n(e).parse(t,r),json:(t,r)=>x3n(e).json(t,r),getType:()=>x3n(e).getType()}}function x3n(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Svi(e){return Object.entries(e)}function Evi(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function G8r(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 Avi(e){return Object.keys(e)}function fCf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function XFt(e){return{withParsedProperties:t=>jgu(e,t)}}function jgu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!G8r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:Q2(n,"object")}]};let a=new Set(Object.keys(t)),u=Evi(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,..._6(r),...XFt(r)}}function dCf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function $8r(e){return e.isProperty}function aOa(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>$8r(n)?n.rawKey:r),_getParsedProperties:()=>Avi(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of Svi(e)){let d=$8r(f)?f.rawKey:u,c=$8r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,hCf(c)&&a.push(d)}return pCf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...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 Svi(e)){let f=$8r(u)?u.valueSchema:u;hCf(f)&&i.push(a)}return pCf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return $8r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>hE.OBJECT};return{...y$(t),..._6(t),...XFt(t),...T3n(t)}}function pCf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!G8r(e))return{ok:!1,errors:[{path:a,message:Q2(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let g=l.transform(o);g.ok?d[l.transformedKey]=g.value:(d[c]=o,f.push(...g.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function T3n(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>_Cf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>_Cf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>hE.OBJECT};return{...r,..._6(r),...XFt(r),...T3n(r)}}}}function _Cf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=fCf(Avi(t),c=>i.has(c)),f=r(Evi(t,u)),d=n(Evi(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function hCf(e){return!LR1(e)}function LR1(e){switch(e.getType()){case hE.ANY:case hE.UNKNOWN:case hE.OPTIONAL:return!0;default:return!1}}function yCf(e){return aOa(e)}function vCf(e){let t={...wgu(e),_getRawProperties:()=>x3n(e)._getRawProperties(),_getParsedProperties:()=>x3n(e)._getParsedProperties()};return{...t,..._6(t),...XFt(t),...T3n(t)}}function oOa(e){let t={parse:(r,n)=>bCf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>bCf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>hE.LIST};return{...y$(t),..._6(t)}}function bCf(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:Q2(e,"list"),path:[]}]}}function gCf(e){return v$(hE.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Q2(r,`"${e}"`)}]})()}function mCf(e){return v$(hE.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:Q2(r,`${e.toString()}`)}]})()}var OCf=v$(hE.ANY,e=>({ok:!0,value:e}));var PCf=v$(hE.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Q2(e,"boolean")}]});var wCf=v$(hE.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Q2(e,"number")}]});var jCf=v$(hE.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:Q2(e,"string")}]});var DCf=v$(hE.UNKNOWN,e=>({ok:!0,value:e}));function ECf(e,t){let r={parse:(n,i)=>SCf({value:n,isKeyNumeric:e.getType()===hE.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)=>SCf({value:n,isKeyNumeric:e.getType()===hE.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:()=>hE.RECORD};return{...y$(r),..._6(r)}}function SCf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return G8r(e)?Svi(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let g=[];return d.ok||g.push(...d.errors),o.ok||g.push(...o.errors),l.ok||g.push(...l.errors),{ok:!1,errors:g}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:Q2(e,"object")}]}}function ACf(e){let t=oOa(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:Q2(n,"Set")}]},getType:()=>hE.SET};return{...y$(r),..._6(r)}}function xCf(e){let t={parse:(r,n)=>MCf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>MCf((i,a)=>i.json(r,a),e,n),getType:()=>hE.UNDISCRIMINATED_UNION};return{...y$(t),..._6(t)}}function MCf(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 f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function TCf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function qCf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=iOa(Avi(t)),a={parse:(u,f)=>CCf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>CCf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>hE.UNION};return{...y$(a),..._6(a),...XFt(a)}}function CCf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!G8r(e))return{ok:!1,errors:[{path:f,message:Q2(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);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,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let g=u(c,l);return g.ok?{ok:!0,value:{[r]:d,...g.value}}:g}var $1=Fn.objectWithoutOptionalProperties({title:Fn.string().optional()});var uOa=Fn.objectWithoutOptionalProperties({file:Fn.string()});var sOa=Fn.objectWithoutOptionalProperties({file:Fn.string()});var cOa=Fn.union("type",{openapi:uOa,protobuf:sOa}).transform({transform:e=>{switch(e.type){case"openapi":return XEr.openapi(e);case"protobuf":return XEr.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ab=Fn.objectWithoutOptionalProperties({source:cOa.optional()});var lOa=Fn.objectWithoutOptionalProperties({typeName:Fn.string()});var fOa=Fn.union("type",{protobuf:lOa}).transform({transform:e=>{switch(e.type){case"protobuf":return S3n.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wie=Fn.objectWithoutOptionalProperties({encoding:fOa.optional()});var A_=Fn.objectWithoutOptionalProperties({description:Fn.string().optional()});var dOa=Fn.enum_(["GenerallyAvailable","Beta","Deprecated"]);var dv=Fn.objectWithoutOptionalProperties({availability:dOa.optional()});var dO=Fn.objectWithoutOptionalProperties({nameOverride:Fn.string().optional(),generatedName:Fn.string()});var VZ=Fn.string();var tDe=Fn.string();var pOa=Fn.objectWithoutOptionalProperties({id:tDe}).extend(A_);var _Oa=Fn.string();var hOa=Fn.objectWithoutOptionalProperties({usernameVariableName:Fn.string().optional(),usernameEnvVar:Fn.string().optional(),passwordVariableName:Fn.string().optional(),passwordEnvVar:Fn.string().optional()});var yOa=Fn.objectWithoutOptionalProperties({tokenVariableName:Fn.string().optional(),tokenEnvVar:Fn.string().optional()});var vOa=Fn.objectWithoutOptionalProperties({headerName:Fn.string(),prefix:Fn.string().optional(),headerVariableName:Fn.string().optional(),headerEnvVar:Fn.string().optional()});var bOa=Fn.objectWithoutOptionalProperties({queryParameterName:Fn.string()});var gOa=Fn.objectWithoutOptionalProperties({snake:Fn.string().optional(),camel:Fn.string().optional(),screamingSnake:Fn.string().optional(),pascal:Fn.string().optional()});var K8r=Fn.objectWithoutOptionalProperties({nameOverride:Fn.string().optional(),generatedName:Fn.string(),value:Fn.string(),casing:gOa.optional()}).extend(A_).extend(dv);var mOa=Fn.objectWithoutOptionalProperties({type:Fn.stringLiteral("namespace"),name:Fn.string()});var OOa=Fn.undiscriminatedUnion([Fn.string(),mOa]);var Y8r=Fn.list(OOa);var K1=Fn.objectWithoutOptionalProperties({groupName:Y8r.optional()});var C3n=Fn.objectWithoutOptionalProperties({default:K8r.optional(),values:Fn.list(K8r)}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Ab).extend($1);var POa=Fn.objectWithoutOptionalProperties({scopesEnum:C3n.optional()});var wOa=Fn.union("type",{basic:hOa,bearer:yOa,header:vOa,query:bOa,oauth:POa}).transform({transform:e=>{switch(e.type){case"basic":return aU.basic(e);case"bearer":return aU.bearer(e);case"header":return aU.header(e);case"query":return aU.query(e);case"oauth":return aU.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var X8r=Fn.number();var jOa=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),url:Fn.string(),audiences:Fn.list(Fn.string()).optional()}).extend(A_);var DOa=Fn.string();var Z8r=Fn.objectWithoutOptionalProperties({namespace:Fn.string().optional()});var Sgu={};_l(Sgu,{FullExample:()=>J2,FullObjectExample:()=>EOa,FullOneOfExample:()=>MOa,KeyValuePair:()=>AOa,LiteralExample:()=>SOa,PrimitiveExample:()=>I3n,PropertyKey:()=>q3n});var q3n=Fn.string();var I3n=Fn.union("type",{int:Fn.object({value:Fn.number()}),int64:Fn.object({value:Fn.number()}),uint:Fn.object({value:Fn.number()}),uint64:Fn.object({value:Fn.number()}),float:Fn.object({value:Fn.number()}),double:Fn.object({value:Fn.number()}),string:Fn.object({value:Fn.string()}),datetime:Fn.object({value:Fn.string()}),date:Fn.object({value:Fn.string()}),base64:Fn.object({value:Fn.string()}),boolean:Fn.object({value:Fn.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return _0.int(e.value);case"int64":return _0.int64(e.value);case"uint":return _0.uint(e.value);case"uint64":return _0.uint64(e.value);case"float":return _0.float(e.value);case"double":return _0.double(e.value);case"string":return _0.string(e.value);case"datetime":return _0.datetime(e.value);case"date":return _0.date(e.value);case"base64":return _0.base64(e.value);case"boolean":return _0.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var SOa=Fn.union("type",{boolean:Fn.object({value:Fn.boolean()}),string:Fn.object({value:Fn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return E3n.boolean(e.value);case"string":return E3n.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var J2=Fn.union("type",{primitive:Fn.object({value:I3n}),object:Fn.lazyObject(()=>EOa),array:Fn.object({value:Fn.list(Fn.lazy(()=>J2))}),map:Fn.object({value:Fn.list(Fn.lazyObject(()=>AOa))}),enum:Fn.object({value:Fn.string()}),literal:Fn.object({value:SOa}),oneOf:Fn.object({value:Fn.lazy(()=>MOa)}),unknown:Fn.object({value:Fn.lazy(()=>J2)})}).transform({transform:e=>{switch(e.type){case"primitive":return n1.primitive(e.value);case"object":return n1.object(e);case"array":return n1.array(e.value);case"map":return n1.map(e.value);case"enum":return n1.enum(e.value);case"literal":return n1.literal(e.value);case"oneOf":return n1.oneOf(e.value);case"unknown":return n1.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var EOa=Fn.objectWithoutOptionalProperties({properties:Fn.record(q3n,Fn.lazy(()=>J2))});var AOa=Fn.objectWithoutOptionalProperties({key:I3n,value:Fn.lazy(()=>J2)});var MOa=Fn.union("type",{discriminated:Fn.object({value:Fn.record(q3n,Fn.lazy(()=>J2))}),undisciminated:Fn.object({value:Fn.lazy(()=>J2)})}).transform({transform:e=>{switch(e.type){case"discriminated":return Q8r.discriminated(e.value);case"undisciminated":return Q8r.undisciminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Egu={};_l(Egu,{AllOfPropertyConflict:()=>G3n,ArraySchema:()=>hPa,Availability:()=>dOa,BooleanSchema:()=>cPa,CasingOverrides:()=>gOa,CommonProperty:()=>wPa,CursorPagination:()=>$Oa,CustomCodeSample:()=>JOa,CustomCodeSampleLanguage:()=>WOa,CustomCodeSampleSdk:()=>QOa,DiscriminatedOneOfSchema:()=>OPa,DoubleSchema:()=>uPa,Endpoint:()=>YOa,EndpointExample:()=>H3n,EndpointResponseExample:()=>VOa,EndpointSdkName:()=>ezr,EnumSchema:()=>C3n,EnumValue:()=>K8r,ErrorExample:()=>ROa,FernExample:()=>LOa,FileResponse:()=>L3n,FileSchema:()=>COa,FullEndpointExample:()=>GOa,GlobalHeader:()=>fPa,Header:()=>k8r,HeaderExample:()=>W3n,HttpEndpointServer:()=>U3n,HttpError:()=>FOa,HttpMethod:()=>B3n,IdempotencyHeader:()=>dPa,IntSchema:()=>aPa,JsonRequest:()=>BOa,JsonResponse:()=>tzr,LiteralSchema:()=>J3n,LiteralSchemaValue:()=>pPa,LongSchema:()=>oPa,MapSchema:()=>yPa,MultipartRequest:()=>F3n,MultipartRequestProperty:()=>IOa,MultipartSchema:()=>qOa,NullableSchema:()=>bPa,ObjectProperty:()=>mPa,ObjectPropertyConflictInfo:()=>$3n,ObjectSchema:()=>_Pa,OctetStreamRequest:()=>R3n,OffsetPagination:()=>KOa,OneOfSchema:()=>gPa,OpenApiIntermediateRepresentation:()=>ICf,OptionalSchema:()=>vPa,Pagination:()=>Q3n,PathParameter:()=>N3n,PathParameterExample:()=>UOa,PrimitiveSchema:()=>nzr,PrimitiveSchemaValue:()=>lPa,QueryParameter:()=>z3n,QueryParameterExample:()=>V3n,ReferencedSchema:()=>ZFt,Request:()=>NOa,Response:()=>zOa,Schema:()=>Y1,Schemas:()=>iPa,SdkGroupInfo:()=>xOa,StringSchema:()=>sPa,SupportedSdkLanguage:()=>HOa,Tags:()=>TOa,TextResponse:()=>rzr,UnDiscriminatedOneOfSchema:()=>PPa,Webhook:()=>kOa,WebhookExampleCall:()=>ZOa,WebhookHttpMethod:()=>XOa,WebsocketChannel:()=>nPa,WebsocketHandshake:()=>ePa,WebsocketMessageExample:()=>tPa,WebsocketSessionExample:()=>rPa});var xOa=Fn.objectWithoutOptionalProperties({summary:Fn.string().optional(),description:Fn.string().optional()});var TOa=Fn.objectWithoutOptionalProperties({tagsById:Fn.record(tDe,pOa),orderedTagIds:Fn.list(tDe).optional()});var B3n=Fn.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var N3n=Fn.objectWithoutOptionalProperties({name:Fn.string(),schema:Fn.lazy(()=>Y1),variableReference:Fn.string().optional(),parameterNameOverride:Fn.string().optional()}).extend(A_).extend(dv).extend(Ab);var z3n=Fn.objectWithoutOptionalProperties({name:Fn.string(),schema:Fn.lazy(()=>Y1),parameterNameOverride:Fn.string().optional()}).extend(A_).extend(dv).extend(Ab);var k8r=Fn.objectWithoutOptionalProperties({name:Fn.string(),schema:Fn.lazy(()=>Y1),env:Fn.string().optional(),parameterNameOverride:Fn.string().optional()}).extend(A_).extend(dv).extend(Ab);var ezr=Fn.objectWithoutOptionalProperties({groupName:Y8r,methodName:Fn.string()});var R3n=Fn.objectWithoutOptionalProperties({}).extend(A_).extend(Ab);var COa=Fn.objectWithoutOptionalProperties({isOptional:Fn.boolean(),isArray:Fn.boolean()});var qOa=Fn.union("type",{file:COa,json:Fn.object({value:Fn.lazy(()=>Y1)})}).transform({transform:e=>{switch(e.type){case"file":return KCe.file(e);case"json":return KCe.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var IOa=Fn.objectWithoutOptionalProperties({key:Fn.string(),schema:qOa,contentType:Fn.string().optional()}).extend(A_);var F3n=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),properties:Fn.list(IOa)}).extend(A_).extend(Ab);var BOa=Fn.objectWithoutOptionalProperties({schema:Fn.lazy(()=>Y1),contentType:Fn.string().optional(),additionalProperties:Fn.boolean()}).extend(A_).extend(Ab);var NOa=Fn.union("type",{octetStream:R3n,multipart:F3n,json:BOa}).transform({transform:e=>{switch(e.type){case"octetStream":return J8r.octetStream(e);case"multipart":return J8r.multipart(e);case"json":return J8r.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var L3n=Fn.objectWithoutOptionalProperties({}).extend(A_).extend(Ab);var tzr=Fn.objectWithoutOptionalProperties({schema:Fn.lazy(()=>Y1),responseProperty:Fn.string().optional()}).extend(A_).extend(Ab);var rzr=Fn.objectWithoutOptionalProperties({}).extend(A_).extend(Ab);var zOa=Fn.union("type",{file:L3n,json:tzr,text:rzr,streamingSse:tzr,streamingText:rzr,streamingJson:tzr}).transform({transform:e=>{switch(e.type){case"file":return Vie.file(e);case"json":return Vie.json(e);case"text":return Vie.text(e);case"streamingSse":return Vie.streamingSse(e);case"streamingText":return Vie.streamingText(e);case"streamingJson":return Vie.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var ROa=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),description:Fn.string().optional(),example:Fn.lazy(()=>J2)});var FOa=Fn.objectWithoutOptionalProperties({schema:Fn.lazy(()=>Y1).optional(),examples:Fn.list(ROa).optional()}).extend(A_).extend(dO).extend(Ab);var U3n=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),url:Fn.string().optional(),audiences:Fn.list(Fn.string()).optional()});var LOa=Fn.unknown();var UOa=Fn.objectWithoutOptionalProperties({name:Fn.string(),parameterNameOverride:Fn.string().optional(),value:Fn.lazy(()=>J2)});var V3n=Fn.objectWithoutOptionalProperties({name:Fn.string(),value:Fn.lazy(()=>J2)});var W3n=Fn.objectWithoutOptionalProperties({name:Fn.string(),value:Fn.lazy(()=>J2)});var VOa=Fn.union("type",{withStreaming:Fn.object({value:Fn.list(Fn.lazy(()=>J2))}),withoutStreaming:Fn.object({value:Fn.lazy(()=>J2)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return tIt.withStreaming(e.value);case"withoutStreaming":return tIt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var WOa=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),language:Fn.string(),code:Fn.string(),install:Fn.string().optional()}).extend(A_);var HOa=Fn.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var QOa=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),sdk:HOa,code:Fn.string()}).extend(A_);var JOa=Fn.union("type",{language:WOa,sdk:QOa}).transform({transform:e=>{switch(e.type){case"language":return kEr.language(e);case"sdk":return kEr.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var GOa=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),pathParameters:Fn.list(UOa).optional(),queryParameters:Fn.list(V3n).optional(),headers:Fn.list(W3n).optional(),request:Fn.lazy(()=>J2).optional(),response:VOa.optional(),codeSamples:Fn.list(JOa)}).extend(A_);var H3n=Fn.union("type",{unknown:Fn.object({value:LOa}),full:GOa}).transform({transform:e=>{switch(e.type){case"unknown":return eIt.unknown(e.value);case"full":return eIt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var $Oa=Fn.objectWithoutOptionalProperties({cursor:Fn.string(),nextCursor:Fn.property("next_cursor",Fn.string()),results:Fn.string()});var KOa=Fn.objectWithoutOptionalProperties({offset:Fn.string(),results:Fn.string(),step:Fn.string().optional(),hasNextPage:Fn.string().optional()});var Q3n=Fn.union("type",{cursor:$Oa,offset:KOa}).transform({transform:e=>{switch(e.type){case"cursor":return ZEr.cursor(e);case"offset":return ZEr.offset(e);default:return e}},untransform:({_visit:e,...t})=>t});var YOa=Fn.objectWithoutOptionalProperties({authed:Fn.boolean(),internal:Fn.boolean().optional(),idempotent:Fn.boolean().optional(),method:B3n,audiences:Fn.list(Fn.string()),path:Fn.string(),summary:Fn.string().optional(),operationId:Fn.string().optional(),tags:Fn.list(tDe),pathParameters:Fn.list(N3n),queryParameters:Fn.list(z3n),headers:Fn.list(k8r),sdkName:ezr.optional(),generatedRequestName:Fn.string(),requestNameOverride:Fn.string().optional(),request:NOa.optional(),response:zOa.optional(),errors:Fn.record(X8r,FOa),server:Fn.list(U3n),examples:Fn.list(H3n),pagination:Q3n.optional()}).extend(A_).extend(dv).extend(Ab).extend(Z8r);var XOa=Fn.enum_(["GET","POST"]);var ZOa=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),payload:Fn.lazy(()=>J2)}).extend(A_);var kOa=Fn.objectWithoutOptionalProperties({sdkName:ezr.optional(),method:XOa,summary:Fn.string().optional(),operationId:Fn.string(),tags:Fn.list(tDe),headers:Fn.list(k8r),generatedPayloadName:Fn.string(),payload:Fn.lazy(()=>Y1),examples:Fn.list(ZOa)}).extend(A_).extend(Ab).extend(Z8r);var ePa=Fn.objectWithoutOptionalProperties({queryParameters:Fn.list(z3n),headers:Fn.list(k8r),pathParameters:Fn.list(N3n)});var tPa=Fn.objectWithoutOptionalProperties({messageType:Fn.string(),payload:Fn.lazy(()=>J2)}).extend(A_);var rPa=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),queryParameters:Fn.list(V3n).optional(),headers:Fn.list(W3n).optional(),messages:Fn.list(tPa)}).extend(A_);var nPa=Fn.objectWithoutOptionalProperties({path:Fn.string(),groupName:Y8r,summary:Fn.string().optional(),handshake:ePa,publish:Fn.lazy(()=>Y1).optional(),subscribe:Fn.lazy(()=>Y1).optional(),examples:Fn.list(rPa)}).extend(A_).extend(Ab);var iPa=Fn.objectWithoutOptionalProperties({rootSchemas:Fn.record(VZ,Fn.lazy(()=>Y1)),namespacedSchemas:Fn.record(DOa,Fn.record(VZ,Fn.lazy(()=>Y1)))});var aPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional(),minimum:Fn.number().optional(),maximum:Fn.number().optional(),exclusiveMinimum:Fn.boolean().optional(),exclusiveMaximum:Fn.boolean().optional(),multipleOf:Fn.number().optional()});var oPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional()});var uPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional(),minimum:Fn.number().optional(),maximum:Fn.number().optional(),exclusiveMinimum:Fn.boolean().optional(),exclusiveMaximum:Fn.boolean().optional(),multipleOf:Fn.number().optional()});var sPa=Fn.objectWithoutOptionalProperties({default:Fn.string().optional(),pattern:Fn.string().optional(),format:Fn.string().optional(),minLength:Fn.number().optional(),maxLength:Fn.number().optional()});var cPa=Fn.objectWithoutOptionalProperties({default:Fn.boolean().optional()});var lPa=Fn.union("type",{int:aPa,int64:oPa,uint:Fn.object({}),uint64:Fn.object({}),float:Fn.object({}),double:uPa,string:sPa,datetime:Fn.object({}),date:Fn.object({}),base64:Fn.object({}),boolean:cPa}).transform({transform:e=>{switch(e.type){case"int":return PD.int(e);case"int64":return PD.int64(e);case"uint":return PD.uint();case"uint64":return PD.uint64();case"float":return PD.float();case"double":return PD.double(e);case"string":return PD.string(e);case"datetime":return PD.datetime();case"date":return PD.date();case"base64":return PD.base64();case"boolean":return PD.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var nzr=Fn.objectWithoutOptionalProperties({schema:lPa}).extend(A_).extend(dO).extend(K1).extend(dv).extend($1);var fPa=Fn.objectWithoutOptionalProperties({header:Fn.string(),name:Fn.string().optional(),optional:Fn.boolean().optional(),env:Fn.string().optional(),schema:Fn.lazy(()=>Y1).optional()});var dPa=Fn.objectWithoutOptionalProperties({header:Fn.string(),name:Fn.string().optional(),env:Fn.string().optional(),schema:Fn.lazy(()=>Y1).optional()});var ICf=Fn.objectWithoutOptionalProperties({apiVersion:Fn.unknown().optional(),title:Fn.string().optional(),description:Fn.string().optional(),basePath:Fn.string().optional(),servers:Fn.list(jOa),groups:Fn.record(Fn.string(),xOa),tags:TOa,hasEndpointsMarkedInternal:Fn.boolean(),endpoints:Fn.list(YOa),webhooks:Fn.list(kOa),channel:Fn.list(nPa),groupedSchemas:iPa,variables:Fn.record(Fn.string(),nzr),nonRequestReferencedSchemas:Fn.set(VZ),securitySchemes:Fn.record(_Oa,wOa),globalHeaders:Fn.list(fPa).optional(),idempotencyHeaders:Fn.list(dPa).optional()});var ZFt=Fn.objectWithoutOptionalProperties({schema:VZ}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Ab).extend($1);var pPa=Fn.union("type",{boolean:Fn.object({value:Fn.boolean()}),string:Fn.object({value:Fn.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return O4.boolean(e.value);case"string":return O4.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var J3n=Fn.objectWithoutOptionalProperties({value:pPa}).extend(A_).extend(dO).extend(K1).extend(dv).extend($1);var Y1=Fn.union("type",{primitive:nzr,object:Fn.lazyObject(()=>_Pa),array:Fn.lazyObject(()=>hPa),map:Fn.lazyObject(()=>yPa),optional:Fn.lazyObject(()=>vPa),enum:C3n,reference:ZFt,literal:J3n,oneOf:Fn.object({value:Fn.lazy(()=>gPa)}),nullable:Fn.lazyObject(()=>bPa),unknown:dO}).transform({transform:e=>{switch(e.type){case"primitive":return vb.primitive(e);case"object":return vb.object(e);case"array":return vb.array(e);case"map":return vb.map(e);case"optional":return vb.optional(e);case"enum":return vb.enum(e);case"reference":return vb.reference(e);case"literal":return vb.literal(e);case"oneOf":return vb.oneOf(e.value);case"nullable":return vb.nullable(e);case"unknown":return vb.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var G3n=Fn.objectWithoutOptionalProperties({propertyKey:Fn.string(),allOfSchemaIds:Fn.list(VZ),conflictingTypeSignatures:Fn.boolean()});var _Pa=Fn.objectWithoutOptionalProperties({allOf:Fn.list(ZFt),properties:Fn.list(Fn.lazyObject(()=>mPa)),allOfPropertyConflicts:Fn.list(G3n),additionalProperties:Fn.boolean()}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Ab).extend($1);var $3n=Fn.objectWithoutOptionalProperties({differentSchema:Fn.boolean()});var mPa=Fn.objectWithoutOptionalProperties({key:Fn.string(),schema:Fn.lazy(()=>Y1),readonly:Fn.boolean().optional(),conflict:Fn.record(VZ,$3n),generatedName:Fn.string(),nameOverride:Fn.string().optional(),audiences:Fn.list(Fn.string())}).extend(dv);var hPa=Fn.objectWithoutOptionalProperties({value:Fn.lazy(()=>Y1)}).extend(A_).extend(dO).extend(K1).extend(dv).extend($1);var yPa=Fn.objectWithoutOptionalProperties({key:nzr,value:Fn.lazy(()=>Y1)}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Wie).extend($1);var vPa=Fn.objectWithoutOptionalProperties({value:Fn.lazy(()=>Y1)}).extend(A_).extend(dO).extend(K1).extend(dv).extend($1);var bPa=Fn.objectWithoutOptionalProperties({value:Fn.lazy(()=>Y1)}).extend(A_).extend(dO).extend(K1).extend(dv).extend($1);var gPa=Fn.union("type",{discriminated:Fn.lazyObject(()=>OPa),undisciminated:Fn.lazyObject(()=>PPa)}).transform({transform:e=>{switch(e.type){case"discriminated":return eAr.discriminated(e);case"undisciminated":return eAr.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var OPa=Fn.objectWithoutOptionalProperties({discriminantProperty:Fn.string(),commonProperties:Fn.list(Fn.lazyObject(()=>wPa)),schemas:Fn.record(Fn.string(),Fn.lazy(()=>Y1))}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Wie).extend(Ab).extend($1);var wPa=Fn.objectWithoutOptionalProperties({key:Fn.string(),schema:Fn.lazy(()=>Y1)});var PPa=Fn.objectWithoutOptionalProperties({schemas:Fn.list(Fn.lazy(()=>Y1))}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Wie).extend(Ab).extend($1);var Agu={};_l(Agu,{ArraySchemaWithExample:()=>WPa,Base64WithExample:()=>RPa,BooleanWithExample:()=>FPa,CommonPropertyWithExample:()=>ZPa,DateWithExample:()=>zPa,DatetimeWithExample:()=>NPa,DiscriminatedOneOfSchemaWithExample:()=>YPa,DoubleWithExample:()=>IPa,EndpointWithExample:()=>NCf,EnumSchemaWithExample:()=>UPa,FloatWithExample:()=>qPa,HeaderWithExample:()=>Y3n,HttpErrorWithExample:()=>APa,Int64WithExample:()=>xPa,IntWithExample:()=>MPa,JsonRequestWithExample:()=>DPa,JsonResponseWithExample:()=>Mvi,MapSchemaWithExample:()=>HPa,NamedFullExample:()=>kFt,NullableSchemaWithExample:()=>JPa,ObjectPropertyWithExample:()=>KPa,ObjectSchemaWithExample:()=>GPa,OneOfSchemaWithExample:()=>$Pa,OptionalSchemaWithExample:()=>QPa,PathParameterWithExample:()=>jPa,PrimitiveSchemaValueWithExample:()=>LPa,PrimitiveSchemaWithExample:()=>X3n,QueryParameterWithExample:()=>K3n,RequestWithExample:()=>SPa,ResponseWithExample:()=>EPa,SchemaWithExample:()=>QC,StringSchemaWithExample:()=>BPa,Uint64WithExample:()=>CPa,UintWithExample:()=>TPa,UnDiscriminatedOneOfSchemaWithExample:()=>XPa,UnknownSchemaWithExample:()=>VPa,WebsocketHandshakeWithExample:()=>BCf});var kFt=Fn.objectWithoutOptionalProperties({name:Fn.string().optional(),value:Fn.unknown()}).extend(A_);var K3n=Fn.objectWithoutOptionalProperties({name:Fn.string(),schema:Fn.lazy(()=>QC),parameterNameOverride:Fn.string().optional()}).extend(A_).extend(dv).extend(Ab);var Y3n=Fn.objectWithoutOptionalProperties({name:Fn.string(),schema:Fn.lazy(()=>QC),env:Fn.string().optional(),parameterNameOverride:Fn.string().optional()}).extend(A_).extend(dv).extend(Ab);var BCf=Fn.objectWithoutOptionalProperties({queryParameters:Fn.list(K3n),headers:Fn.list(Y3n)});var jPa=Fn.objectWithoutOptionalProperties({name:Fn.string(),schema:Fn.lazy(()=>QC),variableReference:Fn.string().optional(),parameterNameOverride:Fn.string().optional()}).extend(A_).extend(dv).extend(Ab);var DPa=Fn.objectWithoutOptionalProperties({schema:Fn.lazy(()=>QC),contentType:Fn.string().optional(),fullExamples:Fn.list(kFt).optional(),additionalProperties:Fn.boolean()}).extend(A_).extend(Ab);var SPa=Fn.union("type",{octetStream:R3n,multipart:F3n,json:DPa}).transform({transform:e=>{switch(e.type){case"octetStream":return YCe.octetStream(e);case"multipart":return YCe.multipart(e);case"json":return YCe.json(e);default:return e}},untransform:({_visit:e,...t})=>t});var Mvi=Fn.objectWithoutOptionalProperties({schema:Fn.lazy(()=>QC),responseProperty:Fn.string().optional(),fullExamples:Fn.list(kFt).optional()}).extend(A_).extend(Ab);var EPa=Fn.union("type",{file:L3n,json:Mvi,text:rzr,streamingSse:tzr,streamingText:rzr,streamingJson:Mvi}).transform({transform:e=>{switch(e.type){case"file":return P4.file(e);case"json":return P4.json(e);case"text":return P4.text(e);case"streamingSse":return P4.streamingSse(e);case"streamingText":return P4.streamingText(e);case"streamingJson":return P4.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var APa=Fn.objectWithoutOptionalProperties({statusCode:X8r,schema:Fn.lazy(()=>QC),fullExamples:Fn.list(kFt).optional()}).extend(A_).extend(dO).extend(Ab);var NCf=Fn.objectWithoutOptionalProperties({authed:Fn.boolean(),internal:Fn.boolean().optional(),idempotent:Fn.boolean().optional(),method:B3n,audiences:Fn.list(Fn.string()),path:Fn.string(),summary:Fn.string().optional(),operationId:Fn.string().optional(),tags:Fn.list(tDe),pathParameters:Fn.list(jPa),queryParameters:Fn.list(K3n),headers:Fn.list(Y3n),sdkName:ezr.optional(),generatedRequestName:Fn.string(),requestNameOverride:Fn.string().optional(),request:SPa.optional(),response:EPa.optional(),errors:Fn.record(X8r,APa),server:Fn.list(U3n),examples:Fn.list(H3n),pagination:Q3n.optional()}).extend(A_).extend(dv).extend(Ab).extend(Z8r);var MPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional(),minimum:Fn.number().optional(),maximum:Fn.number().optional(),exclusiveMinimum:Fn.boolean().optional(),exclusiveMaximum:Fn.boolean().optional(),multipleOf:Fn.number().optional(),example:Fn.number().optional()});var xPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional(),example:Fn.number().optional()});var TPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional(),example:Fn.number().optional()});var CPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional(),example:Fn.number().optional()});var qPa=Fn.objectWithoutOptionalProperties({example:Fn.number().optional()});var IPa=Fn.objectWithoutOptionalProperties({default:Fn.number().optional(),minimum:Fn.number().optional(),maximum:Fn.number().optional(),exclusiveMinimum:Fn.boolean().optional(),exclusiveMaximum:Fn.boolean().optional(),multipleOf:Fn.number().optional(),example:Fn.number().optional()});var BPa=Fn.objectWithoutOptionalProperties({default:Fn.string().optional(),pattern:Fn.string().optional(),format:Fn.string().optional(),minLength:Fn.number().optional(),maxLength:Fn.number().optional(),example:Fn.string().optional()});var NPa=Fn.objectWithoutOptionalProperties({example:Fn.string().optional()});var zPa=Fn.objectWithoutOptionalProperties({example:Fn.string().optional()});var RPa=Fn.objectWithoutOptionalProperties({example:Fn.string().optional()});var FPa=Fn.objectWithoutOptionalProperties({default:Fn.boolean().optional(),example:Fn.boolean().optional()});var LPa=Fn.union("type",{int:MPa,int64:xPa,uint:TPa,uint64:CPa,float:qPa,double:IPa,string:BPa,datetime:NPa,date:zPa,base64:RPa,boolean:FPa}).transform({transform:e=>{switch(e.type){case"int":return Ey.int(e);case"int64":return Ey.int64(e);case"uint":return Ey.uint(e);case"uint64":return Ey.uint64(e);case"float":return Ey.float(e);case"double":return Ey.double(e);case"string":return Ey.string(e);case"datetime":return Ey.datetime(e);case"date":return Ey.date(e);case"base64":return Ey.base64(e);case"boolean":return Ey.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var X3n=Fn.objectWithoutOptionalProperties({schema:LPa}).extend(A_).extend(dO).extend(K1).extend(dv).extend($1);var UPa=Fn.objectWithoutOptionalProperties({default:K8r.optional(),values:Fn.list(K8r),example:Fn.string().optional()}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Ab).extend($1);var VPa=Fn.objectWithoutOptionalProperties({example:Fn.unknown()}).extend(K1).extend(dO).extend(A_).extend(dv).extend($1);var QC=Fn.union("type",{primitive:X3n,object:Fn.lazyObject(()=>GPa),array:Fn.lazyObject(()=>WPa),map:Fn.lazyObject(()=>HPa),optional:Fn.lazyObject(()=>QPa),enum:UPa,reference:ZFt,literal:J3n,oneOf:Fn.object({value:Fn.lazy(()=>$Pa)}),nullable:Fn.lazyObject(()=>JPa),unknown:VPa}).transform({transform:e=>{switch(e.type){case"primitive":return Qp.primitive(e);case"object":return Qp.object(e);case"array":return Qp.array(e);case"map":return Qp.map(e);case"optional":return Qp.optional(e);case"enum":return Qp.enum(e);case"reference":return Qp.reference(e);case"literal":return Qp.literal(e);case"oneOf":return Qp.oneOf(e.value);case"nullable":return Qp.nullable(e);case"unknown":return Qp.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var WPa=Fn.objectWithoutOptionalProperties({value:Fn.lazy(()=>QC),example:Fn.list(Fn.unknown()).optional()}).extend(K1).extend(dO).extend(A_).extend(dv).extend($1);var HPa=Fn.objectWithoutOptionalProperties({key:X3n,value:Fn.lazy(()=>QC),example:Fn.unknown().optional()}).extend(K1).extend(dO).extend(A_).extend(dv).extend(Wie).extend($1);var QPa=Fn.objectWithoutOptionalProperties({value:Fn.lazy(()=>QC)}).extend(K1).extend(dO).extend(A_).extend(dv).extend($1);var JPa=Fn.objectWithoutOptionalProperties({value:Fn.lazy(()=>QC)}).extend(K1).extend(dO).extend(A_).extend(dv).extend($1);var GPa=Fn.objectWithoutOptionalProperties({allOf:Fn.list(ZFt),properties:Fn.list(Fn.lazyObject(()=>KPa)),allOfPropertyConflicts:Fn.list(G3n),fullExamples:Fn.list(kFt).optional(),additionalProperties:Fn.boolean()}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Ab).extend($1);var KPa=Fn.objectWithoutOptionalProperties({key:Fn.string(),schema:Fn.lazy(()=>QC),readonly:Fn.boolean().optional(),audiences:Fn.list(Fn.string()),conflict:Fn.record(VZ,$3n),nameOverride:Fn.string().optional(),generatedName:Fn.string()}).extend(dv);var $Pa=Fn.union("type",{discriminated:Fn.lazyObject(()=>YPa),undisciminated:Fn.lazyObject(()=>XPa)}).transform({transform:e=>{switch(e.type){case"discriminated":return UZ.discriminated(e);case"undisciminated":return UZ.undisciminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var YPa=Fn.objectWithoutOptionalProperties({discriminantProperty:Fn.string(),commonProperties:Fn.list(Fn.lazyObject(()=>ZPa)),schemas:Fn.record(Fn.string(),Fn.lazy(()=>QC))}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Wie).extend(Ab).extend($1);var ZPa=Fn.objectWithoutOptionalProperties({key:Fn.string(),schema:Fn.lazy(()=>QC)});var XPa=Fn.objectWithoutOptionalProperties({schemas:Fn.list(Fn.lazy(()=>QC))}).extend(A_).extend(dO).extend(K1).extend(dv).extend(Wie).extend(Ab).extend($1);function kPa(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Kc(e.type)}}function Z3n(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:Kc(e)}}function bC(e){return typeof e=="string"?e:e.type}function xvi(e){if(typeof e!="string")return e.docs}function zCf(e){if(typeof e!="string")return e.default}function RCf(e){if(typeof e!="string")return e.validation}function UR1(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 FCf(e){let t=e?UR1(e):void 0;if(t==null||t.length===0)return Cfi;let r=[];for(let[n,i]of t.entries())if(typeof i=="string")r.push(dA(i));else if(typeof i=="object")switch(i.type){case"namespace":{n<t.length-1?r.push(dA(i.name)):r.push(i.name,Cfi);break}default:Kc(i.type)}else Kc(i);return r.join("/")}function k3n(e){return Ms.of(`${FCf(e)}.yml`)}function Mgu({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?Cfi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(n=>typeof n=="string"||n.type!=="namespace")]:r=e.groupName,FCf(r))}function LCf({sdkName:e,namespaceOverride:t}){return Ms.of(`${Mgu({sdkName:e,namespaceOverride:t})}.yml`)}function UCf({location:e,namespaceOverride:t}){return t!=null?yf(Ms.of(t),e):e}function S3(e){switch(e){case xH.Deprecated:return"deprecated";case xH.Beta:return"pre-release";case xH.GenerallyAvailable:return"generally-available";default:return}}var VR1=-2147483648,WR1=2147483647,HR1=-17976931348623157e292,QR1=17976931348623157e292;function X1({schema:e,fileContainingReference:t,declarationFile:r=t,context:n,namespace:i}){switch(e.type){case"primitive":return e1a(e);case"array":return Cgu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"map":return qgu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"reference":return Tgu({schema:e,fileContainingReference:t,context:n,namespace:i});case"unknown":return Bgu();case"optional":case"nullable":return Igu({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"enum":return eF1({schema:e,fileContainingReference:t,context:n,declarationFile:r});case"literal":return e.value,Ngu(e);case"object":return tF1({schema:e,fileContainingReference:t,context:n,declarationFile:r,namespace:i});case"oneOf":return rF1({schema:e.value,fileContainingReference:t,context:n,declarationFile:r,namespace:i});default:Kc(e)}}function e1a(e){switch(e.schema.type){case"string":return $R1({description:e.description,schema:e.schema});case"int":return KR1({description:e.description,schema:e.schema});case"float":return YR1({description:e.description,schema:e.schema});case"double":return XR1({description:e.description,schema:e.schema});case"boolean":return JR1({description:e.description,schema:e.schema});case"int64":return GR1({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:S3(e.availability)}:{}}}function JR1({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 GR1({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 $R1({description:e,schema:t}){let r="string",n=ZR1(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 KR1({description:e,schema:t}){let r="integer",n=VCf(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 YR1({description:e,schema:t}){let r="float";if(e==null)return r;let n={type:r};return e!=null&&(n.docs=e),n}function XR1({description:e,schema:t}){let r="double",n=VCf(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 ZR1(e){if(e==null)return;let{format:t,pattern:r,minLength:n,maxLength:i}=e,a=kR1(t);if(!(a==null&&r==null&&n==null&&i==null))return{format:a,pattern:r,minLength:n,maxLength:i}}function kR1(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 VCf(e,t){if(e==null)return;let{minimum:r,maximum:n,multipleOf:i}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=xgu(r,t),n=xgu(n,t),i=xgu(i,t),!(r==null&&n==null&&a==null&&u==null&&i==null))return{min:r,max:n,exclusiveMin:a,exclusiveMax:u,multipleOf:i}}function xgu(e,t){if(e===void 0)return;let[r,n]=t==="integer"?[VR1,WR1]:[HR1,QR1];return e<r||e>n?void 0:e}function Tgu({schema:e,fileContainingReference:t,context:r,namespace:n}){let i=r.getSchema(e.schema,n);if(i==null)return"unknown";let a=nF1(i)??e.schema,u=Z3n(i),f=iF1(i),d=t1a({context:r,fileContainingReference:t,declarationFile:k3n(u),type:a}),c=i.type==="nullable"?`optional<${d}>`:d;return e.description==null&&f==null?c:{type:i.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:S3(e.availability)}:{}}}function Cgu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=X1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=`list<${bC(a)}>`;return e.description==null&&e.title==null?u:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:S3(e.availability)}:{},type:u}}function qgu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=e1a(e.key),u=X1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),f=e.encoding!=null?kPa(e.encoding):void 0,d=`map<${bC(a)}, ${bC(u)}>`;if(e.description==null&&f==null&&e.title==null)return d;let c={type:d};return e.description!=null&&(c.docs=e.description),e.encoding!=null&&(c.encoding=f),e.availability!=null&&(c.availability=S3(e.availability)),c}function Igu({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=X1({schema:e.value,fileContainingReference:t,declarationFile:r,context:n,namespace:i}),u=bC(a),f=xvi(a),d=zCf(a),c=RCf(a),o=u.startsWith("optional<")?u:`optional<${u}>`;if(e.availability==null&&e.description==null&&f==null&&d==null&&c==null&&e.title==null)return o;let l={type:o};return(e.description!=null||f!=null)&&(l.docs=e.description??f),d!=null&&(l.default=d),c!=null&&(l.validation=c),e.availability!=null&&(l.availability=S3(e.availability)),l}function Bgu(){return"unknown"}function Ngu(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Kc(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:S3(e.availability)}:{}}}function eF1({schema:e,fileContainingReference:t,declarationFile:r,context:n}){let i=Tvi(e),a=e.nameOverride??e.generatedName;n.builder.addType(r,{name:a,schema:i.schema});let u=t1a({type:a,fileContainingReference:t,declarationFile:r,context:n});if(e.description==null&&e.default==null&&e.title==null)return u;let f={type:u};return e.description!=null&&(f.docs=e.description),e.default!=null&&(f.default=e.default.value),e.availability!=null&&(f.availability=S3(e.availability)),f}function tF1({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=zgu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=t1a({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:S3(e.availability)}:{}}}function rF1({schema:e,fileContainingReference:t,declarationFile:r,context:n,namespace:i}){let a=Rgu({schema:e,declarationFile:r,context:n,namespace:i}),u=e.nameOverride??e.generatedName;n.builder.addType(r,{name:u,schema:a.schema});let f=t1a({type:u,fileContainingReference:t,declarationFile:r,context:n});return e.description==null&&e.title==null?f:{...e.title!=null?{"display-name":e.title}:{},type:f,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:S3(e.availability)}:{}}}function t1a({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 nF1(e){return vb._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 iF1(e){return vb._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 Crn(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Kc(e)}}function HCf({schema:e,context:t,declarationFile:r,namespace:n}){switch(e.type){case"primitive":return uF1(e);case"array":return aF1({schema:e,context:t,declarationFile:r,namespace:n});case"map":return oF1({schema:e,context:t,declarationFile:r,namespace:n});case"reference":return sF1({schema:e,context:t,declarationFile:r,namespace:n});case"unknown":return lF1(e.nameOverride,e.generatedName);case"optional":case"nullable":return cF1({schema:e,context:t,declarationFile:r,namespace:n});case"enum":return Tvi(e);case"literal":return fF1(e,e.nameOverride,e.generatedName);case"object":return zgu({schema:e,context:t,declarationFile:r,namespace:n});case"oneOf":return Rgu({schema:e.value,context:t,declarationFile:r,namespace:n});default:Kc(e)}}function zgu({schema:e,context:t,declarationFile:r,namespace:n}){let i={},a=new Set;for(let c of e.properties){if(Object.keys(c.conflict).length>0){if(Object.entries(c.conflict).every(([j,M])=>!M.differentSchema))continue;Object.entries(c.conflict).forEach(([j])=>{Fgu({property:c.key,schemaId:j,context:t,namespace:n}).forEach(q=>{a.add(q)})})}let o=X1({schema:c.schema,context:t,fileContainingReference:r,namespace:n}),l=c.audiences,g=c.nameOverride,O=S3(c.availability);i[c.key]=_F1(o,l,g,O)}let u=new Set;for(let c of e.allOfPropertyConflicts)c.allOfSchemaIds.forEach(o=>a.add(o)),c.conflictingTypeSignatures&&u.add(c.propertyKey);let f=[];for(let c of e.allOf){let o=QCf({schema:c.schema,context:t,namespace:n});if(o==null||a.has(c.schema)||a.has(o))continue;let l=X1({schema:vb.reference(c),context:t,fileContainingReference:r,namespace:n});f.push(bC(l))}for(let c of a){let o=Lgu(t,c,n);for(let l of o.properties)i[l.key]==null&&(u.has(l.key)&&(i[l.key]="unknown"),i[l.key]=X1({schema:l.schema,context:t,fileContainingReference:r,namespace:n}));for(let l of o.allOf){if(a.has(l.schema))continue;let g=X1({schema:vb.reference(l),context:t,fileContainingReference:r,namespace:n});f.push(bC(g))}}let d={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(i).map(([c,o])=>pF1(c)?[c,typeof o=="string"?{type:o,name:`_${c}`}:{...o,name:`_${c}`}]:[c,o]))};return f.length>0&&(d.extends=f),e.additionalProperties&&(d["extra-properties"]=!0),e.availability!=null&&(d.availability=S3(e.availability)),e.source!=null&&(d.source=Crn(e.source)),{name:e.nameOverride??e.generatedName,schema:d}}function Fgu({property:e,schemaId:t,context:r,namespace:n}){let i=r.getSchema(t,n);if(i==null)return[];if(i.type==="reference")return Fgu({property:e,schemaId:i.schema,context:r,namespace:n});if(i.type==="object"){let{properties:a,allOf:u}=Lgu(r,t,n),f=a.some(c=>c.key===e),d=[...u.flatMap(c=>Fgu({property:e,context:r,schemaId:c.schema,namespace:n}))];if(f||d.length>0)return[t,...d]}return[]}function Lgu(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 Lgu(e,n.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${n.type}`)}function aF1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Cgu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function oF1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:qgu({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:n})}}function uF1(e){let t=e1a(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 WCf(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function Tvi(e){let t={enum:e.values.map(i=>{let a=i.nameOverride??i.generatedName,u=i.value;if(a===u&&i.description==null&&(i.casing==null||WCf(i.casing)))return a;let f={value:i.value};if(a!==u&&(f.name=a),i.description!=null&&(f.docs=i.description),i.casing!=null&&!WCf(i.casing)){let d={},c=!1;i.casing.camel!=null&&(d.camel=i.casing.camel,c=!0),i.casing.screamingSnake!=null&&(d["screaming-snake"]=i.casing.screamingSnake,c=!0),i.casing.snake!=null&&(d.snake=i.casing.snake,c=!0),i.casing.pascal!=null&&(d.pascal=i.casing.pascal,c=!0),c&&(f.casing=d)}return f})};e.description!=null&&(t.docs=e.description),e.default!=null&&(t.default=e.default.value);let r=new Set,n={...t,enum:[],source:e.source!=null?Crn(e.source):void 0};for(let i of t.enum){let a=typeof i=="string"?i:i.name??i.value;r.has(a.toLowerCase())||(n.enum.push(i),r.add(a.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function sF1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Tgu({schema:e,context:t,fileContainingReference:r,namespace:n})}}function cF1({schema:e,context:t,declarationFile:r,namespace:n}){return{name:e.nameOverride??e.generatedName,schema:Igu({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:n})}}function lF1(e,t){return{name:e??t,schema:Bgu()}}function fF1(e,t,r){return{name:t??r,schema:Ngu(e)}}function Rgu({schema:e,context:t,declarationFile:r,namespace:n}){let i=e.encoding!=null?kPa(e.encoding):void 0;if(e.type==="discriminated"){let u={};for(let d of e.commonProperties)u[d.key]=X1({schema:d.schema,fileContainingReference:r,context:t,namespace:n});let f={};for(let[d,c]of Object.entries(e.schemas))f[d]=X1({schema:c,context:t,fileContainingReference:r,namespace:n});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":u,docs:e.description??void 0,availability:e.availability!=null?S3(e.availability):void 0,union:f,encoding:i,source:e.source!=null?Crn(e.source):void 0}}}let a=[];for(let u of e.schemas)a.push(X1({schema:u,fileContainingReference:r,context:t,namespace:n}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:a,encoding:i,source:e.source!=null?Crn(e.source):void 0}}}var dF1=/^[0-9]/;function pF1(e){return dF1.test(e)}function QCf({schema:e,context:t,namespace:r}){let n=t.getSchema(e,r);if(n!=null)return n.type==="reference"?QCf({context:t,schema:n.schema,namespace:r}):e}function _F1(e,t,r,n){return t.length===0&&r==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...n!=null?{availability:n}:{}}}function JCf(e){let t=e.replace(/^x-|^X-/,"");return dA(t)}var GCf="BasicAuthScheme",r1a="BearerAuthScheme";function $Cf(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:GCf,schema:i}),t||(e.builder.setAuth(GCf),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:r1a,schema:i}),t||(e.builder.setAuth(r1a),t=!0)}else if(n.type==="header")if(t)e.builder.addGlobalHeader({name:n.headerName,schema:{type:"string",name:n.headerVariableName??JCf(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:r1a,schema:i}),t||(e.builder.setAuth(r1a),t=!0),n.scopesEnum!=null&&n.scopesEnum.values.length>0&&e.builder.addType(Ms.of("__package__.yml"),{name:"OauthScope",schema:Tvi(n.scopesEnum).schema})}}function e9t({header:e,context:t,fileContainingReference:r,namespace:n}){let i=X1({schema:e.schema,context:t,fileContainingReference:r,namespace:n}),a=bC(i),u=e.name.replace(/^x-|^X-/,""),f=e.parameterNameOverride!=null?e.parameterNameOverride:dA(u);if(e.description==null&&e.name===f&&e.env==null&&e.availability==null)return a;let d={type:a};return f!==e.name&&(d.name=f),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=S3(e.availability)),d}function n1a({pathParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=X1({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(e.variableReference==null&&e.description==null&&e.availability==null)return bC(i);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:bC(i)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=S3(e.availability)),a}var TSu=require("fs/promises");var KCf={naming:"v1"};function Oh(e,t){let r=Array.isArray(t)?t:[t];for(let n of r){let i=e[n];if(i!=null)return i}}function Cvi(e,t,r,n,i=[]){try{let a=Oh(e,t);if(a!=null)return r.parse(a)}catch{let u=_8t(i).join(" -> ");n.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}var i1a={of(e){return e}};var iy={SDK_METHOD_NAME:i1a.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:i1a.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:i1a.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"};function Oy(e){return e.$ref!=null}function XCe(e){switch(Oh(e,iy.AVAILABILITY)){case"deprecated":return xH.Deprecated;case"beta":return xH.Beta;case"generally-available":return xH.GenerallyAvailable;default:break}if(!Oy(e)&&e.deprecated)return xH.Deprecated}var rDe={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"};function YCf({schema:e,logger:t}){return Oh(e,iy.ENCODING)??void 0}function XCf(e){return Oh(e,iy.FERN_ENUM)}function ZCf({nameOverride:e,generatedName:t,title:r,schema:n,description:i,availability:a}){let u=Oh(n,iy.SDK_GROUP_NAME),f=Oh(n,iy.TYPE_DEFINITION);if(f!=null)return qvi({fernType:f,nameOverride:e,generatedName:t,title:r,description:i,availability:a,groupName:typeof u=="string"?[u]:u})}function qvi({fernType:e,nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u}){return i$({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>{switch(f.v1){case"BASE_64":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.base64({example:void 0})});case"BOOLEAN":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.boolean({default:void 0,example:void 0})});case"DATE":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.date({example:void 0})});case"DATE_TIME":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.datetime({example:void 0})});case"FLOAT":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.float({example:void 0})});case"DOUBLE":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.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 Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.uint({default:void 0,example:void 0})});case"INTEGER":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.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 Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.uint64({default:void 0,example:void 0})});case"LONG":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Qp.primitive({nameOverride:t,generatedName:r,title:n,description:i,availability:a,groupName:u,schema:Ey.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Kc(f.v1)}},unknown:()=>Qp.unknown({nameOverride:t,generatedName:r,title:n,example:void 0,description:i,availability:a,groupName:u}),map:({keyType:f,valueType:d})=>f?.type==="primitive"&&d!=null?Qp.map({nameOverride:t,generatedName:r,title:n,key:f,value:d,description:i,availability:a,groupName:u,encoding:void 0,example:void 0}):void 0,list:f=>f!=null?Qp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,optional:f=>f!=null?Qp.optional({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u}):void 0,set:f=>f!=null?Qp.array({nameOverride:t,generatedName:r,title:n,value:f,description:i,availability:a,groupName:u,example:void 0}):void 0,literal:f=>Qp.literal({nameOverride:t,generatedName:r,title:n,value:f._visit({string:d=>O4.string(d),boolean:d=>O4.boolean(d),_other:()=>{throw new Error("Unexpected literal type")}}),description:i,availability:a,groupName:u}),named:()=>{}}})}function qrn(e){if(e!=null&&typeof e=="boolean")return e}function kCf({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,additionalProperties:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,encoding:l,source:g,namespace:O}){return typeof i=="boolean"||e7n(i)?a1a({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Ey.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:Qp.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:void 0}),groupName:c,example:o,encoding:l}):a1a({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:Ey.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),groupName:void 0},valueSchema:i1(i,d.options.optionalAdditionalProperties?f:!1,d,[...n,"Value"],g,O),groupName:c,example:o,encoding:l})}function a1a({nameOverride:e,generatedName:t,title:r,keySchema:n,valueSchema:i,wrapAsNullable:a,description:u,availability:f,groupName:d,example:c,encoding:o}){return a?Qp.nullable({nameOverride:e,generatedName:t,title:r,value:Qp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:n.availability,key:n,value:i,groupName:d,encoding:o,example:c}),description:u,availability:f,groupName:d}):Qp.map({nameOverride:e,generatedName:t,title:r,description:u,availability:f,key:n,value:i,groupName:d,encoding:o,example:c})}function e7n(e){return e==null?!1:typeof e=="boolean"?e:!Oy(e)&&Object.keys(e).length===0}function e2f({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,item:i,description:a,availability:u,wrapAsNullable:f,context:d,groupName:c,example:o,source:l,namespace:g}){let O=i==null?Qp.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,groupName:c}):i1(i,!1,d,[...n,"Item"],l,g);return hF1({nameOverride:e,generatedName:t,title:r,groupName:c,itemSchema:O,wrapAsNullable:f,description:a,availability:u,example:o})}function hF1({nameOverride:e,generatedName:t,title:r,itemSchema:n,wrapAsNullable:i,description:a,availability:u,groupName:f,example:d}){return i?Qp.nullable({nameOverride:e,generatedName:t,title:r,value:Qp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d}),description:a,availability:u,groupName:f}):Qp.array({nameOverride:e,generatedName:t,title:r,value:n,description:a,availability:u,groupName:f,example:d})}function Ugu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminator:c,context:o,groupName:l,encoding:g,source:O,namespace:w}){let j=c.propertyName,M=Object.fromEntries(Object.entries(c.mapping??{}).map(([B,I])=>{let C=t7n({$ref:I},!1,o,[I],g,O,w);return o.markReferencedByDiscriminatedUnion({$ref:I},j,1),[B,C]})),q=Object.entries(i).filter(([B])=>B!==j).map(([B,I])=>{let C=f!=null&&f.includes(B),L=i1(I,!C,o,[...n,B],O,w);return{key:B,schema:L}});return t2f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:q,description:a,availability:u,discriminant:j,subtypes:M,groupName:l,source:O})}function Vgu({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,availability:u,required:f,wrapAsNullable:d,discriminant:c,variants:o,context:l,groupName:g,encoding:O,source:w,namespace:j}){let M=Object.fromEntries(Object.entries(o).map(([B,I])=>{if(Oy(I)){let C=t7n(I,!1,l,[I.$ref],O,w,j);return l.markReferencedByDiscriminatedUnion(I,c,1),[B,C]}else{let C=izr(I,!1,l,[...n,B],O,w,j,new Set([c]));return[B,C]}})),q=Object.entries(i).filter(([B])=>B!==c).map(([B,I])=>{let C=f!=null&&f.includes(B),L=i1(I,!C,l,[...n,B],w,j);return{key:B,schema:L}});return t2f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:q,description:a,availability:u,discriminant:c,subtypes:M,groupName:g,source:w})}function t2f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,availability:u,discriminant:f,subtypes:d,groupName:c,source:o}){return n?Qp.nullable({nameOverride:e,generatedName:t,title:r,value:Qp.oneOf(UZ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o})),groupName:c,description:a,availability:u}):Qp.oneOf(UZ.discriminated({description:a,availability:u,discriminantProperty:f,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:i,groupName:c,encoding:void 0,source:o}))}function r2f(e){if(e.proto!=null)return S3n.protobuf({typeName:e.proto.type})}var yF1=/^(\d+)/;function o1a(e){let t=e.match(yF1);if(t&&t[0]!=null){let r=t[0],n=e.substring(r.length),i=parseFloat(r);if(!isNaN(i)&&isFinite(i)){let a=r7n(i);return n.length>0?`${a}_${n}`:a}}}function r7n(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),f=e%10;return f===0?n[u]:`${n[u]}_${t[f]}`}if(e<1e3){let u=Math.floor(e/100),f=e%100;return f===0?`${t[u]}_hundred`:`${t[u]}_hundred_${r7n(f)}`}let i=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[i]}_thousand`:`${t[i]}_thousand_${r7n(a)}`}var n7n=/^[a-zA-Z][a-zA-Z0-9_]*$/;function azr({nameOverride:e,generatedName:t,title:r,fernEnum:n,enumVarNames:i,enumValues:a,_default:u,description:f,availability:d,wrapAsNullable:c,groupName:o,context:l,source:g}){let O=gF1(i??[]),w=new Set(a),j=Array.from(w).map((q,B)=>{let I=n?.[q],C=O[B],L=n7n.test(q),K=I?.name??C,te=L?q:Ivi(q);return K!=null&&!n7n.test(K)&&(l?.logger.warn(`Enum name override ${K} is not a valid name. Falling back on ${te}.`),K=void 0),{nameOverride:K,generatedName:te,value:q,description:I?.description,availability:d,casing:{snake:I?.casing?.snake??void 0,pascal:I?.casing?.pascal??void 0,screamingSnake:I?.casing?.screamingSnake??void 0,camel:I?.casing?.camel??void 0}}}),M=u!=null?j.find(q=>q.value===u):void 0;return vF1({wrapAsNullable:c,nameOverride:e,generatedName:t,title:r,values:j,_default:M,description:f,availability:d,groupName:o,source:g})}function vF1({wrapAsNullable:e,nameOverride:t,generatedName:r,title:n,values:i,_default:a,description:u,availability:f,groupName:d,source:c}){return e?Qp.nullable({nameOverride:t,generatedName:r,title:n,value:Qp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,default:a,availability:f,example:void 0,groupName:d,source:c}),description:u,availability:f,groupName:d}):Qp.enum({nameOverride:t,generatedName:r,title:n,values:i,description:u,availability:f,default:a,example:void 0,groupName:d,source:c})}var bF1={"<":"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 Ivi(e){let t=o1a(e),r=bF1[e];return t!=null?FW(dA(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":FW(dA(e)))}function gF1(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 n2f({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:w}){return n==="int64"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="uint32"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="uint64"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w})}function i2f(e){return typeof e=="string"?O4.string(e):typeof e=="boolean"?O4.boolean(e):O4.string(`${e}`)}function a2f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,value:i,description:a,availability:u,groupName:f}){return n?Qp.nullable({nameOverride:e,generatedName:t,title:r,value:Qp.literal({nameOverride:e,generatedName:t,title:r,value:i2f(i),description:a,availability:u,groupName:f}),description:a,availability:u,groupName:f}):Qp.literal({nameOverride:e,generatedName:t,title:r,value:i2f(i),description:a,availability:u,groupName:f})}function Wgu({nameOverride:e,generatedName:t,title:r,format:n,_default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,description:o,availability:l,wrapAsNullable:g,example:O,groupName:w}){return n==null||n==="double"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.double({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="float"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="int32"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.int({default:i,minimum:a,maximum:u,exclusiveMinimum:f,exclusiveMaximum:d,multipleOf:c,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="int64"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.int64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="uint32"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.uint({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="uint64"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.uint64({default:i,example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):n==="time-delta"?oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w}):oU({nameOverride:e,generatedName:t,title:r,primitive:Ey.float({example:O}),wrapAsNullable:g,description:o,availability:l,groupName:w})}var mF1={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},OF1={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}}},PF1={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}}},wF1={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},jF1={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},DF1={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},SF1={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},EF1={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function u1a(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],n=[mF1,OF1,PF1,wF1,jF1,DF1,SF1,EF1],i;do{i=t;for(let a of n)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:f}=a.applyStrategy(t);t=u,r=[...r,...f]}}while(t.join("")!==i.join(""));return r}function MF(e){let t=e.join("_"),r=FW(dA(t));return/^\d/.test(r)?o1a(r)??r:r}function Hgu(e){let t=e.join("_");return dA(t)}function JC(e){switch(e.type){case"object":return vb.object({allOf:e.allOf,properties:e.properties.map(t=>MF1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return vb.array({description:e.description,availability:e.availability,value:JC(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"enum":return vb.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,groupName:e.groupName,source:e.source});case"literal":return vb.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"nullable":return vb.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:JC(e.value),groupName:e.groupName});case"optional":return vb.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:JC(e.value),groupName:e.groupName});case"primitive":return vb.primitive({description:e.description,availability:e.availability,schema:o2f(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return vb.map({description:e.description,availability:e.availability,key:vb.primitive({description:e.key.description,availability:e.key.availability,schema:o2f(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,groupName:e.groupName}),value:JC(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,encoding:e.encoding});case"reference":return vb.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return vb.oneOf(AF1(e.value));case"unknown":return vb.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Kc(e)}}function AF1(e){switch(e.type){case"discriminated":return eAr.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:JC(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,JC(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return eAr.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>JC(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Kc(e)}}function o2f(e){switch(e.type){case"string":return PD.string(e);case"base64":return PD.base64();case"boolean":return PD.boolean(e);case"date":return PD.date();case"datetime":return PD.datetime();case"double":return PD.double(e);case"float":return PD.float();case"int":return PD.int(e);case"int64":return PD.int64(e);case"uint":return PD.uint();case"uint64":return PD.uint64();default:Kc(e)}}function MF1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:JC(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function s1a(e,t){return nDe(JC(e),JC(t))}function nDe(e,t){return e.type==="primitive"&&t.type==="primitive"?u2f(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?xF1(e.values,t.values):e.type==="array"&&t.type==="array"?nDe(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"?nDe(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?TF1(e.value,t.value):e.type==="object"&&t.type==="object"?CF1(e,t):e.type==="map"&&t.type==="map"?u2f(e.key.schema,t.key.schema)&&nDe(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function u2f(e,t){return e.type===t.type}function xF1(e,t){let r=new Set(...e.map(i=>i.value)),n=new Set(...t.map(i=>i.value));return jqt(r,n)}function TF1(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:nDe(n,i)}):e.type==="undisciminated"&&t.type==="undisciminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,n)=>{let i=t.schemas[n];return i==null?!1:nDe(r,i)}):!1}function CF1(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:nDe(a,i.schema)})}function s2f({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,properties:i,description:a,required:u,wrapAsNullable:f,allOf:d,context:c,propertiesToExclude:o,groupName:l,fullExamples:g,additionalProperties:O,availability:w,encoding:j,source:M,namespace:q}){let B=[...u??[]],I={...i},C=[],L=[];for(let G of d)if(Oy(G)){let re=c.resolveSchemaReference(G);if(re.discriminator!=null&&re.discriminator.mapping!=null)continue;if(re.oneOf!=null){for(let Re of re.oneOf){let Dt=Oy(Re)?c.resolveSchemaReference(Re):Re,Ct=i1(Dt,!1,c.DUMMY,n,M,q);Ct.type==="object"&&C.push(...Ct.properties.map(Wt=>Wt.schema.type!=="optional"&&Wt.schema.type!=="nullable"?{...Wt,schema:Qp.optional({nameOverride:void 0,generatedName:"",title:void 0,value:Wt.schema,description:void 0,availability:Wt.availability,groupName:void 0})}:Wt))}continue}let Xe=ozr(G);if(Xe==null)continue;L.push({schemaId:Xe,convertedSchema:Qgu(G,[Xe],M),properties:c2f({schema:G,context:c,breadcrumbs:n,source:M,namespace:q})}),c.markSchemaAsReferencedByNonRequest(Xe)}else{let re=i1(G,!1,c,n,M,q);re.type==="object"&&C.push(...re.properties)}let K={};for(let G of L)for(let[re,Xe]of Object.entries(G.properties)){let Re=K[re];Re!=null?(Re.schemaIds.push(G.schemaId),Re.schemas.some(Ct=>s1a(Ct,Xe))||Re.schemas.push(Xe)):K[re]={schemaIds:[G.schemaId],schemas:[Xe]}}let te=[];for(let[G,re]of Object.entries(K))re.schemaIds.length>1&&te.push({propertyKey:G,allOfSchemaIds:re.schemaIds,conflictingTypeSignatures:re.schemas.length>1});let J=Object.entries(I).map(([G,re])=>{let Xe=B.includes(G),Re=Oh(re,iy.AUDIENCES)??[],Dt=XCe(re),Ct=Oy(re)?!1:re.readOnly,Wt=Oh(re,iy.FERN_PROPERTY_NAME),Bt=[...n,G],or=Hgu(Bt),Pr=Xe?i1(re,!1,c,Bt,M,q):Qp.optional({nameOverride:e,generatedName:or,title:r,description:void 0,availability:Dt,value:i1(re,!1,c,Bt,M,q),groupName:l}),Ur={};for(let It of L){let cr=It.properties[G];cr!=null&&!s1a(Pr,cr)?Ur[It.schemaId]={differentSchema:!0}:cr!=null&&(Ur[It.schemaId]={differentSchema:!1})}return{key:G,schema:Pr,nameOverride:Wt,audiences:Re,conflict:Ur,generatedName:Hgu([...n,G]),availability:Dt,readonly:Ct}});return J.push(...C.map(G=>{let re=G.conflict;for(let Xe of L){let Re=Xe.properties[G.key];Re!=null&&!s1a(G.schema,Re)?re[Xe.schemaId]={differentSchema:!0}:Re!=null&&(re[Xe.schemaId]={differentSchema:!1})}return{...G,conflict:re}})),qF1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:f,properties:J.filter(G=>!o.has(G.key)),description:a,allOf:L.map(G=>G.convertedSchema),allOfPropertyConflicts:te,groupName:l,fullExamples:g,additionalProperties:O,availability:w,source:M})}function qF1({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,properties:i,description:a,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:o,availability:l,source:g}){return n?Qp.nullable({nameOverride:e,generatedName:t,title:r,value:Qp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:e7n(o),availability:void 0,source:g}),description:a,availability:l,groupName:d}):Qp.object({description:a,properties:i,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:f,groupName:d,fullExamples:c,additionalProperties:e7n(o),availability:l,source:g})}function c2f({schema:e,context:t,breadcrumbs:r,source:n,namespace:i}){let a={},[u,f]=Oy(e)?[t.resolveSchemaReference(e),u1a(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...c2f({schema:d,context:t,breadcrumbs:f,source:n,namespace:i})};for(let[d,c]of Object.entries(u.properties??{})){let o=i1(c,!1,t,[...f,d],n,i);a[d]=o}return a}function i7n({nameOverride:e,generatedName:t,title:r,breadcrumbs:n,description:i,availability:a,wrapAsNullable:u,context:f,subtypes:d,groupName:c,encoding:o,source:l,subtypePrefixOverrides:g,namespace:O}){let w=IF1({schemas:d}),j=d.flatMap((B,I)=>{if(!Oy(B)&&B.enum!=null&&f.options.cooerceEnumsToLiterals)return B.enum.map(L=>Qp.literal({nameOverride:void 0,generatedName:MF([t,L]),title:void 0,value:O4.string(L),groupName:void 0,description:void 0,availability:L.availability}));let C=w[I];if(g!=null){let L=g[I];L!=null&&"name"in L&&(C=L.name)}return[i1(B,!1,f,[...n,C??`${I}`],l,O)]}),M=[];for(let B=0;B<j.length;++B){let I=j[B],C=!1;for(let L=B+1;L<j.length;++L){let K=j[L];if(I!=null&&K!=null&&nDe(I,K)){C=!0;break}}I!=null&&!C&&M.push(I)}if(Object.entries(M).every(([B,I])=>I.type==="literal")){let B={},I=[];return Object.entries(M).forEach(([C,L])=>{L.type==="literal"&&L.value.type==="string"&&(I.push(L.value.value),L.description!=null&&(B[L.value.value]={description:L.description}))}),azr({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,fernEnum:B,enumVarNames:void 0,enumValues:I,_default:void 0,groupName:c,context:f,source:l})}return M.length===1&&M[0]!=null?M[0]:l2f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:i,availability:a,subtypes:M,groupName:c,encoding:o,source:l})}function Jgu({nameOverride:e,generatedName:t,title:r,description:n,availability:i,wrapAsNullable:a,context:u,groupName:f,discriminator:d,encoding:c,source:o,namespace:l}){let g=Object.entries(d.mapping??{}).map(([j,M],q)=>{let B={$ref:M},I=t7n(B,!1,u,[M],c,o,l);return u.markSchemaWithDiscriminantValue(B,d.propertyName,j),I.type==="object"&&(I.properties={[d.propertyName]:Qp.literal({nameOverride:void 0,generatedName:MF([t,j]),title:void 0,value:O4.string(j),groupName:void 0,description:void 0,availability:void 0}),...I.properties.filter(C=>C.key!==d.propertyName)}),I}),O=[];for(let j=0;j<g.length;++j){let M=g[j],q=!1;for(let B=j+1;B<g.length;++B){let I=g[B];if(M!=null&&I!=null&&nDe(M,I)){q=!0;break}}M!=null&&!q&&O.push(M)}if(Object.entries(O).every(([j,M])=>M.type==="literal")){let j={},M=[];return Object.entries(O).forEach(([q,B])=>{B.type==="literal"&&B.value.type==="string"&&(M.push(B.value.value),B.description!=null&&(j[B.value.value]={description:B.description}))}),azr({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,fernEnum:j,enumVarNames:void 0,enumValues:M,_default:void 0,groupName:f,context:u,source:o})}return O.length===1&&O[0]!=null?O[0]:l2f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:n,availability:i,subtypes:O,groupName:f,encoding:c,source:o})}function IF1({schemas:e}){let t={},r=0;for(let a of e){if(!Oy(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),f={},d=u;for(let[c,o]of Object.entries(t)){let l=lKi(o,u);d=lKi(d,o),f[c]=l}f[r]=d,t=f}}r++}let n=[],i=0;for(let a of e){let u=t[i];if(u!=null&&u.length>0){let f=u.sort();if(f[0]!=null){n.push(f[0]),++i;continue}}Oy(a)?n.push(r7n(i)??`${i}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?n.push(""):n.push(r7n(i)??`${i}`),++i}return n}function l2f({nameOverride:e,generatedName:t,title:r,wrapAsNullable:n,description:i,availability:a,subtypes:u,groupName:f,encoding:d,source:c}){return n?Qp.nullable({nameOverride:e,generatedName:t,title:r,value:Qp.oneOf(UZ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c})),description:i,availability:a,groupName:f}):Qp.oneOf(UZ.undisciminated({description:i,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,groupName:f,encoding:d,source:c}))}function a7n(e){if(e.default!=null&&typeof e.default=="string")return e.default}function c1a({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;if(r&&typeof r=="number")return r;r&&t.warn(`Expected fallback to be a number, but got ${typeof r}`)}function f2f({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;if(r&&typeof r=="boolean")return r;r&&t.warn(`Expected fallback to be a boolean, but got ${typeof r}`)}function t9t({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;if(r&&typeof r=="string")return r;r&&t.warn(`Expected fallback to be a string, but got ${typeof r}`)}function d2f({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;if(r&&Array.isArray(r))return r;r&&t.warn(`Expected fallback to be a array, but got ${typeof r}`)}var Irn="#/components/schemas/";function i1(e,t,r,n,i,a,u=!1,f=new Set,d){let c=UF1({schema:e,logger:r.logger});if(Oy(e)){let o=ozr(e);return o!=null?(u?r.markSchemaAsReferencedByRequest(o):r.markSchemaAsReferencedByNonRequest(o),t7n(e,t,r,n,c,i,a)):izr(r.resolveSchemaReference(e),t,r,u1a(e.$ref),c,i,a,f,u,d)}return izr(e,t,r,n,c,i,a,f,u,d)}function t7n(e,t,r,n,i,a,u){let f=e.$ref.includes("properties")?izr(r.resolveSchemaReference(e),t,r,n,i,a,u,new Set):Qp.reference(Qgu(e,n,a));return t?Qp.nullable({title:void 0,nameOverride:void 0,generatedName:MF(n),value:f,description:void 0,availability:void 0,groupName:void 0}):f}function BF1(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function izr(e,t,r,n,i,a,u,f=new Set,d=!1,c){let o=Oh(e,iy.TYPE_NAME)??(r.options.useTitlesAsName?BF1(e.title):void 0),l=Oh(e,iy.SDK_GROUP_NAME)??Oh(e,rDe.TAGS)?.[0],g=(typeof l=="string"?[l]:l)??[];g=r.resolveGroupName(g);let O=MF(n),w=e.title,j=e.description,M=XCe(e),q=Oh(e,rDe.EXAMPLES),B=[];e.example!=null&&B.push({name:void 0,value:e.example,description:void 0}),q!=null&&Object.keys(q).length>0&&B.push(...Object.entries(q).map(([C,L])=>({name:L.summary??C,value:L.value,description:L.description})));let I=ZCf({schema:e,description:j,title:w,nameOverride:o,generatedName:O,availability:M});if(I!=null)return I;if(!t&&e.nullable===!0)return izr(e,!0,r,n,i,a,u,f,d,c);if(e.enum!=null&&(e.type==="string"||e.type==null)){if(!Bvi(e.enum))return oU({nameOverride:o,generatedName:O,title:w,primitive:Ey.string({default:a7n(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:t9t({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:j,availability:M});let C=XCf(e);return e.enum.length===1&&e.enum[0]!=null&&C==null?a2f({nameOverride:o,generatedName:O,title:w,wrapAsNullable:t,value:e.enum[0],description:j,availability:M,groupName:g}):azr({nameOverride:o,generatedName:O,title:w,fernEnum:C,enumVarNames:Oh(e,[rDe.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:j,availability:M,wrapAsNullable:t,groupName:g,context:r,source:a})}if(Bvi(e.type)&&e.type[1]!=null&&e.type[0]!=null){let C=e.type[0],L=e.type[1];if(C==="null")return Qp.nullable({nameOverride:o,generatedName:O,title:w,value:izr({...e,type:L},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:M});if(L==="null")return Qp.nullable({nameOverride:o,generatedName:O,title:w,value:izr({...e,type:C},t,r,n,i,a,u,f,d,c),groupName:g,description:e.description,availability:M})}if(Bvi(e.type)&&e.type.length>1){let C=e.type.includes("null"),L=e.type.filter(K=>K!=="null").map(K=>({type:K,nullable:C}));return i7n({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,description:j,availability:M,wrapAsNullable:t,context:r,subtypes:L,groupName:g,encoding:i,source:a,namespace:u})}if(e==="boolean"||e.type==="boolean"){let C=Oh(e,iy.BOOLEAN_LITERAL);return C!=null?_2f({nameOverride:o,generatedName:O,title:w,literal:O4.boolean(C),wrapAsNullable:t,description:j,availability:M,groupName:g}):oU({nameOverride:o,generatedName:O,title:w,primitive:Ey.boolean({default:e.default,example:f2f({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:j,availability:M,groupName:g})}if(e==="number"||e.type==="number")return Wgu({nameOverride:o,generatedName:O,title:w,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:qrn(e.exclusiveMinimum),exclusiveMaximum:qrn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:j,availability:M,wrapAsNullable:t,example:c1a({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="integer"||e.type==="integer")return n2f({nameOverride:o,generatedName:O,title:w,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:qrn(e.exclusiveMinimum),exclusiveMaximum:qrn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:j,availability:M,wrapAsNullable:t,example:c1a({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="float")return Wgu({nameOverride:o,generatedName:O,title:w,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:qrn(e.exclusiveMinimum),exclusiveMaximum:qrn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:j,availability:M,wrapAsNullable:t,example:c1a({schema:e,logger:r.logger,fallback:c}),groupName:g});if(e==="string"||e.type==="string"){if(e.format==="date-time")return oU({nameOverride:o,generatedName:O,title:w,primitive:Ey.datetime({example:t9t({schema:e,logger:r.logger,fallback:c})}),wrapAsNullable:t,description:j,availability:M,groupName:g});if(e.format==="json-string")return Qp.unknown({nameOverride:o,generatedName:O,title:w,description:j,availability:M,groupName:g,example:void 0});let C=v2f(e,"const");return C!=null?_2f({nameOverride:o,generatedName:O,title:w,literal:O4.string(C),wrapAsNullable:t,description:j,availability:M,groupName:g}):oU({nameOverride:o,generatedName:O,title:w,primitive:Ey.string({default:a7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:t9t({schema:e,logger:r.logger,fallback:c})}),groupName:g,wrapAsNullable:t,description:j,availability:M})}if(e.type==="array")return e2f({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,item:e.items,description:j,availability:M,wrapAsNullable:t,context:r,groupName:g,example:d2f({schema:e,logger:r.logger,fallback:c}),source:a,namespace:u});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&p2f(e))return kCf({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,additionalProperties:e.additionalProperties,description:j,availability:M,wrapAsNullable:t,context:r,groupName:g,encoding:i,example:e.example,source:a,namespace:u});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?Jgu({nameOverride:o,generatedName:O,title:w,description:j,availability:M,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Ugu({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,description:j,availability:M,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(Array.isArray(e.type)&&(e.oneOf==null?e.oneOf=e.type:e.oneOf.push(...e.type)),e.oneOf!=null&&e.oneOf.length>0){let C=Oh(e,iy.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||C?Jgu({nameOverride:o,generatedName:O,title:w,description:j,availability:M,wrapAsNullable:t,context:r,groupName:g,discriminator:e.discriminator,encoding:i,source:a,namespace:u}):Ugu({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,description:j,availability:M,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,groupName:g,encoding:i,source:a,namespace:u});if(e.oneOf.length===1&&e.oneOf[0]!=null){let L=i1(e.oneOf[0],t,r,n,a,u,d);return o7n(L,j,g)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let J=e.oneOf[0],G=e.oneOf[1];if(!Oy(J)&&J.type==="null")return i1(G,!0,r,n,a,u);if(!Oy(G)&&G.type==="null")return i1(J,!0,r,n,a,u)}let L=RF1({schemas:e.oneOf});if(L!=null)return azr({nameOverride:o,generatedName:O,title:w,fernEnum:void 0,enumVarNames:void 0,enumValues:L,_default:e.default,description:j,availability:M,wrapAsNullable:t,groupName:g,context:r,source:a});let K=h2f({schemas:e.oneOf,context:r});if(K!=null&&!r.options.discriminatedUnionV2&&!C)return Vgu({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,properties:e.properties??{},required:e.required,description:j,availability:M,wrapAsNullable:t,discriminant:K.discriminant,variants:K.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let te=e.oneOf.filter(J=>!Oy(J)&&J.type==="null").length>0;return i7n({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,description:j,availability:M,wrapAsNullable:t||te,context:r,subtypes:e.oneOf.filter(J=>Oy(J)||J.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let K=i1(e.anyOf[0],t,r,n,a,u,d);return o7n(K,j,g)}if(e.anyOf.length===2){let[K,te]=e.anyOf;if(K!=null&&te!=null){if(!Oy(K)&&K.type==="null"){let J=i1(te,!0,r,n,a,u);return o7n(J,j,g)}else if(!Oy(te)&&te.type==="null"){let J=i1(K,!0,r,n,a,u);return o7n(J,j,g)}}}let C=h2f({schemas:e.anyOf,context:r});if(C!=null&&!r.options.discriminatedUnionV2)return Vgu({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,properties:e.properties??{},required:e.required,description:j,availability:M,wrapAsNullable:t,discriminant:C.discriminant,variants:C.schemas,context:r,groupName:g,encoding:i,source:a,namespace:u});let L=e.anyOf.filter(K=>!Oy(K)&&K.type==="null").length>0;return i7n({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,description:j,availability:M,wrapAsNullable:t||L,context:r,subtypes:e.anyOf.filter(K=>Oy(K)||K.type!=="null"),encoding:i,groupName:g,source:a,namespace:u})}if(e.allOf!=null||e.properties!=null){let C=[];for(let K of e.allOf??[])(Oy(K)||Object.keys(K).length>0)&&C.push(K);if((e.properties==null||e.properties.length===0)&&C.length===1&&C[0]!=null){let K=i1(C[0],t,r,n,a,u,d);return o7n(K,j,g)}let L=C.filter(K=>{let te=l1a(K);return te||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify(K)}`),te});if((e.properties==null||e.properties.length===0)&&L.length===1&&L[0]!=null){let K=i1(L[0],t,r,n,a,u,d);return o7n(K,j,g)}return s2f({nameOverride:o,generatedName:O,title:w,breadcrumbs:n,properties:e.properties??{},description:j,required:e.required,wrapAsNullable:t,allOf:L,context:r,propertiesToExclude:f,groupName:g,fullExamples:B,additionalProperties:e.additionalProperties,availability:M,encoding:i,source:a,namespace:u})}if(e.type==="object"&&NF1(e)&&zF1(e)&&p2f(e))return a1a({nameOverride:o,generatedName:O,title:w,description:j,availability:M,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${O}Key`,title:void 0,description:void 0,availability:void 0,schema:Ey.string({default:a7n(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:t9t({schema:e,logger:r.logger,fallback:c})}),groupName:g},valueSchema:Qp.unknown({nameOverride:void 0,generatedName:`${O}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,groupName:g}),groupName:g,encoding:i,example:e.example});if(e.type==null){let C=e.example??e.default;return Qp.unknown({nameOverride:o,generatedName:O,title:w,description:j,availability:M,groupName:g,example:C})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(n)} value=${JSON.stringify(e)}`)}function ozr(e){if(e.$ref.startsWith(Irn))return e.$ref.replace(Irn,"")}function Qgu(e,t,r){let n=Oh(e,iy.TYPE_NAME),i=MF(t),a=e.description,u=XCe(e),f=ozr(e);if(f==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return vb.reference({generatedName:i,nameOverride:n,title:void 0,schema:f,description:a??void 0,availability:u,groupName:void 0,source:r})}function NF1(e){return e.oneOf==null||e.oneOf.length===0}function zF1(e){return e.allOf==null||e.allOf.length===0}function p2f(e){return e.properties==null||Object.keys(e.properties).length===0}function Bvi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function o7n(e,t,r){return e.type==="reference"?Qp.reference({...e,description:t,availability:e.availability,groupName:r}):e.type==="optional"?Qp.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e.type==="nullable"?Qp.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,groupName:r}):e}function l1a(e){return Oy(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>l1a(t)):e.oneOf!=null?e.oneOf.every(t=>l1a(t)):e.anyOf!=null?e.anyOf.every(t=>l1a(t)):!1}function _2f({literal:e,wrapAsNullable:t,groupName:r,description:n,availability:i,nameOverride:a,generatedName:u,title:f}){return t?Qp.nullable({nameOverride:a,generatedName:u,title:f,value:Qp.literal({nameOverride:a,generatedName:u,title:f,value:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Qp.literal({nameOverride:a,generatedName:u,title:f,value:e,groupName:r,description:n,availability:i})}function oU({primitive:e,wrapAsNullable:t,groupName:r,description:n,availability:i,generatedName:a,nameOverride:u,title:f}){return r=typeof r=="string"?[r]:r,t?Qp.nullable({nameOverride:u,generatedName:a,title:f,value:Qp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r}),groupName:r,description:n,availability:i}):Qp.primitive({nameOverride:u,generatedName:a,title:f,schema:e,description:n,availability:i,groupName:r})}function RF1({schemas:e}){let t=new Set;for(let r of e){if(Oy(r))return;if(r.enum!=null&&Bvi(r.enum))r.enum.forEach(n=>t.add(n));else return}return Array.from(t)}function h2f({schemas:e,context:t}){let r={};for(let n of e){let i=y2f({schema:n,context:t});for(let[a,u]of Object.entries(i)){let f=r[a];f!=null?f[u]=n:r[a]={[u]:n}}}for(let[n,i]of Object.entries(r))if(Object.keys(i).length===e.length)return{discriminant:n,schemas:i}}function y2f({schema:e,context:t}){let r=Oy(e)?t.resolveSchemaReference(e):e;return FF1({schema:r,context:t})}function FF1({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let n of e.anyOf){let i=y2f({schema:n,context:t});for(let[a,u]of Object.entries(i??{}))r[a]=u}return r}for(let[n,i]of Object.entries(e.properties??{})){let a=Oy(i)?t.resolveSchemaReference(i):i;a.type==="string"&&a.enum!=null&&Bvi(a.enum)&&LF1(a.enum).length===1&&a.enum[0]!=null&&(r[n]=a.enum[0]);let u=v2f(a,"const");a.type==="string"&&u!=null&&(r[n]=u),n==="type"&&a.example!=null&&(r[n]=a.example)}return r}function LF1(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function v2f(e,t){let r=e[t];if(r!=null)return r}function UF1({schema:e,logger:t}){let r=YCf({schema:e,logger:t});if(r!=null)return r2f(r)}function f1a(e,t){let r={},n={};return e==null?r=t:n={[e]:t},{rootSchemas:r,namespacedSchemas:n}}var b2f="#/components/messages/",Ggu=class{logger;document;taskContext;DUMMY;options;namespace;constructor({document:t,taskContext:r,options:n,namespace:i}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=n,this.namespace=i}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let n=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};n.push(i)}return n.concat(t??[])}resolveSchemaReference(t){if(this.document.components==null||this.document.components.schemas==null||!t.$ref.startsWith(Irn))throw new Error(`Failed to resolve ${t.$ref}`);let n=t.$ref.substring(Irn.length).split("/");if(n[0]==null)throw new Error(`${t.$ref} is undefined`);let i=this.document.components.schemas[n[0]];if(i==null)throw new Error(`${n[0]} is undefined`);if(Oy(i)&&(i=this.resolveSchemaReference(i)),n[1]==="properties"&&n[2]!=null){let a=i.properties?.[n[2]];if(a==null)throw new Error(`${t.$ref} is undefiened. Property does not exist on object.`);Oy(a)?i=this.resolveSchemaReference(a):i=a}return i}resolveMessageReference(t){if(this.document.components==null||this.document.components.messages==null||!t.$ref.startsWith(b2f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(b2f.length),n=this.document.components.messages[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}},d1a=class extends Ggu{constructor({document:t,taskContext:r,options:n,namespace:i}){super({document:t,taskContext:r,options:n,namespace:i})}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,n){}markSchemaWithDiscriminantValue(t,r,n){}};function uzr(e){if(typeof e=="string")return n1.primitive(_0.string(e));if(typeof e=="number")return Number.isInteger(e)?n1.primitive(_0.int(e)):n1.primitive(_0.double(e));if(typeof e=="boolean")return n1.primitive(_0.boolean(e));if(Array.isArray(e)){let t=e.map(r=>uzr(r));return t.length===0?void 0:n1.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,n]of Object.entries(e)){let i=uzr(n);i!=null&&t.push({key:_0.string(r),value:i})}return n1.map(t)}}function Nvi(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function g2f(e){if(e!=null&&Array.isArray(e))return e}var szr=class{schemas;constructor(t){this.schemas=t}buildExample({schema:t,exampleId:r,example:n,options:i,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:n,options:{...i,maxCheckerDepth:i.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:n,depth:i,visitedSchemaIds:a,options:u,skipReadonly:f}){switch(n.type){case"enum":return typeof r=="string"&&m2f({schema:n,value:r})?n1.enum(r):n.values[0]!=null?n1.enum(n.values[0]?.value):void 0;case"literal":return n1.literal(n.value);case"nullable":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:!1});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"optional":{if(r==null&&!this.hasExample(n.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(i,u)))return;let d=this.buildExampleHelper({schema:n.value,visitedSchemaIds:a,exampleId:t,example:r,depth:i,options:u,skipReadonly:!1});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:n.schema,example:r,options:u});return n1.primitive(d)}case"reference":{let d=this.schemas[n.schema];if(d!=null&&!a.has(n.schema)){a.add(n.schema);let c=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:i,options:u,skipReadonly:!1});return a.delete(n.schema),c}return}case"oneOf":switch(n.value.type){case"discriminated":{let d={},c={},o={},l=Nvi(r),g=l?.[n.value.discriminantProperty],O=n.value.schemas[g],w=[],j=this.getDiscriminatedUnionVariantSchema(n.value,l);j!=null&&w.push(j),w.push(...Object.entries(n.value.schemas));for(let M of w)if(g!=null&&O!=null&&O.type==="object"){c=this.getAllProperties(O),o=this.getAllRequiredProperties(O),d[n.value.discriminantProperty]=n1.primitive(_0.string(g));break}else{let q=this.getObjectSchema(M[1]);if(q==null)continue;c=this.getAllProperties(q),o=this.getAllRequiredProperties(q),d[n.value.discriminantProperty]=n1.primitive(_0.string(M[0]))}for(let M of n.value.commonProperties){c[M.key]={schema:M.schema,readonly:!1};let q=this.getResolvedSchema(M.schema);q.type!=="optional"&&q.type!=="nullable"&&(o[M.key]=M.schema)}for(let[M,q]of Object.entries(c)){let B=M in o;if(B&&l?.[M]!=null){let I=this.buildExampleHelper({schema:q.schema,exampleId:t,example:l[M],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:!1});if(I!=null)d[M]=I;else return}else{let I=this.buildExampleHelper({exampleId:t,schema:q.schema,example:l?.[M],visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:!1});if(I!=null)d[M]=I;else if(B)return}}return n1.oneOf(Q8r.discriminated(d))}case"undisciminated":{let d=this.getUnDiscriminatedUnionVariantSchema(n.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:i,options:u,skipReadonly:!1});break}}return;case"unknown":if(r!=null){let d=uzr(r);if(d!=null)return n1.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(i,u)?void 0:u.isParameter?n1.primitive(_0.string(u.name??"string")):n1.map([{key:_0.string("key"),value:n1.primitive(_0.string("value"))}]);case"array":{let d=g2f(r),c=[];if(d!=null&&d.length>0)for(let o of d){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:!1});l!=null&&c.push(l)}else if(n.example!=null&&n.example.length>0)for(let o of n.example){let l=this.buildExampleHelper({exampleId:t,example:o,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:!1});l!=null&&c.push(l)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,depth:i+1,visitedSchemaIds:a,options:u,skipReadonly:!1});o!=null&&c.push(o)}return n1.array(c)}case"map":{let d=Nvi(r??n.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[g,O]of Object.entries(d)){let w=this.buildExampleFromPrimitive({schema:n.key.schema,example:g,options:u}),j=this.buildExampleHelper({exampleId:t,example:O,schema:n.value,visitedSchemaIds:a,depth:i+1,options:u,skipReadonly:!1});j!=null&&l.push({key:w,value:j})}return n1.map(l)}if(n.key.schema.type==="string"&&n.value.type==="unknown")return n1.map([{key:_0.string("key"),value:n1.unknown(n1.primitive(_0.string("value")))}]);let c=this.buildExampleFromPrimitive({schema:n.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:n.value,visitedSchemaIds:a,depth:i+1,options:{...u,name:"value"},skipReadonly:!1});return o!=null?n1.map([{key:c,value:o}]):n1.map([])}case"object":{let d={},c=n.fullExamples?.find(O=>O.name===t)??n.fullExamples?.find(O=>O.name==null)??n.fullExamples?.[0],o=Nvi(r)??(c!=null?Nvi(c.value):{})??{},l=this.getAllProperties(n),g=this.getAllRequiredProperties(n);for(let[O,w]of Object.entries(l)){if(f&&w.readonly)continue;let j=O in g,M=Object.keys(o).includes(O),q=this.buildExampleHelper({schema:w.schema,exampleId:t,example:o[O],visitedSchemaIds:a,depth:i+1,options:{...u,name:O},skipReadonly:!1});if(j&&q!=null)d[O]=q;else{if(j)return;(M&&q!=null||!u.ignoreOptionals&&q!=null)&&(d[O]=q)}}return n1.object({properties:d})}default:Kc(n)}}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let n=r?.[t.discriminantProperty];if(n==null||typeof n!="string")return Object.entries(t.schemas)[0];let i=t.schemas[n];return i==null?Object.entries(t.schemas)[0]:[n,i]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return m2f({schema:t,value:r})?5:0;case"object":{if(!sS(r))return 0;let n=this.getAllProperties(t),i=0;for(let[a,u]of Object.entries(n))r[a]!=null?(i++,i+=this.calcExampleHeuristic(u.schema,r[a])):i--;return i}case"array":{if(!Array.isArray(r))return 0;let n=0;for(let i of r)n+=this.calcExampleHeuristic(t.value,i);return n}case"map":{if(!sS(r))return 0;let n=0;for(let[,i]of Object.entries(r))n+=this.calcExampleHeuristic(t.value,i);return n}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let n=this.getResolvedSchema(t);return n==null?0:this.calcExampleHeuristic(n,r)}case"oneOf":return Object.values(t.value.schemas).map(i=>this.calcExampleHeuristic(i,r)).sort((i,a)=>a-i)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,n=new Set,i){if(this.exceedsMaxCheckerDepth(r,i))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,n,i);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,n,i);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,n,i))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!n.has(t.schema)){n.add(t.schema);let u=this.hasExample(a,r,n,i);return n.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,n,i));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let n of t.properties)r[n.key]={schema:n.schema,readonly:n.readonly??!1};for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let n of t.properties){let i=this.getResolvedSchema(n.schema);i.type!=="optional"&&i.type!=="nullable"&&(r[n.key]=n.schema)}for(let n of t.allOf){let i=this.schemas[n.schema];if(i==null)continue;let a=this.getResolvedSchema(i);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:n}){switch(r.type){case"string":return t!=null&&typeof t=="string"?_0.string(t):r.example!=null?_0.string(r.example):_0.string(n.name??nD.STRING);case"base64":return t!=null&&typeof t=="string"?_0.base64(t):r.example!=null?_0.base64(r.example):_0.base64(nD.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?_0.boolean(t):r.example!=null?_0.boolean(r.example):_0.boolean(nD.BOOLEAN);case"date":return t!=null&&typeof t=="string"?_0.date(t):r.example!=null?_0.date(r.example):_0.date(nD.DATE);case"datetime":return t!=null&&typeof t=="string"?_0.datetime(t):r.example!=null?_0.datetime(r.example):_0.datetime(nD.DATE_TIME);case"double":return t!=null&&typeof t=="number"?_0.double(t):r.example!=null?_0.double(r.example):_0.double(nD.DOUBLE);case"float":return t!=null&&typeof t=="number"?_0.float(t):r.example!=null?_0.float(r.example):_0.float(nD.FLOAT);case"int":return t!=null&&typeof t=="number"?_0.int(t):r.example!=null?_0.int(r.example):_0.int(nD.INT);case"int64":return t!=null&&typeof t=="number"?_0.int64(t):r.example!=null?_0.int64(r.example):_0.int64(nD.INT64);case"uint":return t!=null&&typeof t=="number"?_0.uint(t):r.example!=null?_0.uint(r.example):_0.uint(nD.UINT);case"uint64":return t!=null&&typeof t=="number"?_0.uint64(t):r.example!=null?_0.uint64(r.example):_0.uint64(nD.UINT64);default:Kc(r)}}};function m2f({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function r9t(e){switch(e.type){case"object":return Qp.object({allOf:e.allOf,properties:e.properties.map(t=>WF1(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source});case"array":return Qp.array({description:e.description,availability:e.availability,value:r9t(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0});case"enum":return Qp.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,groupName:e.groupName,example:void 0,source:e.source});case"literal":return Qp.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,groupName:e.groupName});case"nullable":return Qp.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:r9t(e.value),groupName:e.groupName});case"optional":return Qp.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:r9t(e.value),groupName:e.groupName});case"primitive":return Qp.primitive({description:e.description,availability:e.availability,schema:O2f(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName});case"map":return Qp.map({description:e.description,availability:e.availability,key:Qp.primitive({description:e.key.description,availability:e.key.availability,schema:O2f(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,groupName:e.groupName}),value:r9t(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,groupName:e.groupName,encoding:e.encoding,example:void 0});case"reference":return Qp.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,groupName:e.groupName,source:e.source});case"oneOf":return Qp.oneOf(VF1(e.value));case"unknown":return Qp.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,groupName:void 0,description:void 0,availability:void 0});default:Kc(e)}}function VF1(e){switch(e.type){case"discriminated":return UZ.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:r9t(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,r9t(r)])),groupName:e.groupName,encoding:e.encoding,source:e.source});case"undisciminated":return UZ.undisciminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>r9t(t)),groupName:e.groupName,encoding:e.encoding,source:e.source});default:Kc(e)}}function O2f(e){switch(e.type){case"string":return Ey.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return Ey.base64({example:void 0});case"boolean":return Ey.boolean({default:e.default,example:void 0});case"date":return Ey.date({example:void 0});case"datetime":return Ey.datetime({example:void 0});case"double":return Ey.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return Ey.float({example:void 0});case"int":return Ey.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return Ey.int64({default:e.default,example:void 0});case"uint":return Ey.uint({default:void 0,example:void 0});case"uint64":return Ey.uint64({default:void 0,example:void 0});default:Kc(e)}}function WF1(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:r9t(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly}}function p1a(e){return e.type!=="optional"&&e.type!=="nullable"}function zvi(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var _1a=class{exampleTypeFactory;logger;schemas;constructor(t,r){this.schemas=t,this.exampleTypeFactory=new szr(t),this.logger=r}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=QF1(t.request),n=JF1(t.response);if(r?.type==="unsupported"||n?.type==="unsupported")return[];let i=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let g=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});g!=null&&i.push([void 0,g])}else for(let{name:g,value:O}of r.examples){let w=this.exampleTypeFactory.buildExample({skipReadonly:t.method==="POST"||t.method==="PUT",schema:r.schema,exampleId:g,example:O,options:{isParameter:!1,ignoreOptionals:!0}});w!=null&&i.push([g,w])}if(l&&i.length===0)return this.logger.warn(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(n!=null&&n.type==="present"){let l=this.isSchemaRequired(n.schema);if(n.examples.length===0){let g=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:void 0,example:void 0,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});g!=null&&(t.response?.type==="json"?a.push([void 0,tIt.withoutStreaming(g)]):t.response?.type==="streamingJson"&&a.push([void 0,tIt.withStreaming([g])]))}else for(let{name:g,value:O}of n.examples){let w=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:n.schema,exampleId:g,example:O,options:{maxDepth:3,isParameter:!1,ignoreOptionals:!1}});w!=null&&(t.response?.type==="json"?a.push([g,tIt.withoutStreaming(w)]):t.response?.type==="streamingJson"&&a.push([g,tIt.withStreaming([w])]))}if(l&&a.length===0)return this.logger.warn(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!n9t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:O})}let f=[];for(let l of t.queryParameters){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!n9t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&f.push({name:l.name,value:O})}let d=[];for(let l of t.headers){let g=this.isSchemaRequired(l.schema),O=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(O!=null&&!n9t(O)&&(this.logger.warn(`Expected a primitive example but got ${O.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),O=void 0),g&&O==null)return[];O!=null&&d.push({name:l.name,value:O})}let c=[];t.request!=null&&t.response!=null?c=HF1(i,a):t.request!=null?c=i.map(([l,g])=>({id:l,request:g,response:void 0})):t.response!=null&&(c=a.map(([l,g])=>({id:l,request:void 0,response:g})));let o=t.examples.filter(l=>zvi(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let g=l.value["code-samples"];if(g!=null)return this.convertCodeSamples(g)}return}else return l.codeSamples}).filter(l=>HM(l));return c.length===0?[eIt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:void 0,response:void 0,codeSamples:o})]:c.map(({id:l,request:g,response:O})=>eIt.full({name:l,description:void 0,pathParameters:u,queryParameters:f,headers:d,request:g,response:O,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?kEr.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):kEr.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?TH.Csharp:r.sdk,code:r.code})).filter(HM)}isSchemaRequired(t){return p1a(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function HF1(e,t){let r=[];if(e.length<=1){let[i,a]=e[0]??[];if(t.length===0)return r.push({id:i,request:a,response:void 0}),r;for(let[u,f]of t)r.push({id:u??i,request:a,response:f});return r}if(t.length<=1){let[i,a]=t[0]??[];if(t.length===0)return r.push({id:i,request:void 0,response:a}),r;for(let[u,f]of e)r.push({id:u??i,request:f,response:a});return r}let n=new Set;for(let[i,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(i==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let f=!1;for(let d=0;d<t.length;d++){let[c,o]=t[d];c!=null||n.has(d)||i===c&&(r.push({id:i,request:a,response:o}),c!=null&&n.add(d),f=!0)}!f&&u!=null&&r.push({id:i,request:a,response:u})}for(let i=0;i<t.length;i++){if(n.has(i))continue;let[a,u]=t[i],f=e.find(([d])=>d==null)?.[1]??e[0]?.[1];f!=null&&r.push({id:a,request:f,response:u})}return r}function QF1(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:GF1(e),examples:[]}:e.type==="json"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function JF1(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function n9t(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return n9t(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undisciminated":return n9t(e.value.value);default:return!1}default:Kc(e)}}function GF1(e){return Qp.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:r9t(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0}).filter(HM),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source})}var h1a=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new szr(t),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,publish:n,subscribe:i,handshake:a,source:u,namespace:f}){let d=[];for(let c of r){let o=[];for(let O of a.queryParameters){let w=this.isSchemaRequired(O.schema),j=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.queryParameters?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});j!=null&&!n9t(j)&&(j=void 0),!(w&&j==null)&&j!=null&&o.push({name:O.name,value:j})}let l=[];for(let O of a.headers){let w=this.isSchemaRequired(O.schema),j=this.exampleTypeFactory.buildExample({schema:O.schema,exampleId:void 0,example:c.headers?.[O.name],options:{name:O.name,isParameter:!0,ignoreOptionals:!0}});j!=null&&!n9t(j)&&(j=void 0),!(w&&j==null)&&j!=null&&l.push({name:O.name,value:j})}let g=[];for(let O of c.messages){let w=t.resolveMessageReference({$ref:`#/components/messages/${O.messageId}`}),j=Oy(w.payload)?t.resolveSchemaReference(w.payload):w.payload,M=this.exampleTypeFactory.buildExample({schema:i1(j,!1,t,[O.messageId],u,f),exampleId:void 0,example:O.value,options:{isParameter:!1,ignoreOptionals:!0}});M!=null&&g.push({messageType:O.type,payload:M,description:void 0})}d.push({name:c.summary,queryParameters:o,headers:l,description:c.description,messages:g})}return d}buildWebsocketSessionExample({publish:t,subscribe:r,handshake:n}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},a=[];for(let f of n.queryParameters){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!n9t(c)&&(c=void 0),d&&c==null)return;c!=null&&a.push({name:f.name,value:c})}let u=[];for(let f of n.headers){let d=this.isSchemaRequired(f.schema),c=this.exampleTypeFactory.buildExample({schema:f.schema,exampleId:void 0,example:void 0,options:{name:f.name,isParameter:!0,ignoreOptionals:!0}});if(c!=null&&!n9t(c)&&(c=void 0),d&&c==null)return;c!=null&&u.push({name:f.name,value:c})}if(t!=null){let f=this.exampleTypeFactory.buildExample({schema:t,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"publish",payload:f,description:void 0})}if(r!=null){let f=this.exampleTypeFactory.buildExample({schema:r,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});f!=null&&i.messages.push({messageType:"subscribe",payload:f,description:void 0})}return i}isSchemaRequired(t){return p1a(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var Rvi={FERN_DISPLAY_NAME:"x-fern-display-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path"};function P2f(e){return Oh(e,Rvi.FERN_EXAMPLES)??[]}function j2f({document:e,taskContext:t,options:r,source:n,asyncApiOptions:i,namespace:a}){let u=[];a!=null&&u.push(a),e.tags?.[0]!=null?u.push(e.tags[0].name):i.naming!=="v2"&&u.push("websocket");let f=new d1a({document:e,taskContext:t,options:r,namespace:a}),d={},c;for(let[l,g]of Object.entries(e.components?.schemas??{})){let O=i1(g,!1,f,[l],n,a);d[l]=O}let o=new h1a(d,t.logger);for(let[l,g]of Object.entries(e.channels??{})){if(g.bindings?.ws==null){f.logger.error(`Channel ${l} does not have websocket bindings. Skipping.`);continue}let O=[];if(g.parameters!=null)for(let[B,I]of Object.entries(g.parameters??{}))O.push({name:B,description:I.description,parameterNameOverride:void 0,schema:I.schema!=null?i1(I.schema,!1,f,u,n,a):Qp.primitive({schema:Ey.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:XCe(I),source:n});let w=[];if(g.bindings.ws.headers!=null){let B=g.bindings.ws.headers.required??[];for(let[I,C]of Object.entries(g.bindings.ws.headers.properties??{})){let L=Oy(C)?f.resolveSchemaReference(C):C;w.push({name:I,schema:i1(L,!B.includes(I),f,u,n,a),description:L.description,parameterNameOverride:void 0,env:void 0,availability:XCe(L),source:n})}}let j=[];if(g.bindings.ws.query!=null){let B=g.bindings.ws.query.required??[];for(let[I,C]of Object.entries(g.bindings.ws.query.properties??{})){let L=Oy(C)?f.resolveSchemaReference(C):C;j.push({name:I,schema:i1(L,!B.includes(I),f,u,n,a),description:L.description,parameterNameOverride:void 0,availability:XCe(L),source:n})}}let M;g.publish!=null&&(M=w2f({generatedName:g.publish.operationId??"PublishEvent",event:g.publish,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i}));let q;if(g.subscribe!=null&&(q=w2f({generatedName:g.subscribe.operationId??"SubscribeEvent",event:g.subscribe,breadcrumbs:u,context:f,source:n,options:r,asyncApiOptions:i})),w.length>0||j.length>0||M!=null||q!=null){let B=P2f(g),I=[];if(B.length>0)I=o.buildWebsocketSessionExamplesForExtension({context:f,extensionExamples:B,handshake:{headers:w,queryParameters:j},publish:M,subscribe:q,source:n,namespace:a});else{let L=o.buildWebsocketSessionExample({handshake:{headers:w,queryParameters:j},publish:M,subscribe:q});L!=null&&I.push(L)}let C=e.tags?.[0]?.name!=null?[e.tags?.[0].name]:void 0;c={handshake:{headers:w.map(L=>({...L,schema:JC(L.schema),env:L.env})),queryParameters:j.map(L=>({...L,schema:JC(L.schema)})),pathParameters:O.map(L=>({...L,parameterNameOverride:void 0,schema:JC(L.schema)}))},groupName:f.resolveTags(C,"Websocket"),publish:M!=null?JC(M):M,subscribe:q!=null?JC(q):q,summary:Oh(g,Rvi.FERN_DISPLAY_NAME),path:l,description:void 0,examples:I,source:n};break}}return{groupedSchemas:f1a(a,d),channel:c,basePath:Oh(e,Rvi.BASE_PATH)}}function w2f({generatedName:e,event:t,context:r,breadcrumbs:n,source:i,options:a,asyncApiOptions:u}){if(t.message.oneOf!=null){let f=[],d=[];for(let c of t.message.oneOf){let o,l={type:"notFound"};if(Oy(c)){let g=r.resolveMessageReference(c);!Oy(g.payload)&&u.naming==="v2"?(l=g.name?{type:"name",name:g.name}:l,o={...g.payload,title:g.name??g.payload.title,description:g.name??g.payload.description}):o=g.payload}else o=c;d.push(l),f.push(o)}return i7n({description:t.description??t.message.description,availability:XCe(t.message),subtypes:f,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:n,context:r,encoding:void 0,source:i,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}var _nn=tu(lzf(),1);var fzf=require("fs/promises");async function jDa({absoluteFilepathToOverrides:e,data:t,context:r}){let n=null;try{let i=(await(0,fzf.readFile)(e,"utf8")).toString();try{n=JSON.parse(i)}catch{n=f0.load(i,{json:!0})}}catch{return r.failAndThrow(`Failed to read overrides from file ${e}`)}return JQo({data:t,overrides:n})}var acw={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},ocw={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:acw,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}};async function pzf({absolutePathToOpenAPI:e,absolutePathToOpenAPIOverrides:t,context:r}){let n=await dzf({absolutePathToOpenAPI:e}),i;if(t!=null?i=t:typeof n=="object"&&n[iy.OPENAPI_OVERIDES_FILEPATH]!=null&&(i=yf(ub(e),Ms.of(n[iy.OPENAPI_OVERIDES_FILEPATH]))),i!=null){let a=await jDa({absoluteFilepathToOverrides:i,context:r,data:n});return await dzf({absolutePathToOpenAPI:e,parsed:a})}return n}async function dzf({absolutePathToOpenAPI:e,parsed:t}){let r={config:new _nn.Config({apis:{},styleguide:{plugins:[ocw],rules:{spec:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};return(t!=null?await(0,_nn.bundle)({...r,doc:{source:new _nn.Source(e,"<openapi>"),parsed:t}}):await(0,_nn.bundle)({...r,ref:e})).bundle.parsed}var DLf=tu(O9f(),1);function P9f(e){return Oh(e,iy.ASYNC_CONFIG)}var w9f="$request.";function j9f(e){let t=Oh(e,iy.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:bhw(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function bhw(e){return e.startsWith(w9f)?e.slice(w9f.length):e}function D9f(e){let t=e;if(t.cursor!=null)return ZEr.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});let r=e;return ZEr.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}function S9f(e,t){let r=Oh(t,iy.PAGINATION);if(r!=null){if(typeof r=="boolean"){let n=Oh(e,iy.PAGINATION);if(typeof n=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return n==null?void 0:D9f(n)}return D9f(r)}}function E9f(e){let t=ghw(e),r={};return vSu({obj:t,occurrences:r,breadcrumbs:[]}),r}function vSu({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let n of e)vSu({obj:n,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let n=e.$ref;t[n]==null?t[n]=1:t[n]+=1;return}for(let n in e)vSu({obj:e[n],occurrences:t,breadcrumbs:[...r,n]})}}}function ghw(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?zgi(r.get):void 0,put:r?.put!=null?zgi(r.put):void 0,post:r?.post!=null?zgi(r.post):void 0,patch:r?.patch!=null?zgi(r.patch):void 0,delete:r?.delete!=null?zgi(r.delete):void 0}]))}}function zgi(e){return{...e,requestBody:e.requestBody!=null?Oy(e.requestBody)?e.requestBody:mhw(e.requestBody):void 0}}function mhw(e){let t,r;for(let n in e.content){let i=gB.parse(n);i!=null&&(i.isJSON()?t=e.content[n]:i.isMultipart()&&(r=e.content[n]))}return r!=null&&t!=null?{...e,content:{[gB.MULTIPART_FORM_DATA]:r}}:e}var A9f="#/components/parameters/",M9f="#/components/responses/",x9f="#/components/examples/",T9f="#/components/requestBodies/",ONn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;namespace;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=n,this.refOccurrences=E9f(t),this.options=i,this.source=a,this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};r.push(n)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return{"x-fern-type":"unknown",additionalProperties:!0};n=n[i]}return n==null?{"x-fern-type":"unknown",additionalProperties:!0}:(Oy(n)&&(n=this.resolveSchemaReference(n)),n)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(A9f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(A9f.length),n=this.document.components.parameters[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Oy(n)?this.resolveParameterReference(n):n}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(T9f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(T9f.length),n=this.document.components.requestBodies[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Oy(n)?this.resolveRequestBodyReference(n):n}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(M9f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(M9f.length),n=this.document.components.responses[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Oy(n)?this.resolveResponseReference(n):n}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(x9f))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(x9f.length),n=this.document.components.examples[r];if(n==null)throw new Error(`${t.$ref} is undefined`);return Oy(n)?this.resolveExampleReference(n):n}referenceExists(t){let r=t.substring(2).split("/").map(i=>i.replace(/~1/g,"/")),n=this.document;for(let i of r){if(typeof n!="object"||n==null)return!1;n=n[i]}return!0}};var PNn=class extends ONn{constructor({document:t,taskContext:r,options:n,source:i,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:n,source:i,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,n){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,n){}getDiscriminatedUnionMetadata(t){}};var Px;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let a={};for(let u of i)a[u]=u;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(let f of a)u[f]=i[f];return e.objectValues(u)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let u in i)Object.prototype.hasOwnProperty.call(i,u)&&a.push(u);return a},e.find=(i,a)=>{for(let u of i)if(a(u))return u},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(Px||(Px={}));var gSu;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(gSu||(gSu={}));var x0=Px.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Zzr=e=>{switch(typeof e){case"undefined":return x0.undefined;case"string":return x0.string;case"number":return isNaN(e)?x0.nan:x0.number;case"boolean":return x0.boolean;case"function":return x0.function;case"bigint":return x0.bigint;case"symbol":return x0.symbol;case"object":return Array.isArray(e)?x0.array:e===null?x0.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?x0.promise:typeof Map<"u"&&e instanceof Map?x0.map:typeof Set<"u"&&e instanceof Set?x0.set:typeof Date<"u"&&e instanceof Date?x0.date:x0.object;default:return x0.unknown}},hh=Px.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ohw=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),lDe=class e extends Error{constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let r=t||function(a){return a.message},n={_errors:[]},i=a=>{for(let u of a.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)n._errors.push(r(u));else{let f=n,d=0;for(;d<u.path.length;){let c=u.path[d];d===u.path.length-1?(f[c]=f[c]||{_errors:[]},f[c]._errors.push(r(u))):f[c]=f[c]||{_errors:[]},f=f[c],d++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Px.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};lDe.create=e=>new lDe(e);var DNn=(e,t)=>{let r;switch(e.code){case hh.invalid_type:e.received===x0.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case hh.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Px.jsonStringifyReplacer)}`;break;case hh.unrecognized_keys:r=`Unrecognized key(s) in object: ${Px.joinValues(e.keys,", ")}`;break;case hh.invalid_union:r="Invalid input";break;case hh.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Px.joinValues(e.options)}`;break;case hh.invalid_enum_value:r=`Invalid enum value. Expected ${Px.joinValues(e.options)}, received '${e.received}'`;break;case hh.invalid_arguments:r="Invalid function arguments";break;case hh.invalid_return_type:r="Invalid function return type";break;case hh.invalid_date:r="Invalid date";break;case hh.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Px.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case hh.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case hh.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case hh.custom:r="Invalid input";break;case hh.invalid_intersection_types:r="Intersection results could not be merged";break;case hh.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case hh.not_finite:r="Number must be finite";break;default:r=t.defaultError,Px.assertNever(e)}return{message:r}},I9f=DNn;function Phw(e){I9f=e}function CSa(){return I9f}var qSa=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],u={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let f="",d=n.filter(c=>!!c).slice().reverse();for(let c of d)f=c(u,{data:t,defaultError:f}).message;return{...i,path:a,message:f}},whw=[];function o0(e,t){let r=CSa(),n=qSa({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===DNn?void 0:DNn].filter(i=>!!i)});e.common.issues.push(n)}var E$=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return nP;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let a=await i.key,u=await i.value;n.push({key:a,value:u})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:a,value:u}=i;if(a.status==="aborted"||u.status==="aborted")return nP;a.status==="dirty"&&t.dirty(),u.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof u.value<"u"||i.alwaysSet)&&(n[a.value]=u.value)}return{status:t.value,value:n}}},nP=Object.freeze({status:"aborted"}),jNn=e=>({status:"dirty",value:e}),nk=e=>({status:"valid",value:e}),mSu=e=>e.status==="aborted",OSu=e=>e.status==="dirty",Lgi=e=>e.status==="valid",Ugi=e=>typeof Promise<"u"&&e instanceof Promise;function ISa(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function B9f(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r}var jg;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(jg||(jg={}));var Rgi,Fgi,f2e=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},C9f=(e,t)=>{if(Lgi(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new lDe(e.common.issues);return this._error=r,this._error}}};function Dj(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(u,f)=>{var d,c;let{message:o}=e;return u.code==="invalid_enum_value"?{message:o??f.defaultError}:typeof f.data>"u"?{message:(d=o??n)!==null&&d!==void 0?d:f.defaultError}:u.code!=="invalid_type"?{message:f.defaultError}:{message:(c=o??r)!==null&&c!==void 0?c:f.defaultError}},description:i}}var Sj=class{constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(t){return Zzr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Zzr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new E$,ctx:{common:t.parent.common,data:t.data,parsedType:Zzr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Ugi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){var n;let i={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Zzr(t)},a=this._parseSync({data:t,path:i.path,parent:i});return C9f(i,a)}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Zzr(t)},i=this._parse({data:t,path:n.path,parent:n}),a=await(Ugi(i)?i:Promise.resolve(i));return C9f(n,a)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{let u=t(i),f=()=>a.addIssue({code:hh.custom,...n(i)});return typeof Promise<"u"&&u instanceof Promise?u.then(d=>d?!0:(f(),!1)):u?!0:(f(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new fDe({schema:this,typeName:TO.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return l2e.create(this,this._def)}nullable(){return O9t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return gAr.create(this,this._def)}promise(){return t5r.create(this,this._def)}or(t){return Cnn.create([this,t],this._def)}and(t){return qnn.create(this,t,this._def)}transform(t){return new fDe({...Dj(this._def),schema:this,typeName:TO.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Rnn({...Dj(this._def),innerType:this,defaultValue:r,typeName:TO.ZodDefault})}brand(){return new Vgi({typeName:TO.ZodBranded,type:this,...Dj(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Fnn({...Dj(this._def),innerType:this,catchValue:r,typeName:TO.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Wgi.create(this,t)}readonly(){return Lnn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},jhw=/^c[^\s-]{8,}$/i,Dhw=/^[0-9a-z]+$/,Shw=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ehw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ahw=/^[a-z0-9_-]{21}$/i,Mhw=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xhw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Thw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",bSu,Chw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,qhw=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ihw=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,N9f="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Bhw=new RegExp(`^${N9f}$`);function z9f(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function Nhw(e){return new RegExp(`^${z9f(e)}$`)}function R9f(e){let t=`${N9f}T${z9f(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function zhw(e,t){return!!((t==="v4"||!t)&&Chw.test(e)||(t==="v6"||!t)&&qhw.test(e))}var kzr=class e extends Sj{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==x0.string){let a=this._getOrReturnCtx(t);return o0(a,{code:hh.invalid_type,expected:x0.string,received:a.parsedType}),nP}let n=new E$,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let u=t.data.length>a.value,f=t.data.length<a.value;(u||f)&&(i=this._getOrReturnCtx(t,i),u?o0(i,{code:hh.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):f&&o0(i,{code:hh.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")xhw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"email",code:hh.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")bSu||(bSu=new RegExp(Thw,"u")),bSu.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"emoji",code:hh.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ehw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"uuid",code:hh.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Ahw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"nanoid",code:hh.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")jhw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"cuid",code:hh.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Dhw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"cuid2",code:hh.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Shw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"ulid",code:hh.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),o0(i,{validation:"url",code:hh.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"regex",code:hh.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?R9f(a).test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Bhw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Nhw(a).test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Mhw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"duration",code:hh.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?zhw(t.data,a.version)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"ip",code:hh.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Ihw.test(t.data)||(i=this._getOrReturnCtx(t,i),o0(i,{validation:"base64",code:hh.invalid_string,message:a.message}),n.dirty()):Px.assertNever(a);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:hh.invalid_string,...jg.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...jg.errToObj(t)})}url(t){return this._addCheck({kind:"url",...jg.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...jg.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...jg.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...jg.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...jg.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...jg.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...jg.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...jg.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...jg.errToObj(t)})}datetime(t){var r,n;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(r=t?.offset)!==null&&r!==void 0?r:!1,local:(n=t?.local)!==null&&n!==void 0?n:!1,...jg.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...jg.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...jg.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...jg.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...jg.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...jg.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...jg.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...jg.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...jg.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...jg.errToObj(r)})}nonempty(t){return this.min(1,jg.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};kzr.create=e=>{var t;return new kzr({checks:[],typeName:TO.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Dj(e)})};function Rhw(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(e.toFixed(i).replace(".","")),u=parseInt(t.toFixed(i).replace(".",""));return a%u/Math.pow(10,i)}var Snn=class e extends Sj{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==x0.number){let a=this._getOrReturnCtx(t);return o0(a,{code:hh.invalid_type,expected:x0.number,received:a.parsedType}),nP}let n,i=new E$;for(let a of this._def.checks)a.kind==="int"?Px.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?Rhw(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.not_finite,message:a.message}),i.dirty()):Px.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,jg.toString(r))}gt(t,r){return this.setLimit("min",t,!1,jg.toString(r))}lte(t,r){return this.setLimit("max",t,!0,jg.toString(r))}lt(t,r){return this.setLimit("max",t,!1,jg.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:jg.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:jg.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:jg.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:jg.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:jg.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:jg.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:jg.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:jg.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:jg.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:jg.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Px.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Snn.create=e=>new Snn({checks:[],typeName:TO.ZodNumber,coerce:e?.coerce||!1,...Dj(e)});var Enn=class e extends Sj{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==x0.bigint){let a=this._getOrReturnCtx(t);return o0(a,{code:hh.invalid_type,expected:x0.bigint,received:a.parsedType}),nP}let n,i=new E$;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),o0(n,{code:hh.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):Px.assertNever(a);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,jg.toString(r))}gt(t,r){return this.setLimit("min",t,!1,jg.toString(r))}lte(t,r){return this.setLimit("max",t,!0,jg.toString(r))}lt(t,r){return this.setLimit("max",t,!1,jg.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:jg.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:jg.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:jg.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:jg.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:jg.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:jg.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Enn.create=e=>{var t;return new Enn({checks:[],typeName:TO.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...Dj(e)})};var Ann=class extends Sj{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==x0.boolean){let n=this._getOrReturnCtx(t);return o0(n,{code:hh.invalid_type,expected:x0.boolean,received:n.parsedType}),nP}return nk(t.data)}};Ann.create=e=>new Ann({typeName:TO.ZodBoolean,coerce:e?.coerce||!1,...Dj(e)});var Mnn=class e extends Sj{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==x0.date){let a=this._getOrReturnCtx(t);return o0(a,{code:hh.invalid_type,expected:x0.date,received:a.parsedType}),nP}if(isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return o0(a,{code:hh.invalid_date}),nP}let n=new E$,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),o0(i,{code:hh.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Px.assertNever(a);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:jg.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:jg.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Mnn.create=e=>new Mnn({checks:[],coerce:e?.coerce||!1,typeName:TO.ZodDate,...Dj(e)});var SNn=class extends Sj{_parse(t){if(this._getType(t)!==x0.symbol){let n=this._getOrReturnCtx(t);return o0(n,{code:hh.invalid_type,expected:x0.symbol,received:n.parsedType}),nP}return nk(t.data)}};SNn.create=e=>new SNn({typeName:TO.ZodSymbol,...Dj(e)});var xnn=class extends Sj{_parse(t){if(this._getType(t)!==x0.undefined){let n=this._getOrReturnCtx(t);return o0(n,{code:hh.invalid_type,expected:x0.undefined,received:n.parsedType}),nP}return nk(t.data)}};xnn.create=e=>new xnn({typeName:TO.ZodUndefined,...Dj(e)});var Tnn=class extends Sj{_parse(t){if(this._getType(t)!==x0.null){let n=this._getOrReturnCtx(t);return o0(n,{code:hh.invalid_type,expected:x0.null,received:n.parsedType}),nP}return nk(t.data)}};Tnn.create=e=>new Tnn({typeName:TO.ZodNull,...Dj(e)});var e5r=class extends Sj{constructor(){super(...arguments),this._any=!0}_parse(t){return nk(t.data)}};e5r.create=e=>new e5r({typeName:TO.ZodAny,...Dj(e)});var bAr=class extends Sj{constructor(){super(...arguments),this._unknown=!0}_parse(t){return nk(t.data)}};bAr.create=e=>new bAr({typeName:TO.ZodUnknown,...Dj(e)});var _It=class extends Sj{_parse(t){let r=this._getOrReturnCtx(t);return o0(r,{code:hh.invalid_type,expected:x0.never,received:r.parsedType}),nP}};_It.create=e=>new _It({typeName:TO.ZodNever,...Dj(e)});var ENn=class extends Sj{_parse(t){if(this._getType(t)!==x0.undefined){let n=this._getOrReturnCtx(t);return o0(n,{code:hh.invalid_type,expected:x0.void,received:n.parsedType}),nP}return nk(t.data)}};ENn.create=e=>new ENn({typeName:TO.ZodVoid,...Dj(e)});var gAr=class e extends Sj{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==x0.array)return o0(r,{code:hh.invalid_type,expected:x0.array,received:r.parsedType}),nP;if(i.exactLength!==null){let u=r.data.length>i.exactLength.value,f=r.data.length<i.exactLength.value;(u||f)&&(o0(r,{code:u?hh.too_big:hh.too_small,minimum:f?i.exactLength.value:void 0,maximum:u?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(o0(r,{code:hh.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(o0(r,{code:hh.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((u,f)=>i.type._parseAsync(new f2e(r,u,r.path,f)))).then(u=>E$.mergeArray(n,u));let a=[...r.data].map((u,f)=>i.type._parseSync(new f2e(r,u,r.path,f)));return E$.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:jg.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:jg.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:jg.toString(r)}})}nonempty(t){return this.min(1,t)}};gAr.create=(e,t)=>new gAr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:TO.ZodArray,...Dj(t)});function wNn(e){if(e instanceof Zie){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=l2e.create(wNn(n))}return new Zie({...e._def,shape:()=>t})}else return e instanceof gAr?new gAr({...e._def,type:wNn(e.element)}):e instanceof l2e?l2e.create(wNn(e.unwrap())):e instanceof O9t?O9t.create(wNn(e.unwrap())):e instanceof m9t?m9t.create(e.items.map(t=>wNn(t))):e}var Zie=class e extends Sj{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Px.objectKeys(t);return this._cached={shape:t,keys:r}}_parse(t){if(this._getType(t)!==x0.object){let c=this._getOrReturnCtx(t);return o0(c,{code:hh.invalid_type,expected:x0.object,received:c.parsedType}),nP}let{status:n,ctx:i}=this._processInputParams(t),{shape:a,keys:u}=this._getCached(),f=[];if(!(this._def.catchall instanceof _It&&this._def.unknownKeys==="strip"))for(let c in i.data)u.includes(c)||f.push(c);let d=[];for(let c of u){let o=a[c],l=i.data[c];d.push({key:{status:"valid",value:c},value:o._parse(new f2e(i,l,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof _It){let c=this._def.unknownKeys;if(c==="passthrough")for(let o of f)d.push({key:{status:"valid",value:o},value:{status:"valid",value:i.data[o]}});else if(c==="strict")f.length>0&&(o0(i,{code:hh.unrecognized_keys,keys:f}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let o of f){let l=i.data[o];d.push({key:{status:"valid",value:o},value:c._parse(new f2e(i,l,i.path,o)),alwaysSet:o in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let o of d){let l=await o.key,g=await o.value;c.push({key:l,value:g,alwaysSet:o.alwaysSet})}return c}).then(c=>E$.mergeObjectSync(n,c)):E$.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(t){return jg.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{var i,a,u,f;let d=(u=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&u!==void 0?u:n.defaultError;return r.code==="unrecognized_keys"?{message:(f=jg.errToObj(t).message)!==null&&f!==void 0?f:d}:{message:d}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:TO.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};return Px.objectKeys(t).forEach(n=>{t[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}omit(t){let r={};return Px.objectKeys(this.shape).forEach(n=>{t[n]||(r[n]=this.shape[n])}),new e({...this._def,shape:()=>r})}deepPartial(){return wNn(this)}partial(t){let r={};return Px.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}),new e({...this._def,shape:()=>r})}required(t){let r={};return Px.objectKeys(this.shape).forEach(n=>{if(t&&!t[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof l2e;)a=a._def.innerType;r[n]=a}}),new e({...this._def,shape:()=>r})}keyof(){return F9f(Px.objectKeys(this.shape))}};Zie.create=(e,t)=>new Zie({shape:()=>e,unknownKeys:"strip",catchall:_It.create(),typeName:TO.ZodObject,...Dj(t)});Zie.strictCreate=(e,t)=>new Zie({shape:()=>e,unknownKeys:"strict",catchall:_It.create(),typeName:TO.ZodObject,...Dj(t)});Zie.lazycreate=(e,t)=>new Zie({shape:e,unknownKeys:"strip",catchall:_It.create(),typeName:TO.ZodObject,...Dj(t)});var Cnn=class extends Sj{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(a){for(let f of a)if(f.result.status==="valid")return f.result;for(let f of a)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;let u=a.map(f=>new lDe(f.ctx.common.issues));return o0(r,{code:hh.invalid_union,unionErrors:u}),nP}if(r.common.async)return Promise.all(n.map(async a=>{let u={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(i);{let a,u=[];for(let d of n){let c={...r,common:{...r.common,issues:[]},parent:null},o=d._parseSync({data:r.data,path:r.path,parent:c});if(o.status==="valid")return o;o.status==="dirty"&&!a&&(a={result:o,ctx:c}),c.common.issues.length&&u.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let f=u.map(d=>new lDe(d));return o0(r,{code:hh.invalid_union,unionErrors:f}),nP}}get options(){return this._def.options}};Cnn.create=(e,t)=>new Cnn({options:e,typeName:TO.ZodUnion,...Dj(t)});var vAr=e=>e instanceof Inn?vAr(e.schema):e instanceof fDe?vAr(e.innerType()):e instanceof Bnn?[e.value]:e instanceof Nnn?e.options:e instanceof znn?Px.objectValues(e.enum):e instanceof Rnn?vAr(e._def.innerType):e instanceof xnn?[void 0]:e instanceof Tnn?[null]:e instanceof l2e?[void 0,...vAr(e.unwrap())]:e instanceof O9t?[null,...vAr(e.unwrap())]:e instanceof Vgi||e instanceof Lnn?vAr(e.unwrap()):e instanceof Fnn?vAr(e._def.innerType):[],BSa=class e extends Sj{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==x0.object)return o0(r,{code:hh.invalid_type,expected:x0.object,received:r.parsedType}),nP;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(o0(r,{code:hh.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),nP)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let a of r){let u=vAr(a.shape[t]);if(!u.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let f of u){if(i.has(f))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(f)}`);i.set(f,a)}}return new e({typeName:TO.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...Dj(n)})}};function PSu(e,t){let r=Zzr(e),n=Zzr(t);if(e===t)return{valid:!0,data:e};if(r===x0.object&&n===x0.object){let i=Px.objectKeys(t),a=Px.objectKeys(e).filter(f=>i.indexOf(f)!==-1),u={...e,...t};for(let f of a){let d=PSu(e[f],t[f]);if(!d.valid)return{valid:!1};u[f]=d.data}return{valid:!0,data:u}}else if(r===x0.array&&n===x0.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let a=0;a<e.length;a++){let u=e[a],f=t[a],d=PSu(u,f);if(!d.valid)return{valid:!1};i.push(d.data)}return{valid:!0,data:i}}else return r===x0.date&&n===x0.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var qnn=class extends Sj{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(a,u)=>{if(mSu(a)||mSu(u))return nP;let f=PSu(a.value,u.value);return f.valid?((OSu(a)||OSu(u))&&r.dirty(),{status:r.value,value:f.data}):(o0(n,{code:hh.invalid_intersection_types}),nP)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,u])=>i(a,u)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};qnn.create=(e,t,r)=>new qnn({left:e,right:t,typeName:TO.ZodIntersection,...Dj(r)});var m9t=class e extends Sj{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==x0.array)return o0(n,{code:hh.invalid_type,expected:x0.array,received:n.parsedType}),nP;if(n.data.length<this._def.items.length)return o0(n,{code:hh.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),nP;!this._def.rest&&n.data.length>this._def.items.length&&(o0(n,{code:hh.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((u,f)=>{let d=this._def.items[f]||this._def.rest;return d?d._parse(new f2e(n,u,n.path,f)):null}).filter(u=>!!u);return n.common.async?Promise.all(a).then(u=>E$.mergeArray(r,u)):E$.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};m9t.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new m9t({items:e,typeName:TO.ZodTuple,rest:null,...Dj(t)})};var NSa=class e extends Sj{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==x0.object)return o0(n,{code:hh.invalid_type,expected:x0.object,received:n.parsedType}),nP;let i=[],a=this._def.keyType,u=this._def.valueType;for(let f in n.data)i.push({key:a._parse(new f2e(n,f,n.path,f)),value:u._parse(new f2e(n,n.data[f],n.path,f)),alwaysSet:f in n.data});return n.common.async?E$.mergeObjectAsync(r,i):E$.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof Sj?new e({keyType:t,valueType:r,typeName:TO.ZodRecord,...Dj(n)}):new e({keyType:kzr.create(),valueType:t,typeName:TO.ZodRecord,...Dj(r)})}},ANn=class extends Sj{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==x0.map)return o0(n,{code:hh.invalid_type,expected:x0.map,received:n.parsedType}),nP;let i=this._def.keyType,a=this._def.valueType,u=[...n.data.entries()].map(([f,d],c)=>({key:i._parse(new f2e(n,f,n.path,[c,"key"])),value:a._parse(new f2e(n,d,n.path,[c,"value"]))}));if(n.common.async){let f=new Map;return Promise.resolve().then(async()=>{for(let d of u){let c=await d.key,o=await d.value;if(c.status==="aborted"||o.status==="aborted")return nP;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}})}else{let f=new Map;for(let d of u){let c=d.key,o=d.value;if(c.status==="aborted"||o.status==="aborted")return nP;(c.status==="dirty"||o.status==="dirty")&&r.dirty(),f.set(c.value,o.value)}return{status:r.value,value:f}}}};ANn.create=(e,t,r)=>new ANn({valueType:t,keyType:e,typeName:TO.ZodMap,...Dj(r)});var MNn=class e extends Sj{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==x0.set)return o0(n,{code:hh.invalid_type,expected:x0.set,received:n.parsedType}),nP;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(o0(n,{code:hh.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(o0(n,{code:hh.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function u(d){let c=new Set;for(let o of d){if(o.status==="aborted")return nP;o.status==="dirty"&&r.dirty(),c.add(o.value)}return{status:r.value,value:c}}let f=[...n.data.values()].map((d,c)=>a._parse(new f2e(n,d,n.path,c)));return n.common.async?Promise.all(f).then(d=>u(d)):u(f)}min(t,r){return new e({...this._def,minSize:{value:t,message:jg.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:jg.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};MNn.create=(e,t)=>new MNn({valueType:e,minSize:null,maxSize:null,typeName:TO.ZodSet,...Dj(t)});var zSa=class e extends Sj{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==x0.function)return o0(r,{code:hh.invalid_type,expected:x0.function,received:r.parsedType}),nP;function n(f,d){return qSa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,CSa(),DNn].filter(c=>!!c),issueData:{code:hh.invalid_arguments,argumentsError:d}})}function i(f,d){return qSa({data:f,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,CSa(),DNn].filter(c=>!!c),issueData:{code:hh.invalid_return_type,returnTypeError:d}})}let a={errorMap:r.common.contextualErrorMap},u=r.data;if(this._def.returns instanceof t5r){let f=this;return nk(async function(...d){let c=new lDe([]),o=await f._def.args.parseAsync(d,a).catch(O=>{throw c.addIssue(n(d,O)),c}),l=await Reflect.apply(u,this,o);return await f._def.returns._def.type.parseAsync(l,a).catch(O=>{throw c.addIssue(i(l,O)),c})})}else{let f=this;return nk(function(...d){let c=f._def.args.safeParse(d,a);if(!c.success)throw new lDe([n(d,c.error)]);let o=Reflect.apply(u,this,c.data),l=f._def.returns.safeParse(o,a);if(!l.success)throw new lDe([i(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:m9t.create(t).rest(bAr.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||m9t.create([]).rest(bAr.create()),returns:r||bAr.create(),typeName:TO.ZodFunction,...Dj(n)})}},Inn=class extends Sj{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Inn.create=(e,t)=>new Inn({getter:e,typeName:TO.ZodLazy,...Dj(t)});var Bnn=class extends Sj{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return o0(r,{received:r.data,code:hh.invalid_literal,expected:this._def.value}),nP}return{status:"valid",value:t.data}}get value(){return this._def.value}};Bnn.create=(e,t)=>new Bnn({value:e,typeName:TO.ZodLiteral,...Dj(t)});function F9f(e,t){return new Nnn({values:e,typeName:TO.ZodEnum,...Dj(t)})}var Nnn=class e extends Sj{constructor(){super(...arguments),Rgi.set(this,void 0)}_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return o0(r,{expected:Px.joinValues(n),received:r.parsedType,code:hh.invalid_type}),nP}if(ISa(this,Rgi,"f")||B9f(this,Rgi,new Set(this._def.values),"f"),!ISa(this,Rgi,"f").has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return o0(r,{received:r.data,code:hh.invalid_enum_value,options:n}),nP}return nk(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Rgi=new WeakMap;Nnn.create=F9f;var znn=class extends Sj{constructor(){super(...arguments),Fgi.set(this,void 0)}_parse(t){let r=Px.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==x0.string&&n.parsedType!==x0.number){let i=Px.objectValues(r);return o0(n,{expected:Px.joinValues(i),received:n.parsedType,code:hh.invalid_type}),nP}if(ISa(this,Fgi,"f")||B9f(this,Fgi,new Set(Px.getValidEnumValues(this._def.values)),"f"),!ISa(this,Fgi,"f").has(t.data)){let i=Px.objectValues(r);return o0(n,{received:n.data,code:hh.invalid_enum_value,options:i}),nP}return nk(t.data)}get enum(){return this._def.values}};Fgi=new WeakMap;znn.create=(e,t)=>new znn({values:e,typeName:TO.ZodNativeEnum,...Dj(t)});var t5r=class extends Sj{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==x0.promise&&r.common.async===!1)return o0(r,{code:hh.invalid_type,expected:x0.promise,received:r.parsedType}),nP;let n=r.parsedType===x0.promise?r.data:Promise.resolve(r.data);return nk(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};t5r.create=(e,t)=>new t5r({type:e,typeName:TO.ZodPromise,...Dj(t)});var fDe=class extends Sj{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===TO.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:u=>{o0(n,u),u.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let u=i.transform(n.data,a);if(n.common.async)return Promise.resolve(u).then(async f=>{if(r.value==="aborted")return nP;let d=await this._def.schema._parseAsync({data:f,path:n.path,parent:n});return d.status==="aborted"?nP:d.status==="dirty"||r.value==="dirty"?jNn(d.value):d});{if(r.value==="aborted")return nP;let f=this._def.schema._parseSync({data:u,path:n.path,parent:n});return f.status==="aborted"?nP:f.status==="dirty"||r.value==="dirty"?jNn(f.value):f}}if(i.type==="refinement"){let u=f=>{let d=i.refinement(f,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(n.common.async===!1){let f=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return f.status==="aborted"?nP:(f.status==="dirty"&&r.dirty(),u(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(f=>f.status==="aborted"?nP:(f.status==="dirty"&&r.dirty(),u(f.value).then(()=>({status:r.value,value:f.value}))))}if(i.type==="transform")if(n.common.async===!1){let u=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Lgi(u))return u;let f=i.transform(u.value,a);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(u=>Lgi(u)?Promise.resolve(i.transform(u.value,a)).then(f=>({status:r.value,value:f})):u);Px.assertNever(i)}};fDe.create=(e,t,r)=>new fDe({schema:e,typeName:TO.ZodEffects,effect:t,...Dj(r)});fDe.createWithPreprocess=(e,t,r)=>new fDe({schema:t,effect:{type:"preprocess",transform:e},typeName:TO.ZodEffects,...Dj(r)});var l2e=class extends Sj{_parse(t){return this._getType(t)===x0.undefined?nk(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};l2e.create=(e,t)=>new l2e({innerType:e,typeName:TO.ZodOptional,...Dj(t)});var O9t=class extends Sj{_parse(t){return this._getType(t)===x0.null?nk(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};O9t.create=(e,t)=>new O9t({innerType:e,typeName:TO.ZodNullable,...Dj(t)});var Rnn=class extends Sj{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===x0.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Rnn.create=(e,t)=>new Rnn({innerType:e,typeName:TO.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Dj(t)});var Fnn=class extends Sj{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ugi(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new lDe(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new lDe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Fnn.create=(e,t)=>new Fnn({innerType:e,typeName:TO.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Dj(t)});var xNn=class extends Sj{_parse(t){if(this._getType(t)!==x0.nan){let n=this._getOrReturnCtx(t);return o0(n,{code:hh.invalid_type,expected:x0.nan,received:n.parsedType}),nP}return{status:"valid",value:t.data}}};xNn.create=e=>new xNn({typeName:TO.ZodNaN,...Dj(e)});var Fhw=Symbol("zod_brand"),Vgi=class extends Sj{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Wgi=class e extends Sj{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?nP:a.status==="dirty"?(r.dirty(),jNn(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?nP:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:TO.ZodPipeline})}},Lnn=class extends Sj{_parse(t){let r=this._def.innerType._parse(t),n=i=>(Lgi(i)&&(i.value=Object.freeze(i.value)),i);return Ugi(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Lnn.create=(e,t)=>new Lnn({innerType:e,typeName:TO.ZodReadonly,...Dj(t)});function L9f(e,t={},r){return e?e5r.create().superRefine((n,i)=>{var a,u;if(!e(n)){let f=typeof t=="function"?t(n):typeof t=="string"?{message:t}:t,d=(u=(a=f.fatal)!==null&&a!==void 0?a:r)!==null&&u!==void 0?u:!0,c=typeof f=="string"?{message:f}:f;i.addIssue({code:"custom",...c,fatal:d})}}):e5r.create()}var Lhw={object:Zie.lazycreate},TO;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(TO||(TO={}));var Uhw=(e,t={message:`Input not instance of ${e.name}`})=>L9f(r=>r instanceof e,t),U9f=kzr.create,V9f=Snn.create,Vhw=xNn.create,Whw=Enn.create,W9f=Ann.create,Hhw=Mnn.create,Qhw=SNn.create,Jhw=xnn.create,Ghw=Tnn.create,$hw=e5r.create,Khw=bAr.create,Yhw=_It.create,Xhw=ENn.create,Zhw=gAr.create,khw=Zie.create,eyw=Zie.strictCreate,tyw=Cnn.create,ryw=BSa.create,nyw=qnn.create,iyw=m9t.create,ayw=NSa.create,oyw=ANn.create,uyw=MNn.create,syw=zSa.create,cyw=Inn.create,lyw=Bnn.create,fyw=Nnn.create,dyw=znn.create,pyw=t5r.create,q9f=fDe.create,_yw=l2e.create,hyw=O9t.create,yyw=fDe.createWithPreprocess,vyw=Wgi.create,byw=()=>U9f().optional(),gyw=()=>V9f().optional(),myw=()=>W9f().optional(),Oyw={string:e=>kzr.create({...e,coerce:!0}),number:e=>Snn.create({...e,coerce:!0}),boolean:e=>Ann.create({...e,coerce:!0}),bigint:e=>Enn.create({...e,coerce:!0}),date:e=>Mnn.create({...e,coerce:!0})},Pyw=nP,dDe=Object.freeze({__proto__:null,defaultErrorMap:DNn,setErrorMap:Phw,getErrorMap:CSa,makeIssue:qSa,EMPTY_PATH:whw,addIssueToContext:o0,ParseStatus:E$,INVALID:nP,DIRTY:jNn,OK:nk,isAborted:mSu,isDirty:OSu,isValid:Lgi,isAsync:Ugi,get util(){return Px},get objectUtil(){return gSu},ZodParsedType:x0,getParsedType:Zzr,ZodType:Sj,datetimeRegex:R9f,ZodString:kzr,ZodNumber:Snn,ZodBigInt:Enn,ZodBoolean:Ann,ZodDate:Mnn,ZodSymbol:SNn,ZodUndefined:xnn,ZodNull:Tnn,ZodAny:e5r,ZodUnknown:bAr,ZodNever:_It,ZodVoid:ENn,ZodArray:gAr,ZodObject:Zie,ZodUnion:Cnn,ZodDiscriminatedUnion:BSa,ZodIntersection:qnn,ZodTuple:m9t,ZodRecord:NSa,ZodMap:ANn,ZodSet:MNn,ZodFunction:zSa,ZodLazy:Inn,ZodLiteral:Bnn,ZodEnum:Nnn,ZodNativeEnum:znn,ZodPromise:t5r,ZodEffects:fDe,ZodTransformer:fDe,ZodOptional:l2e,ZodNullable:O9t,ZodDefault:Rnn,ZodCatch:Fnn,ZodNaN:xNn,BRAND:Fhw,ZodBranded:Vgi,ZodPipeline:Wgi,ZodReadonly:Lnn,custom:L9f,Schema:Sj,ZodSchema:Sj,late:Lhw,get ZodFirstPartyTypeKind(){return TO},coerce:Oyw,any:$hw,array:Zhw,bigint:Whw,boolean:W9f,date:Hhw,discriminatedUnion:ryw,effect:q9f,enum:fyw,function:syw,instanceof:Uhw,intersection:nyw,lazy:cyw,literal:lyw,map:oyw,nan:Vhw,nativeEnum:dyw,never:Yhw,null:Ghw,nullable:hyw,number:V9f,object:khw,oboolean:myw,onumber:gyw,optional:_yw,ostring:byw,pipeline:vyw,preprocess:yyw,promise:pyw,record:ayw,set:uyw,strictObject:eyw,string:U9f,symbol:Qhw,transformer:q9f,tuple:iyw,undefined:Jhw,union:tyw,unknown:Khw,void:Xhw,NEVER:Pyw,ZodIssueCode:hh,quotelessJson:Ohw,ZodError:lDe});var wyw=dDe.object({lang:dDe.string(),label:dDe.optional(dDe.string()),source:dDe.string()}),wSu=dDe.array(wyw);var H9f={README_EXT:"x-readme"};function jyw(e){if(!Array.isArray(e))return!1;for(let t of e)if(!sS(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function Q9f(e){let t=Oh(e,H9f.README_EXT);if(!sS(t))return[];let r=t["code-samples"];if(!jyw(r))return[];let n=[];for(let i of r)n.push({name:i.name,language:i.language,code:i.code,install:i.install,docs:void 0});return n}function J9f(e,t,r){let n=Oh(t,iy.EXAMPLES)??[],i=Cvi(t,rDe.REDOCLY_CODE_SAMPLES_KEBAB,wSu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],u=[...Cvi(t,rDe.REDOCLY_CODE_SAMPLES_CAMEL,wSu,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...i];u.length>0&&n.push({"code-samples":u.map(d=>({name:d.label??d.lang,language:d.lang,code:d.source,install:void 0,docs:void 0}))});let f=Q9f(t);return f.length>0&&n.push({"code-samples":f}),n.map(eIt.unknown)}function G9f(e){let t=Oh(e,iy.AVAILABILITY);if(t==="ga"||t==="generally-available")return xH.GenerallyAvailable;if(t==="beta"||t==="pre-release")return xH.Beta;if(t==="deprecated")return xH.Deprecated;if(e.deprecated)return xH.Deprecated}function RSa(e){return{url:Dyw({url:e.url,variables:e.variables??{}}),description:e.description,name:Syw(e),audiences:Oh(e,iy.AUDIENCES)}}function Dyw({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([n,i])=>[n,i.default]));for(let[n,i]of Object.entries(r))e=e.replace(`{${n}}`,i);return e}function Syw(e){let t=Oh(e,[iy.SERVER_NAME_V1,iy.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function $9f(e){return Oh(e,iy.PARAMETER_NAME)}function K9f(e){return Oh(e,iy.SDK_VARIABLE)}function FSa({path:e,httpMethod:t,parameters:r,context:n,requestBreadcrumbs:i,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let f of r){let d=Oy(f)?n.resolveParameterReference(f):f,c=d.required??!1,o=XCe(d),l=[...i,d.name],g=MF(l);t9t({schema:d,logger:n.logger})?.includes(" ")&&n.logger.warn("Parameter example contains a space, which is ambiguous. Consider using enums for multiple examples, or use an encoding if a space is part of the parameter.");let O=d.schema!=null?i1(d.schema,!c,n,l,a,n.namespace,!1,new Set,t9t({schema:d,logger:n.logger})):c?Qp.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Ey.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:t9t({schema:d,logger:n.logger})}),description:void 0,availability:o,groupName:void 0}):Qp.optional({nameOverride:void 0,generatedName:g,title:void 0,value:Qp.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:Ey.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:t9t({schema:d,logger:n.logger})}),description:void 0,availability:void 0,groupName:void 0}),description:void 0,availability:o,groupName:void 0});if(d.in==="header"&&d.schema!=null&&!Oy(d.schema)&&d.schema.default!=null){let j=d.schema.default;typeof j=="string"&&j.length>0&&(O=Qp.literal({nameOverride:void 0,generatedName:g,title:void 0,value:O4.string(j),description:void 0,availability:o,groupName:void 0}))}let w={name:d.name,schema:O,description:d.description,parameterNameOverride:$9f(d),availability:o,source:a};d.in==="query"?u.queryParameters.push(w):d.in==="path"?u.pathParameters.push({...w,variableReference:K9f(d)}):d.in==="header"?!Eyw.has(d.name)&&!n.authHeaders.has(d.name)?u.headers.push({...w,env:void 0}):n.logger.debug(`Ignoring ${d.name} header, in ${t.toUpperCase()} ${e}`):n.logger.warn(`Skipping ${d.in} parameter, ${d.name}, in ${t.toUpperCase()} ${e}`)}return u}var Eyw=new Set(["User-Agent","Content-Length","Content-Type","X-Forwarded-For","Cookie","Origin","Content-Disposition","X-Ping-Custom-Domain"]);function Y9f(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r,schema:i??{},examples:jSu(n,t)}}}function TNn(e,t){for(let r of Object.keys(e))if(r.includes("json")||r==="*/*"){let n=e[r];if(n==null)continue;let i=n.schema;return{contentType:r.includes("*")?void 0:r,schema:i??{},examples:jSu(n,t)}}}function X9f(e,t){for(let r of Object.keys(e)){let n=e[r];if(n==null)continue;return{schema:n.schema??{},examples:jSu(n,t)}}}function jSu(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let n=Oh(e,rDe.EXAMPLES);return n!=null&&Object.keys(n).length>0&&r.push(...Object.entries(n).map(([i,a])=>({name:a.summary??i,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([i,a])=>{let u=Oy(a)?t.resolveExampleReference(a):a;return{name:u.summary??i,value:u.value,description:u.description}})),r}function Ayw(e){for(let[t,r]of Object.entries(e.content))if(gB.parse(t)?.isMultipart())return{schema:r.schema,encoding:r.encoding}}function Myw(e){for(let t in e.content)if(gB.parse(t)?.isOctetStream())return!0;return!1}function xyw(e,t){let r=Oy(e)?DSu(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([n,i])=>!Oy(i)&&i.type==="string"&&i.format==="binary")!=null}function CNn({requestBody:e,document:t,context:r,requestBreadcrumbs:n,source:i,namespace:a}){let u=Oy(e)?r.resolveRequestBodyReference(e):e,f=Ayw(u),d=f?.schema,c=f?.encoding,o=TNn(u.content,r);if(Myw(u))return YCe.octetStream({description:u.description,source:i});if(d!=null&&o==null||d!=null&&xyw(d,t)){let g=Oy(d)?DSu(d,t):{id:void 0,schema:d},O=i1(g.schema,!1,r,n,i,a),w=[];if(O.type==="object")for(let j of O.properties){if(j.schema.type==="primitive"&&j.schema.schema.type==="string"&&j.schema.schema.format==="binary"){w.push({key:j.key,schema:KCe.file({isOptional:!1,isArray:!1}),description:j.schema.description,contentType:c?.[j.key]?.contentType});continue}if(j.schema.type==="optional"&&j.schema.value.type==="primitive"&&j.schema.value.schema.type==="string"&&j.schema.value.schema.format==="binary"){w.push({key:j.key,schema:KCe.file({isOptional:!0,isArray:!1}),description:j.schema.description,contentType:c?.[j.key]?.contentType});continue}if(j.schema.type==="array"&&j.schema.value.type==="primitive"&&j.schema.value.schema.type==="string"&&j.schema.value.schema.format==="binary"){w.push({key:j.key,schema:KCe.file({isOptional:!1,isArray:!0}),description:j.schema.description,contentType:c?.[j.key]?.contentType});continue}if(j.schema.type==="optional"&&j.schema.value.type==="array"&&j.schema.value.value.type==="primitive"&&j.schema.value.value.schema.type==="string"&&j.schema.value.value.schema.format==="binary"){w.push({key:j.key,schema:KCe.file({isOptional:!0,isArray:!0}),description:j.schema.description,contentType:c?.[j.key]?.contentType});continue}w.push({key:j.key,schema:KCe.json(j.schema),description:void 0,contentType:c?.[j.key]?.contentType})}return YCe.multipart({name:Oy(d)&&r.getNumberOfOccurrencesForRef(d)===1?g.id:void 0,description:g.schema.description,properties:w,source:i})}if(o==null)return;let l=i1(o.schema,!1,r,n,i,a,!0);return YCe.json({description:void 0,schema:l,contentType:o.contentType,fullExamples:o.examples,additionalProperties:!Oy(o.schema)&&e7n(o.schema.additionalProperties),source:i})}function DSu(e,t){if(!e.$ref.startsWith(Irn))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=ozr(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let n=t.components?.schemas?.[r];if(n==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return Oy(n)?DSu(n,t):{id:r,schema:n}}var SSu={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},Z9f=new Set(Object.values(SSu));var Tyw=["200","201","202","204"];function eLf({operationContext:e,responses:t,context:r,responseBreadcrumbs:n,responseStatusCode:i,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let f=Cyw({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,c;for(let o of i!=null?[i]:Tyw){let l=t[o];l!=null&&(d=!0,c==null&&(c=k9f({operationContext:e,response:l,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})))}if(c==null&&!d&&t.default!=null&&(c=k9f({operationContext:e,response:t.default,context:r,responseBreadcrumbs:n,streamFormat:a,source:u,namespace:r.namespace})),c!=null)switch(c.type){case"json":return{value:c,errors:f};case"streamingJson":case"streamingSse":return{value:c,errors:f};case"file":case"text":case"streamingText":return{value:c,errors:f};default:Kc(c)}return{value:void 0,errors:f}}function k9f({operationContext:e,streamFormat:t,response:r,context:n,responseBreadcrumbs:i,source:a,namespace:u}){let f=Oy(r)?n.resolveResponseReference(r):r;if(f.content!=null&&Object.entries(f.content).find(([l,g])=>{if(g.schema==null)return!1;let O=Oy(g.schema)?n.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return P4.file({description:f.description,source:a});let d=Y9f(f.content??{},n);if(d!=null&&t!=null)switch(t){case"json":return P4.streamingJson({description:f.description,responseProperty:Oh(e.operation,iy.RESPONSE_PROPERTY),fullExamples:d.examples,schema:i1(d.schema,!1,n,i,a,u),source:a});case"sse":return P4.streamingSse({description:f.description,responseProperty:void 0,schema:JC(i1(d.schema,!1,n,i,a,u)),source:a})}let c=TNn(f.content??{},n);if(c!=null){if(t!=null)switch(t){case"json":return P4.streamingJson({description:f.description,responseProperty:void 0,fullExamples:c.examples,schema:i1(c.schema,!1,n,i,a,u),source:a});case"sse":return P4.streamingSse({description:f.description,responseProperty:void 0,schema:JC(i1(c.schema,!1,n,i,a,u)),source:a})}return P4.json({description:f.description,schema:i1(c.schema,!1,n,i,a,u),responseProperty:Oh(e.operation,iy.RESPONSE_PROPERTY),fullExamples:c.examples,source:a})}for(let[o,l]of Object.entries(f.content??{})){let g=gB.parse(o);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo())return P4.file({description:f.description,source:a});if(g.isPlainText()){let O=l.schema;if(O==null)return P4.text({description:f.description,source:a});let w=Oy(O)?n.resolveSchemaReference(O):O;return w.type==="string"&&w.format==="byte"?P4.file({description:f.description,source:a}):P4.text({description:f.description,source:a})}}}}function Cyw({responses:e,context:t,source:r,namespace:n}){let i={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let f=parseInt(a);if(f<400||f>600)continue;let d=Oy(u)?t.resolveResponseReference(u):u,c=X9f(d.content??{},t),o=SSu[f];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}i[f]={statusCode:f,nameOverride:void 0,generatedName:o,description:d.description,schema:i1(c?.schema??{},!1,t,[o,"Body"],r,n),fullExamples:c?.examples,source:r}}return i}function mAr({operationContext:e,context:t,responseStatusCode:r,suffix:n,streamFormat:i,source:a}){let{document:u,operation:f,path:d,method:c,baseBreadcrumbs:o,sdkMethodName:l}=e,g=Oh(f,iy.IDEMPOTENT),O=Oh(f,[iy.REQUEST_NAME_V1,iy.REQUEST_NAME_V2]),w=[...o,"Request"],j=FSa({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:w,path:d,httpMethod:c,source:a}),M=f.requestBody!=null?CNn({requestBody:f.requestBody,document:u,context:new PNn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:w,source:a,namespace:t.namespace}):void 0;(j.queryParameters.length>0||j.headers.length>0)&&M!=null&&M.type==="json"&&M.schema.type!=="object"&&f.requestBody!=null?M=CNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...w,"Body"],source:a,namespace:t.namespace}):f.requestBody!=null&&(M=CNn({requestBody:f.requestBody,document:u,context:t,requestBreadcrumbs:[...w],source:a,namespace:t.namespace}));let q=[...o,"Response"],B=eLf({operationContext:e,streamFormat:i,responses:f.responses,context:t,responseBreadcrumbs:q,responseStatusCode:r,source:a}),I=G9f(f),C=J9f(e,f,t),L=Oh(f,iy.SERVER_NAME_V2);return{summary:f.summary,internal:Oh(f,rDe.INTERNAL),idempotent:g,audiences:Oh(f,iy.AUDIENCES)??[],operationId:f.operationId!=null&&n!=null?f.operationId+"_"+n:f.operationId,tags:t.resolveTagsToTagIds(f.tags),namespace:t.namespace,sdkName:l,pathParameters:j.pathParameters,queryParameters:j.queryParameters,headers:j.headers,requestNameOverride:O??void 0,generatedRequestName:MF(w),request:M,response:B.value,errors:B.errors,server:L!=null?[{name:L,url:void 0,audiences:void 0}]:(f.servers??[]).map(K=>RSa(K)),description:f.description,authed:qyw(f,u),availability:I,method:c,path:d,examples:C,pagination:e.pagination,source:a}}function qyw(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function rLf({operationContext:e,context:t,asyncExtension:r,source:n}){let{operation:i,pathItemParameters:a,operationParameters:u}=e,f=r.discriminant.name,d=r.discriminant.value,c=r["response-status-code"],o=tLf({context:t,headerToIgnore:f,parameters:a}),l=tLf({context:t,headerToIgnore:f,parameters:u}),g=mAr({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...i,responses:Object.fromEntries(Object.entries(i.responses).filter(([w])=>parseInt(w)!==c))}},context:t,streamFormat:void 0,source:n}),O=mAr({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:c,streamFormat:void 0,source:n});return O.headers.push({name:f,schema:Qp.literal({nameOverride:void 0,generatedName:MF([f]),title:void 0,description:void 0,availability:void 0,value:O4.string(d),groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:n}),{sync:g,async:O}}function tLf({context:e,headerToIgnore:t,parameters:r}){return r.filter(n=>{let i=Oy(n)?e.resolveParameterReference(n):n;return!(i.in==="header"&&i.name===t)})}var ESu="stream";function oLf({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:mAr({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:void 0};case"streamCondition":{let n=nLf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(n?.schemaReference!=null){let c=ozr(n.schemaReference);c!=null&&t.excludeSchema(c)}let i=iLf({operation:e.operation,response:r.responseStream}),a=mAr({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+ESu}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:n?.requestBody,responses:i},baseBreadcrumbs:[...e.baseBreadcrumbs,ESu]},context:t,streamFormat:r.format,suffix:ESu,source:t.source});a.examples=a.examples.filter(c=>aLf(c,t)!==!1);let u=nLf({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),f=iLf({operation:e.operation,response:r.response}),d=mAr({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:f}},context:t,source:t.source});return d.examples=d.examples.filter(c=>aLf(c,t)!==!0),{streaming:a,nonStreaming:d}}default:Kc(r)}}function nLf({context:e,operation:t,streamingExtension:r,isStreaming:n}){if(t.requestBody==null)return;let i=Oy(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=TNn(i.content,e);if(a==null)return;let u=Oy(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let f=u.properties?.[r.streamConditionProperty];f!=null&&Oy(f)&&(f=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":n,...f??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[gB.APPLICATION_JSON]:{schema:d}}},schemaReference:Oy(a.schema)?a.schema:void 0}}function iLf({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[gB.APPLICATION_JSON]:{schema:t}}}}}function aLf(e,t){return e._visit({unknown:r=>{let n=hie.serialization.ExampleEndpointCallSchema.parse(r);if(!n.ok){t.logger.error("Failed to parse example",n.errors.toString());return}if(n.value.response!=null)return n.value.response.stream!=null},full:()=>{},_other:()=>{}})}function uLf({context:e,operationContext:t,source:r}){let{document:n,operation:i,path:a,method:u,baseBreadcrumbs:f,sdkMethodName:d}=t,c=[...f,"Payload"],o=FSa({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:c,path:a,httpMethod:u,source:r});if(i.requestBody==null){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`);return}if(u!=="POST"&&u!=="GET"){e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`);return}let l=CNn({requestBody:i.requestBody,document:n,context:e,requestBreadcrumbs:[...f,"Payload"],source:r,namespace:e.namespace});if(l==null||l.type!=="json"){e.logger.error(`Skipping webhook ${a} because non-json request body`);return}if(i.operationId==null){e.logger.error(`Skipping webhook ${a} because no operation id present`);return}return{summary:i.summary,sdkName:d,namespace:e.namespace,method:u,operationId:i.operationId,tags:e.resolveTagsToTagIds(i.tags),headers:o.headers,generatedPayloadName:MF(c),payload:l.schema,description:i.description,examples:Iyw(l.fullExamples),source:r}}function Iyw(e){if(e==null)return[];let t=[];for(let r of e){let n=uzr(r.value);n!=null&&t.push({description:r.description,name:r.name,payload:n})}return t}function ASu({context:e,pathItemContext:t,operation:r,convertToWebhook:n}){let i=Oh(r,iy.IGNORE);if(i!=null&&i){e.logger.info(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=Byw(r,e),u=S9f(e.document,r),f={...t,sdkMethodName:a,baseBreadcrumbs:Nyw({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path}),operation:r,operationParameters:r.parameters??[],pagination:u};if(n){let l=uLf({context:e,operationContext:f,source:e.source});return l!=null?{type:"webhook",value:l}:void 0}let d=j9f(r);if(d!=null){let l=oLf({context:e,operationContext:f,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let c=P9f(r);if(c!=null){let l=rLf({context:e,operationContext:f,asyncExtension:c,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:mAr({context:e,operationContext:f,streamFormat:void 0,source:e.source})}}function Byw(e,t){let r=Oh(e,iy.SDK_METHOD_NAME),n=Oh(e,iy.SDK_GROUP_NAME)??[];if(r!=null){let i=typeof n=="string"?[n]:n;return i=t.resolveGroupName(i),{groupName:i,methodName:r}}}function Nyw({sdkMethodName:e,operation:t,httpMethod:r,path:n}){let i=[];if(e!=null){if(e.groupName.length>0){let a=e.groupName[e.groupName.length-1];a!=null&&i.push(typeof a=="string"?a:a.name)}i.push(e.methodName)}else t.operationId!=null?i.push(t.operationId):i.push(dA(`${r}_${n.split("/").join("_")}`));return i}function sLf(e,t,r,n){let i=[],a=lLf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=zyw({operation:f.operation}),c=ASu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:d});c!=null&&i.push(c)}return i}function cLf(e,t,r,n){let i=[],a=lLf(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let f of a){let d=ASu({context:n,pathItemContext:{...u,method:f.method},operation:f.operation,convertToWebhook:!0});d!=null&&i.push(d)}return i}function lLf(e){let t=[];return e.get!=null&&t.push({method:h$.Get,operation:e.get}),e.post!=null&&t.push({method:h$.Post,operation:e.post}),e.put!=null&&t.push({method:h$.Put,operation:e.put}),e.delete!=null&&t.push({method:h$.Delete,operation:e.delete}),e.patch!=null&&t.push({method:h$.Patch,operation:e.patch}),t}function zyw({operation:e}){return Oh(e,[iy.WEBHOOK])??!1}function fLf(e){let t=Oh(e,iy.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=Oh(e,iy.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function dLf(e){return Oh(e,iy.FERN_BASIC_AUTH)}function MSu(e,t){if(Oy(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return Ryw(e,t)}function Ryw(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=Oh(e,rDe.BEARER_FORMAT),n=Oh(e,iy.FERN_HEADER_AUTH);return aU.header({headerName:e.name,prefix:r!=null?"Bearer":n?.prefix,headerVariableName:n?.name??Oh(e,iy.HEADER_VARIABLE_NAME),headerEnvVar:n?.env})}else if(e.type==="http"&&e.scheme==="bearer"){let r=Oh(e,iy.FERN_BEARER_TOKEN);return aU.bearer({tokenVariableName:r?.name??Oh(e,iy.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme==="basic"){let r=dLf(e),n=fLf(e);return aU.basic({usernameVariableName:r?.username?.name??n.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??n.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return aU.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return aU.oauth({scopesEnum:Fyw(e,t)})}throw new Error(`Failed to convert security scheme ${JSON.stringify(e)}`)}function Fyw(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let n=azr({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,u])=>[a,{description:u}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,groupName:void 0,context:void 0,source:t}),i=JC(n);if(i.type==="enum")return i}}function pLf(e){return Oh(e,iy.BASE_PATH)}var Lyw=dDe.record(dDe.string(),dDe.object({summary:dDe.string().optional(),description:dDe.string().optional()}));function _Lf({document:e,context:t}){return Cvi(e,iy.GROUPS,Lyw,t.logger)}function hLf({context:e,document:t}){return Oh(t,iy.FERN_VERSION)??void 0}function yLf(e){let t=Oh(e,iy.FERN_GLOBAL_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?qvi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function vLf(e){let t=Oh(e,iy.FERN_IDEMPOTENCY_HEADERS),r=[];for(let n of t??[])r.push({...n,schema:n.type!=null?qvi({fernType:n.type,description:void 0,availability:void 0,generatedName:n.name??n.header,title:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function bLf(e){let t=Oh(e,iy.SDK_VARIABLES);return t==null?{}:Object.fromEntries(Object.entries(t).map(([r,n])=>{if(n.type==="string")return[r,{nameOverride:void 0,generatedName:MF([r]),title:n.title,schema:PD.string({default:a7n(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,groupName:void 0}];throw new Error(`Variable ${r} has unsupported schema ${JSON.stringify(n)}`)}))}var Uyw="webhooks";function gLf(e){return Oh(e,Uyw)??{}}var LSa=class extends ONn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discrminatedUnionReferences={};discrminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:n,options:i,source:a,namespace:u})}getDummy(){return new PNn({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,n){let i=this.discrminatedUnionReferences[t.$ref];i!=null?(i.discriminants.add(r),i.numReferences+=n):this.discrminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:n}}getReferencesFromDiscriminatedUnion(t){return this.discrminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,n){let i=this.discrminatedUnionMetadata[t.$ref];i!=null?i.discriminants.set(r,n):this.discrminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,n]])}}getDiscriminatedUnionMetadata(t){return this.discrminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function mLf(e){return Oh(e,iy.RESOLUTIONS)}function OLf({openapi:e}){let t=mLf(e);if(t==null)return e;let r={};for(let n of t){let i=`#/components/schemas/${n.name}`;for(let a of n.resolutions)e=Vyw({openapi:e,schemaReference:a,schemaName:n.name}),e=PLf({openapi:e,replaceReference:a,schemaReference:i,replacedReferences:r}),r={...r,...Object.fromEntries(n.resolutions.map(u=>[i,u]))}}return e}function Vyw({openapi:e,schemaReference:t,schemaName:r}){let n=t.replace("#/","").split("/").map(a=>a.replace("~1","/")),i=e;for(let a of n){let u=i[a];if(u==null)return e;i=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=i,e}function PLf({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:n}){let i=Object.keys(n).filter(d=>t.startsWith(d)).sort((d,c)=>c.length-d.length)[0];if(i!=null){let d=n[i];if(d!=null){let c=r.replace(i,d);return PLf({openapi:e,replaceReference:t,schemaReference:c,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replace("~1","/")),u=e;for(let d of a.slice(0,-1)){let c=u[d];if(c==null)return e;u=c}let f=a[a.length-1];return f==null||(u[f]={$ref:r}),e}function USa({openApi:e,taskContext:t,options:r,source:n,namespace:i}){e=OLf({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([te,J])=>MSu(J,n)==null?[]:[te,MSu(J,n)])),u=new Set(...Object.entries(a).map(([te,J])=>J.type==="basic"||J.type==="bearer"?"Authorization":J.type==="header"?J.headerName:null)),f=new LSa({document:e,taskContext:t,authHeaders:u,options:r,source:n,namespace:i}),d=bLf(e),c=yLf(e),o=vLf(e),l=r.audiences??[],g=[],O=[];Object.entries(e.paths??{}).forEach(([te,J])=>{if(J==null)return;t.logger.debug(`Converting path ${te}`);let G=sLf(te,J,e,f);for(let re of G){let Xe=wLf({operation:re});if(!(l.length>0&&!l.some(Re=>Xe.includes(Re))))switch(re.type){case"async":g.push(re.sync),g.push(re.async);break;case"http":g.push(re.value);break;case"streaming":g.push(re.streaming),re.nonStreaming&&g.push(re.nonStreaming);break;case"webhook":O.push(re.value);break;default:Kc(re)}}}),Object.entries(gLf(e)).forEach(([te,J])=>{if(J==null)return;t.logger.debug(`Converting path ${te}`);let G=cLf(te,J,e,f);for(let re of G){let Xe=wLf({operation:re});l.length>0&&!l.some(Re=>Xe.includes(Re))||O.push(re.value)}});let w=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([te,J])=>{if(!Oy(J)){let G=Oh(J,iy.IGNORE);if(G!=null&&G)return[];if(Z9f.has(te))return[te,i1({...J,"x-fern-type-name":`${te}Body`},!1,f,[te],n,i)]}return[te,i1(J,!1,f,[te],n,i)]}).filter(te=>te.length>0)),j=Wyw(w,f,n),M=Hyw(j,f),q={};for(let[te,J]of Object.entries(M)){let G=JC(J);f.isSchemaExcluded(te)||(q[te]=G,t.logger.debug(`Converted schema ${te}`))}let B=new szr(M),I=new _1a(M,f.logger),C=g.map(te=>{let J=te.examples,G=J;if(!r.disableExamples&&(J.length===0||J.every(zvi))){let Re=I.buildEndpointExample(te);Re.length>0&&(G=[...Re,...J.filter(Dt=>!zvi(Dt))])}let re=te.request,Xe=te.response;return{...te,request:re?.type==="json"?{...re,schema:JC(re.schema)}:re,response:Xe?.type==="json"?{...Xe,schema:JC(Xe.schema)}:Xe,queryParameters:te.queryParameters.map(Re=>({description:Re.description,name:Re.name,schema:JC(Re.schema),parameterNameOverride:Re.parameterNameOverride,availability:Re.availability,source:Re.source})),pathParameters:te.pathParameters.map(Re=>({description:Re.description,name:Re.name,schema:JC(Re.schema),parameterNameOverride:Re.parameterNameOverride,variableReference:Re.variableReference,availability:Re.availability,source:Re.source})),headers:te.headers.map(Re=>({description:Re.description,name:Re.name,schema:JC(Re.schema),parameterNameOverride:Re.parameterNameOverride,env:Re.env,availability:Re.availability,source:Re.source})),examples:G,errors:yy(te.errors,Re=>{let Dt=Re.fullExamples?.map(Ct=>{let Wt=uzr(Ct.value);if(Wt!=null)return{name:Ct.name,description:Ct.description,example:Wt}}).filter(HM);if(Dt?.length===0){let Ct=B.buildExample({schema:Re.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Ct!=null&&Dt.push({name:void 0,description:void 0,example:Ct})}return{generatedName:Re.generatedName,nameOverride:Re.nameOverride,schema:JC(Re.schema),description:Re.description,source:Re.source,examples:Dt}})}}),L=_Lf({document:e,context:f});return{apiVersion:hLf({context:f,document:e}),basePath:pLf(e),title:e.info.title,description:e.info.description,groups:Object.fromEntries(Object.entries(L??{}).map(([te,J])=>[te,{summary:J.summary??void 0,description:J.description??void 0}])),servers:(e.servers??[]).map(te=>RSa(te)),tags:{tagsById:Object.fromEntries((e.tags??[]).map(te=>[te.name,{id:te.name,description:te.description}])),orderedTagIds:e.tags?.map(te=>te.name)},endpoints:C,webhooks:O,channel:[],groupedSchemas:f1a(i,q),securitySchemes:a,hasEndpointsMarkedInternal:C.some(te=>te.internal),nonRequestReferencedSchemas:f.getReferencedSchemas(),variables:d,globalHeaders:c,idempotencyHeaders:o}}function Wyw(e,t,r){let n={};for(let[i,a]of Object.entries(e)){if(a.type!=="object"){n[i]=a;continue}let u={$ref:`#/components/schemas/${i}`},f=t.getReferencesFromDiscriminatedUnion(u);if(f==null){n[i]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!f.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!f.discriminants.has(o.propertyKey)),source:r};n[i]=d;let c=jLf({schema:a,schemas:e});for(let o of[...new Set(c)]){let l=n[o]??e[o];l==null||l.type!=="object"||(n[o]={...l,type:"object",properties:l.properties.filter(g=>!f.discriminants.has(g.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(g=>!f.discriminants.has(g.propertyKey))})}}return n}function Hyw(e,t){let r={};for(let[n,i]of Object.entries(e)){if(i.type!=="object"){r[n]=i;continue}let a={$ref:`#/components/schemas/${n}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[n]=i;continue}let f=[];for(let c of i.properties)if(u.discriminants.has(c.key)){let o=u.discriminants.get(c.key);o!=null&&f.push({...c,schema:Qp.literal({nameOverride:void 0,generatedName:MF([i.generatedName,o]),title:void 0,value:O4.string(o),groupName:void 0,description:void 0,availability:i.availability})})}else f.push(c);let d={...i,type:"object",properties:f};r[n]=d}return r}function jLf({schema:e,schemas:t}){let r=[];for(let n of e.allOf){r.push(n.schema);let i=t[n.schema];i!=null&&i.type==="object"&&r.push(...jLf({schema:i,schemas:t}))}return r}function wLf({operation:e}){let t=[];switch(e.type){case"async":t=e.async.audiences;break;case"http":t=e.value.audiences;break;case"streaming":t=e.streaming.audiences;break;case"webhook":break;default:Kc(e)}return t}async function SLf({openApi:e,taskContext:t,options:r,source:n,namespace:i}){let a=await(0,DLf.convertObj)(e,{});return USa({openApi:a.openapi,taskContext:t,options:r,source:n,namespace:i})}var Unn={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,cooerceEnumsToLiterals:!0};async function Vnn({absoluteFilePathToWorkspace:e,specs:t,taskContext:r,optionOverrides:n}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channel:[],groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let a of t){let u=(await(0,TSu.readFile)(a.absoluteFilepath)).toString(),f=mq(e,a.source.file);a.source.relativePathToDependency!=null&&(f=yf(a.source.relativePathToDependency,f));let d=a.source.type==="protobuf"?XEr.protobuf({file:f}):XEr.openapi({file:f});if(u.includes("openapi")||u.includes("swagger")){let c=await pzf({absolutePathToOpenAPI:a.absoluteFilepath,context:r,absolutePathToOpenAPIOverrides:a.absoluteFilepathToOverrides});if(Gyw(c)){let o=USa({openApi:c,taskContext:r,options:xSu({specSettings:a.settings,overrides:n}),source:d,namespace:a.namespace});i=ELf(i,o)}else if($yw(c)){let o=await SLf({openApi:c,taskContext:r,options:xSu({specSettings:a.settings}),source:d,namespace:a.namespace});i=ELf(i,o)}}else if(u.includes("asyncapi")){let c=await Jyw({absoluteFilePathToAsyncAPI:a.absoluteFilepath,context:r,absoluteFilePathToAsyncAPIOverrides:a.absoluteFilepathToOverrides}),o=j2f({document:c,taskContext:r,options:xSu({specSettings:a.settings}),source:d,asyncApiOptions:Qyw({specSettings:a.settings}),namespace:a.namespace});o.channel!=null&&i.channel.push(o.channel),o.groupedSchemas!=null&&(i.groupedSchemas=ALf(i.groupedSchemas,o.groupedSchemas)),o.basePath!=null&&(i.basePath=o.basePath)}else r.failAndThrow(`${a.absoluteFilepath} is not a valid OpenAPI or AsyncAPI file`)}return i}function xSu({specSettings:e,overrides:t}){return{disableExamples:t?.disableExamples??Unn.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.shouldUseUndiscriminatedUnionsWithLiterals??Unn.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.shouldUseTitleAsName??Unn.useTitlesAsName,audiences:t?.audiences??e?.audiences??Unn.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??Unn.optionalAdditionalProperties,cooerceEnumsToLiterals:t?.cooerceEnumsToLiterals??e?.cooerceEnumsToLiterals??Unn.cooerceEnumsToLiterals}}function Qyw({specSettings:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??KCf.naming}}function ELf(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channel:[...e.channel,...t.channel],groupedSchemas:ALf(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function ALf(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,n]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...n}:e.namespacedSchemas[r]=n;return e}async function Jyw({absoluteFilePathToAsyncAPI:e,absoluteFilePathToAsyncAPIOverrides:t,context:r}){let n=(await(0,TSu.readFile)(e)).toString(),i=await f0.load(n);return t!=null?await jDa({absoluteFilepathToOverrides:t,context:r,data:i}):i}function Gyw(e){return e.openapi!=null}function $yw(e){return e.swagger!=null}function WSa({queryParameter:e,context:t,fileContainingReference:r,namespace:n}){let i=CSu({schema:e.schema,context:t,fileContainingReference:r,namespace:n});if(i==null)return;let a=bC(i.value);if(a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>"),e.description==null&&!i.allowMultiple&&e.parameterNameOverride==null&&e.availability==null)return a;let u={type:a};return i.allowMultiple&&(u["allow-multiple"]=!0),e.description!=null&&(u.docs=e.description),e.parameterNameOverride!=null&&(u.name=e.parameterNameOverride),e.availability!=null&&(u.availability=S3(e.availability)),u}function CSu({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:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,declarationFile:Ms.of(QA),fileContainingReference:r,namespace:n}),allowMultiple:!0};if(i.type==="oneOf"&&i.value.type==="undisciminated"){let a=[];for(let[u,f]of Object.entries(i.value.schemas))f.type==="literal"&&f.value.type==="string"&&(n7n.test(f.value.value)?a.push(f.value.value):a.push({value:f.value.value,name:Ivi(f.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),{value:e.generatedName,allowMultiple:!1};if(i.value.schemas.length===2){let[u,f]=i.value.schemas;if(u!=null&&f!=null&&VSa({array:u,primitive:f}))return{value:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:f,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(u!=null&&f!=null&&VSa({array:u,primitive:f}))return{value:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[u,f]of Object.entries(i.value.schemas))return CSu({schema:f,context:t,fileContainingReference:r,namespace:n})}else if(i.type==="object")return}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:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:i.value,description:e.description??i.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,declarationFile:Ms.of(QA),namespace:n}),allowMultiple:!0}}if(e.value.type==="array")return{value:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undisciminated"){let i=[];for(let[a,u]of Object.entries(e.value.value.schemas))u.type==="literal"&&u.value.type==="string"&&(n7n.test(u.value.value)?i.push(u.value.value):i.push({value:u.value.value,name:Ivi(u.value.value)}));if(i.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:i}}),{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[a,u]=e.value.value.schemas;if(a!=null&&u!=null&&VSa({array:a,primitive:u}))return{value:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0};if(a!=null&&u!=null&&VSa({array:u,primitive:a}))return{value:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:a,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}}for(let[a,u]of Object.entries(e.value.value.schemas))return CSu({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:void 0,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n})}else if(e.value.type==="object")return;return{value:X1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}return e.type==="array"?{value:X1({schema:vb.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,groupName:void 0}),context:t,fileContainingReference:r,namespace:n}),allowMultiple:!0}:{value:X1({schema:e,context:t,fileContainingReference:r,namespace:n}),allowMultiple:!1}}function VSa({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function MLf({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"]=Kyw(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=Yyw({context:t,namedFullExamples:e.headers}));for(let n of e.messages){let i=r5r(n.payload);i!=null&&r.messages.push({type:n.messageType,body:i})}return r}function Kyw(e){let t={};return e.forEach(r=>{let n=r5r(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function Yyw({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=r5r(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function r5r(e){switch(e.type){case"primitive":return xLf(e.value);case"object":return TLf(e.properties);case"array":return Xyw(e.value);case"map":return Zyw(e.value);case"oneOf":return kyw(e.value);case"enum":return e.value;case"literal":return e0w(e.value);case"unknown":return r5r(e.value);default:Kc(e)}}function xLf(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:Kc(e)}}function TLf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r5r(r)]))}function Xyw(e){return e.map(t=>r5r(t))}function Zyw(e){return Object.fromEntries(e.map(t=>[xLf(t.key),r5r(t.value)]))}function kyw(e){return e.type==="discriminated"?TLf(e.value):r5r(e.value)}function e0w(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Kc(e)}}function OAr(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function HSa(e,t){return t??(e?.groupName!=null?OAr(e.groupName):void 0)}function CLf({channel:e,context:t,declarationFile:r}){let n={path:e.path,auth:!1};e.summary!=null&&(n["display-name"]=e.summary);let i=OAr(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=n1a({pathParameter:d,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 d of e.handshake.queryParameters){let c=WSa({queryParameter:d,context:t,fileContainingReference:r,namespace:i});c!=null&&(u[d.name]=c)}Object.keys(u).length>0&&(n["query-parameters"]=u);let f={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let c=e9t({header:d,context:t,fileContainingReference:r,namespace:i});f[d.name]=c}Object.keys(f).length>0&&(n.headers=f),t.builder.addChannel(r,{channel:n}),e.subscribe!=null&&t.builder.addChannelMessage(r,{messageId:"subscribe",message:{origin:"server",body:X1({schema:e.subscribe,context:t,fileContainingReference:r,namespace:i})}}),e.publish!=null&&t.builder.addChannelMessage(r,{messageId:"publish",message:{origin:"client",body:X1({schema:e.publish,context:t,fileContainingReference:r,namespace:i})}});for(let d of e.examples){let c=MLf({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:c})}}var qLf="Production",ILf="Default";function BLf(e){return Object.entries(e).reduce((t,[r,n])=>(g6n(n)?Object.entries(n.urls).forEach(([i,a])=>{t[i]=a}):t[r]=typeof n=="string"?n:n.url,t),{})}function NLf(e){if(e.environmentOverrides!=null){for(let[f,d]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:f,schema:d});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=[];for(let f of e.ir.servers){let d=f.audiences?{url:f.url,audiences:f.audiences}:f.url;if(f.name==null){r.push(d);continue}t[f.name]=d}let n={},i=[];for(let f of e.ir.endpoints)for(let d of f.server){if(d.url==null)continue;let c=d.audiences?{url:d.url,audiences:d.audiences}:d.url;if(d.name==null){i.push(c);continue}n[d.name]=c}let a=Object.keys(t).length,u=Object.keys(n).length;if(a===0&&u===0){let f=e.ir.servers[0]?.url,d=e.ir.servers[0]?.audiences;f!=null&&(e.builder.addEnvironment({name:ILf,schema:d?{url:f,audiences:d}:f}),e.builder.setDefaultEnvironment(ILf))}else if(a>0&&u===0){let f=0;r.length>0&&e.logger.error(`Skipping servers ${r.map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);for(let[d,c]of Object.entries(t))f===0&&e.builder.setDefaultEnvironment(d),e.builder.addEnvironment({name:d,schema:c}),f+=1}else if(u>0){(r.length>0||i.length>0)&&e.logger.error(`Skipping servers ${[...r,...i].map(d=>typeof d=="string"?d:d.url).join(", ")} because x-fern-server-name was not provided.`);let f=Object.entries(t)[0];if(f!=null){let[d,c]=f;e.setDefaultServerName(d)}e.builder.addEnvironment({name:qLf,schema:{urls:{...BLf(t),...BLf(n)}}}),e.builder.setDefaultEnvironment(qLf)}}function QSa(e){return bC(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var qSu=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},t0w=.75,r0w=new Set("authorization");function zLf(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?Z3n(n.schema):void 0,u=a!=null?OAr(a):void 0,f=Ms.of("api.yml");i={name:n.name,env:n.env,type:n.schema!=null?bC(X1({schema:n.schema,context:e,fileContainingReference:u?yf(Ms.of(dA(u)),f):f,namespace:u}))??"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(r0w.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let f=t[a.name],d=e9t({header:{...a,schema:f?.schema??a.schema,name:f?.name??a.name},fileContainingReference:Ms.of(u5),context:e,namespace:void 0});u=new qSu(d),r[a.name]=u}u.increment()}let n=e.ir.endpoints.length*t0w;for(let[i,a]of Object.entries(r)){let u=t[i],f=a.count===e.ir.endpoints.length,d=a.count>=n;u==null&&(f?e.builder.addGlobalHeader({name:i,schema:a.schema}):d&&e.builder.addGlobalHeader({name:i,schema:QSa(a.schema)}))}}}function RLf(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?Z3n(t.schema):void 0,n=r!=null?OAr(r):void 0,i=e9t({header:{...t,schema:t.schema??vb.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,groupName:void 0,nameOverride:void 0,schema:PD.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:Ms.of(u5),context:e,namespace:n});e.builder.addIdempotencyHeader({name:t.header,schema:QSa(i)})}}function ik(e){switch(e.type){case"primitive":return LLf(e.value);case"object":return ULf(e.properties);case"array":return VLf(e.value);case"map":return n0w(e.value);case"oneOf":return i0w(e.value);case"enum":return e.value;case"literal":return a0w(e.value);case"unknown":return ik(e.value);default:Kc(e)}}function FLf(e){switch(e.type){case"withStreaming":return{stream:VLf(e.value)};case"withoutStreaming":return{body:ik(e.value)};default:Kc(e)}}function LLf(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!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:Kc(e)}}function ULf(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,ik(r)]))}function VLf(e){return e.map(t=>ik(t))}function n0w(e){return Object.fromEntries(e.map(t=>[LLf(t.key),ik(t.value)]))}function i0w(e){return e.type==="discriminated"?ULf(e.value):ik(e.value)}function a0w(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Kc(e)}}function WLf({endpointExample:e,context:t}){let r={};return e.type!=="full"?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"]=o0w(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=u0w(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=s0w({context:t,namedFullExamples:e.headers})),e.request!=null&&(r.request=ik(e.request)),e.response!=null&&(r.response=FLf(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(n=>n.type==="language"?{name:n.name??void 0,docs:n.description??void 0,language:n.language,code:n.code,install:n.install??void 0}:{name:n.name??void 0,docs:n.description??void 0,sdk:n.sdk,code:n.code}).filter(HM)),r)}function o0w(e){let t={};return e.forEach(r=>{let n=ik(r.value);n!=null&&(t[r.parameterNameOverride??r.name]=n)}),t}function u0w(e){let t={};return e.forEach(r=>{let n=ik(r.value);Array.isArray(n)?t[r.name]=n[0]:n!=null&&(t[r.name]=n)}),t}function s0w({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),n={};return t.forEach(i=>{let a=ik(i.value);r.has(i.name)||a!=null&&(n[i.name]=a)}),n}function HLf(e){return h$._visit(e,{get:()=>hie.HttpMethodSchema.Get,post:()=>hie.HttpMethodSchema.Post,put:()=>hie.HttpMethodSchema.Put,patch:()=>hie.HttpMethodSchema.Patch,delete:()=>hie.HttpMethodSchema.Delete,head:()=>{throw new Error("HEAD is unsupported")},options:()=>{throw new Error("HEAD is unsupported")},trace:()=>{throw new Error("HEAD is unsupported")},_other:()=>{throw new Error("Unkown http method is unsupported")}})}function QLf({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:n}=r.ir,i=[],a=new Set,u=e.path,f=HSa(e.sdkName,e.namespace),d={};for(let j of e.pathParameters)j.parameterNameOverride&&(u=u.replace(j.name,j.parameterNameOverride)),d[j.parameterNameOverride??j.name]=n1a({pathParameter:j,context:r,fileContainingReference:t,namespace:f}),a.add(j.name);let c={};for(let j of e.queryParameters){let M=WSa({queryParameter:j,context:r,fileContainingReference:t,namespace:f});M!=null&&(c[j.name]=M,a.add(j.name))}let o;e.pagination!=null&&(e.pagination.type==="cursor"?o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results}:o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage});let l={path:u,method:HLf(e.method),auth:e.authed,docs:e.description??void 0,pagination:o};Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let g={},O=r.builder.getGlobalHeaderNames(),w=e.headers.filter(j=>!O.has(j.name));for(let j of w){let M=e9t({header:j,context:r,fileContainingReference:t,namespace:f});g[j.name]=M,a.add(typeof M=="string"?j.name:M.name??j.name)}if(e.request!=null){let j=l0w({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,queryParameters:Object.keys(c).length>0?c:void 0,nonRequestReferencedSchemas:Array.from(n),headers:Object.keys(g).length>0?g:void 0,usedNames:a,namespace:f});l.request=j.value,i=[...i,...j.schemaIdsToExclude??[]]}else{let j=Object.keys(c).length>0,M=Object.keys(g).length>0,q={};(j||M)&&(q.name=e.requestNameOverride??e.generatedRequestName),j&&(q["query-parameters"]=c),M&&(q.headers=g),Object.keys(q).length>0&&(l.request=q)}if(e.response!=null&&e.response._visit({json:j=>{let M=X1({schema:j.schema,context:r,fileContainingReference:t,namespace:f});l.response={docs:j.description??void 0,type:bC(M)},j.responseProperty!=null&&(l.response.property=j.responseProperty)},streamingJson:j=>{let M=X1({schema:j.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:j.description??void 0,type:bC(M),format:"json"}},streamingSse:j=>{let M=X1({schema:j.schema,context:r,fileContainingReference:t,namespace:f});l["response-stream"]={docs:j.description??void 0,type:bC(M),format:"sse"}},file:j=>{l.response={docs:j.description??void 0,type:"file"}},streamingText:j=>{l["response-stream"]={docs:j.description??void 0,type:"text"}},text:j=>{l.response={docs:j.description??void 0,type:"text"}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let j=r.getDefaultServerName(),M=e.server[0];M==null?j!=null&&(l.url=j):l.url=M.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=S3(e.availability)),Object.entries(e.errors).forEach(([j,M])=>{let q=M.generatedName,B=Ms.of(QA);r.builder.enableUniqueErrorsPerEndpoint&&(q=`${e.generatedRequestName}${M.generatedName}`,M.schema!=null&&(M.schema.type!=="reference"&&M.schema.type!=="oneOf"?M.schema.generatedName=`${e.generatedRequestName}${M.schema.generatedName}`:M.schema.type==="oneOf"&&(M.schema.value.generatedName=`${e.generatedRequestName}${M.schema.value.generatedName}`)));let I={"status-code":parseInt(j)},C=UCf({location:JLf,namespaceOverride:f});if(M.schema!=null){let te=X1({schema:M.schema,context:r,fileContainingReference:C,declarationFile:C,namespace:f});I.type=bC(te),I.docs=M.description}r.builder.addError(C,{name:q,schema:r.isErrorUnknownSchema(parseInt(j))?{...I,type:"unknown"}:I}),l.errors==null&&(l.errors=[]);let L=r.builder.addImport({file:t,fileToImport:C});l.errors.push(L!=null?`${L}.${q}`:q),I.type!=null&&M.examples?.forEach(te=>{let J={value:ik(te.example),name:te.name,docs:te.description};r.builder.addErrorExample(C,{name:q,example:J})})}),e.examples.length>0&&(l.examples=c0w({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[ISu,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:i}}function c0w({endpointExamples:e,context:t}){return e.map(r=>{try{return WLf({endpointExample:r,context:t})}catch(n){throw console.error(`Error building endpoint example: ${n}`),n}})}function l0w({endpoint:e,declarationFile:t,context:r,request:n,requestNameOverride:i,generatedRequestName:a,queryParameters:u,nonRequestReferencedSchemas:f,headers:d,usedNames:c,namespace:o}){if(n.type==="json"){let l=n.schema.type==="reference"?n.schema.schema:void 0,g=n.schema.type==="reference"?r.getSchema(n.schema.schema,o):n.schema;if(g?.type!=="object"||l!=null&&f.includes(l)){let q=X1({schema:n.schema,fileContainingReference:t,context:r,namespace:o}),B={schemaIdsToExclude:[],value:{body:q}},I=Object.keys(u??{}).length>0,C=Object.keys(d??{}).length>0;return I&&(B.value["query-parameters"]=u),C&&(B.value.headers=d),(I||C)&&(B.value.name=i??a),n.contentType!=null&&(B.value["content-type"]=n.contentType),n.description!=null&&(B.value.docs=n.description),B}let O=Object.fromEntries(g.properties.filter(q=>q.readonly==null?!0:!((e.method==="POST"||e.method==="PUT")&&q.readonly)).map(q=>{let B=X1({schema:q.schema,fileContainingReference:t,context:r,namespace:o}),I=q.nameOverride??q.key,C=S3(q.availability);if(!c.has(I)&&q.audiences.length<=0)return c.add(I),q.nameOverride!=null?[q.key,{type:bC(B),docs:xvi(B),name:q.nameOverride,availability:C}]:[q.key,C?{...typeof B=="string"?{type:B}:B,availability:C}:B];let L={type:bC(B),docs:xvi(B)};return c.has(I)&&(L.name=q.generatedName),q.audiences.length>0&&(L.audiences=q.audiences),C!=null&&(L.availability=C),c.add(I),[q.key,L]})),w=g.allOf.map(q=>{let B=X1({schema:vb.reference(q),fileContainingReference:t,context:r,namespace:o});return bC(B)}),j={properties:O};w.length>0&&(j.extends=w),n.additionalProperties&&(j["extra-properties"]=!0);let M={name:i??g.nameOverride??g.generatedName,"query-parameters":u,headers:d,body:j};return n.contentType!=null&&(M["content-type"]=n.contentType),n.description!=null&&(M.docs=n.description),{schemaIdsToExclude:l!=null?[l]:[],value:M}}else{if(n.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":gB.APPLICATION_OCTET_STREAM,...n.description?{docs:n.description}:{}}};if(n.type==="multipart"){let l=Object.fromEntries(n.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let w={type:O};return g.description!=null&&(w.docs=g.description),g.contentType!=null&&(w["content-type"]=g.contentType),[g.key,w]}return[g.key,O]}else{let O=X1({schema:g.schema.value,fileContainingReference:t,context:r,namespace:o});return g.contentType!=null&&(typeof O=="string"?O={type:O,"content-type":g.contentType}:O["content-type"]=g.contentType),[g.key,O]}}));return{schemaIdsToExclude:n.name==null?[]:[n.name],value:{name:i??n.name??a,"query-parameters":u,headers:d,body:{properties:l},"content-type":gB.MULTIPART_FORM_DATA,...n.description?{docs:n.description}:{}}}}else Kc(n)}}function f0w({location:e,namespaceOverride:t}){return t!=null?{...e,file:yf(Ms.of(t),e.file)}:e}function d0w(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],n=e.operationId;if(n==null)return r!=null?{file:Ms.of(`${dA(r)}.yml`),endpointId:e.summary!=null?dA(e.summary):dA(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Ms.of(QA),endpointId:dA(e.summary)}:{file:Ms.of(QA),endpointId:dA(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Ms.of(QA),endpointId:n};let i=Hgi(r),a=Hgi(n);if(jqt(i,a))return{file:Ms.of("__package__.yml"),endpointId:r};let u=h0w({operationId:n,tag:r,path:e.path,method:e.method});if(u!=null)return u;let f=[];for(let d=0;d<i.length;++d){let c=i[d];if(c!=null&&c===a[d])f.push(c);else{let o=dA(r);return{file:Ms.of(`${o}.yml`),endpointId:n,tag:r}}}if(f.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Ms.of(dA(f.join("_"))+".yml"),endpointId:dA(a.slice(f.length).join("_")),tag:r}}function Qgi(e){let t=e.tags[0];if(e.sdkName!=null){let r=Mgu({sdkName:e.sdkName,namespaceOverride:e.namespace}),n=`${r}.yml`,i=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Ms.of(n),endpointId:e.sdkName.methodName,tag:i?t:void 0}}return f0w({namespaceOverride:e.namespace,location:d0w(e)})}function Hgi(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=_8t(t),t}var p0w=new RegExp("[^a-zA-Z0-9{}]+"),_0w=new RegExp("[{}]","g");function h0w({operationId:e,tag:t,path:r,method:n}){let a=`${r.split(p0w).join("_").replaceAll(_0w,"_")}_${n.toLowerCase()}`;if(e.endsWith(a))return{file:Ms.of(dA(t)+".yml"),endpointId:dA(e.slice(0,-1*a.length)),tag:t}}function GLf(e){let t=new Set,{endpoints:r,tags:n}=e.ir,i=[];for(let a of r){let{endpointId:u,file:f,tag:d}=Qgi(a),c=f.split(".")[0];c!=null&&t.add(c);let o;if(a.sdkName!=null){let O=e.ir.groups;for(let w of a.sdkName.groupName){let j=typeof w=="string"?w:w.name,M=O[j];if(M==null)break;if(M.summary!=null||M.description!=null){o=O[j];break}}}let l=d==null?void 0:n.tagsById[d],g=QLf({context:e,endpoint:a,declarationFile:f});i=[...i,...g.schemaIdsToExclude],e.builder.addEndpoint(f,{name:u,schema:g.value,source:a.source!=null?Crn(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(f,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:i,sdkGroups:t}}function $Lf(e){for(let[t,r]of Object.entries(e.ir.variables)){let n=r.groupName!=null?OAr(r.groupName):void 0,i=X1({schema:vb.primitive(r),context:e,fileContainingReference:Ms.of(QA),namespace:n});e.builder.addVariable({name:t,schema:{type:bC(i),docs:r.description??void 0}})}}function KLf(e){for(let t of e.ir.webhooks){let r=b0w({webhook:t,context:e});if(r==null)continue;let n=HSa(t.sdkName,t.namespace),i={};for(let u of t.headers)i[u.name]=e9t({header:u,context:e,fileContainingReference:r.file,namespace:n});let a={method:t.method,"display-name":t.summary??void 0,headers:i,payload:X1({schema:t.payload,context:e,fileContainingReference:r.file,namespace:n}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:ik(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function y0w({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:yf(Ms.of(t),e.file)}:e}function v0w({webhook:e,context:t}){let r=e.tags[0],n=e.operationId;if(r==null)return{file:Ms.of(QA),endpointId:n};let i=Hgi(r),a=Hgi(n);if(jqt(i,a))return{file:Ms.of("__package__.yml"),endpointId:r};let u=[];for(let f=0;f<i.length;++f){let d=i[f];if(d!=null&&d===a[f])u.push(d);else{let c=dA(r);return{file:Ms.of(`${c}.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:Ms.of(dA(u.join("_"))+".yml"),endpointId:dA(a.slice(u.length).join("_")),tag:r}}function b0w({webhook:e,context:t}){return e.sdkName!=null?{file:LCf({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:y0w({namespaceOverride:e.namespace,location:v0w({webhook:e,context:t})})}var g0w=Ms.of(QA);function YLf(e){switch(e.type){case"object":return P9t(e.groupName);case"enum":return P9t(e.groupName);case"oneOf":return P9t(e.value.groupName);case"array":return P9t(e.groupName);case"map":return P9t(e.groupName);case"reference":return P9t(e.groupName);case"literal":return P9t(e.groupName);case"optional":return P9t(e.groupName);case"nullable":return P9t(e.groupName);case"primitive":return P9t(e.groupName);case"unknown":return g0w;default:Kc(e)}}function P9t(e){return k3n(e)}var ISu="external",JLf=Ms.of(QA);function XLf({schemas:e,schemaIdsToExclude:t,namespace:r,context:n}){for(let[i,a]of Object.entries(e)){if(t.includes(i))continue;let u=YLf(a),f=HCf({schema:a,context:n,declarationFile:u,namespace:r});if(O6n(f.schema)){let d=bC(f.schema);if(d===(f.name??i)||d===`optional<${f.name??i}>`)continue}n.builder.addType(u,{name:f.name??i,schema:f.schema})}}function ZLf(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),NLf(e),zLf(e),RLf(e),$Cf(e),$Lf(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(ISu);let{schemaIdsToExclude:t,sdkGroups:r}=GLf(e);KLf(e);for(let n of e.ir.channel){let i=k3n(n.groupName);CLf({channel:n,context:e,declarationFile:i})}XLf({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:t,namespace:void 0,context:e});for(let[n,i]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))XLf({schemas:i,schemaIdsToExclude:t,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(i=>r.has(i))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}var Jgi=class{context;constructor(t){this.context=t}};var n5r=tu(require("path"),1);var JSa=tu(require("path"),1),GSa=class e{files={};directories={};getAllFiles(){let t={},r=(n,i)=>{for(let[u,f]of Object.entries(n.files)){let d=i!=null?Ms.of(`${i}${JSa.default.sep}${u}`):Ms.of(u);t[d]=f}let a=Object.keys(n.directories).sort();for(let u of a){let f=i!=null?`${i}${JSa.default.sep}${u}`:u,d=n.directories[u];r(d,f)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(JSa.default.sep))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Ms.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 Wnn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new GSa,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 XSr(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??{}),r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}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)}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??dA((ub(r)+"/"+(0,n5r.basename)(r,(0,n5r.extname)(r))).replaceAll("__package__","root"));if(t===Ms.of(u5))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[i]=mq(ub(j_.of(`/${t}`)),j_.of(`/${r}`)),i;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[i]=mq(ub(j_.of(`/${t}`)),j_.of(`/${r}`)),i}addType(t,{name:r,schema:n}){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(f=>jqt(f,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=n5r.default.join(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:n5r.default.join(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:n5r.default.join(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===QA?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}};var $Sa=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;constructor({taskContext:t,ir:r,enableUniqueErrorsPerEndpoint:n,detectGlobalHeaders:i,environmentOverrides:a,globalHeaderOverrides:u,authOverrides:f}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.enableUniqueErrorsPerEndpoint=n,this.builder=new Wnn(n),r.title!=null&&this.builder.setDisplayName({displayName:r.title}),this.detectGlobalHeaders=i,this.environmentOverrides=a,this.authOverrides=f,this.globalHeaderOverrides=u;let d={};if(!this.enableUniqueErrorsPerEndpoint)for(let c of r.endpoints)for(let[o,l]of Object.entries(c.errors)){let g=parseInt(o),O=d[g];O==null&&l.schema!=null?d[g]=l.schema:O!=null&&l.schema!=null&&nDe(O,l.schema)||this.unknownSchema.add(g)}}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)}};function BSu(e){let t=new $Sa(e);return ZLf(t)}function KSa(e,t){return yy(e,t)}var d2e=class extends Z6t{specs;sources;constructor({specs:t,...r}){super(r),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t)}async getOpenAPIIr({context:t,relativePathToDependency:r},n){let i=await brn({context:t,specs:this.specs,relativePathToDependency:r});return await Vnn({absoluteFilePathToWorkspace:this.absoluteFilePath,specs:i,taskContext:t,optionOverrides:m0w(n)})}async getDefinition({context:t,relativePathToDependency:r},n){let i=await this.getOpenAPIIr({context:t,relativePathToDependency:r},n),a=BSu({authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0,taskContext:t,ir:i,enableUniqueErrorsPerEndpoint:n?.enableUniqueErrorsPerEndpoint??!1,detectGlobalHeaders:n?.detectGlobalHeaders??!0});return{absoluteFilePath:j_.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:f0.dump(a.rootApiFile)},namedDefinitionFiles:{...KSa(a.definitionFiles,u=>({absoluteFilepath:j_.of("/DUMMY_PATH"),rawContents:f0.dump(u),contents:u})),[Ms.of(QA)]:{absoluteFilepath:j_.of("/DUMMY_PATH"),rawContents:f0.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new k6t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(HM)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,n=[];return t.reduce((i,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),i.push({type:a.type,id:_8r(),absoluteFilePath:u})),i},n)}};function Ggi(e){if(e.settings==null)return;let t={detectGlobalHeaders:!0};return e.settings.unions==="v1"&&(t.enableDiscriminatedUnionV2=!0),t}function m0w(e){if(e==null)return;let t={};return e.enableDiscriminatedUnionV2&&(t.discriminatedUnionV2=!0),e.optionalAdditionalProperties&&(t.optionalAdditionalProperties=!0),e.cooerceEnumsToLiterals&&(t.cooerceEnumsToLiterals=!0),t}function kLf(e,t){if(O0w(e))return t.alias(e);if(P0w(e))return t.enum(e);if(w0w(e))return t.object(e);if(j0w(e))return t.union(e);Kc(e)}function O0w(e){return e?.alias!=null}function P0w(e){return e?.values!=null}function w0w(e){return e?.fields!=null}function j0w(e){return e?.union!=null}var vEa={};_l(vEa,{ConjureAliasDeclaration:()=>rEa,ConjureArgument:()=>_Ea,ConjureArgumentWithParamType:()=>pEa,ConjureDefinitions:()=>lEa,ConjureEndpoint:()=>hEa,ConjureEnumDeclaration:()=>sEa,ConjureEnumVariant:()=>uEa,ConjureEnumWithDocs:()=>oEa,ConjureObjectDeclaration:()=>aEa,ConjureParamType:()=>dEa,ConjurePrimitive:()=>tEa,ConjureService:()=>yEa,ConjureServiceName:()=>eEa,ConjureType:()=>o5r,ConjureTypeDeclaration:()=>cEa,ConjureTypeReference:()=>u5r,ConjureTypeWithDocs:()=>nEa,ConjureTypes:()=>fEa,ConjureUnionDeclaration:()=>iEa,DefinitionFile:()=>SUf,WithDocs:()=>j9t,commons:()=>LSu,conjure:()=>USu,services:()=>VSu,types:()=>WSu});var LSu={};_l(LSu,{WithDocs:()=>j9t});var Uy={};_l(Uy,{JsonError:()=>qNn,ParseError:()=>INn,any:()=>pUf,boolean:()=>_Uf,booleanLiteral:()=>dUf,date:()=>tUf,discriminant:()=>wUf,enum_:()=>XSa,getObjectLikeUtils:()=>w9t,getObjectUtils:()=>NNn,getSchemaUtils:()=>y6,isProperty:()=>a5r,lazy:()=>rUf,lazyObject:()=>cUf,list:()=>kSa,number:()=>hUf,object:()=>ZSa,objectWithoutOptionalProperties:()=>sUf,optional:()=>NSu,property:()=>iUf,record:()=>gUf,set:()=>mUf,string:()=>yUf,stringLiteral:()=>fUf,transform:()=>zSu,undiscriminatedUnion:()=>PUf,union:()=>DUf,unknown:()=>vUf,withParsedProperties:()=>FSu});var vE={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 $2(e,t){return`Expected ${t}. Received ${D0w(e)}.`}function D0w(e){if(Array.isArray(e))return"list";if(e===null)return"null";switch(typeof e){case"string":return`"${e}"`;case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function A$(e){return{...e,json:eUf(e.json),parse:eUf(e.parse)}}function eUf(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(`
1951
- `)),{ok:!0,value:t}):n}}function YSa(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var qNn=class e extends Error{errors;constructor(t){super(t.map(YSa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var INn=class e extends Error{errors;constructor(t){super(t.map(YSa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function y6(e){return{optional:()=>NSu(e),transform:t=>zSu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new INn(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new qNn(n.errors)}}}function NSu(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:()=>vE.OPTIONAL};return{...t,...y6(t)}}function zSu(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,...y6(r)}}var S0w=/^([+-]?\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 tUf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$2(t,"string")}]}:S0w.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:$2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:$2(t,"Date object")}]},getType:()=>vE.DATE};return{...A$(e),...y6(e)}}function M$(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...A$(r),...y6(r)}}}function XSa(e){let t=new Set(e);return M$(vE.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:$2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:$2(n,"enum")}]}:{ok:!0,value:n})()}function rUf(e){let t=RSu(e);return{...t,...y6(t)}}function RSu(e){return{parse:(t,r)=>BNn(e).parse(t,r),json:(t,r)=>BNn(e).json(t,r),getType:()=>BNn(e).getType()}}function BNn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function $gi(e){return Object.entries(e)}function Kgi(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function i5r(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 Ygi(e){return Object.keys(e)}function nUf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function w9t(e){return{withParsedProperties:t=>FSu(e,t)}}function FSu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!i5r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:$2(n,"object")}]};let a=new Set(Object.keys(t)),u=Kgi(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...y6(r),...w9t(r)}}function iUf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function a5r(e){return e.isProperty}function ZSa(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>a5r(n)?n.rawKey:r),_getParsedProperties:()=>Ygi(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of $gi(e)){let d=a5r(f)?f.rawKey:u,c=a5r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,uUf(c)&&a.push(d)}return aUf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...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 $gi(e)){let f=a5r(u)?u.valueSchema:u;uUf(f)&&i.push(a)}return aUf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return a5r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>vE.OBJECT};return{...A$(t),...y6(t),...w9t(t),...NNn(t)}}function aUf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!i5r(e))return{ok:!1,errors:[{path:a,message:$2(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let g=l.transform(o);g.ok?d[l.transformedKey]=g.value:(d[c]=o,f.push(...g.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function NNn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>oUf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>oUf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>vE.OBJECT};return{...r,...y6(r),...w9t(r),...NNn(r)}}}}function oUf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=nUf(Ygi(t),c=>i.has(c)),f=r(Kgi(t,u)),d=n(Kgi(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function uUf(e){return!E0w(e)}function E0w(e){switch(e.getType()){case vE.ANY:case vE.UNKNOWN:case vE.OPTIONAL:return!0;default:return!1}}function sUf(e){return ZSa(e)}function cUf(e){let t={...RSu(e),_getRawProperties:()=>BNn(e)._getRawProperties(),_getParsedProperties:()=>BNn(e)._getParsedProperties()};return{...t,...y6(t),...w9t(t),...NNn(t)}}function kSa(e){let t={parse:(r,n)=>lUf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>lUf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>vE.LIST};return{...A$(t),...y6(t)}}function lUf(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:$2(e,"list"),path:[]}]}}function fUf(e){return M$(vE.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:$2(r,`"${e}"`)}]})()}function dUf(e){return M$(vE.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:$2(r,`${e.toString()}`)}]})()}var pUf=M$(vE.ANY,e=>({ok:!0,value:e}));var _Uf=M$(vE.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"boolean")}]});var hUf=M$(vE.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"number")}]});var yUf=M$(vE.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"string")}]});var vUf=M$(vE.UNKNOWN,e=>({ok:!0,value:e}));function gUf(e,t){let r={parse:(n,i)=>bUf({value:n,isKeyNumeric:e.getType()===vE.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)=>bUf({value:n,isKeyNumeric:e.getType()===vE.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:()=>vE.RECORD};return{...A$(r),...y6(r)}}function bUf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return i5r(e)?$gi(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let g=[];return d.ok||g.push(...d.errors),o.ok||g.push(...o.errors),l.ok||g.push(...l.errors),{ok:!1,errors:g}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:$2(e,"object")}]}}function mUf(e){let t=kSa(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:$2(n,"Set")}]},getType:()=>vE.SET};return{...A$(r),...y6(r)}}function PUf(e){let t={parse:(r,n)=>OUf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>OUf((i,a)=>i.json(r,a),e,n),getType:()=>vE.UNDISCRIMINATED_UNION};return{...A$(t),...y6(t)}}function OUf(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 f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function wUf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function DUf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=XSa(Ygi(t)),a={parse:(u,f)=>jUf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>jUf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>vE.UNION};return{...A$(a),...y6(a),...w9t(a)}}function jUf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!i5r(e))return{ok:!1,errors:[{path:f,message:$2(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);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,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let g=u(c,l);return g.ok?{ok:!0,value:{[r]:d,...g.value}}:g}var j9t=Uy.objectWithoutOptionalProperties({docs:Uy.string().optional()});var USu={};_l(USu,{ConjureServiceName:()=>eEa,DefinitionFile:()=>SUf});var eEa=Uy.string();var tEa=Uy.enum_(["rid","string","safelong","integer","double","boolean"]);var o5r=Uy.undiscriminatedUnion([tEa,Uy.string()]);var rEa=Uy.objectWithoutOptionalProperties({alias:o5r,docs:Uy.string().optional()});var nEa=Uy.objectWithoutOptionalProperties({type:o5r,docs:Uy.string().optional()});var u5r=Uy.undiscriminatedUnion([o5r,nEa]);var iEa=Uy.objectWithoutOptionalProperties({union:Uy.record(Uy.string(),u5r)});var aEa=Uy.objectWithoutOptionalProperties({fields:Uy.record(Uy.string(),u5r)});var oEa=Uy.objectWithoutOptionalProperties({value:Uy.string()}).extend(j9t);var uEa=Uy.undiscriminatedUnion([Uy.string(),oEa]);var sEa=Uy.objectWithoutOptionalProperties({values:Uy.list(uEa)});var cEa=Uy.undiscriminatedUnion([rEa,iEa,aEa,sEa]);var lEa=Uy.objectWithoutOptionalProperties({objects:Uy.record(Uy.string(),cEa).optional()});var fEa=Uy.objectWithoutOptionalProperties({conjureImports:Uy.property("conjure-imports",Uy.record(Uy.string(),Uy.string()).optional()),definitions:lEa.optional()});var dEa=Uy.enum_(["path","query","body"]);var pEa=Uy.objectWithoutOptionalProperties({paramType:Uy.property("param-type",dEa),type:Uy.string()}).extend(j9t);var _Ea=Uy.undiscriminatedUnion([Uy.string(),pEa]);var hEa=Uy.objectWithoutOptionalProperties({http:Uy.string(),args:Uy.record(Uy.string(),_Ea).optional(),returns:u5r.optional()}).extend(j9t);var yEa=Uy.objectWithoutOptionalProperties({name:Uy.string().optional(),package:Uy.string().optional(),basePath:Uy.property("base-path",Uy.string().optional()),endpoints:Uy.record(Uy.string(),hEa).optional()}).extend(j9t);var SUf=Uy.objectWithoutOptionalProperties({types:fEa.optional(),services:Uy.record(eEa,yEa).optional()});var VSu={};_l(VSu,{ConjureArgument:()=>_Ea,ConjureArgumentWithParamType:()=>pEa,ConjureEndpoint:()=>hEa,ConjureParamType:()=>dEa,ConjureService:()=>yEa});var WSu={};_l(WSu,{ConjureAliasDeclaration:()=>rEa,ConjureDefinitions:()=>lEa,ConjureEnumDeclaration:()=>sEa,ConjureEnumVariant:()=>uEa,ConjureEnumWithDocs:()=>oEa,ConjureObjectDeclaration:()=>aEa,ConjurePrimitive:()=>tEa,ConjureType:()=>o5r,ConjureTypeDeclaration:()=>cEa,ConjureTypeReference:()=>u5r,ConjureTypeWithDocs:()=>nEa,ConjureTypes:()=>fEa,ConjureUnionDeclaration:()=>iEa});var EUf=require("fs/promises");async function AUf(e,t){let r=[];for(let n of await xxe(e,t))r.push(await A0w({relativeFilepath:mq(e,n),absoluteFilepath:n}));return r}async function A0w({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,EUf.readFile)(t)).toString().replaceAll(": rid",": string").replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": binary",": file").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:vEa.DefinitionFile.parseOrThrow(f0.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}var Xgi=class extends Jgi{fernDefinitionBuilder=new Wnn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:n,globalHeaderOverrides:i}){if(r!=null){for(let[a,u]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:u});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(n!=null){for(let[a,u]of Object.entries(n.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});n["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(n["default-environment"]),n["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(n["default-url"])}return await MUf(t,(a,u,f)=>{for(let[o,l]of Object.entries(f.services??{})){let g=pKi({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=Ms.of(`${g}/__package__.yml`);return}let c=V$o(u)?.split(".")[0];c!=null&&(this.conjureFilepathToFernFilepath[u]=Ms.of(`${c}/__package__.yml`))}),await MUf(t,(a,u,f)=>{if(f.services==null||Object.keys(f.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[u];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[c,o]of Object.entries(f.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Ms.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:Ms.of(l),alias:c})}this.importAllTypes({conjureFile:f,fernFilePath:d});return}for(let[d,c]of Object.entries(f.services)){let o=pKi({value:d,suffix:"Service"}),l=Ms.of(`${o}/__package__.yml`),g={};c.basePath!=null&&(g["base-path"]=c.basePath),c.docs!=null&&(g.docs=c.docs),this.fernDefinitionBuilder.setServiceInfo(l,g),this.importAllTypes({conjureFile:f,fernFilePath:l});for(let[O,w]of Object.entries(f.types?.conjureImports??{})){let j=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Ms.of(w)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:Ms.of(j),alias:O})}for(let[O,w]of Object.entries(c.endpoints??{})){let j=GQo(w.http);if(j.type==="failure"){this.context?.logger.error(`Failed to parse ${w.http}. Skipping.`);continue}let M={auth:!0,path:j.path,method:j.method,response:w.returns},q={};if(w.args!=null)for(let B of j.pathParameters){let I=w.args[B];if(I==null)throw new Error(`Failed to find path parameter ${B} in ${w.http}`);q[B]=typeof I=="string"?I:{type:I.type}}Object.entries(q).length>0&&(M["path-parameters"]=q);for(let[B,I]of Object.entries(w.args??{}))if(q[B]==null)if(typeof I=="string")M.request={body:{type:I}};else switch(I.paramType){case"body":M.request={body:{type:I.type}};break;case"query":M.request==null?M.request={"query-parameters":{[B]:I.type}}:typeof M.request!="string"&&M.request?.["query-parameters"]==null?M.request["query-parameters"]={[B]:I.type}:typeof M.request!="string"&&M.request?.["query-parameters"]!=null&&(M.request["query-parameters"][B]=I.type)}M.request!=null&&typeof M.request!="string"&&M.request?.["query-parameters"]!=null&&(M.request.name=`${O}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:O,schema:M,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[n,i]of Object.entries(t.types?.definitions?.objects??{}))kLf(i,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:a})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:n}){let i=yf(ub(t),Ms.of(r)),a=IBr(n,i),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function MUf(e,t){for(let r of await AUf(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}var bEa=class extends Z6t{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=yf(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new k6t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let i=await new Xgi(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:j_.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:i.rootApiFile["default-url"],contents:i.rootApiFile,rawContents:f0.dump(i.rootApiFile)},namedDefinitionFiles:{...KSa(i.definitionFiles,a=>({absoluteFilepath:j_.of("/DUMMY_PATH"),rawContents:f0.dump(a),contents:a})),[Ms.of(QA)]:{absoluteFilepath:j_.of("/DUMMY_PATH"),rawContents:f0.dump(i.packageMarkerFile),contents:i.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function HSu(e,t){for(let[r,n]of o8(e.failures))M0w({relativeFilepath:r,failure:n,logger:t})}function M0w({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case wj.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case wj.FILE_READ:r.error("Failed to open file: "+e);break;case wj.FILE_MISSING:r.error("Missing file: "+e);break;case wj.FILE_PARSE:t.error instanceof ddi?r.error(Nqt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case wj.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of x0w(n))r.error(Nqt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case wj.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case wj.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${KKi}: `+t.dependencyName);break;case wj.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case wj.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case wj.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Nqt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:Kc(t)}}function x0w(e){switch(e.code){case e_.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${nl.underline(e.expected)} but received ${nl.underline(e.received)}`}];case e_.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${nl.underline(t)}`}));case e_.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>nl.underline(t)).join(", ")}`}];case e_.invalid_union:case e_.invalid_arguments:case e_.invalid_return_type:case e_.invalid_date:case e_.invalid_string:case e_.too_small:case e_.too_big:case e_.invalid_intersection_types:case e_.not_multiple_of:case e_.custom:default:return[{title:e.message}]}}var xUf=require("fs/promises");async function TUf(e,t){let r=[];for(let n of await xxe(e,t))r.push(await T0w({relativeFilepath:mq(e,n),absoluteFilepath:n}));return r}async function T0w({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,xUf.readFile)(t)).toString()}}async function CUf({absolutePathToWorkspace:e}){let t=yf(e,Ms.of(S$c));if(!await Vh(t))return;let n=await TUf(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}async function QSu({absolutePathToWorkspace:e,namespace:t,definitions:r}){let n=[];for(let i of r){let a=i.overrides!=null?yf(e,Ms.of(i.overrides)):void 0;if(i.schema.type==="protobuf"){let f=yf(e,Ms.of(i.schema.root));if(!await Vh(f))return{didSucceed:!1,failures:{[Ms.of(i.schema.root)]:{type:wj.FILE_MISSING}}};let d=yf(e,Ms.of(i.schema.target));if(!await Vh(d))return{didSucceed:!1,failures:{[Ms.of(i.schema.target)]:{type:wj.FILE_MISSING}}};n.push({type:"protobuf",absoluteFilepathToProtobufRoot:f,absoluteFilepathToProtobufTarget:d,absoluteFilepathToOverrides:a,generateLocally:i.schema.localGeneration,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0}});continue}let u=yf(e,Ms.of(i.schema.path));if(!await Vh(u))return{didSucceed:!1,failures:{[Ms.of(i.schema.path)]:{type:wj.FILE_MISSING}}};if(i.overrides!=null&&a!=null&&!await Vh(a))return{didSucceed:!1,failures:{[Ms.of(i.overrides)]:{type:wj.FILE_MISSING}}};n.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,asyncApiNaming:i.settings?.asyncApiMessageNaming,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0},source:{type:"openapi",file:u},namespace:t})}return n}async function Zgi({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:n}){let i=await yP.loadGeneratorsConfiguration({absolutePathToWorkspace:e,context:t}),a;try{a=await CUf({absolutePathToWorkspace:e})}catch{}if(i?.api!=null&&i?.api.type==="conjure")return{didSucceed:!0,workspace:new bEa({workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Ms.of(i.api.pathToConjureDefinition)})};if(i?.api!=null&&(i.api.type==="singleNamespace"&&i.api.definitions.length>0||i.api.type==="multiNamespace")){let u=[];if(i.api.type==="singleNamespace"){let f=await QSu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.definitions});if(!Array.isArray(f))return f;u.push(...f)}else{for(let[f,d]of Object.entries(i.api.definitions)){let c=await QSu({absolutePathToWorkspace:e,namespace:f,definitions:d});if(!Array.isArray(c))return c;u.push(...c)}if(i.api.rootDefinitions!=null){let f=await QSu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.rootDefinitions});if(!Array.isArray(f))return f;u.push(...f)}}return{didSucceed:!0,workspace:new d2e({specs:u,workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r})}}return await Vh(yf(e,Ms.of(AL)))?{didSucceed:!0,workspace:new D3n({absoluteFilePath:e,generatorsConfiguration:i,workspaceName:n,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:Zgi})}:{didSucceed:!1,failures:{[Ms.of(BZr)]:{type:wj.MISCONFIGURED_DIRECTORY}}}}var qUf=require("fs/promises");var IUf=tu(require("path"),1);async function JSu({fernDirectory:e,context:t}){let r=yf(e,Ms.of(eSr));if(!await Vh(r))return;let n=await C0w({absolutePathToDocsDefinition:e,context:t});if(n!=null)return{type:"docs",absoluteFilePath:e,config:n,workspaceName:void 0,absoluteFilepathToDocsConfig:yf(e,Ms.of(eSr))}}async function C0w({absolutePathToDocsDefinition:e,context:t}){if(!await Vh(e))return;let r=yf(e,Ms.of(eSr));return await q0w({absolutePathOfConfiguration:r,context:t})}async function q0w({absolutePathOfConfiguration:e,context:t}){let r=await(0,qUf.readFile)(e),n=f0.load(r.toString());return await I0w({value:n,context:t,filepathBeingParsed:e})}async function I0w({value:e,context:t,filepathBeingParsed:r}){let n=await $xe.RawSchemas.Serializer.DocsConfiguration.parse(e);if(n.ok)return n.value;let i=n.errors.map(u=>{let f=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return aZ({content:f,prefix:" - "})}),a=[`Failed to parse file: ${IUf.default.relative(process.cwd(),r)}`,...i].join(`
1951
+ `)),{ok:!0,value:t}):n}}function YSa(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var qNn=class e extends Error{errors;constructor(t){super(t.map(YSa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var INn=class e extends Error{errors;constructor(t){super(t.map(YSa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function y6(e){return{optional:()=>NSu(e),transform:t=>zSu(e,t),parseOrThrow:(t,r)=>{let n=e.parse(t,r);if(n.ok)return n.value;throw new INn(n.errors)},jsonOrThrow:(t,r)=>{let n=e.json(t,r);if(n.ok)return n.value;throw new qNn(n.errors)}}}function NSu(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:()=>vE.OPTIONAL};return{...t,...y6(t)}}function zSu(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,...y6(r)}}var S0w=/^([+-]?\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 tUf(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:$2(t,"string")}]}:S0w.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:$2(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:$2(t,"Date object")}]},getType:()=>vE.DATE};return{...A$(e),...y6(e)}}function M$(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...A$(r),...y6(r)}}}function XSa(e){let t=new Set(e);return M$(vE.ENUM,(n,{allowUnrecognizedEnumValues:i,breadcrumbsPrefix:a=[]}={})=>typeof n!="string"?{ok:!1,errors:[{path:a,message:$2(n,"string")}]}:!t.has(n)&&!i?{ok:!1,errors:[{path:a,message:$2(n,"enum")}]}:{ok:!0,value:n})()}function rUf(e){let t=RSu(e);return{...t,...y6(t)}}function RSu(e){return{parse:(t,r)=>BNn(e).parse(t,r),json:(t,r)=>BNn(e).json(t,r),getType:()=>BNn(e).getType()}}function BNn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function $gi(e){return Object.entries(e)}function Kgi(e,t){let r=new Set(t);return Object.entries(e).reduce((n,[i,a])=>(r.has(i)&&(n[i]=a),n),{})}function i5r(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 Ygi(e){return Object.keys(e)}function nUf(e,t){let r=[],n=[];for(let i of e)t(i)?r.push(i):n.push(i);return[r,n]}function w9t(e){return{withParsedProperties:t=>FSu(e,t)}}function FSu(e,t){let r={parse:(n,i)=>{let a=e.parse(n,i);if(!a.ok)return a;let u=Object.entries(t).reduce((f,[d,c])=>({...f,[d]:typeof c=="function"?c(a.value):c}),{});return{ok:!0,value:{...a.value,...u}}},json:(n,i)=>{if(!i5r(n))return{ok:!1,errors:[{path:i?.breadcrumbsPrefix??[],message:$2(n,"object")}]};let a=new Set(Object.keys(t)),u=Kgi(n,Object.keys(n).filter(f=>!a.has(f)));return e.json(u,i)},getType:()=>e.getType()};return{...r,...y6(r),...w9t(r)}}function iUf(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function a5r(e){return e.isProperty}function ZSa(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,n])=>a5r(n)?n.rawKey:r),_getParsedProperties:()=>Ygi(e),parse:(r,n)=>{let i={},a=[];for(let[u,f]of $gi(e)){let d=a5r(f)?f.rawKey:u,c=a5r(f)?f.valueSchema:f,o={rawKey:d,parsedKey:u,valueSchema:c};i[d]=o,uUf(c)&&a.push(d)}return aUf({value:r,requiredKeys:a,getProperty:u=>{let f=i[u];if(f!=null)return{transformedKey:f.parsedKey,transform:d=>f.valueSchema.parse(d,{...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 $gi(e)){let f=a5r(u)?u.valueSchema:u;uUf(f)&&i.push(a)}return aUf({value:r,requiredKeys:i,getProperty:a=>{let u=e[a];if(u!=null)return a5r(u)?{transformedKey:u.rawKey,transform:f=>u.valueSchema.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:f=>u.json(f,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:n?.unrecognizedObjectKeys,skipValidation:n?.skipValidation,breadcrumbsPrefix:n?.breadcrumbsPrefix,omitUndefined:n?.omitUndefined})},getType:()=>vE.OBJECT};return{...A$(t),...y6(t),...w9t(t),...NNn(t)}}function aUf({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:n="fail",skipValidation:i=!1,breadcrumbsPrefix:a=[]}){if(!i5r(e))return{ok:!1,errors:[{path:a,message:$2(e,"object")}]};let u=new Set(t),f=[],d={};for(let[c,o]of Object.entries(e)){let l=r(c);if(l!=null){u.delete(c);let g=l.transform(o);g.ok?d[l.transformedKey]=g.value:(d[c]=o,f.push(...g.errors))}else switch(n){case"fail":f.push({path:[...a,c],message:`Unexpected key "${c}"`});break;case"strip":break;case"passthrough":d[c]=o;break}}return f.push(...t.filter(c=>u.has(c)).map(c=>({path:a,message:`Missing required key "${c}"`}))),f.length===0||i?{ok:!0,value:d}:{ok:!1,errors:f}}function NNn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(n,i)=>oUf({extensionKeys:t._getRawProperties(),value:n,transformBase:a=>e.parse(a,i),transformExtension:a=>t.parse(a,i)}),json:(n,i)=>oUf({extensionKeys:t._getParsedProperties(),value:n,transformBase:a=>e.json(a,i),transformExtension:a=>t.json(a,i)}),getType:()=>vE.OBJECT};return{...r,...y6(r),...w9t(r),...NNn(r)}}}}function oUf({extensionKeys:e,value:t,transformBase:r,transformExtension:n}){let i=new Set(e),[a,u]=nUf(Ygi(t),c=>i.has(c)),f=r(Kgi(t,u)),d=n(Kgi(t,a));return f.ok&&d.ok?{ok:!0,value:{...f.value,...d.value}}:{ok:!1,errors:[...f.ok?[]:f.errors,...d.ok?[]:d.errors]}}function uUf(e){return!E0w(e)}function E0w(e){switch(e.getType()){case vE.ANY:case vE.UNKNOWN:case vE.OPTIONAL:return!0;default:return!1}}function sUf(e){return ZSa(e)}function cUf(e){let t={...RSu(e),_getRawProperties:()=>BNn(e)._getRawProperties(),_getParsedProperties:()=>BNn(e)._getParsedProperties()};return{...t,...y6(t),...w9t(t),...NNn(t)}}function kSa(e){let t={parse:(r,n)=>lUf(r,(i,a)=>e.parse(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,n)=>lUf(r,(i,a)=>e.json(i,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>vE.LIST};return{...A$(t),...y6(t)}}function lUf(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:$2(e,"list"),path:[]}]}}function fUf(e){return M$(vE.STRING_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:$2(r,`"${e}"`)}]})()}function dUf(e){return M$(vE.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:n=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:n,message:$2(r,`${e.toString()}`)}]})()}var pUf=M$(vE.ANY,e=>({ok:!0,value:e}));var _Uf=M$(vE.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"boolean")}]});var hUf=M$(vE.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"number")}]});var yUf=M$(vE.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:$2(e,"string")}]});var vUf=M$(vE.UNKNOWN,e=>({ok:!0,value:e}));function gUf(e,t){let r={parse:(n,i)=>bUf({value:n,isKeyNumeric:e.getType()===vE.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)=>bUf({value:n,isKeyNumeric:e.getType()===vE.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:()=>vE.RECORD};return{...A$(r),...y6(r)}}function bUf({value:e,isKeyNumeric:t,transformKey:r,transformValue:n,breadcrumbsPrefix:i=[]}){return i5r(e)?$gi(e).reduce((a,[u,f])=>{if(f==null)return a;let d=a,c=u;if(t){let O=u.length>0?Number(u):NaN;isNaN(O)||(c=O)}let o=r(c),l=n(f,c);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let g=[];return d.ok||g.push(...d.errors),o.ok||g.push(...o.errors),l.ok||g.push(...l.errors),{ok:!1,errors:g}},{ok:!0,value:{}}):{ok:!1,errors:[{path:i,message:$2(e,"object")}]}}function mUf(e){let t=kSa(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:$2(n,"Set")}]},getType:()=>vE.SET};return{...A$(r),...y6(r)}}function PUf(e){let t={parse:(r,n)=>OUf((i,a)=>i.parse(r,a),e,n),json:(r,n)=>OUf((i,a)=>i.json(r,a),e,n),getType:()=>vE.UNDISCRIMINATED_UNION};return{...A$(t),...y6(t)}}function OUf(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 f of u.errors)n.push({path:f.path,message:`[Variant ${i}] ${f.message}`})}return{ok:!1,errors:n}}function wUf(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function DUf(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,n=typeof e=="string"?e:e.parsedDiscriminant,i=XSa(Ygi(t)),a={parse:(u,f)=>jUf({value:u,discriminant:r,transformedDiscriminant:n,transformDiscriminantValue:d=>i.parse(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.parse(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),json:(u,f)=>jUf({value:u,discriminant:n,transformedDiscriminant:r,transformDiscriminantValue:d=>i.json(d,{allowUnrecognizedEnumValues:f?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...f?.breadcrumbsPrefix??[],n]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:f?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,c)=>c.json(d,f),breadcrumbsPrefix:f?.breadcrumbsPrefix}),getType:()=>vE.UNION};return{...A$(a),...y6(a),...w9t(a)}}function jUf({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:n,getAdditionalPropertiesSchema:i,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:f=[]}){if(!i5r(e))return{ok:!1,errors:[{path:f,message:$2(e,"object")}]};let{[t]:d,...c}=e;if(d==null)return{ok:!1,errors:[{path:f,message:`Missing discriminant ("${t}")`}]};let o=n(d);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,...c}}:{ok:!1,errors:[{path:[...f,t],message:"Unexpected discriminant value"}]};let g=u(c,l);return g.ok?{ok:!0,value:{[r]:d,...g.value}}:g}var j9t=Uy.objectWithoutOptionalProperties({docs:Uy.string().optional()});var USu={};_l(USu,{ConjureServiceName:()=>eEa,DefinitionFile:()=>SUf});var eEa=Uy.string();var tEa=Uy.enum_(["rid","string","safelong","integer","double","boolean"]);var o5r=Uy.undiscriminatedUnion([tEa,Uy.string()]);var rEa=Uy.objectWithoutOptionalProperties({alias:o5r,docs:Uy.string().optional()});var nEa=Uy.objectWithoutOptionalProperties({type:o5r,docs:Uy.string().optional()});var u5r=Uy.undiscriminatedUnion([o5r,nEa]);var iEa=Uy.objectWithoutOptionalProperties({union:Uy.record(Uy.string(),u5r)});var aEa=Uy.objectWithoutOptionalProperties({fields:Uy.record(Uy.string(),u5r)});var oEa=Uy.objectWithoutOptionalProperties({value:Uy.string()}).extend(j9t);var uEa=Uy.undiscriminatedUnion([Uy.string(),oEa]);var sEa=Uy.objectWithoutOptionalProperties({values:Uy.list(uEa)});var cEa=Uy.undiscriminatedUnion([rEa,iEa,aEa,sEa]);var lEa=Uy.objectWithoutOptionalProperties({objects:Uy.record(Uy.string(),cEa).optional()});var fEa=Uy.objectWithoutOptionalProperties({conjureImports:Uy.property("conjure-imports",Uy.record(Uy.string(),Uy.string()).optional()),definitions:lEa.optional()});var dEa=Uy.enum_(["path","query","body"]);var pEa=Uy.objectWithoutOptionalProperties({paramType:Uy.property("param-type",dEa),type:Uy.string()}).extend(j9t);var _Ea=Uy.undiscriminatedUnion([Uy.string(),pEa]);var hEa=Uy.objectWithoutOptionalProperties({http:Uy.string(),args:Uy.record(Uy.string(),_Ea).optional(),returns:u5r.optional()}).extend(j9t);var yEa=Uy.objectWithoutOptionalProperties({name:Uy.string().optional(),package:Uy.string().optional(),basePath:Uy.property("base-path",Uy.string().optional()),endpoints:Uy.record(Uy.string(),hEa).optional()}).extend(j9t);var SUf=Uy.objectWithoutOptionalProperties({types:fEa.optional(),services:Uy.record(eEa,yEa).optional()});var VSu={};_l(VSu,{ConjureArgument:()=>_Ea,ConjureArgumentWithParamType:()=>pEa,ConjureEndpoint:()=>hEa,ConjureParamType:()=>dEa,ConjureService:()=>yEa});var WSu={};_l(WSu,{ConjureAliasDeclaration:()=>rEa,ConjureDefinitions:()=>lEa,ConjureEnumDeclaration:()=>sEa,ConjureEnumVariant:()=>uEa,ConjureEnumWithDocs:()=>oEa,ConjureObjectDeclaration:()=>aEa,ConjurePrimitive:()=>tEa,ConjureType:()=>o5r,ConjureTypeDeclaration:()=>cEa,ConjureTypeReference:()=>u5r,ConjureTypeWithDocs:()=>nEa,ConjureTypes:()=>fEa,ConjureUnionDeclaration:()=>iEa});var EUf=require("fs/promises");async function AUf(e,t){let r=[];for(let n of await xxe(e,t))r.push(await A0w({relativeFilepath:mq(e,n),absoluteFilepath:n}));return r}async function A0w({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,EUf.readFile)(t)).toString().replaceAll(": rid",": string").replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": binary",": file").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:vEa.DefinitionFile.parseOrThrow(f0.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}var Xgi=class extends Jgi{fernDefinitionBuilder=new Wnn(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:n,globalHeaderOverrides:i}){if(r!=null){for(let[a,u]of Object.entries(r["auth-schemes"]??{}))this.fernDefinitionBuilder.addAuthScheme({name:a,schema:u});r.auth!=null&&this.fernDefinitionBuilder.setAuth(r.auth)}if(n!=null){for(let[a,u]of Object.entries(n.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});n["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(n["default-environment"]),n["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(n["default-url"])}return await MUf(t,(a,u,f)=>{for(let[o,l]of Object.entries(f.services??{})){let g=pKi({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=Ms.of(`${g}/__package__.yml`);return}let c=V$o(u)?.split(".")[0];c!=null&&(this.conjureFilepathToFernFilepath[u]=Ms.of(`${c}/__package__.yml`))}),await MUf(t,(a,u,f)=>{if(f.services==null||Object.keys(f.services??{}).length===0){let d=this.conjureFilepathToFernFilepath[u];if(d==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[c,o]of Object.entries(f.types?.conjureImports??{})){let l=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Ms.of(o)});this.fernDefinitionBuilder.addImport({file:d,fileToImport:Ms.of(l),alias:c})}this.importAllTypes({conjureFile:f,fernFilePath:d});return}for(let[d,c]of Object.entries(f.services)){let o=pKi({value:d,suffix:"Service"}),l=Ms.of(`${o}/__package__.yml`),g={};c.basePath!=null&&(g["base-path"]=c.basePath),c.docs!=null&&(g.docs=c.docs),this.fernDefinitionBuilder.setServiceInfo(l,g),this.importAllTypes({conjureFile:f,fernFilePath:l});for(let[O,w]of Object.entries(f.types?.conjureImports??{})){let j=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Ms.of(w)});this.fernDefinitionBuilder.addImport({file:l,fileToImport:Ms.of(j),alias:O})}for(let[O,w]of Object.entries(c.endpoints??{})){let j=GQo(w.http);if(j.type==="failure"){this.context?.logger.error(`Failed to parse ${w.http}. Skipping.`);continue}let M={auth:!0,path:j.path,method:j.method,response:w.returns},q={};if(w.args!=null)for(let B of j.pathParameters){let I=w.args[B];if(I==null)throw new Error(`Failed to find path parameter ${B} in ${w.http}`);q[B]=typeof I=="string"?I:{type:I.type}}Object.entries(q).length>0&&(M["path-parameters"]=q);for(let[B,I]of Object.entries(w.args??{}))if(q[B]==null)if(typeof I=="string")M.request={body:{type:I}};else switch(I.paramType){case"body":M.request={body:{type:I.type}};break;case"query":M.request==null?M.request={"query-parameters":{[B]:I.type}}:typeof M.request!="string"&&M.request?.["query-parameters"]==null?M.request["query-parameters"]={[B]:I.type}:typeof M.request!="string"&&M.request?.["query-parameters"]!=null&&(M.request["query-parameters"][B]=I.type)}M.request!=null&&typeof M.request!="string"&&M.request?.["query-parameters"]!=null&&(M.request.name=`${O}Request`),this.fernDefinitionBuilder.addEndpoint(l,{name:O,schema:M,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[n,i]of Object.entries(t.types?.definitions?.objects??{}))kLf(i,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:n,schema:Object.fromEntries(Object.entries(a.union).map(([u,f])=>[u,{type:typeof f=="string"?f:f.type,docs:typeof f=="string"?void 0:f.docs,key:u}]))})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:n}){let i=yf(ub(t),Ms.of(r)),a=IBr(n,i),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function MUf(e,t){for(let r of await AUf(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}var bEa=class extends Z6t{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=yf(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let n=await this.getDefinition({context:t},r);return new k6t({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:n,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let i=await new Xgi(t).import({absolutePathToConjureFolder:this.absolutePathToConjureFolder,authOverrides:this.generatorsConfiguration?.api?.auth!=null?{...this.generatorsConfiguration?.api}:void 0,environmentOverrides:this.generatorsConfiguration?.api?.environments!=null?{...this.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.generatorsConfiguration?.api?.headers!=null?{...this.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:j_.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:i.rootApiFile["default-url"],contents:i.rootApiFile,rawContents:f0.dump(i.rootApiFile)},namedDefinitionFiles:{...KSa(i.definitionFiles,a=>({absoluteFilepath:j_.of("/DUMMY_PATH"),rawContents:f0.dump(a),contents:a})),[Ms.of(QA)]:{absoluteFilepath:j_.of("/DUMMY_PATH"),rawContents:f0.dump(i.packageMarkerFile),contents:i.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function HSu(e,t){for(let[r,n]of o8(e.failures))M0w({relativeFilepath:r,failure:n,logger:t})}function M0w({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case wj.MISCONFIGURED_DIRECTORY:r.error("Misconfigured fern directory: please see the docs at https://buildwithfern.com/learn/api-definition/introduction/what-is-the-fern-folder");break;case wj.FILE_READ:r.error("Failed to open file: "+e);break;case wj.FILE_MISSING:r.error("Missing file: "+e);break;case wj.FILE_PARSE:t.error instanceof ddi?r.error(Nqt({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case wj.STRUCTURE_VALIDATION:for(let n of t.error.issues)for(let{title:i,subtitle:a}of x0w(n))r.error(Nqt({title:i,subtitle:a,breadcrumbs:[e,...n.path]}));break;case wj.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case wj.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${KKi}: `+t.dependencyName);break;case wj.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case wj.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case wj.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(Nqt({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(n=>n!=="")]}));break;default:Kc(t)}}function x0w(e){switch(e.code){case e_.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${nl.underline(e.expected)} but received ${nl.underline(e.received)}`}];case e_.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${nl.underline(t)}`}));case e_.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>nl.underline(t)).join(", ")}`}];case e_.invalid_union:case e_.invalid_arguments:case e_.invalid_return_type:case e_.invalid_date:case e_.invalid_string:case e_.too_small:case e_.too_big:case e_.invalid_intersection_types:case e_.not_multiple_of:case e_.custom:default:return[{title:e.message}]}}var xUf=require("fs/promises");async function TUf(e,t){let r=[];for(let n of await xxe(e,t))r.push(await T0w({relativeFilepath:mq(e,n),absoluteFilepath:n}));return r}async function T0w({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,xUf.readFile)(t)).toString()}}async function CUf({absolutePathToWorkspace:e}){let t=yf(e,Ms.of(S$c));if(!await Vh(t))return;let n=await TUf(t,"{md,mdx}");return{files:await Promise.all(n.map(i=>({absoluteFilepath:i.absoluteFilepath,contents:i.fileContents})))}}async function QSu({absolutePathToWorkspace:e,namespace:t,definitions:r}){let n=[];for(let i of r){let a=i.overrides!=null?yf(e,Ms.of(i.overrides)):void 0;if(i.schema.type==="protobuf"){let f=yf(e,Ms.of(i.schema.root));if(!await Vh(f))return{didSucceed:!1,failures:{[Ms.of(i.schema.root)]:{type:wj.FILE_MISSING}}};let d=yf(e,Ms.of(i.schema.target));if(!await Vh(d))return{didSucceed:!1,failures:{[Ms.of(i.schema.target)]:{type:wj.FILE_MISSING}}};n.push({type:"protobuf",absoluteFilepathToProtobufRoot:f,absoluteFilepathToProtobufTarget:d,absoluteFilepathToOverrides:a,generateLocally:i.schema.localGeneration,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0}});continue}let u=yf(e,Ms.of(i.schema.path));if(!await Vh(u))return{didSucceed:!1,failures:{[Ms.of(i.schema.path)]:{type:wj.FILE_MISSING}}};if(i.overrides!=null&&a!=null&&!await Vh(a))return{didSucceed:!1,failures:{[Ms.of(i.overrides)]:{type:wj.FILE_MISSING}}};n.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:i.audiences??[],shouldUseTitleAsName:i.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:i.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,asyncApiNaming:i.settings?.asyncApiMessageNaming,optionalAdditionalProperties:i.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:i.settings?.coerceEnumsToLiterals??!0},source:{type:"openapi",file:u},namespace:t})}return n}async function Zgi({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:n}){let i=await yP.loadGeneratorsConfiguration({absolutePathToWorkspace:e,context:t}),a;try{a=await CUf({absolutePathToWorkspace:e})}catch{}if(i?.api!=null&&i?.api.type==="conjure")return{didSucceed:!0,workspace:new bEa({workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Ms.of(i.api.pathToConjureDefinition)})};if(i?.api!=null&&(i.api.type==="singleNamespace"&&i.api.definitions.length>0||i.api.type==="multiNamespace")){let u=[];if(i.api.type==="singleNamespace"){let f=await QSu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.definitions});if(!Array.isArray(f))return f;u.push(...f)}else{for(let[f,d]of Object.entries(i.api.definitions)){let c=await QSu({absolutePathToWorkspace:e,namespace:f,definitions:d});if(!Array.isArray(c))return c;u.push(...c)}if(i.api.rootDefinitions!=null){let f=await QSu({absolutePathToWorkspace:e,namespace:void 0,definitions:i.api.rootDefinitions});if(!Array.isArray(f))return f;u.push(...f)}}return{didSucceed:!0,workspace:new d2e({specs:u,workspaceName:n,absoluteFilePath:e,generatorsConfiguration:i,changelog:a,cliVersion:r})}}return await Vh(yf(e,Ms.of(AL)))?{didSucceed:!0,workspace:new D3n({absoluteFilePath:e,generatorsConfiguration:i,workspaceName:n,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:Zgi})}:{didSucceed:!1,failures:{[Ms.of(BZr)]:{type:wj.MISCONFIGURED_DIRECTORY}}}}var qUf=require("fs/promises");var IUf=tu(require("path"),1);async function JSu({fernDirectory:e,context:t}){let r=yf(e,Ms.of(eSr));if(!await Vh(r))return;let n=await C0w({absolutePathToDocsDefinition:e,context:t});if(n!=null)return{type:"docs",absoluteFilePath:e,config:n,workspaceName:void 0,absoluteFilepathToDocsConfig:yf(e,Ms.of(eSr))}}async function C0w({absolutePathToDocsDefinition:e,context:t}){if(!await Vh(e))return;let r=yf(e,Ms.of(eSr));return await q0w({absolutePathOfConfiguration:r,context:t})}async function q0w({absolutePathOfConfiguration:e,context:t}){let r=await(0,qUf.readFile)(e),n=f0.load(r.toString());return await I0w({value:n,context:t,filepathBeingParsed:e})}async function I0w({value:e,context:t,filepathBeingParsed:r}){let n=await $xe.RawSchemas.Serializer.DocsConfiguration.parse(e);if(n.ok)return n.value;let i=n.errors.map(u=>{let f=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return aZ({content:f,prefix:" - "})}),a=[`Failed to parse file: ${IUf.default.relative(process.cwd(),r)}`,...i].join(`
1952
1952
  `);return t.failAndThrow(a)}var BUf=require("fs/promises");async function GSu({context:e,nameOverride:t,...r}){let n=await X7r(t);return n==null?e.failAndThrow(`Directory "${t??Mqt}" not found.`):await NUf({absolutePathToFernDirectory:n,context:e,nameOverride:t,...r})}async function NUf({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i,context:a}){let u=[];return(await Vh(yf(e,Ms.of(ABr)))||await Vh(yf(e,Ms.of(AL)))||await Vh(yf(e,Ms.of(s8)))||await Vh(yf(e,Ms.of(BZr)))||await Vh(yf(e,Ms.of(E$c))))&&(u=await zUf({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:i})),{config:await z8t.loadProjectConfig({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await JSu({fernDirectory:e,context:a}),loadAPIWorkspace:f=>f==null?u[0]:u.find(d=>d.workspaceName===f)}}async function zUf({cliName:e,fernDirectory:t,context:r,cliVersion:n,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:a}){let u=yf(t,Ms.of(ABr));if(await Vh(u)){let o=(await(0,BUf.readdir)(u,{withFileTypes:!0})).reduce((O,w)=>(w.isDirectory()&&O.push(w.name),O),[]);if(i!=null){if(!o.includes(i))return r.failAndThrow("API does not exist: "+i)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let O=`There are multiple workspaces. You must specify one with --api:
1953
1953
  `,w=Math.max(...o.map(j=>j.length));return O+=o.map(j=>{let M=`${e} ${process.argv.slice(2).join(" ")} --api ${j}`;return` \u203A ${nl.bold(j.padEnd(w))} ${nl.dim(M)}`}).join(`
1954
1954
  `),r.failAndThrow(O)}}let l=[],g=i!=null?o.filter(O=>O===i):o;return await Promise.all(g.map(async O=>{let w=await Zgi({absolutePathToWorkspace:yf(u,Ms.of(O)),context:r,cliVersion:n,workspaceName:O});w.didSucceed?l.push(w.workspace):(HSu(w,r.logger),r.failAndThrow())})),l}let d=await Zgi({absolutePathToWorkspace:t,context:r,cliVersion:n,workspaceName:void 0});return d.didSucceed?[d.workspace]:(HSu(d,r.logger),[])}async function rI(e,t,r=!1){let n=e.addTask().start(),i=await GSu({...t,cliName:e.environment.cliName,cliVersion:e.environment.packageVersion,context:n});return n.finish(),r&&i.docsWorkspaces!=null?e.registerWorkspaces([...i.apiWorkspaces,i.docsWorkspaces]):e.registerWorkspaces(i.apiWorkspaces),e.registerProject(i),i}var QUf=tu(Spi(),1);var FUf=require("fs/promises");var zNn={GitHub:"github",Local:"local-file-system",PackageRegistry:"publish"};async function LUf({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,apiKeyFallback:i="FERN_DEFAULT",project:{apiWorkspaces:a},outputLocation:u,excludedModes:f,includedModes:d}){let c={};await Promise.all(a.map(async l=>{await e.runTaskForWorkspace(l,async g=>{if(n!=null&&(l.workspaceName==null||!n.has(l.workspaceName)))return;let O=await yP.loadGeneratorsConfiguration({absolutePathToWorkspace:l.absoluteFilePath,context:g});if(O==null||O.groups==null)return;let w=l.workspaceName??i;c[w]={};for(let j of O.groups)r!=null&&!r.has(j.groupName)||(c[w][j.groupName]=j.generators.filter(M=>{let q=!0;return d!=null&&(q=RUf(M,d)),f!=null&&(q=!RUf(M,f)),q}).filter(M=>t==null||t.has(M.name)).map(M=>M.name))})}));let o=f0.dump(c);if(u==null){process.stdout.write(o);return}try{await(0,FUf.writeFile)(u,o)}catch(l){e.failAndThrow(`Could not write file to the specified location: ${u}`,l)}}function RUf(e,t){let r,n=e.outputMode.type;switch(n){case"downloadFiles":r=zNn.Local;break;case"github":case"githubV2":r=zNn.GitHub;break;case"publish":case"publishV2":r=zNn.PackageRegistry;break;default:Kc(n)}return t.has(r)}async function UUf({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,project:{apiWorkspaces:i}}){let a;return await Promise.all(i.map(async u=>{await e.runTaskForWorkspace(u,async f=>{if(n!=null&&(u.workspaceName==null||n!==u.workspaceName))return;let d=await yP.loadGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath,context:f});if(!(d==null||d.groups==null)){for(let c of d.groups)if(r===c.groupName)for(let o of c.generators)t===o.name&&(a=o)}})})),a}var VUf=require("fs/promises");async function WUf({project:e,outputLocation:t,context:r}){let n=e.config.organization;if(t==null){process.stdout.write(n);return}try{await(0,VUf.writeFile)(t,n)}catch(i){r.failAndThrow(`Could not write file to the specified location: ${t}`,i)}}var gEa=require("fs/promises"),kgi=tu(require("path"),1),RNn=tu(rk(),1);async function B0w({absolutePathToWorkspace:e,context:t,generatorFilter:r,groupFilter:n,includeMajor:i,channel:a,cliVersion:u}){let f=yP.getPathToGeneratorsConfiguration({absolutePathToWorkspace:e});if(!await Vh(f)){t.logger.debug("Generators configuration file was not found, no generators to upgrade.");return}let d=await(0,gEa.readFile)(f);t.logger.debug(`Found generators: ${d.toString()}`);let c=RNn.default.parseDocument(d.toString()),o=c.get("groups");if(o==null){t.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}if(!RNn.default.isMap(o)){t.failAndThrow(`Expected 'groups' to be a map in ${kgi.default.relative(process.cwd(),f)}`);return}t.logger.debug(`Groups found: ${o.toString()}`);for(let l of o.items){let g=l.key.value,O=l.value;if(!RNn.default.isMap(O)){t.failAndThrow(`Expected group ${g} to be a map in ${kgi.default.relative(process.cwd(),f)}`);continue}if(n!=null&&n!==g){t.logger.debug(`Skipping group ${g} as it does not match the filter: ${n}`);continue}let w=O.get("generators");if(!RNn.default.isSeq(w)){t.failAndThrow(`Expected group ${g} to have a 'generators' key in ${kgi.default.relative(process.cwd(),f)}`);continue}t.logger.debug(`Generators found: ${w.toString()}`);for(let j of w.items){RNn.default.isMap(j)||t.failAndThrow(`Expected generator in group ${g} to be a map in ${kgi.default.relative(process.cwd(),f)}`);let M=j.get("name");if(r!=null&&M!==r){t.logger.debug(`Skipping generator ${M} as it does not match the filter: ${r}`);continue}let q=yP.getGeneratorNameOrThrow(M,t),B=j.get("version"),I=await yP.getLatestGeneratorVersion({generatorName:q,cliVersion:u,currentGeneratorVersion:B,channel:a,includeMajor:i,context:t});I!=null&&(t.logger.debug(nl.green(`Upgrading ${M} from ${B} to ${I}`)),j.set("version",I))}}return c.toString()}async function HUf({cliContext:e,generator:t,group:r,project:{apiWorkspaces:n},includeMajor:i,channel:a}){await Promise.all(n.map(async u=>{await e.runTaskForWorkspace(u,async f=>{let d=await yP.loadRawGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath,context:f})??{};if(d==null||d.groups==null){f.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}u.workspaceName==null?f.logger.info("Upgrading generators."):f.logger.info(`Upgrading generators in workspace: ${u.workspaceName}.`);let c=await B0w({absolutePathToWorkspace:u.absoluteFilePath,context:f,generatorFilter:t,groupFilter:r,includeMajor:i,channel:a,cliVersion:e.environment.packageVersion});c!=null&&await(0,gEa.writeFile)(u.generatorsConfiguration?.absolutePathToConfiguration??yP.getPathToGeneratorsConfiguration({absolutePathToWorkspace:u.absoluteFilePath}),c)})}))}var JUf=require("fs/promises");function GUf(e,t){e.command("organization",!1,r=>r.option("output",{string:!0,alias:"o",description:"The location to output the organization name as a text file, defaults to standard out."}),async r=>{await t.instrumentPostHogEvent({command:"fern organization",properties:{outputLocation:r.output}}),await WUf({project:await rI(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),context:t,outputLocation:r.output})})}function $Uf(e,t){e.command("generator","Operate on the generators within your Fern configuration",r=>{r.command("list",!1,n=>n.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generators",{string:!0,type:"array",description:"The type of generator to include in the list, ex: `fern-typescript-node-sdk`. If omitted, all generators will be listed."}).option("groups",{type:"array",string:!0,description:"The groups to include generators from, if group is not specified, the all generators of the specified type will be listed."}).option("apis",{type:"array",string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("api-fallback",{string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("include-mode",{choices:Object.values(zNn),type:"array",description:"The generator output modes to include within the outputted list."}).option("exclude-mode",{choices:Object.values(zNn),type:"array",description:"The generator output modes to exclude within the outputted list."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator list",properties:{outputLocation:n.output}}),await LUf({project:await rI(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),generatorFilter:n.generators?new Set(n.generators):void 0,groupFilter:n.groups?new Set(n.groups):void 0,apiFilter:n.apis?new Set(n.apis):void 0,apiKeyFallback:n.apiFallback,cliContext:t,outputLocation:n.output,includedModes:n["include-mode"]?new Set(n["include-mode"]):void 0,excludedModes:n["exclude-mode"]?new Set(n["exclude-mode"]):void 0})}).command("upgrade",`Upgrades the specified generator in ${s8} to the latest stable version.`,n=>n.option("generator",{string:!0,description:"The type of generator to upgrade, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,description:"The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."}).option("api",{string:!0,description:"The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."}).option("include-major",{boolean:!0,default:!1,description:"Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."}).option("channel",{demandOption:!1,choices:Object.values(QUf.FernRegistry.generators.ReleaseType)}).option("list",{demandOption:!1,boolean:!0,default:!1,description:"When specified, a list of available upgrades will be displayed, but no upgrade will be taken."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator upgrade",properties:{generator:n.generator,version:n.version,api:n.api,group:n.group,includeMajor:n.includeMajor,rc:n.rc}});let i=await rI(t,{commandLineApiWorkspace:n.api,defaultToAllApiWorkspaces:!0});if(n.list){t.suppressUpgradeMessage();let a=await dga({cliContext:t,project:i,generatorFilter:n.generator,groupFilter:n.group,includeMajor:n.includeMajor,channel:n.channel}),u=await g0u({generatorUpgradeInfo:a,header:`Generator Upgrades