fern-api 0.47.0 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +3 -3
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1571,7 +1571,7 @@ ${c.indent}`:""}${r7l(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
|
|
|
1571
1571
|
`}),r.replaceAll(/\n$/g,"")}function Gjw(e){return e?ju.green(j5r.radioOn):j5r.radioOff}var E3a=Ji(IOe(),1);function FWf(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var SBn=class extends B6{_run(t){this.done=t;let r=L8(this.rl),i=r.line.pipe((0,E3a.map)(this.filterInput.bind(this))),n=this.handleSubmitEvents(i);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,E3a.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
|
|
1572
1572
|
`+ju.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?ju.cyan(FWf(t,this.opt.mask)):ju.italic.dim("[hidden]"):this.opt.mask?FWf(t,this.opt.mask):ju.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 lHf=Ji(f3u(),1),fHf=Ji(IOe(),1);var zBn=class extends B6{_run(t){this.done=t,this.editorResult=new fHf.Subject;let r=L8(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?ju.dim("Received"):ju.dim("Press <enter> to launch your preferred editor."),t&&(r=ju.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,lHf.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 gHf=Ji(_Hf(),1);var vHf=Ji(require("readline"),1),bHf=Ji(yHf(),1),Jci=class{constructor(t){this.rl||=vHf.default.createInterface(Nww(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 Nww(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new bHf.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var IBn=class extends Jci{constructor(t={}){super(t),this.log=(0,gHf.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return vBn(this.rl,this.bottomBar.split(`
|
|
1573
1573
|
`).length),this}updateBottomBar(t){return vBn(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+`
|
|
1574
|
-
`}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&&j3a(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var AHf=Ji(PHf(),1),qHf=Ji(gRu(),1),THf=Ji(EHf(),1),TE=Ji(IOe(),1),CHf=Ji(DCn(),1);var J3a=Ji(IOe(),1),MHf=Ji(DCn(),1),G3a=function(e,t,r){return typeof e[t]!="function"?(0,J3a.of)(e):(0,J3a.from)((0,MHf.default)(e[t])(r).then(i=>(e[t]=i,e)))};var RBn={isPlainObject:AHf.default,set:THf.default,get:qHf.default},t$i=class extends Jci{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=RBn.isPlainObject(r)?{...r}:{},RBn.isPlainObject(t)&&(t=Object.values(t).every(n=>RBn.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,TE.from)(t):t;return this.process=i.pipe((0,TE.concatMap)(this.processQuestion.bind(this)),(0,TE.publish)()),this.process.connect(),this.process.pipe((0,TE.reduce)((n,a)=>(RBn.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,TE.defer)(()=>(0,TE.of)(t).pipe((0,TE.concatMap)(this.setDefaultType.bind(this)),(0,TE.concatMap)(this.filterIfRunnable.bind(this)),(0,TE.concatMap)(()=>G3a(t,"message",this.answers)),(0,TE.concatMap)(()=>G3a(t,"default",this.answers)),(0,TE.concatMap)(()=>G3a(t,"choices",this.answers)),(0,TE.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,TE.defer)(()=>(0,TE.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,TE.defer)(()=>(0,TE.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&RBn.get(this.answers,t.name)!==void 0)return(0,TE.empty)();if(t.when===!1)return(0,TE.empty)();if(typeof t.when!="function")return(0,TE.of)(t);let{answers:r}=this;return(0,TE.defer)(()=>(0,TE.from)((0,CHf.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,TE.filter)(i=>i!=null)))}};function BHf(e){let t=function(r,i){let n;try{n=new t$i(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",gBn),this.registerPrompt("input",Fci),this.registerPrompt("number",OBn),this.registerPrompt("confirm",mBn),this.registerPrompt("rawlist",PBn),this.registerPrompt("expand",jBn),this.registerPrompt("checkbox",wBn),this.registerPrompt("password",SBn),this.registerPrompt("editor",zBn)},t.restoreDefaultPrompts(),t}var _3u=BHf();function r1w(e,t){_3u.registerPrompt(e,t)}function i1w(){_3u.restoreDefaultPrompts()}var n1w={prompt:_3u,ui:{BottomBar:IBn,Prompt:t$i},createPromptModule:BHf,registerPrompt:r1w,restoreDefaultPrompts:i1w,Separator:eZ},K3a=n1w;var GQf=Ji(xHf()),WDw="4.2.1",fIt;(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",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(fIt||(fIt={}));function $Dw(e,t){if(!e)throw new Error(t)}function HDw(e){return e?.replace(/\/+$/,"")}async function QDw(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function JDw(){return new Date().getTime()}function LQf(){return new Date().toISOString()}function KQf(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var GBn=String.fromCharCode,UQf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f2a={};function GDw(e,t){if(!f2a[e]){f2a[e]={};for(let r=0;r<e.length;r++)f2a[e][e.charAt(r)]=r}return f2a[e][t]}var KBn={compressToBase64:function(e){if(e==null)return"";let t=KBn._compress(e,6,function(r){return UQf.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:KBn._decompress(e.length,32,function(t){return GDw(UQf,e.charAt(t))})},compress:function(e){return KBn._compress(e,16,function(t){return GBn(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,f="",s="",o="",c=2,b=3,g=2,O=0,m=0,S;for(S=0;S<e.length;S+=1)if(f=e.charAt(S),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=b++,n[f]=!0),s=o+f,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(f)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:KBn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,f=3,s="",o,c,b,g,O,m,S;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;S=GBn(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;S=GBn(b);break;case 2:return""}for(i[3]=S,c=S,n.push(S);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,f),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(S=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=GBn(b),S=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=GBn(b),S=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,f),f++),i[S])s=i[S];else if(S===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,f),f++)}}},i2u=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var d2a="0123456789abcdef",p2a=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=d2a.charAt(this.bytes[r]>>>4),t+=d2a.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=d2a.charAt(this.bytes[r]>>>4),t+=d2a.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},n2u=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??KDw()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return p2a.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,p2a.ofInner(t)}},KDw=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),VQf,WQf=()=>YDw().toString(),YDw=()=>(VQf||(VQf=new n2u)).generate(),_2a=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},YBn=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function $Qf(e){return typeof e=="object"&&(e instanceof _2a||e instanceof YBn)}var a2u=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new i2u,this._isInitialized=!1,$Dw(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=HDw(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:$Qf},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(fIt.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(fIt.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(fIt.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=WQf();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(f=>f.json()).catch(f=>{this._events.emit("error",f)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0&&(f=!1),f}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),f=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:f,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:LQf(),uuid:i?.uuid?i.uuid:WQf()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(fIt.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(fIt.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=KQf(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(fIt.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(fIt.Queue)||[];this.setPersistedProperty(fIt.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:LQf()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${JDw()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,f=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(KBn.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,f)}catch(s){throw s instanceof YBn||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let f=new AbortController;return setTimeout(()=>f.abort(),l),f.signal}),await QDw(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(f){throw new YBn(f)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new _2a(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(fIt.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!$Qf(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},o2u=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},u2u=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!u2u){let e=FQf();u2u=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var YQf=u2u,XDw=1152921504606847e3,ZDw=["is_not"],h2a=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},x6=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},s2u=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||YQf,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let f of this.featureFlags)if(t===f.key){l=f;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(f){f instanceof x6?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async f=>{try{let s=this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let o=await this.computeFeatureFlagPayloadLocally(f.key,s);o&&(u[f.key]=o)}catch(s){s instanceof x6||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new x6("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let f=this.groupTypeMapping[String(l)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new x6("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return this.matchFeatureFlagProperties(t,i[f],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,f=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of f)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof x6)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new x6("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let f=l.type,s=!1;if(f==="cohort"?s=ZQf(l,n,this.cohorts,this.debugMode):s=XQf(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&HQf(t.key,r)>a/100)}getMatchingVariant(t,r){let i=HQf(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new h2a("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof h2a&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=KQf(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function HQf(e,t,r=""){let i=(0,GQf.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/XDw}function XQf(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new x6("Operator is_not_set is not supported")}else throw new x6(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!ZDw.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function f(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return QQf(String(n))&&String(u).match(String(n))!==null;case"not_regex":return QQf(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?f(u,String(n),a):f(u,s,a):f(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=kDw(String(n));if(s==null&&(s=JQf(n)),s==null)throw new x6(`Invalid date: ${n}`);let o=JQf(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new x6(`Unknown operator: ${a}`)}}function ZQf(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new x6("can't match cohort without a given cohort property value");let a=r[n];return kQf(a,t,r,i)}function kQf(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let f=kQf(l,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof x6)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new x6("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let f;l.type==="cohort"?f=ZQf(l,t,r,i):f=XQf(l,t);let s=l.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof x6)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new x6("can't match cohort without a given cohort property value");return n==="AND"}}function QQf(e){try{return new RegExp(e),!0}catch{return!1}}function JQf(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new x6(`${e} is in an invalid date format`)}else throw new x6(`The date provided ${e} must be a string, number, or date object`)}function kDw(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var eEw=30*1e3,tEw=50*1e3,s$i=class extends a2u{constructor(t,r={}){super(t,r),this._memoryStorage=new o2u,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new s2u({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:eEw,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||tEw}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):YQf(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return WDw}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:f}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:f})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,S]of Object.entries(b))g[`$feature/${m}`]=S;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:f,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,f,s);f=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,f,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:f,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),f==null&&(f=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,u,l);u=f.allPersonProperties,l=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},c2u=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};c2u.POSTHOG_ID_TAG="posthog_distinct_id";var y2a=class{posthog;constructor({posthogApiKey:t}){this.posthog=new s$i(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.47.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var XBn=class{async sendEvent(){}async identify(){}async flush(){}};var c$i=require("fs/promises"),iJf=require("os"),nJf=require("path");var eJf=Ji(require("crypto")),b2a=new Uint8Array(256),v2a=b2a.length;function l2u(){return v2a>b2a.length-16&&(eJf.default.randomFillSync(b2a),v2a=0),b2a.slice(v2a,v2a+=16)}var W8=[];for(let e=0;e<256;++e)W8.push((e+256).toString(16).slice(1));function tJf(e,t=0){return W8[e[t+0]]+W8[e[t+1]]+W8[e[t+2]]+W8[e[t+3]]+"-"+W8[e[t+4]]+W8[e[t+5]]+"-"+W8[e[t+6]]+W8[e[t+7]]+"-"+W8[e[t+8]]+W8[e[t+9]]+"-"+W8[e[t+10]]+W8[e[t+11]]+W8[e[t+12]]+W8[e[t+13]]+W8[e[t+14]]+W8[e[t+15]]}var rJf=Ji(require("crypto")),f2u={randomUUID:rJf.default.randomUUID};function rEw(e,t,r){if(f2u.randomUUID&&!t&&!e)return f2u.randomUUID();e=e||{};let i=e.random||(e.rng||l2u)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return tJf(i)}var V9t=rEw;var iEw="id",nEw=".fern",ZBn=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new s$i(r),this.userId=t==null?void 0:DBu(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.47.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=ys(Zl.of((0,iJf.homedir)()),Lo.of(nEw),Lo.of(iEw));await If(t)||(await(0,c$i.mkdir)((0,nJf.dirname)(t),{recursive:!0}),await(0,c$i.writeFile)(t,V9t())),this.persistedDistinctId=(await(0,c$i.readFile)(t)).toString()}return this.persistedDistinctId}};var d2u;async function l$i(){return d2u==null&&(d2u=await aEw()),d2u}async function aEw(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new XBn;let r=await pxa();return r!=null?new ZBn({token:r,posthogApiKey:e}):await dxa()!=null?new y2a({posthogApiKey:e}):new ZBn({token:void 0,posthogApiKey:e})}catch{return new XBn}}function kBn(e,t){return function(){return e.apply(t,arguments)}}var{toString:oEw}=Object.prototype,{getPrototypeOf:h2u}=Object,O2a=(e=>t=>{let r=oEw.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),dIt=e=>(e=e.toLowerCase(),t=>O2a(t)===e),m2a=e=>t=>typeof t===e,{isArray:f$i}=Array,exn=m2a("undefined");function uEw(e){return e!==null&&!exn(e)&&e.constructor!==null&&!exn(e.constructor)&&FOe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var uJf=dIt("ArrayBuffer");function sEw(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uJf(e.buffer),t}var cEw=m2a("string"),FOe=m2a("function"),sJf=m2a("number"),P2a=e=>e!==null&&typeof e=="object",lEw=e=>e===!0||e===!1,g2a=e=>{if(O2a(e)!=="object")return!1;let t=h2u(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},fEw=dIt("Date"),dEw=dIt("File"),pEw=dIt("Blob"),_Ew=dIt("FileList"),hEw=e=>P2a(e)&&FOe(e.pipe),yEw=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||FOe(e.append)&&((t=O2a(e))==="formdata"||t==="object"&&FOe(e.toString)&&e.toString()==="[object FormData]"))},vEw=dIt("URLSearchParams"),[bEw,gEw,OEw,mEw]=["ReadableStream","Request","Response","Headers"].map(dIt),PEw=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function txn(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),f$i(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function cJf(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var Xci=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,lJf=e=>!exn(e)&&e!==Xci;function _2u(){let{caseless:e}=lJf(this)&&this||{},t={},r=(i,n)=>{let a=e&&cJf(t,n)||n;g2a(t[a])&&g2a(i)?t[a]=_2u(t[a],i):g2a(i)?t[a]=_2u({},i):f$i(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&txn(arguments[i],r);return t}var jEw=(e,t,r,{allOwnKeys:i}={})=>(txn(t,(n,a)=>{r&&FOe(n)?e[a]=kBn(n,r):e[a]=n},{allOwnKeys:i}),e),wEw=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),SEw=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},DEw=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&h2u(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},EEw=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},MEw=e=>{if(!e)return null;if(f$i(e))return e;let t=e.length;if(!sJf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},AEw=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&h2u(Uint8Array)),qEw=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},TEw=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},CEw=dIt("HTMLFormElement"),BEw=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),aJf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),xEw=dIt("RegExp"),fJf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};txn(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},zEw=e=>{fJf(e,(t,r)=>{if(FOe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(FOe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},IEw=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return f$i(e)?i(e):i(String(e).split(t)),r},REw=()=>{},NEw=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,p2u="abcdefghijklmnopqrstuvwxyz",oJf="0123456789",dJf={DIGIT:oJf,ALPHA:p2u,ALPHA_DIGIT:p2u+p2u.toUpperCase()+oJf},FEw=(e=16,t=dJf.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function LEw(e){return!!(e&&FOe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var UEw=e=>{let t=new Array(10),r=(i,n)=>{if(P2a(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=f$i(i)?[]:{};return txn(i,(u,l)=>{let f=r(u,n+1);!exn(f)&&(a[l]=f)}),t[n]=void 0,a}}return i};return r(e,0)},VEw=dIt("AsyncFunction"),WEw=e=>e&&(P2a(e)||FOe(e))&&FOe(e.then)&&FOe(e.catch),pJf=((e,t)=>e?setImmediate:t?((r,i)=>(Xci.addEventListener("message",({source:n,data:a})=>{n===Xci&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Xci.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",FOe(Xci.postMessage)),$Ew=typeof queueMicrotask<"u"?queueMicrotask.bind(Xci):typeof process<"u"&&process.nextTick||pJf,Zu={isArray:f$i,isArrayBuffer:uJf,isBuffer:uEw,isFormData:yEw,isArrayBufferView:sEw,isString:cEw,isNumber:sJf,isBoolean:lEw,isObject:P2a,isPlainObject:g2a,isReadableStream:bEw,isRequest:gEw,isResponse:OEw,isHeaders:mEw,isUndefined:exn,isDate:fEw,isFile:dEw,isBlob:pEw,isRegExp:xEw,isFunction:FOe,isStream:hEw,isURLSearchParams:vEw,isTypedArray:AEw,isFileList:_Ew,forEach:txn,merge:_2u,extend:jEw,trim:PEw,stripBOM:wEw,inherits:SEw,toFlatObject:DEw,kindOf:O2a,kindOfTest:dIt,endsWith:EEw,toArray:MEw,forEachEntry:qEw,matchAll:TEw,isHTMLForm:CEw,hasOwnProperty:aJf,hasOwnProp:aJf,reduceDescriptors:fJf,freezeMethods:zEw,toObjectSet:IEw,toCamelCase:BEw,noop:REw,toFiniteNumber:NEw,findKey:cJf,global:Xci,isContextDefined:lJf,ALPHABET:dJf,generateString:FEw,isSpecCompliantForm:LEw,toJSONObject:UEw,isAsyncFn:VEw,isThenable:WEw,setImmediate:pJf,asap:$Ew};function d$i(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}Zu.inherits(d$i,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:Zu.toJSONObject(this.config),code:this.code,status:this.status}}});var _Jf=d$i.prototype,hJf={};["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=>{hJf[e]={value:e}});Object.defineProperties(d$i,hJf);Object.defineProperty(_Jf,"isAxiosError",{value:!0});d$i.from=(e,t,r,i,n,a)=>{let u=Object.create(_Jf);return Zu.toFlatObject(e,u,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),d$i.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Xd=d$i;var yJf=Ji(KNr(),1),j2a=yJf.default;function y2u(e){return Zu.isPlainObject(e)||Zu.isArray(e)}function bJf(e){return Zu.endsWith(e,"[]")?e.slice(0,-2):e}function vJf(e,t,r){return e?e.concat(t).map(function(n,a){return n=bJf(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function HEw(e){return Zu.isArray(e)&&!e.some(y2u)}var QEw=Zu.toFlatObject(Zu,{},null,function(t){return/^is[A-Z]/.test(t)});function JEw(e,t,r){if(!Zu.isObject(e))throw new TypeError("target must be an object");t=t||new(j2a||FormData),r=Zu.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,S){return!Zu.isUndefined(S[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zu.isSpecCompliantForm(t);if(!Zu.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(Zu.isDate(O))return O.toISOString();if(!f&&Zu.isBlob(O))throw new Xd("Blob is not supported. Use a Buffer instead.");return Zu.isArrayBuffer(O)||Zu.isTypedArray(O)?f&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,S){let E=O;if(O&&!S&&typeof O=="object"){if(Zu.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(Zu.isArray(O)&&HEw(O)||(Zu.isFileList(O)||Zu.endsWith(m,"[]"))&&(E=Zu.toArray(O)))return m=bJf(m),E.forEach(function(M,q){!(Zu.isUndefined(M)||M===null)&&t.append(u===!0?vJf([m],q,a):u===null?m:m+"[]",s(M))}),!1}return y2u(O)?!0:(t.append(vJf(S,m,a),s(O)),!1)}let c=[],b=Object.assign(QEw,{defaultVisitor:o,convertValue:s,isVisitable:y2u});function g(O,m){if(!Zu.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),Zu.forEach(O,function(E,A){(!(Zu.isUndefined(E)||E===null)&&n.call(t,E,Zu.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!Zu.isObject(e))throw new TypeError("data must be an object");return g(e),t}var c9r=JEw;function gJf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function OJf(e,t){this._pairs=[],e&&c9r(e,this,t)}var mJf=OJf.prototype;mJf.append=function(t,r){this._pairs.push([t,r])};mJf.toString=function(t){let r=t?function(i){return t.call(this,i,gJf)}:gJf;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var PJf=OJf;function GEw(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Zci(e,t,r){if(!t)return e;let i=r&&r.encode||GEw,n=r&&r.serialize,a;if(n?a=n(t,r):a=Zu.isURLSearchParams(t)?t.toString():new PJf(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var v2u=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zu.forEach(this.handlers,function(i){i!==null&&t(i)})}},b2u=v2u;var p$i={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var jJf=Ji(require("url"),1),wJf=jJf.default.URLSearchParams;var SJf={isNode:!0,classes:{URLSearchParams:wJf,FormData:j2a,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var m2u={};$n(m2u,{hasBrowserEnv:()=>O2u,hasStandardBrowserEnv:()=>KEw,hasStandardBrowserWebWorkerEnv:()=>YEw,navigator:()=>g2u,origin:()=>XEw});var O2u=typeof window<"u"&&typeof document<"u",g2u=typeof navigator=="object"&&navigator||void 0,KEw=O2u&&(!g2u||["ReactNative","NativeScript","NS"].indexOf(g2u.product)<0),YEw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",XEw=O2u&&window.location.href||"http://localhost";var CA={...m2u,...SJf};function P2u(e,t){return c9r(e,new CA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return CA.isNode&&Zu.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function ZEw(e){return Zu.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function kEw(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function eMw(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),f=a>=r.length;return u=!u&&Zu.isArray(n)?n.length:u,f?(Zu.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!Zu.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&Zu.isArray(n[u])&&(n[u]=kEw(n[u])),!l)}if(Zu.isFormData(e)&&Zu.isFunction(e.entries)){let r={};return Zu.forEachEntry(e,(i,n)=>{t(ZEw(i),n,r,0)}),r}return null}var w2a=eMw;function tMw(e,t,r){if(Zu.isString(e))try{return(t||JSON.parse)(e),Zu.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var j2u={transitional:p$i,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=Zu.isObject(t);if(a&&Zu.isHTMLForm(t)&&(t=new FormData(t)),Zu.isFormData(t))return n?JSON.stringify(w2a(t)):t;if(Zu.isArrayBuffer(t)||Zu.isBuffer(t)||Zu.isStream(t)||Zu.isFile(t)||Zu.isBlob(t)||Zu.isReadableStream(t))return t;if(Zu.isArrayBufferView(t))return t.buffer;if(Zu.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return P2u(t,this.formSerializer).toString();if((l=Zu.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return c9r(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),tMw(t)):t}],transformResponse:[function(t){let r=this.transitional||j2u.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(Zu.isResponse(t)||Zu.isReadableStream(t))return t;if(t&&Zu.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Xd.from(l,Xd.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:CA.classes.FormData,Blob:CA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zu.forEach(["delete","get","head","post","put","patch"],e=>{j2u.headers[e]={}});var _$i=j2u;var rMw=Zu.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"]),DJf=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1574
|
+
`}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&&j3a(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var AHf=Ji(PHf(),1),qHf=Ji(gRu(),1),THf=Ji(EHf(),1),TE=Ji(IOe(),1),CHf=Ji(DCn(),1);var J3a=Ji(IOe(),1),MHf=Ji(DCn(),1),G3a=function(e,t,r){return typeof e[t]!="function"?(0,J3a.of)(e):(0,J3a.from)((0,MHf.default)(e[t])(r).then(i=>(e[t]=i,e)))};var RBn={isPlainObject:AHf.default,set:THf.default,get:qHf.default},t$i=class extends Jci{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=RBn.isPlainObject(r)?{...r}:{},RBn.isPlainObject(t)&&(t=Object.values(t).every(n=>RBn.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,TE.from)(t):t;return this.process=i.pipe((0,TE.concatMap)(this.processQuestion.bind(this)),(0,TE.publish)()),this.process.connect(),this.process.pipe((0,TE.reduce)((n,a)=>(RBn.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,TE.defer)(()=>(0,TE.of)(t).pipe((0,TE.concatMap)(this.setDefaultType.bind(this)),(0,TE.concatMap)(this.filterIfRunnable.bind(this)),(0,TE.concatMap)(()=>G3a(t,"message",this.answers)),(0,TE.concatMap)(()=>G3a(t,"default",this.answers)),(0,TE.concatMap)(()=>G3a(t,"choices",this.answers)),(0,TE.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,TE.defer)(()=>(0,TE.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,TE.defer)(()=>(0,TE.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&RBn.get(this.answers,t.name)!==void 0)return(0,TE.empty)();if(t.when===!1)return(0,TE.empty)();if(typeof t.when!="function")return(0,TE.of)(t);let{answers:r}=this;return(0,TE.defer)(()=>(0,TE.from)((0,CHf.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,TE.filter)(i=>i!=null)))}};function BHf(e){let t=function(r,i){let n;try{n=new t$i(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",gBn),this.registerPrompt("input",Fci),this.registerPrompt("number",OBn),this.registerPrompt("confirm",mBn),this.registerPrompt("rawlist",PBn),this.registerPrompt("expand",jBn),this.registerPrompt("checkbox",wBn),this.registerPrompt("password",SBn),this.registerPrompt("editor",zBn)},t.restoreDefaultPrompts(),t}var _3u=BHf();function r1w(e,t){_3u.registerPrompt(e,t)}function i1w(){_3u.restoreDefaultPrompts()}var n1w={prompt:_3u,ui:{BottomBar:IBn,Prompt:t$i},createPromptModule:BHf,registerPrompt:r1w,restoreDefaultPrompts:i1w,Separator:eZ},K3a=n1w;var GQf=Ji(xHf()),WDw="4.2.1",fIt;(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",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay"})(fIt||(fIt={}));function $Dw(e,t){if(!e)throw new Error(t)}function HDw(e){return e?.replace(/\/+$/,"")}async function QDw(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function JDw(){return new Date().getTime()}function LQf(){return new Date().toISOString()}function KQf(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var GBn=String.fromCharCode,UQf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f2a={};function GDw(e,t){if(!f2a[e]){f2a[e]={};for(let r=0;r<e.length;r++)f2a[e][e.charAt(r)]=r}return f2a[e][t]}var KBn={compressToBase64:function(e){if(e==null)return"";let t=KBn._compress(e,6,function(r){return UQf.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:KBn._decompress(e.length,32,function(t){return GDw(UQf,e.charAt(t))})},compress:function(e){return KBn._compress(e,16,function(t){return GBn(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,f="",s="",o="",c=2,b=3,g=2,O=0,m=0,S;for(S=0;S<e.length;S+=1)if(f=e.charAt(S),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=b++,n[f]=!0),s=o+f,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(f)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:KBn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,f=3,s="",o,c,b,g,O,m,S;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;S=GBn(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;S=GBn(b);break;case 2:return""}for(i[3]=S,c=S,n.push(S);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,f),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(S=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=GBn(b),S=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=GBn(b),S=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,f),f++),i[S])s=i[S];else if(S===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,f),f++)}}},i2u=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};var d2a="0123456789abcdef",p2a=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=d2a.charAt(this.bytes[r]>>>4),t+=d2a.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=d2a.charAt(this.bytes[r]>>>4),t+=d2a.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},n2u=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??KDw()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return p2a.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,p2a.ofInner(t)}},KDw=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),VQf,WQf=()=>YDw().toString(),YDw=()=>(VQf||(VQf=new n2u)).generate(),_2a=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},YBn=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function $Qf(e){return typeof e=="object"&&(e instanceof _2a||e instanceof YBn)}var a2u=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new i2u,this._isInitialized=!1,$Dw(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=HDw(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:$Qf},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(fIt.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(fIt.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(fIt.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=WQf();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(f=>f.json()).catch(f=>{this._events.emit("error",f)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0&&(f=!1),f}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let f=l[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),f=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:f,payloads:o}}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:LQf(),uuid:i?.uuid?i.uuid:WQf()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(fIt.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(fIt.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=KQf(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(fIt.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(fIt.Queue)||[];this.setPersistedProperty(fIt.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:LQf()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${JDw()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,f=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(KBn.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,f)}catch(s){throw s instanceof YBn||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let f=new AbortController;return setTimeout(()=>f.abort(),l),f.signal}),await QDw(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(f){throw new YBn(f)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new _2a(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(fIt.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!$Qf(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},o2u=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},u2u=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!u2u){let e=FQf();u2u=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var YQf=u2u,XDw=1152921504606847e3,ZDw=["is_not"],h2a=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},x6=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},s2u=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||YQf,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let f of this.featureFlags)if(t===f.key){l=f;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(f){f instanceof x6?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async f=>{try{let s=this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let o=await this.computeFeatureFlagPayloadLocally(f.key,s);o&&(u[f.key]=o)}catch(s){s instanceof x6||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new x6("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let f=this.groupTypeMapping[String(l)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new x6("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return this.matchFeatureFlagProperties(t,i[f],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,f=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of f)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof x6)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new x6("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let f=l.type,s=!1;if(f==="cohort"?s=ZQf(l,n,this.cohorts,this.debugMode):s=XQf(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&HQf(t.key,r)>a/100)}getMatchingVariant(t,r){let i=HQf(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new h2a("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),this.featureFlags=r.flags||[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||[],this.loadedSuccessfullyOnce=!0}catch(t){t instanceof h2a&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=KQf(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function HQf(e,t,r=""){let i=(0,GQf.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/XDw}function XQf(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new x6("Operator is_not_set is not supported")}else throw new x6(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!ZDw.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function f(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return QQf(String(n))&&String(u).match(String(n))!==null;case"not_regex":return QQf(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?f(u,String(n),a):f(u,s,a):f(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=kDw(String(n));if(s==null&&(s=JQf(n)),s==null)throw new x6(`Invalid date: ${n}`);let o=JQf(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new x6(`Unknown operator: ${a}`)}}function ZQf(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new x6("can't match cohort without a given cohort property value");let a=r[n];return kQf(a,t,r,i)}function kQf(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let f=kQf(l,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof x6)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new x6("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let f;l.type==="cohort"?f=ZQf(l,t,r,i):f=XQf(l,t);let s=l.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof x6)i&&console.debug(`Failed to compute property ${l} locally: ${f}`),u=!0;else throw f}if(u)throw new x6("can't match cohort without a given cohort property value");return n==="AND"}}function QQf(e){try{return new RegExp(e),!0}catch{return!1}}function JQf(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new x6(`${e} is in an invalid date format`)}else throw new x6(`The date provided ${e} must be a string, number, or date object`)}function kDw(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var eEw=30*1e3,tEw=50*1e3,s$i=class extends a2u{constructor(t,r={}){super(t,r),this._memoryStorage=new o2u,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new s2u({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:eEw,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||tEw}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):YQf(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return WDw}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:f}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:f})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,S]of Object.entries(b))g[`$feature/${m}`]=S;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:f,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,f,s);f=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,f,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:f,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),f==null&&(f=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,u,l);u=f.allPersonProperties,l=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},c2u=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};c2u.POSTHOG_ID_TAG="posthog_distinct_id";var y2a=class{posthog;constructor({posthogApiKey:t}){this.posthog=new s$i(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.47.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var XBn=class{async sendEvent(){}async identify(){}async flush(){}};var c$i=require("fs/promises"),iJf=require("os"),nJf=require("path");var eJf=Ji(require("crypto")),b2a=new Uint8Array(256),v2a=b2a.length;function l2u(){return v2a>b2a.length-16&&(eJf.default.randomFillSync(b2a),v2a=0),b2a.slice(v2a,v2a+=16)}var W8=[];for(let e=0;e<256;++e)W8.push((e+256).toString(16).slice(1));function tJf(e,t=0){return W8[e[t+0]]+W8[e[t+1]]+W8[e[t+2]]+W8[e[t+3]]+"-"+W8[e[t+4]]+W8[e[t+5]]+"-"+W8[e[t+6]]+W8[e[t+7]]+"-"+W8[e[t+8]]+W8[e[t+9]]+"-"+W8[e[t+10]]+W8[e[t+11]]+W8[e[t+12]]+W8[e[t+13]]+W8[e[t+14]]+W8[e[t+15]]}var rJf=Ji(require("crypto")),f2u={randomUUID:rJf.default.randomUUID};function rEw(e,t,r){if(f2u.randomUUID&&!t&&!e)return f2u.randomUUID();e=e||{};let i=e.random||(e.rng||l2u)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return tJf(i)}var V9t=rEw;var iEw="id",nEw=".fern",ZBn=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new s$i(r),this.userId=t==null?void 0:DBu(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.47.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=ys(Zl.of((0,iJf.homedir)()),Lo.of(nEw),Lo.of(iEw));await If(t)||(await(0,c$i.mkdir)((0,nJf.dirname)(t),{recursive:!0}),await(0,c$i.writeFile)(t,V9t())),this.persistedDistinctId=(await(0,c$i.readFile)(t)).toString()}return this.persistedDistinctId}};var d2u;async function l$i(){return d2u==null&&(d2u=await aEw()),d2u}async function aEw(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new XBn;let r=await pxa();return r!=null?new ZBn({token:r,posthogApiKey:e}):await dxa()!=null?new y2a({posthogApiKey:e}):new ZBn({token:void 0,posthogApiKey:e})}catch{return new XBn}}function kBn(e,t){return function(){return e.apply(t,arguments)}}var{toString:oEw}=Object.prototype,{getPrototypeOf:h2u}=Object,O2a=(e=>t=>{let r=oEw.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),dIt=e=>(e=e.toLowerCase(),t=>O2a(t)===e),m2a=e=>t=>typeof t===e,{isArray:f$i}=Array,exn=m2a("undefined");function uEw(e){return e!==null&&!exn(e)&&e.constructor!==null&&!exn(e.constructor)&&FOe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var uJf=dIt("ArrayBuffer");function sEw(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uJf(e.buffer),t}var cEw=m2a("string"),FOe=m2a("function"),sJf=m2a("number"),P2a=e=>e!==null&&typeof e=="object",lEw=e=>e===!0||e===!1,g2a=e=>{if(O2a(e)!=="object")return!1;let t=h2u(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},fEw=dIt("Date"),dEw=dIt("File"),pEw=dIt("Blob"),_Ew=dIt("FileList"),hEw=e=>P2a(e)&&FOe(e.pipe),yEw=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||FOe(e.append)&&((t=O2a(e))==="formdata"||t==="object"&&FOe(e.toString)&&e.toString()==="[object FormData]"))},vEw=dIt("URLSearchParams"),[bEw,gEw,OEw,mEw]=["ReadableStream","Request","Response","Headers"].map(dIt),PEw=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function txn(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),f$i(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function cJf(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var Xci=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,lJf=e=>!exn(e)&&e!==Xci;function _2u(){let{caseless:e}=lJf(this)&&this||{},t={},r=(i,n)=>{let a=e&&cJf(t,n)||n;g2a(t[a])&&g2a(i)?t[a]=_2u(t[a],i):g2a(i)?t[a]=_2u({},i):f$i(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&txn(arguments[i],r);return t}var jEw=(e,t,r,{allOwnKeys:i}={})=>(txn(t,(n,a)=>{r&&FOe(n)?e[a]=kBn(n,r):e[a]=n},{allOwnKeys:i}),e),wEw=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),SEw=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},DEw=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&h2u(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},EEw=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},MEw=e=>{if(!e)return null;if(f$i(e))return e;let t=e.length;if(!sJf(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},AEw=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&h2u(Uint8Array)),qEw=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},TEw=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},CEw=dIt("HTMLFormElement"),BEw=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),aJf=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),xEw=dIt("RegExp"),fJf=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};txn(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},zEw=e=>{fJf(e,(t,r)=>{if(FOe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(FOe(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},IEw=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return f$i(e)?i(e):i(String(e).split(t)),r},REw=()=>{},NEw=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,p2u="abcdefghijklmnopqrstuvwxyz",oJf="0123456789",dJf={DIGIT:oJf,ALPHA:p2u,ALPHA_DIGIT:p2u+p2u.toUpperCase()+oJf},FEw=(e=16,t=dJf.ALPHA_DIGIT)=>{let r="",{length:i}=t;for(;e--;)r+=t[Math.random()*i|0];return r};function LEw(e){return!!(e&&FOe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var UEw=e=>{let t=new Array(10),r=(i,n)=>{if(P2a(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=f$i(i)?[]:{};return txn(i,(u,l)=>{let f=r(u,n+1);!exn(f)&&(a[l]=f)}),t[n]=void 0,a}}return i};return r(e,0)},VEw=dIt("AsyncFunction"),WEw=e=>e&&(P2a(e)||FOe(e))&&FOe(e.then)&&FOe(e.catch),pJf=((e,t)=>e?setImmediate:t?((r,i)=>(Xci.addEventListener("message",({source:n,data:a})=>{n===Xci&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Xci.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",FOe(Xci.postMessage)),$Ew=typeof queueMicrotask<"u"?queueMicrotask.bind(Xci):typeof process<"u"&&process.nextTick||pJf,Zu={isArray:f$i,isArrayBuffer:uJf,isBuffer:uEw,isFormData:yEw,isArrayBufferView:sEw,isString:cEw,isNumber:sJf,isBoolean:lEw,isObject:P2a,isPlainObject:g2a,isReadableStream:bEw,isRequest:gEw,isResponse:OEw,isHeaders:mEw,isUndefined:exn,isDate:fEw,isFile:dEw,isBlob:pEw,isRegExp:xEw,isFunction:FOe,isStream:hEw,isURLSearchParams:vEw,isTypedArray:AEw,isFileList:_Ew,forEach:txn,merge:_2u,extend:jEw,trim:PEw,stripBOM:wEw,inherits:SEw,toFlatObject:DEw,kindOf:O2a,kindOfTest:dIt,endsWith:EEw,toArray:MEw,forEachEntry:qEw,matchAll:TEw,isHTMLForm:CEw,hasOwnProperty:aJf,hasOwnProp:aJf,reduceDescriptors:fJf,freezeMethods:zEw,toObjectSet:IEw,toCamelCase:BEw,noop:REw,toFiniteNumber:NEw,findKey:cJf,global:Xci,isContextDefined:lJf,ALPHABET:dJf,generateString:FEw,isSpecCompliantForm:LEw,toJSONObject:UEw,isAsyncFn:VEw,isThenable:WEw,setImmediate:pJf,asap:$Ew};function d$i(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}Zu.inherits(d$i,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:Zu.toJSONObject(this.config),code:this.code,status:this.status}}});var _Jf=d$i.prototype,hJf={};["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=>{hJf[e]={value:e}});Object.defineProperties(d$i,hJf);Object.defineProperty(_Jf,"isAxiosError",{value:!0});d$i.from=(e,t,r,i,n,a)=>{let u=Object.create(_Jf);return Zu.toFlatObject(e,u,function(f){return f!==Error.prototype},l=>l!=="isAxiosError"),d$i.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Xd=d$i;var yJf=Ji(KNr(),1),j2a=yJf.default;function y2u(e){return Zu.isPlainObject(e)||Zu.isArray(e)}function bJf(e){return Zu.endsWith(e,"[]")?e.slice(0,-2):e}function vJf(e,t,r){return e?e.concat(t).map(function(n,a){return n=bJf(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function HEw(e){return Zu.isArray(e)&&!e.some(y2u)}var QEw=Zu.toFlatObject(Zu,{},null,function(t){return/^is[A-Z]/.test(t)});function JEw(e,t,r){if(!Zu.isObject(e))throw new TypeError("target must be an object");t=t||new(j2a||FormData),r=Zu.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,S){return!Zu.isUndefined(S[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zu.isSpecCompliantForm(t);if(!Zu.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(Zu.isDate(O))return O.toISOString();if(!f&&Zu.isBlob(O))throw new Xd("Blob is not supported. Use a Buffer instead.");return Zu.isArrayBuffer(O)||Zu.isTypedArray(O)?f&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,S){let E=O;if(O&&!S&&typeof O=="object"){if(Zu.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(Zu.isArray(O)&&HEw(O)||(Zu.isFileList(O)||Zu.endsWith(m,"[]"))&&(E=Zu.toArray(O)))return m=bJf(m),E.forEach(function(M,q){!(Zu.isUndefined(M)||M===null)&&t.append(u===!0?vJf([m],q,a):u===null?m:m+"[]",s(M))}),!1}return y2u(O)?!0:(t.append(vJf(S,m,a),s(O)),!1)}let c=[],b=Object.assign(QEw,{defaultVisitor:o,convertValue:s,isVisitable:y2u});function g(O,m){if(!Zu.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),Zu.forEach(O,function(E,A){(!(Zu.isUndefined(E)||E===null)&&n.call(t,E,Zu.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!Zu.isObject(e))throw new TypeError("data must be an object");return g(e),t}var c9r=JEw;function gJf(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function OJf(e,t){this._pairs=[],e&&c9r(e,this,t)}var mJf=OJf.prototype;mJf.append=function(t,r){this._pairs.push([t,r])};mJf.toString=function(t){let r=t?function(i){return t.call(this,i,gJf)}:gJf;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var PJf=OJf;function GEw(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Zci(e,t,r){if(!t)return e;let i=r&&r.encode||GEw,n=r&&r.serialize,a;if(n?a=n(t,r):a=Zu.isURLSearchParams(t)?t.toString():new PJf(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var v2u=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zu.forEach(this.handlers,function(i){i!==null&&t(i)})}},b2u=v2u;var p$i={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var jJf=Ji(require("url"),1),wJf=jJf.default.URLSearchParams;var SJf={isNode:!0,classes:{URLSearchParams:wJf,FormData:j2a,Blob:typeof Blob<"u"&&Blob||null},protocols:["http","https","file","data"]};var m2u={};$n(m2u,{hasBrowserEnv:()=>O2u,hasStandardBrowserEnv:()=>KEw,hasStandardBrowserWebWorkerEnv:()=>YEw,navigator:()=>g2u,origin:()=>XEw});var O2u=typeof window<"u"&&typeof document<"u",g2u=typeof navigator=="object"&&navigator||void 0,KEw=O2u&&(!g2u||["ReactNative","NativeScript","NS"].indexOf(g2u.product)<0),YEw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",XEw=O2u&&window.location.href||"http://localhost";var CA={...m2u,...SJf};function P2u(e,t){return c9r(e,new CA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return CA.isNode&&Zu.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function ZEw(e){return Zu.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function kEw(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function eMw(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),f=a>=r.length;return u=!u&&Zu.isArray(n)?n.length:u,f?(Zu.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!Zu.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&Zu.isArray(n[u])&&(n[u]=kEw(n[u])),!l)}if(Zu.isFormData(e)&&Zu.isFunction(e.entries)){let r={};return Zu.forEachEntry(e,(i,n)=>{t(ZEw(i),n,r,0)}),r}return null}var w2a=eMw;function tMw(e,t,r){if(Zu.isString(e))try{return(t||JSON.parse)(e),Zu.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var j2u={transitional:p$i,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=Zu.isObject(t);if(a&&Zu.isHTMLForm(t)&&(t=new FormData(t)),Zu.isFormData(t))return n?JSON.stringify(w2a(t)):t;if(Zu.isArrayBuffer(t)||Zu.isBuffer(t)||Zu.isStream(t)||Zu.isFile(t)||Zu.isBlob(t)||Zu.isReadableStream(t))return t;if(Zu.isArrayBufferView(t))return t.buffer;if(Zu.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return P2u(t,this.formSerializer).toString();if((l=Zu.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return c9r(l?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),tMw(t)):t}],transformResponse:[function(t){let r=this.transitional||j2u.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(Zu.isResponse(t)||Zu.isReadableStream(t))return t;if(t&&Zu.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Xd.from(l,Xd.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:CA.classes.FormData,Blob:CA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zu.forEach(["delete","get","head","post","put","patch"],e=>{j2u.headers[e]={}});var _$i=j2u;var rMw=Zu.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"]),DJf=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1575
1575
|
`).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&rMw[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var EJf=Symbol("internals");function rxn(e){return e&&String(e).trim().toLowerCase()}function S2a(e){return e===!1||e==null?e:Zu.isArray(e)?e.map(S2a):String(e)}function iMw(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var nMw=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function w2u(e,t,r,i,n){if(Zu.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!Zu.isString(t)){if(Zu.isString(i))return t.indexOf(i)!==-1;if(Zu.isRegExp(i))return i.test(t)}}function aMw(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function oMw(e,t){let r=Zu.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var h$i=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,f,s){let o=rxn(f);if(!o)throw new Error("header name must be a non-empty string");let c=Zu.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||f]=S2a(l))}let u=(l,f)=>Zu.forEach(l,(s,o)=>a(s,o,f));if(Zu.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(Zu.isString(t)&&(t=t.trim())&&!nMw(t))u(DJf(t),r);else if(Zu.isHeaders(t))for(let[l,f]of t.entries())a(f,l,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=rxn(t),t){let i=Zu.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return iMw(n);if(Zu.isFunction(r))return r.call(this,n,i);if(Zu.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=rxn(t),t){let i=Zu.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||w2u(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=rxn(u),u){let l=Zu.findKey(i,u);l&&(!r||w2u(i,i[l],l,r))&&(delete i[l],n=!0)}}return Zu.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||w2u(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return Zu.forEach(this,(n,a)=>{let u=Zu.findKey(i,a);if(u){r[u]=S2a(n),delete r[a];return}let l=t?aMw(a):String(a).trim();l!==a&&delete r[a],r[l]=S2a(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Zu.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&Zu.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
1576
1576
|
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[EJf]=this[EJf]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=rxn(u);i[l]||(oMw(n,u),i[l]=!0)}return Zu.isArray(t)?t.forEach(a):a(t),this}};h$i.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Zu.reduceDescriptors(h$i.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});Zu.freezeMethods(h$i);var mB=h$i;function ixn(e,t){let r=this||_$i,i=t||r,n=mB.from(i.headers),a=i.data;return Zu.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function nxn(e){return!!(e&&e.__CANCEL__)}function MJf(e,t,r){Xd.call(this,e??"canceled",Xd.ERR_CANCELED,t,r),this.name="CanceledError"}Zu.inherits(MJf,Xd,{__CANCEL__:!0});var LOe=MJf;function W9t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new Xd("Request failed with status code "+r.status,[Xd.ERR_BAD_REQUEST,Xd.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function S2u(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function D2u(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function kci(e,t){return e&&!S2u(t)?D2u(e,t):t}var $Jf=Ji(y3u(),1),HJf=Ji(require("http"),1),QJf=Ji(require("https"),1),JJf=Ji(require("util"),1),GJf=Ji(T3u(),1),xTr=Ji(require("zlib"),1);var eli="1.7.7";function axn(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var uMw=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function E2u(e,t,r){let i=r&&r.Blob||CA.classes.Blob,n=axn(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=uMw.exec(e);if(!a)throw new Xd("Invalid URL",Xd.ERR_INVALID_URL);let u=a[1],l=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),l?"base64":"utf8");if(t){if(!i)throw new Xd("Blob is not supported",Xd.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new Xd("Unsupported protocol "+n,Xd.ERR_NOT_SUPPORT)}var tli=Ji(require("stream"),1);var AJf=Ji(require("stream"),1);var M2u=Symbol("internals"),A2u=class extends AJf.default.Transform{constructor(t){t=Zu.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!Zu.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[M2u]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[M2u];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[M2u],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,f=1e3/l,s=a/f,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),S=null,E=u,A,M=0;if(a){let q=Date.now();(!n.ts||(M=q-n.ts)>=l)&&(n.ts=q,A=s-n.bytes,n.bytes=A<0?-A:0,M=0),A=s-n.bytes}if(a){if(A<=0)return setTimeout(()=>{O(null,g)},l-M);A<E&&(E=A)}E&&m>E&&m-E>o&&(S=g.subarray(E),g=g.subarray(0,E)),c(g,S?()=>{process.nextTick(O,null,S)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},q2u=A2u;var KJf=require("events");var TJf=require("util"),CJf=require("stream");var{asyncIterator:qJf}=Symbol,sMw=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[qJf]?yield*e[qJf]():yield e},D2a=sMw;var cMw=Zu.ALPHABET.ALPHA_DIGIT+"-_",oxn=new TJf.TextEncoder,l9r=`\r
|
|
1577
1577
|
`,lMw=oxn.encode(l9r),fMw=2,T2u=class{constructor(t,r){let{escapeName:i}=this.constructor,n=Zu.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${l9r}`;n?r=oxn.encode(String(r).replace(/\r?\n|\r\n?/g,l9r)):a+=`Content-Type: ${r.type||"application/octet-stream"}${l9r}`,this.headers=oxn.encode(a+l9r),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+fMw,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Zu.isTypedArray(t)?yield t:yield*D2a(t),yield lMw}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},dMw=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+Zu.generateString(n,cMw)}=r||{};if(!Zu.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=oxn.encode("--"+a+l9r),l=oxn.encode("--"+a+"--"+l9r+l9r),f=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new T2u(c,b);return f+=g.size,g});f+=u.byteLength*s.length,f=Zu.toFiniteNumber(f);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(o["Content-Length"]=f),t&&t(o),CJf.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},BJf=dMw;var xJf=Ji(require("stream"),1),C2u=class extends xJf.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},zJf=C2u;var pMw=(e,t)=>Zu.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,IJf=pMw;function _Mw(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),o=i[a];u||(u=s),r[n]=f,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var RJf=_Mw;function hMw(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),c=o-r;c>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-c)))},()=>n&&u(n)]}var NJf=hMw;var BTr=(e,t,r=3)=>{let i=0,n=RJf(50,250);return NJf(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,f=u-i,s=n(f),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:f,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},y$i=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},v$i=e=>(...t)=>Zu.asap(()=>e(...t));var FJf={flush:xTr.default.constants.Z_SYNC_FLUSH,finishFlush:xTr.default.constants.Z_SYNC_FLUSH},yMw={flush:xTr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:xTr.default.constants.BROTLI_OPERATION_FLUSH},LJf=Zu.isFunction(xTr.default.createBrotliDecompress),{http:vMw,https:bMw}=GJf.default,gMw=/https:?/,UJf=CA.protocols.map(e=>e+":"),VJf=(e,[t,r])=>(e.on("end",r).on("error",r),t);function OMw(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function YJf(e,t,r){let i=t;if(!i&&i!==!1){let n=(0,$Jf.getProxyForUrl)(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){YJf(a,t,a.href)}}var mMw=typeof process<"u"&&Zu.kindOf(process)==="process",PMw=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},u=f=>{a(f),t(f)},l=f=>{a(f,!0),r(f)};e(u,l,f=>i=f).catch(l)}),jMw=({address:e,family:t})=>{if(!Zu.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},WJf=(e,t)=>jMw(Zu.isObject(e)?e:{address:e,family:t}),XJf=mMw&&function(t){return PMw(async function(i,n,a){let{data:u,lookup:l,family:f}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let Pe=IJf(l,Xe=>Zu.isArray(Xe)?Xe:[Xe]);l=(Xe,wt,we)=>{Pe(Xe,wt,(Ie,Ht,Me)=>{if(Ie)return we(Ie);let Vt=Zu.isArray(Ht)?Ht.map(ut=>WJf(ut)):[WJf(Ht,Me)];wt.all?we(Ie,Vt):we(Ie,Vt[0].address,Vt[0].family)})}}let m=new KJf.EventEmitter,S=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((Pe,Xe)=>{b=!0,Xe&&(g=!0,S())});function E(Pe){m.emit("abort",!Pe||Pe.type?new LOe(null,t,O):Pe)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(E),t.signal&&(t.signal.aborted?E():t.signal.addEventListener("abort",E)));let A=kci(t.baseURL,t.url),M=new URL(A,CA.hasBrowserEnv?CA.origin:void 0),q=M.protocol||UJf[0];if(q==="data:"){let Pe;if(c!=="GET")return W9t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Pe=E2u(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Xe){throw Xd.from(Xe,Xd.ERR_BAD_REQUEST,t)}return s==="text"?(Pe=Pe.toString(o),(!o||o==="utf8")&&(Pe=Zu.stripBOM(Pe))):s==="stream"&&(Pe=tli.default.Readable.from(Pe)),W9t(i,n,{data:Pe,status:200,statusText:"OK",headers:new mB,config:t})}if(UJf.indexOf(q)===-1)return n(new Xd("Unsupported protocol "+q,Xd.ERR_BAD_REQUEST,t));let B=mB.from(t.headers).normalize();B.set("User-Agent","axios/"+eli,!1);let{onUploadProgress:F,onDownloadProgress:Q}=t,R=t.maxRate,V,$;if(Zu.isSpecCompliantForm(u)){let Pe=B.getContentType(/boundary=([-_\w\d]{10,70})/i);u=BJf(u,Xe=>{B.set(Xe)},{tag:`axios-${eli}-boundary`,boundary:Pe&&Pe[1]||void 0})}else if(Zu.isFormData(u)&&Zu.isFunction(u.getHeaders)){if(B.set(u.getHeaders()),!B.hasContentLength())try{let Pe=await JJf.default.promisify(u.getLength).call(u);Number.isFinite(Pe)&&Pe>=0&&B.setContentLength(Pe)}catch{}}else if(Zu.isBlob(u))u.size&&B.setContentType(u.type||"application/octet-stream"),B.setContentLength(u.size||0),u=tli.default.Readable.from(D2a(u));else if(u&&!Zu.isStream(u)){if(!Buffer.isBuffer(u))if(Zu.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(Zu.isString(u))u=Buffer.from(u,"utf-8");else return n(new Xd("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Xd.ERR_BAD_REQUEST,t));if(B.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new Xd("Request body larger than maxBodyLength limit",Xd.ERR_BAD_REQUEST,t))}let re=Zu.toFiniteNumber(B.getContentLength());Zu.isArray(R)?(V=R[0],$=R[1]):V=$=R,u&&(F||V)&&(Zu.isStream(u)||(u=tli.default.Readable.from(u,{objectMode:!1})),u=tli.default.pipeline([u,new q2u({maxRate:Zu.toFiniteNumber(V)})],Zu.noop),F&&u.on("progress",VJf(u,y$i(re,BTr(v$i(F),!1,3)))));let G;if(t.auth){let Pe=t.auth.username||"",Xe=t.auth.password||"";G=Pe+":"+Xe}if(!G&&M.username){let Pe=M.username,Xe=M.password;G=Pe+":"+Xe}G&&B.delete("authorization");let ee;try{ee=Zci(M.pathname+M.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Pe){let Xe=new Error(Pe.message);return Xe.config=t,Xe.url=t.url,Xe.exists=!0,n(Xe)}B.set("Accept-Encoding","gzip, compress, deflate"+(LJf?", br":""),!1);let de={path:ee,method:c,headers:B.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:G,protocol:q,family:f,beforeRedirect:OMw,beforeRedirects:{}};!Zu.isUndefined(l)&&(de.lookup=l),t.socketPath?de.socketPath=t.socketPath:(de.hostname=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,de.port=M.port,YJf(de,t.proxy,q+"//"+M.hostname+(M.port?":"+M.port:"")+de.path));let ge,ve=gMw.test(de.protocol);if(de.agent=ve?t.httpsAgent:t.httpAgent,t.transport?ge=t.transport:t.maxRedirects===0?ge=ve?QJf.default:HJf.default:(t.maxRedirects&&(de.maxRedirects=t.maxRedirects),t.beforeRedirect&&(de.beforeRedirects.config=t.beforeRedirect),ge=ve?bMw:vMw),t.maxBodyLength>-1?de.maxBodyLength=t.maxBodyLength:de.maxBodyLength=1/0,t.insecureHTTPParser&&(de.insecureHTTPParser=t.insecureHTTPParser),O=ge.request(de,function(Xe){if(O.destroyed)return;let wt=[Xe],we=+Xe.headers["content-length"];if(Q||$){let ut=new q2u({maxRate:Zu.toFiniteNumber($)});Q&&ut.on("progress",VJf(ut,y$i(we,BTr(v$i(Q),!0,3)))),wt.push(ut)}let Ie=Xe,Ht=Xe.req||O;if(t.decompress!==!1&&Xe.headers["content-encoding"])switch((c==="HEAD"||Xe.statusCode===204)&&delete Xe.headers["content-encoding"],(Xe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":wt.push(xTr.default.createUnzip(FJf)),delete Xe.headers["content-encoding"];break;case"deflate":wt.push(new zJf),wt.push(xTr.default.createUnzip(FJf)),delete Xe.headers["content-encoding"];break;case"br":LJf&&(wt.push(xTr.default.createBrotliDecompress(yMw)),delete Xe.headers["content-encoding"])}Ie=wt.length>1?tli.default.pipeline(wt,Zu.noop):wt[0];let Me=tli.default.finished(Ie,()=>{Me(),S()}),Vt={status:Xe.statusCode,statusText:Xe.statusMessage,headers:new mB(Xe.headers),config:t,request:Ht};if(s==="stream")Vt.data=Ie,W9t(i,n,Vt);else{let ut=[],he=0;Ie.on("data",function(bt){ut.push(bt),he+=bt.length,t.maxContentLength>-1&&he>t.maxContentLength&&(g=!0,Ie.destroy(),n(new Xd("maxContentLength size of "+t.maxContentLength+" exceeded",Xd.ERR_BAD_RESPONSE,t,Ht)))}),Ie.on("aborted",function(){if(g)return;let bt=new Xd("maxContentLength size of "+t.maxContentLength+" exceeded",Xd.ERR_BAD_RESPONSE,t,Ht);Ie.destroy(bt),n(bt)}),Ie.on("error",function(bt){O.destroyed||n(Xd.from(bt,null,t,Ht))}),Ie.on("end",function(){try{let bt=ut.length===1?ut[0]:Buffer.concat(ut);s!=="arraybuffer"&&(bt=bt.toString(o),(!o||o==="utf8")&&(bt=Zu.stripBOM(bt))),Vt.data=bt}catch(bt){return n(Xd.from(bt,null,t,Vt.request,Vt))}W9t(i,n,Vt)})}m.once("abort",ut=>{Ie.destroyed||(Ie.emit("error",ut),Ie.destroy())})}),m.once("abort",Pe=>{n(Pe),O.destroy(Pe)}),O.on("error",function(Xe){n(Xd.from(Xe,null,t,O))}),O.on("socket",function(Xe){Xe.setKeepAlive(!0,1e3*60)}),t.timeout){let Pe=parseInt(t.timeout,10);if(Number.isNaN(Pe)){n(new Xd("error trying to parse `config.timeout` to int",Xd.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(Pe,function(){if(b)return;let wt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",we=t.transitional||p$i;t.timeoutErrorMessage&&(wt=t.timeoutErrorMessage),n(new Xd(wt,we.clarifyTimeoutError?Xd.ETIMEDOUT:Xd.ECONNABORTED,t,O)),E()})}if(Zu.isStream(u)){let Pe=!1,Xe=!1;u.on("end",()=>{Pe=!0}),u.once("error",wt=>{Xe=!0,O.destroy(wt)}),u.on("close",()=>{!Pe&&!Xe&&E(new LOe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var ZJf=CA.hasStandardBrowserEnv?function(){let t=CA.navigator&&/(msie|trident)/i.test(CA.navigator.userAgent),r=document.createElement("a"),i;function n(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 i=n(window.location.href),function(u){let l=Zu.isString(u)?n(u):u;return l.protocol===i.protocol&&l.host===i.host}}():function(){return function(){return!0}}();var kJf=CA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];Zu.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),Zu.isString(i)&&u.push("path="+i),Zu.isString(n)&&u.push("domain="+n),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 eGf=e=>e instanceof mB?{...e}:e;function pIt(e,t){t=t||{};let r={};function i(s,o,c){return Zu.isPlainObject(s)&&Zu.isPlainObject(o)?Zu.merge.call({caseless:c},s,o):Zu.isPlainObject(o)?Zu.merge({},o):Zu.isArray(o)?o.slice():o}function n(s,o,c){if(Zu.isUndefined(o)){if(!Zu.isUndefined(s))return i(void 0,s,c)}else return i(s,o,c)}function a(s,o){if(!Zu.isUndefined(o))return i(void 0,o)}function u(s,o){if(Zu.isUndefined(o)){if(!Zu.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let f={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:l,headers:(s,o)=>n(eGf(s),eGf(o),!0)};return Zu.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=f[o]||n,b=c(e[o],t[o],o);Zu.isUndefined(b)&&c!==l||(r[o]=b)}),r}var E2a=e=>{let t=pIt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=mB.from(u),t.url=Zci(kci(t.baseURL,t.url),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let f;if(Zu.isFormData(r)){if(CA.hasStandardBrowserEnv||CA.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((f=u.getContentType())!==!1){let[s,...o]=f?f.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(CA.hasStandardBrowserEnv&&(i&&Zu.isFunction(i)&&(i=i(t)),i||i!==!1&&ZJf(t.url))){let s=n&&a&&kJf.read(a);s&&u.set(n,s)}return t};var wMw=typeof XMLHttpRequest<"u",tGf=wMw&&function(e){return new Promise(function(r,i){let n=E2a(e),a=n.data,u=mB.from(n.headers).normalize(),{responseType:l,onUploadProgress:f,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let S=new XMLHttpRequest;S.open(n.method.toUpperCase(),n.url,!0),S.timeout=n.timeout;function E(){if(!S)return;let M=mB.from("getAllResponseHeaders"in S&&S.getAllResponseHeaders()),B={data:!l||l==="text"||l==="json"?S.responseText:S.response,status:S.status,statusText:S.statusText,headers:M,config:e,request:S};W9t(function(Q){r(Q),m()},function(Q){i(Q),m()},B),S=null}"onloadend"in S?S.onloadend=E:S.onreadystatechange=function(){!S||S.readyState!==4||S.status===0&&!(S.responseURL&&S.responseURL.indexOf("file:")===0)||setTimeout(E)},S.onabort=function(){S&&(i(new Xd("Request aborted",Xd.ECONNABORTED,e,S)),S=null)},S.onerror=function(){i(new Xd("Network Error",Xd.ERR_NETWORK,e,S)),S=null},S.ontimeout=function(){let q=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",B=n.transitional||p$i;n.timeoutErrorMessage&&(q=n.timeoutErrorMessage),i(new Xd(q,B.clarifyTimeoutError?Xd.ETIMEDOUT:Xd.ECONNABORTED,e,S)),S=null},a===void 0&&u.setContentType(null),"setRequestHeader"in S&&Zu.forEach(u.toJSON(),function(q,B){S.setRequestHeader(B,q)}),Zu.isUndefined(n.withCredentials)||(S.withCredentials=!!n.withCredentials),l&&l!=="json"&&(S.responseType=n.responseType),s&&([b,O]=BTr(s,!0),S.addEventListener("progress",b)),f&&S.upload&&([c,g]=BTr(f),S.upload.addEventListener("progress",c),S.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=M=>{S&&(i(!M||M.type?new LOe(null,e,S):M),S.abort(),S=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let A=axn(n.url);if(A&&CA.protocols.indexOf(A)===-1){i(new Xd("Unsupported protocol "+A+":",Xd.ERR_BAD_REQUEST,e));return}S.send(a||null)})};var SMw=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,l();let o=s instanceof Error?s:this.reason;i.abort(o instanceof Xd?o:new LOe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new Xd(`timeout ${t} of ms exceeded`,Xd.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=i;return f.unsubscribe=()=>Zu.asap(l),f}},rGf=SMw;var DMw=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},EMw=async function*(e,t){for await(let r of MMw(e))yield*DMw(r,t)},MMw=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},B2u=(e,t,r,i)=>{let n=EMw(e,t),a=0,u,l=f=>{u||(u=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:o}=await n.next();if(s){l(),f.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}f.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(f){return l(f),n.return()}},{highWaterMark:2})};var A2a=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",nGf=A2a&&typeof ReadableStream=="function",AMw=A2a&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),aGf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},qMw=nGf&&aGf(()=>{let e=!1,t=new Request(CA.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),iGf=64*1024,x2u=nGf&&aGf(()=>Zu.isReadableStream(new Response("").body)),M2a={stream:x2u&&(e=>e.body)};A2a&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!M2a[t]&&(M2a[t]=Zu.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new Xd(`Response type '${t}' is not supported`,Xd.ERR_NOT_SUPPORT,i)})})})(new Response);var TMw=async e=>{if(e==null)return 0;if(Zu.isBlob(e))return e.size;if(Zu.isSpecCompliantForm(e))return(await new Request(CA.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Zu.isArrayBufferView(e)||Zu.isArrayBuffer(e))return e.byteLength;if(Zu.isURLSearchParams(e)&&(e=e+""),Zu.isString(e))return(await AMw(e)).byteLength},CMw=async(e,t)=>{let r=Zu.toFiniteNumber(e.getContentLength());return r??TMw(t)},oGf=A2a&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:f,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=E2a(e);s=s?(s+"").toLowerCase():"text";let g=rGf([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),S;try{if(f&&qMw&&r!=="get"&&r!=="head"&&(S=await CMw(o,i))!==0){let B=new Request(t,{method:"POST",body:i,duplex:"half"}),F;if(Zu.isFormData(i)&&(F=B.headers.get("content-type"))&&o.setContentType(F),B.body){let[Q,R]=y$i(S,BTr(v$i(f)));i=B2u(B.body,iGf,Q,R)}}Zu.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let A=await fetch(O),M=x2u&&(s==="stream"||s==="response");if(x2u&&(l||M&&m)){let B={};["status","statusText","headers"].forEach(V=>{B[V]=A[V]});let F=Zu.toFiniteNumber(A.headers.get("content-length")),[Q,R]=l&&y$i(F,BTr(v$i(l),!0))||[];A=new Response(B2u(A.body,iGf,Q,()=>{R&&R(),m&&m()}),B)}s=s||"text";let q=await M2a[Zu.findKey(M2a,s)||"text"](A,e);return!M&&m&&m(),await new Promise((B,F)=>{W9t(B,F,{data:q,headers:mB.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new Xd("Network Error",Xd.ERR_NETWORK,e,O),{cause:E.cause||E}):Xd.from(E,E&&E.code,e,O)}});var z2u={http:XJf,xhr:tGf,fetch:oGf};Zu.forEach(z2u,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var uGf=e=>`- ${e}`,BMw=e=>Zu.isFunction(e)||e===null||e===!1,q2a={getAdapter:e=>{e=Zu.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!BMw(r)&&(i=z2u[(u=String(r)).toLowerCase()],i===void 0))throw new Xd(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,f])=>`adapter ${l} `+(f===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1716,7 +1716,7 @@ ${M}${A}${q}${Ned.default.cursorHide}`});var Ixn=Ji(vwa(),1);function uFu(e,t){i
|
|
|
1716
1716
|
Run ${ju.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1717
1717
|
Run ${ju.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),g$i(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function bFu({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!std(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,f)=>l.generatorName.localeCompare(f.generatorName)||l.currentVersion.localeCompare(f.currentVersion));for(let l of u)n+=`
|
|
1718
1718
|
${await d2w(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+ju.dim(l.currentVersion)+ju.reset(" \u2192 ")+ju.green(l.latestVersion);return n+=`
|
|
1719
|
-
`,i?g$i(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function d2w(e){let r=await new utd.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 p2w({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await ltd({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=RFr(o.name,c),g=await n8t({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await ltd({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,f,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][f]==null&&(u.versions[l][f]={});let c=RFr(s.name,o),b=await n8t({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][f][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function ltd({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await Fzt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let f of l.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,u)}})}))}function ftd(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let f=oZ(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function FNa({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await p2w({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[f,s]of Object.entries(l.versions))u.push(...ftd(s,f,t.logger));else u.push(...ftd(l.versions,void 0,t.logger))}return u}var $xn=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var K$i=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Y$i=e=>e!==null&&typeof e=="object";var Hxn=(...e)=>{for(let t of e)if((!Y$i(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return mFu({},...e)},gFu=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function LNa(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:mFu(e[r]??[],t[r]??[])}var OFu=(e={},t={})=>({beforeRequest:LNa(e,t,"beforeRequest"),beforeRetry:LNa(e,t,"beforeRetry"),afterResponse:LNa(e,t,"afterResponse"),beforeError:LNa(e,t,"beforeError")}),mFu=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Y$i(n)){for(let[a,u]of Object.entries(n))Y$i(u)&&a in t&&(u=mFu(t[a],u)),t={...t,[a]:u};Y$i(n.hooks)&&(i=OFu(i,n.hooks),t.hooks=i),Y$i(n.headers)&&(r=gFu(r,n.headers),t.headers=r)}return t};var dtd=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),ptd=typeof globalThis.AbortController=="function",_td=typeof globalThis.ReadableStream=="function",htd=typeof globalThis.FormData=="function",UNa=["get","post","put","patch","head","delete"],_2w=()=>{};_2w();var ytd={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},VNa=2147483647,WNa=Symbol("stop"),vtd={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},btd={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 Otd=e=>UNa.includes(e)?e.toUpperCase():e,h2w=["get","put","head","delete","options","trace"],y2w=[408,413,429,500,502,503,504],v2w=[413,429,503],gtd={limit:2,methods:h2w,statusCodes:y2w,afterStatusCodes:v2w,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},mtd=(e={})=>{if(typeof e=="number")return{...gtd,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{...gtd,...e}};async function PFu(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new K$i(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function jFu(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Ptd=(e,t)=>{let r={};for(let i in t)!(i in btd)&&!(i in vtd)&&!(i in e)&&(r[i]=t[i]);return r};var Qxn=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>VNa)throw new RangeError(`The \`timeout\` option cannot be greater than ${VNa}`);await Promise.resolve();let l=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let f=new $xn(l,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!_td)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,f]of Object.entries(ytd))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:gFu(this._input.headers,r.headers),hooks:OFu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Otd(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:mtd(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(ptd){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(dtd&&(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 n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(htd&&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 K$i)throw t;if(t instanceof $xn){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),VNa);if(this._retryCount<1)throw r;await jFu(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===WNa)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=Ptd(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):PFu(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},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:i},new Uint8Array);async function l(){let{done:f,value:s}=await u.read();if(f){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var wFu=e=>{let t=(r,i)=>Qxn.create(r,Hxn(e,i));for(let r of UNa)t[r]=(i,n)=>Qxn.create(i,Hxn(e,n,{method:r}));return t.create=r=>wFu(Hxn(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),wFu(Hxn(e,r))),t.stop=WNa,t},b2w=wFu(),jtd=b2w;var Qtd=Ji(Htd(),1);function AFu(e){let t=(0,Qtd.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Lrd=Ji(Frd(),1),Urd=Ji(vwa(),1),WFu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},$Fu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function HFu(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??AFu(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,Lrd.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,l&&(f.authorization=`${l.type} ${l.token}`);let s;try{s=await jtd(u,{headers:f,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new WFu(e):c}if(t.allVersions)return s;let o=new $Fu(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=Urd.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function Zxn(e,t){let{version:r}=await HFu(e.toLowerCase(),t);return r}async function Eli({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:Zxn(e.packageName,{version:t?"prerelease":"latest"})}var Vrd=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],t4a=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Zw.Info;constructor(t){this.ttyAwareLogger=new NNa(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.47.0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${ju.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new uEe}failWithoutThrowing(t,r){this.didSucceed=!1,xNa({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await l$i()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await ctd({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1719
|
+
`,i?g$i(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function d2w(e){let r=await new utd.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 p2w({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await ltd({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=RFr(o.name,c),g=await n8t({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await ltd({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,f,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][f]==null&&(u.versions[l][f]={});let c=RFr(s.name,o),b=await n8t({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][f][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function ltd({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await Fzt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let f of l.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,u)}})}))}function ftd(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let f=oZ(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function FNa({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await p2w({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[f,s]of Object.entries(l.versions))u.push(...ftd(s,f,t.logger));else u.push(...ftd(l.versions,void 0,t.logger))}return u}var $xn=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var K$i=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Y$i=e=>e!==null&&typeof e=="object";var Hxn=(...e)=>{for(let t of e)if((!Y$i(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return mFu({},...e)},gFu=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function LNa(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:mFu(e[r]??[],t[r]??[])}var OFu=(e={},t={})=>({beforeRequest:LNa(e,t,"beforeRequest"),beforeRetry:LNa(e,t,"beforeRetry"),afterResponse:LNa(e,t,"afterResponse"),beforeError:LNa(e,t,"beforeError")}),mFu=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(Y$i(n)){for(let[a,u]of Object.entries(n))Y$i(u)&&a in t&&(u=mFu(t[a],u)),t={...t,[a]:u};Y$i(n.hooks)&&(i=OFu(i,n.hooks),t.hooks=i),Y$i(n.headers)&&(r=gFu(r,n.headers),t.headers=r)}return t};var dtd=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),ptd=typeof globalThis.AbortController=="function",_td=typeof globalThis.ReadableStream=="function",htd=typeof globalThis.FormData=="function",UNa=["get","post","put","patch","head","delete"],_2w=()=>{};_2w();var ytd={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},VNa=2147483647,WNa=Symbol("stop"),vtd={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},btd={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 Otd=e=>UNa.includes(e)?e.toUpperCase():e,h2w=["get","put","head","delete","options","trace"],y2w=[408,413,429,500,502,503,504],v2w=[413,429,503],gtd={limit:2,methods:h2w,statusCodes:y2w,afterStatusCodes:v2w,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},mtd=(e={})=>{if(typeof e=="number")return{...gtd,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{...gtd,...e}};async function PFu(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new K$i(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function jFu(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Ptd=(e,t)=>{let r={};for(let i in t)!(i in btd)&&!(i in vtd)&&!(i in e)&&(r[i]=t[i]);return r};var Qxn=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>VNa)throw new RangeError(`The \`timeout\` option cannot be greater than ${VNa}`);await Promise.resolve();let l=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let f=new $xn(l,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!_td)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,f]of Object.entries(ytd))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:gFu(this._input.headers,r.headers),hooks:OFu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Otd(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:mtd(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(ptd){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(dtd&&(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 n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(htd&&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 K$i)throw t;if(t instanceof $xn){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),VNa);if(this._retryCount<1)throw r;await jFu(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===WNa)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=Ptd(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):PFu(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},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:i},new Uint8Array);async function l(){let{done:f,value:s}=await u.read();if(f){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var wFu=e=>{let t=(r,i)=>Qxn.create(r,Hxn(e,i));for(let r of UNa)t[r]=(i,n)=>Qxn.create(i,Hxn(e,n,{method:r}));return t.create=r=>wFu(Hxn(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),wFu(Hxn(e,r))),t.stop=WNa,t},b2w=wFu(),jtd=b2w;var Qtd=Ji(Htd(),1);function AFu(e){let t=(0,Qtd.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Lrd=Ji(Frd(),1),Urd=Ji(vwa(),1),WFu=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},$Fu=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function HFu(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??AFu(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,Lrd.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,l&&(f.authorization=`${l.type} ${l.token}`);let s;try{s=await jtd(u,{headers:f,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new WFu(e):c}if(t.allVersions)return s;let o=new $Fu(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=Urd.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function Zxn(e,t){let{version:r}=await HFu(e.toLowerCase(),t);return r}async function Eli({cliEnvironment:e,includePreReleases:t=!1}){return e.packageVersion==="0.0.0"?e.packageVersion:Zxn(e.packageName,{version:t?"prerelease":"latest"})}var Vrd=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],t4a=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Zw.Info;constructor(t){this.ttyAwareLogger=new NNa(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.47.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${ju.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new uEe}failWithoutThrowing(t,r){this.didSucceed=!1,xNa({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvaialable(),this.ttyAwareLogger.finish(),await(await l$i()).flush(),this.exitProgram()}async nudgeUpgradeIfAvaialable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await ctd({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1720
1720
|
`)||(r+=`
|
|
1721
1721
|
`),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=Ggu(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new Rxn(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new uEe}finally{i.finish()}return n}async instrumentPostHogEvent(t){(await l$i()).sendEvent(t)}logger=EAn(this.log.bind(this));constructTaskInitForWorkspace(t){let r=Wrd(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Wrd(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Vrd[this.numTasks++%Vrd.length],u=ju.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===jC.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(i=>X4r.indexOf(i.level)>=X4r.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===Zw.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 Eli({cliEnvironment:this.environment,includePreReleases:t}),i=oZ(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await FNa({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await rFu({message:t,default:r})}};function Wrd(e){return`[${e}]:`}var owd=require("fs/promises");function yAe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(ju.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(ju.dim(r)),i.join(`
|
|
1722
1722
|
`)}var E0d=require("fs/promises");var vIt=class e{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;type=e.Type;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var JOe=class extends vIt{definition;sources;constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var kxn=class{context;constructor(t){this.context=t}};var r4a=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let f=n!=null?ph.of(`${n}${izt}${u}`):ph.of(u);t[f]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${izt}${u}`:u,f=i.directories[u];r(f,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(izt))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[ph.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var Mli=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new r4a,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),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 Lqr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))jNw(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??jg((rEe(r)+"/"+Joi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===ph.of(T7))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=yOa(rEe(o5i.of(`/${t}`)),o5i.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=yOa(rEe(o5i.of(`/${t}`)),o5i.of(`/${r}`)),n}addType(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>Jxt(l,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=xx(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:xx(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:xx(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===gw?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function jNw(e){return e?.header!=null}var bIt={openapi:e=>({...e,type:"openapi",_visit:function(t){return bIt._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return bIt._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 iHi={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return iHi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var hN={basic:e=>({...e,type:"basic",_visit:function(t){return hN._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return hN._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return hN._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return hN._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return hN._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 A0={primitive:e=>({value:e,type:"primitive",_visit:function(t){return A0._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return A0._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return A0._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return A0._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return A0._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return A0._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return A0._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return A0._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 wp={int:e=>({value:e,type:"int",_visit:function(t){return wp._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return wp._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return wp._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return wp._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return wp._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return wp._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return wp._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return wp._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return wp._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return wp._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return wp._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 nHi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return nHi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return nHi._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 M9r={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return M9r._visit(this,t)}}),undisciminated:e=>({value:e,type:"undisciminated",_visit:function(t){return M9r._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 Q8={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case Q8.GenerallyAvailable:return t.generallyAvailable();case Q8.Beta:return t.beta();case Q8.Deprecated:return t.deprecated();default:return t._other()}}};var UTr={cursor:e=>({...e,type:"cursor",_visit:function(t){return UTr._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return UTr._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 VTr={language:e=>({...e,type:"language",_visit:function(t){return VTr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return VTr._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 J8={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 J8.Curl:return t.curl();case J8.Python:return t.python();case J8.Javascript:return t.javascript();case J8.Typescript:return t.typescript();case J8.Go:return t.go();case J8.Ruby:return t.ruby();case J8.Csharp:return t.csharp();case J8.Java:return t.java();case J8.Js:return t.js();case J8.Node:return t.node();case J8.Ts:return t.ts();case J8.Nodets:return t.nodets();case J8.Golang:return t.golang();case J8.Dotnet:return t.dotnet();case J8.Jvm:return t.jvm();default:return t._other()}}};var gIt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return gIt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return gIt._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 OIt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return OIt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return OIt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var wU={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case wU.Get:return t.get();case wU.Post:return t.post();case wU.Put:return t.put();case wU.Patch:return t.patch();case wU.Delete:return t.delete();case wU.Head:return t.head();case wU.Options:return t.options();case wU.Trace:return t.trace();default:return t._other()}}};var A9r={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return A9r._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return A9r._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return A9r._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 vAe={file:e=>({...e,type:"file",_visit:function(t){return vAe._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return vAe._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 uZ={file:e=>({...e,type:"file",_visit:function(t){return uZ._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return uZ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return uZ._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return uZ._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return uZ._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return uZ._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 jh={primitive:e=>({...e,type:"primitive",_visit:function(t){return jh._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return jh._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return jh._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return jh._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return jh._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return jh._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return jh._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return jh._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return jh._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return jh._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return jh._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 Vm={int:e=>({...e,type:"int",_visit:function(t){return Vm._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Vm._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Vm._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Vm._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Vm._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Vm._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Vm._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Vm._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Vm._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Vm._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Vm._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 CT={boolean:e=>({value:e,type:"boolean",_visit:function(t){return CT._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return CT._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 WTr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return WTr._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return WTr._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 GOe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return GOe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return GOe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return GOe._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 BT={file:e=>({...e,type:"file",_visit:function(t){return BT._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return BT._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return BT._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return BT._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return BT._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return BT._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 Cl={primitive:e=>({...e,type:"primitive",_visit:function(t){return Cl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Cl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Cl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Cl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Cl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Cl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Cl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Cl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Cl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Cl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Cl._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 tQ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return tQ._visit(this,t)}}),undisciminated:e=>({...e,type:"undisciminated",_visit:function(t){return tQ._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 $d={int:e=>({...e,type:"int",_visit:function(t){return $d._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return $d._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return $d._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return $d._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return $d._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return $d._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return $d._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return $d._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return $d._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return $d._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return $d._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 uy={};$n(uy,{AllOfPropertyConflict:()=>DHi,ArraySchema:()=>_Fa,ArraySchemaWithExample:()=>VFa,Availability:()=>d4a,Base64WithExample:()=>RFa,BasicSecurityScheme:()=>h4a,BearerSecurityScheme:()=>y4a,BooleanSchema:()=>sFa,BooleanWithExample:()=>NFa,CasingOverrides:()=>g4a,CommonProperty:()=>PFa,CommonPropertyWithExample:()=>XFa,CursorPagination:()=>K4a,CustomCodeSample:()=>J4a,CustomCodeSampleLanguage:()=>$4a,CustomCodeSampleSdk:()=>Q4a,DateWithExample:()=>IFa,DatetimeWithExample:()=>zFa,DiscriminatedOneOfSchema:()=>OFa,DiscriminatedOneOfSchemaWithExample:()=>KFa,DoubleSchema:()=>oFa,DoubleWithExample:()=>BFa,Encoding:()=>f4a,Endpoint:()=>X4a,EndpointExample:()=>mHi,EndpointResponseExample:()=>W4a,EndpointSdkName:()=>X9t,EndpointWithExample:()=>gid,EnumSchema:()=>sHi,EnumSchemaWithExample:()=>LFa,EnumValue:()=>C9r,ErrorExample:()=>N4a,FernExample:()=>L4a,FileResponse:()=>yHi,FileSchema:()=>C4a,FloatWithExample:()=>CFa,FullEndpointExample:()=>G4a,FullExample:()=>BE,FullObjectExample:()=>E4a,FullOneOfExample:()=>A4a,GlobalHeader:()=>lFa,Header:()=>z9r,HeaderExample:()=>OHi,HeaderSecurityScheme:()=>v4a,HeaderWithExample:()=>N9r,HttpEndpointServer:()=>bHi,HttpError:()=>F4a,HttpErrorWithExample:()=>EFa,HttpMethod:()=>fHi,IdempotencyHeader:()=>fFa,Int64WithExample:()=>AFa,IntSchema:()=>nFa,IntWithExample:()=>MFa,JsonRequest:()=>z4a,JsonRequestWithExample:()=>wFa,JsonResponse:()=>vHi,JsonResponseWithExample:()=>AHi,KeyValuePair:()=>M4a,LiteralExample:()=>D4a,LiteralSchema:()=>SHi,LiteralSchemaValue:()=>dFa,LongSchema:()=>aFa,MapSchema:()=>hFa,MapSchemaWithExample:()=>WFa,MultipartRequest:()=>hHi,MultipartRequestProperty:()=>x4a,MultipartSchema:()=>B4a,NamedFullExample:()=>k9t,Namespace:()=>O4a,NamespaceId:()=>S4a,NullableSchema:()=>vFa,NullableSchemaWithExample:()=>HFa,OauthSecurityScheme:()=>P4a,ObjectProperty:()=>gFa,ObjectPropertyConflictInfo:()=>EHi,ObjectPropertyWithExample:()=>GFa,ObjectSchema:()=>pFa,ObjectSchemaWithExample:()=>QFa,OctetStreamRequest:()=>_Hi,OffsetPagination:()=>Y4a,OneOfSchema:()=>bFa,OneOfSchemaWithExample:()=>JFa,OpenApiIntermediateRepresentation:()=>vid,OpenApiSource:()=>u4a,OptionalSchema:()=>yFa,OptionalSchemaWithExample:()=>$Fa,Pagination:()=>PHi,PathParameter:()=>dHi,PathParameterExample:()=>U4a,PathParameterWithExample:()=>jFa,PrimitiveExample:()=>lHi,PrimitiveSchema:()=>R9r,PrimitiveSchemaValue:()=>cFa,PrimitiveSchemaValueWithExample:()=>FFa,PrimitiveSchemaWithExample:()=>qHi,PropertyKey:()=>cHi,ProtobufEncoding:()=>l4a,ProtobufSource:()=>s4a,QueryParameter:()=>pHi,QueryParameterExample:()=>gHi,QueryParameterWithExample:()=>MHi,QuerySecurityScheme:()=>b4a,ReferencedSchema:()=>Z9t,Request:()=>I4a,RequestWithExample:()=>SFa,Response:()=>R4a,ResponseWithExample:()=>DFa,Schema:()=>hg,SchemaId:()=>rQ,SchemaWithExample:()=>MD,Schemas:()=>iFa,SdkGroup:()=>m4a,SdkGroupInfo:()=>q4a,SdkGroupName:()=>B9r,SecurityScheme:()=>j4a,SecuritySchemeId:()=>_4a,Server:()=>w4a,Source:()=>c4a,StatusCode:()=>x9r,StreamingResponseExample:()=>V4a,StringSchema:()=>uFa,StringSchemaWithExample:()=>xFa,SupportedSdkLanguage:()=>H4a,Tag:()=>p4a,TagId:()=>iQ,Tags:()=>T4a,TextResponse:()=>I9r,Uint64WithExample:()=>TFa,UintWithExample:()=>qFa,UnDiscriminatedOneOfSchema:()=>mFa,UnDiscriminatedOneOfSchemaWithExample:()=>YFa,UnknownSchemaWithExample:()=>UFa,Webhook:()=>Z4a,WebhookExampleCall:()=>wHi,WebhookHttpMethod:()=>jHi,WebhookWithExample:()=>Oid,WebsocketChannel:()=>rFa,WebsocketHandshake:()=>k4a,WebsocketHandshakeWithExample:()=>bid,WebsocketMessageExample:()=>eFa,WebsocketSessionExample:()=>tFa,WithAvailability:()=>w_,WithDescription:()=>af,WithEncoding:()=>sZ,WithInline:()=>bS,WithName:()=>Jv,WithNamespace:()=>Y9t,WithSdkGroupName:()=>_g,WithSource:()=>hh,WithTitle:()=>pg,commons:()=>YFu,example:()=>XFu,finalIr:()=>ZFu,parseIr:()=>kFu});var YFu={};$n(YFu,{BasicSecurityScheme:()=>h4a,BearerSecurityScheme:()=>y4a,Encoding:()=>f4a,HeaderSecurityScheme:()=>v4a,Namespace:()=>O4a,NamespaceId:()=>S4a,OauthSecurityScheme:()=>P4a,OpenApiSource:()=>u4a,ProtobufEncoding:()=>l4a,ProtobufSource:()=>s4a,QuerySecurityScheme:()=>b4a,SchemaId:()=>rQ,SdkGroup:()=>m4a,SdkGroupName:()=>B9r,SecurityScheme:()=>j4a,SecuritySchemeId:()=>_4a,Server:()=>w4a,Source:()=>c4a,StatusCode:()=>x9r,Tag:()=>p4a,TagId:()=>iQ,WithAvailability:()=>w_,WithDescription:()=>af,WithEncoding:()=>sZ,WithInline:()=>bS,WithName:()=>Jv,WithNamespace:()=>Y9t,WithSdkGroupName:()=>_g,WithSource:()=>hh,WithTitle:()=>pg});var Et={};$n(Et,{JsonError:()=>aHi,ParseError:()=>oHi,any:()=>nid,bigint:()=>Hrd,boolean:()=>aid,booleanLiteral:()=>iid,date:()=>Qrd,discriminant:()=>_id,enum_:()=>n4a,getObjectLikeUtils:()=>mIt,getObjectUtils:()=>Ali,getSchemaUtils:()=>CE,isProperty:()=>T9r,lazy:()=>Jrd,lazyObject:()=>eid,list:()=>o4a,number:()=>oid,object:()=>a4a,objectWithoutOptionalProperties:()=>krd,optional:()=>QFu,property:()=>Krd,record:()=>lid,set:()=>fid,string:()=>uid,stringLiteral:()=>rid,transform:()=>JFu,undiscriminatedUnion:()=>pid,union:()=>yid,unknown:()=>sid,withParsedProperties:()=>KFu});var wm={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function ED(e,t){return`Expected ${t}. Received ${wNw(e)}.`}function wNw(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function yN(e){return{...e,json:$rd(e.json),parse:$rd(e.parse)}}function $rd(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
@@ -1730,7 +1730,7 @@ plugins:
|
|
|
1730
1730
|
- enum_type=string
|
|
1731
1731
|
- default_response=false
|
|
1732
1732
|
`,ZUa=class{context;constructor({context:t}){this.context=t}async generate({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r,local:i}){return i?this.generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}):this.generateRemote()}async generateLocal({absoluteFilepathToProtobufRoot:t,absoluteFilepathToProtobufTarget:r}){let i=await this.setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}),n=wA(t,r);return this.doGenerateLocal({cwd:i,target:n})}async setupProtobufGeneratorConfig({absoluteFilepathToProtobufRoot:t}){let r=Zl.of((await rOd.default.dir()).path);return await(0,kUa.cp)(t,r,{recursive:!0}),await(0,kUa.writeFile)(ys(r,Lo.of(Y_1)),Z_1),r}async doGenerateLocal({cwd:t,target:r}){let i=XUa("which",{cwd:t,logger:this.context.logger});try{await i(["buf"])}catch{this.context.failAndThrow("Missing required dependency; please install 'buf' to continue (e.g. 'brew install buf').")}try{await i(["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 n=XUa("buf",{cwd:t,logger:this.context.logger});return await n(["config","init"]),await n(["generate",r]),ys(t,Lo.of(X_1))}async generateRemote(){this.context.failAndThrow("Remote Protobuf generation is unimplemented.")}};async function zIt({context:e,specs:t,relativePathToDependency:r}){let i=new ZUa({context:e}),n=t.filter(l=>l.type==="openapi").map(l=>({...l,relativePathToDependency:r})),a=t.filter(l=>l.type==="protobuf"),u=await Promise.all(a.map(async l=>k_1({generator:i,protobufSpec:l,relativePathToDependency:r})));return[...n,...u]}async function k_1({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 tjd=require("fs"),zJi=require("fs/promises");var rjd=require("os"),ijd=Ji(require("path"),1),njd=require("stream/promises"),ajd=Ji(oWa(),1),ojd=Ji(CY(),1);var lJu=Ji(Hsi(),1);var LO;(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"})(LO||(LO={}));var Av1=oTr();async function ujd({dependencyName:e,dependenciesConfiguration:t,context:r,rootApiFile:i,cliVersion:n,settings:a,loadAPIWorkspace:u}){let l,f={type:LO.FAILED_TO_LOAD_DEPENDENCY,dependencyName:e},s=t.dependencies[e];return s==null?f={type:LO.DEPENDENCY_NOT_LISTED,dependencyName:e}:await r.runInteractiveTask({name:`Download ${Iv1(s)}`},async o=>{switch(s.type){case"version":l=await xv1({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;case"local":l=await Bv1({context:o,dependency:s,cliVersion:n,settings:a,loadAPIWorkspace:u});return;default:Ho(s)}}),l!=null?{didSucceed:!0,definition:l}:{didSucceed:!1,failure:f}}var sjd="dependencies";var qv1="metadata.json",Tv1=".fern";function Cv1(e){return ys(Zl.of((0,rjd.homedir)()),Lo.of(Tv1),Lo.of(sjd),Lo.of(e.organization),Lo.of(e.apiName),Lo.of(e.version))}async function Bv1({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){if(n==null){t.failWithoutThrowing("Failed to load api definition");return}t.logger.info("Parsing...");let a=await n({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:Lo.of(e.path)},i);return t.logger.info("Loaded..."),u}async function xv1({dependency:e,context:t,cliVersion:r,settings:i,loadAPIWorkspace:n}){let a=Cv1(e),u=ys(a,Lo.of(sjd)),l=ys(a,Lo.of(qv1)),f;if(!await If(u)||!await If(l)){t.logger.info("Downloading manifest...");let c=await Av1.definitionRegistry.get(lJu.FernFiddle.OrganizationId(e.organization),lJu.FernFiddle.ApiId(e.apiName),e.version);if(!c.ok){c.error._visit({orgDoesNotExistError:()=>{t.failWithoutThrowing("Organization does not exist")},apiDoesNotExistError:()=>{t.failWithoutThrowing("API does not exist")},versionDoesNotExistError:()=>{t.failWithoutThrowing("Version does not exist")},_other:m=>{t.failWithoutThrowing("Failed to download API manifest",m)}});return}let b=c.body.yamlSchemaVersion!=null?parseInt(c.body.yamlSchemaVersion):void 0,g=bli(r),O=bli(c.body.cliVersion);if(b!=null){if(b>1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a higher version of fern. Upgrade this workspace to ${c.body.cliVersion}`);return}else if(b<1){t.failWithoutThrowing(`${e.organization}/${e.apiName}@${e.version} on a lower version of fern. Upgrade it to ${r}`);return}}else if(g.major!==O.major||g.minor!==O.minor){t.failWithoutThrowing(`CLI version is ${c.body.cliVersion}. Expected ${g.major}.${g.minor}.x (to match current workspace).`);return}t.logger.info("Downloading..."),t.logger.debug("Remote URL: "+c.body.definitionS3DownloadUrl),await(0,zJi.mkdir)(u,{recursive:!0});try{await zv1({s3PreSignedReadUrl:c.body.definitionS3DownloadUrl,absolutePathToLocalOutput:u})}catch(m){t.failWithoutThrowing("Failed to download API",m);return}f=c.body,await(0,zJi.writeFile)(l,JSON.stringify(f))}else f=JSON.parse((await(0,zJi.readFile)(l)).toString());if(t.logger.info("Parsing..."),n==null){t.failWithoutThrowing("Failed to load API");return}let s=await n({absolutePathToWorkspace:u,context:t,cliVersion:f.cliVersion,workspaceName:void 0});if(!s.didSucceed){t.failWithoutThrowing("Failed to parse dependency after downloading",s.failures);return}if(s.workspace.type==="oss"){t.failWithoutThrowing("Dependency must be a fern workspace.");return}return await s.workspace.getDefinition({context:t},i)}async function zv1({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await Wx.get(e,{responseType:"stream"}),i=await ojd.default.dir(),n=ijd.default.join(i.path,"api.tgz");await(0,njd.pipeline)(r.data,(0,tjd.createWriteStream)(n)),await(0,ajd.extract)({file:n,cwd:t})}function Iv1(e){switch(e.type){case"version":return`@${e.organization}/${e.apiName}`;case"local":return`${e.path}`;default:Ho(e)}}var mjd=Ji(_jd(),1);function uWa(e,t){for(let[r,i]of Rz(e))Nv1({relativeFilepath:r,failure:i,logger:t})}function Nv1({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case LO.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 LO.FILE_READ:r.error("Failed to open file: "+e);break;case LO.FILE_MISSING:r.error("Missing file: "+e);break;case LO.FILE_PARSE:t.error instanceof BAn?r.error(yAe({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case LO.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of Fv1(i))r.error(yAe({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case LO.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case LO.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${jba}: `+t.dependencyName);break;case LO.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case LO.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case LO.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(yAe({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));for(let i of t.error.allErrors)i!==t.error.error&&r.debug(yAe({title:i.message??"Unknown error",breadcrumbs:[e,...i.instancePath.split("/").filter(n=>n!=="")]}));break;default:Ho(t)}}function Fv1(e){switch(e.code){case Dl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${ju.underline(e.expected)} but received ${ju.underline(e.received)}`}];case Dl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${ju.underline(t)}`}));case Dl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>ju.underline(t)).join(", ")}`}];case Dl.invalid_union:case Dl.invalid_arguments:case Dl.invalid_return_type:case Dl.invalid_date:case Dl.invalid_string:case Dl.too_small:case Dl.too_big:case Dl.invalid_intersection_types:case Dl.not_multiple_of:case Dl.custom:default:return[{title:e.message}]}}var hjd=require("fs/promises");async function yjd(e,t){let r=[];for(let i of await DH(e,t))r.push(await Lv1({relativeFilepath:wA(e,i),absoluteFilepath:i}));return r}async function Lv1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,hjd.readFile)(t)).toString()}}async function vjd(e){let t={},r={};function i(n){try{t[n.relativeFilepath]={defaultUrl:void 0,contents:Vd.load(n.fileContents,{schema:Vd.CORE_SCHEMA}),rawContents:n.fileContents}}catch(a){r[n.relativeFilepath]={type:LO.FILE_PARSE,error:a}}}return await Promise.all(e.map(i)),Object.keys(r).length>0?{didSucceed:!1,failures:r}:{didSucceed:!0,files:t}}async function bjd({dependenciesConfiguration:e,structuralValidationResult:t,context:r,cliVersion:i,settings:n,loadAPIWorkspace:a}){let u={},l={},f={};return await Promise.all(Rz(t.packageMarkers).map(async([s,o])=>{if(o.contents.export==null)u[s]=o;else{let{export:c,...b}=o.contents;if(bH(b)>0)f[s]={type:LO.EXPORTING_PACKAGE_MARKER_OTHER_KEYS,pathOfPackageMarker:s};else{let g=Zp(s);if($xt(t.namedDefinitionFiles).some(m=>m!==s&&m.startsWith(g)))f[s]={type:LO.EXPORT_PACKAGE_HAS_DEFINITIONS,pathToPackage:g};else{let m=await ujd({dependencyName:typeof o.contents.export=="string"?o.contents.export:o.contents.export.dependency,dependenciesConfiguration:e,context:r,rootApiFile:t.rootApiFile.contents,cliVersion:i,settings:n,loadAPIWorkspace:a});m.didSucceed?l[Zp(s)]={definition:m.definition,url:typeof o.contents.export=="object"?o.contents.export.url:void 0}:f[s]=m.failure}}}})),bH(f)>0?{didSucceed:!1,failures:f}:{didSucceed:!0,packageMarkers:u,importedDefinitions:l}}var gjd=Ji(require("path"),1);var pJu={};$n(pJu,{additionalProperties:()=>$v1,default:()=>Qv1,definitions:()=>Hv1,properties:()=>Vv1,required:()=>Wv1,type:()=>Uv1});var Uv1="object",Vv1={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"}]}},Wv1=["name"],$v1=!1,Hv1={"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"}]},"token-header":{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}},Qv1={type:Uv1,properties:Vv1,required:Wv1,additionalProperties:$v1,definitions:Hv1};var _Ju={};$n(_Ju,{additionalProperties:()=>Kv1,default:()=>Xv1,definitions:()=>Yv1,properties:()=>Gv1,type:()=>Jv1});var Jv1="object",Gv1={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"}]}},Kv1=!1,Yv1={"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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{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"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{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:{$ref:"#/definitions/types.TypeReferenceSchema"}},{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}},Xv1={type:Jv1,properties:Gv1,additionalProperties:Kv1,definitions:Yv1};var hJu={};$n(hJu,{additionalProperties:()=>eb1,default:()=>rb1,definitions:()=>tb1,properties:()=>kv1,type:()=>Zv1});var Zv1="object",kv1={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"}]}},eb1=!1,tb1={"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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},inline:{oneOf:[{type:"boolean"},{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"}]},"path-parameters":{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/service.HttpPathParameterSchema"}},{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"}]},transport:{oneOf:[{$ref:"#/definitions/service.ServiceTransport"},{type:"null"}]},source:{oneOf:[{$ref:"#/definitions/source.SourceSchema"},{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:{$ref:"#/definitions/types.TypeReferenceSchema"}},{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"}]}},rb1={type:Zv1,properties:kv1,additionalProperties:eb1,definitions:tb1};function Ojd({files:e,absolutePathToDefinition:t}){let r,i={},n={},a={};for(let[u,l]of Rz(e)){let f=l.contents,s=o=>{a[u]={type:LO.JSONSCHEMA_VALIDATION,error:o}};if(u===T7){let o=NMn(f,pJu);if(o.success){let c=cU.serialization.RootApiFileSchema.parseOrThrow(f);r={defaultUrl:c["default-url"],contents:c,rawContents:l.rawContents}}else s(o)}else if(gjd.default.basename(u)===gw){let o=NMn(f,hJu);if(o.success){let c=cU.serialization.PackageMarkerFileSchema.parseOrThrow(f);n[u]={defaultUrl:typeof c.export=="object"?c.export.url:void 0,contents:c,rawContents:l.rawContents}}else s(o)}else{let o=NMn(f,_Ju);if(o.success){let c=cU.serialization.DefinitionFileSchema.parseOrThrow(f);i[u]={defaultUrl:void 0,contents:c,rawContents:l.rawContents,absoluteFilePath:ys(t,u)}}else s(o)}}return r==null?{didSucceed:!1,failures:{[Lo.of(T7)]:{type:LO.FILE_MISSING},...a}}:Object.keys(a).length>0?{didSucceed:!1,failures:a}:{didSucceed:!0,namedDefinitionFiles:i,rootApiFile:r,packageMarkers:n}}var KLr=class extends vIt{context;fernWorkspaces={};loadAPIWorkspace;constructor({context:t,loadAPIWorkspace:r,...i}){super(i),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 i=(0,mjd.default)(r??{}),n=this.fernWorkspaces[i];if(n==null){let a=t||this.context,u=ys(this.absoluteFilePath,Lo.of(V2)),l=await pwu({absolutePathToWorkspace:this.absoluteFilePath,context:a}),f=await yjd(u,"{yml,yaml}"),s=await vjd(f);if(!s.didSucceed)return uWa(s.failures,a.logger),a.failAndThrow();let o=Ojd({files:s.files,absolutePathToDefinition:u});if(!o.didSucceed)return uWa(o.failures,a.logger),a.failAndThrow();let c=await bjd({dependenciesConfiguration:l,structuralValidationResult:o,context:a,cliVersion:this.cliVersion,settings:r,loadAPIWorkspace:this.loadAPIWorkspace});if(!c.didSucceed)return uWa(c.failures,a.logger),a.failAndThrow();n=new JOe({absoluteFilePath:this.absoluteFilePath,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:l,workspaceName:this.workspaceName,definition:{absoluteFilePath:u,rootApiFile:o.rootApiFile,namedDefinitionFiles:o.namedDefinitionFiles,packageMarkers:c.packageMarkers,importedDefinitions:c.importedDefinitions},cliVersion:this.cliVersion,sources:[]}),this.fernWorkspaces[i]=n}return n}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var nR=class extends szn{specs;sources;loader;constructor({specs:t,...r}){super({...r,respectReadonlySchemas:t.every(i=>i.settings?.respectReadonlySchemas),onlyIncludeReferencedSchemas:t.every(i=>i.settings?.onlyIncludeReferencedSchemas),inlinePathParameters:t.every(i=>i.settings?.inlinePathParameters),objectQueryParameters:t.every(i=>i.settings?.objectQueryParameters),exampleGeneration:t[0]?.settings?.exampleGeneration}),this.specs=t,this.sources=this.convertSpecsToIdentifiableSources(t),this.loader=new xIt(this.absoluteFilePath)}async getOpenAPIIr({context:t,relativePathToDependency:r},i){let n=await zIt({context:t,specs:this.specs,relativePathToDependency:r});return dfi({context:t,documents:await this.loader.loadDocuments({context:t,specs:n}),options:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.respectReadonlySchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.objectQueryParameters,exampleGeneration:i?.exampleGeneration??this.exampleGeneration}})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new JOe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:this.sources})}getAbsoluteFilePaths(){return[this.absoluteFilePath,...this.specs.flatMap(t=>[t.type==="protobuf"?t.absoluteFilepathToProtobufTarget:t.absoluteFilepath,t.absoluteFilepathToOverrides]).filter(O0)]}getSources(){return this.sources}convertSpecsToIdentifiableSources(t){let r=new Set,i=[];return t.reduce((n,a)=>{let u=a.type==="protobuf"?a.absoluteFilepathToProtobufRoot:a.absoluteFilepath;return r.has(u)||(r.add(u),n.push({type:a.type,id:V9t(),absoluteFilePath:u})),n},i)}};var Yjd=require("fs/promises");var AWa={};$n(AWa,{ConjureAliasDeclaration:()=>_Wa,ConjureArgument:()=>DWa,ConjureArgumentWithParamType:()=>SWa,ConjureDefinitions:()=>PWa,ConjureEndpoint:()=>EWa,ConjureEnumDeclaration:()=>OWa,ConjureEnumVariant:()=>gWa,ConjureEnumWithDocs:()=>bWa,ConjureObjectDeclaration:()=>vWa,ConjureParamType:()=>wWa,ConjurePrimitive:()=>pWa,ConjureService:()=>MWa,ConjureServiceName:()=>dWa,ConjureType:()=>ZLr,ConjureTypeDeclaration:()=>mWa,ConjureTypeReference:()=>kLr,ConjureTypeWithDocs:()=>hWa,ConjureTypes:()=>jWa,ConjureUnionDeclaration:()=>yWa,DefinitionFile:()=>Kjd,WithDocs:()=>MLt,commons:()=>OJu,conjure:()=>mJu,services:()=>PJu,types:()=>jJu});var OJu={};$n(OJu,{WithDocs:()=>MLt});var ep={};$n(ep,{JsonError:()=>NJi,ParseError:()=>FJi,any:()=>Ijd,bigint:()=>jjd,boolean:()=>Rjd,booleanLiteral:()=>zjd,date:()=>wjd,discriminant:()=>Qjd,enum_:()=>cWa,getObjectLikeUtils:()=>NIt,getObjectUtils:()=>Rfi,getSchemaUtils:()=>zE,isProperty:()=>XLr,lazy:()=>Sjd,lazyObject:()=>Cjd,list:()=>fWa,number:()=>Njd,object:()=>lWa,objectWithoutOptionalProperties:()=>Tjd,optional:()=>yJu,property:()=>Ejd,record:()=>Vjd,set:()=>Wjd,string:()=>Fjd,stringLiteral:()=>xjd,transform:()=>vJu,undiscriminatedUnion:()=>Hjd,union:()=>Gjd,unknown:()=>Ljd,withParsedProperties:()=>gJu});var Dm={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function qD(e,t){return`Expected ${t}. Received ${ib1(e)}.`}function ib1(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function SN(e){return{...e,json:Pjd(e.json),parse:Pjd(e.parse)}}function Pjd(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1733
|
-
`)),{ok:!0,value:t}):i}}function sWa(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var NJi=class e extends Error{errors;constructor(t){super(t.map(sWa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var FJi=class e extends Error{errors;constructor(t){super(t.map(sWa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function zE(e){return{optional:()=>yJu(e),transform:t=>vJu(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new FJi(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new NJi(i.errors)}}}function yJu(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>Dm.OPTIONAL};return{...t,...zE(t)}}function vJu(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...zE(r)}}function jjd(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:qD(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:qD(t,"bigint")}]},getType:()=>Dm.BIGINT};return{...SN(e),...zE(e)}}var nb1=/^([+-]?\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 wjd(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:qD(t,"string")}]}:nb1.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:qD(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:qD(t,"Date object")}]},getType:()=>Dm.DATE};return{...SN(e),...zE(e)}}function LU(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...SN(r),...zE(r)}}}function cWa(e){let t=new Set(e);return LU(Dm.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:qD(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:qD(i,"enum")}]}:{ok:!0,value:i})()}function Sjd(e){let t=bJu(e);return{...t,...zE(t)}}function bJu(e){return{parse:(t,r)=>LJi(e).parse(t,r),json:(t,r)=>LJi(e).json(t,r),getType:()=>LJi(e).getType()}}function LJi(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Q7n(e){return Object.entries(e)}function J7n(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function YLr(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 G7n(e){return Object.keys(e)}function Djd(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function NIt(e){return{withParsedProperties:t=>gJu(e,t)}}function gJu(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[f,s])=>({...l,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!YLr(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:qD(i,"object")}]};let a=new Set(Object.keys(t)),u=J7n(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...zE(r),...NIt(r)}}function Ejd(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function XLr(e){return e.isProperty}function lWa(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>XLr(i)?i.rawKey:r),_getParsedProperties:()=>G7n(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of Q7n(e)){let f=XLr(l)?l.rawKey:u,s=XLr(l)?l.valueSchema:l,o={rawKey:f,parsedKey:u,valueSchema:s};n[f]=o,qjd(s)&&a.push(f)}return Mjd({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:f=>l.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of Q7n(e)){let l=XLr(u)?u.valueSchema:u;qjd(l)&&n.push(a)}return Mjd({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return XLr(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>Dm.OBJECT};return{...SN(t),...zE(t),...NIt(t),...Rfi(t)}}function Mjd({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!YLr(e))return{ok:!1,errors:[{path:a,message:qD(e,"object")}]};let u=new Set(t),l=[],f={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?f[c.transformedKey]=b.value:(f[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:f}:{ok:!1,errors:l}}function Rfi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Ajd({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Ajd({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>Dm.OBJECT};return{...r,...zE(r),...NIt(r),...Rfi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>Dm.OBJECT};return{...t,...zE(t),...NIt(t),...Rfi(t)}}}}function Ajd({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=Djd(G7n(t),s=>n.has(s)),l=r(J7n(t,u)),f=i(J7n(t,a));return l.ok&&f.ok?{ok:!0,value:{...l.value,...f.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...f.ok?[]:f.errors]}}function qjd(e){return!ab1(e)}function ab1(e){switch(e.getType()){case Dm.ANY:case Dm.UNKNOWN:case Dm.OPTIONAL:return!0;default:return!1}}function Tjd(e){return lWa(e)}function Cjd(e){let t={...bJu(e),_getRawProperties:()=>LJi(e)._getRawProperties(),_getParsedProperties:()=>LJi(e)._getParsedProperties()};return{...t,...zE(t),...NIt(t),...Rfi(t)}}function fWa(e){let t={parse:(r,i)=>Bjd(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Bjd(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Dm.LIST};return{...SN(t),...zE(t)}}function Bjd(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:qD(e,"list"),path:[]}]}}function xjd(e){return LU(Dm.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:qD(r,`"${e}"`)}]})()}function zjd(e){return LU(Dm.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:qD(r,`${e.toString()}`)}]})()}var Ijd=LU(Dm.ANY,e=>({ok:!0,value:e}));var Rjd=LU(Dm.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qD(e,"boolean")}]});var Njd=LU(Dm.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qD(e,"number")}]});var Fjd=LU(Dm.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qD(e,"string")}]});var Ljd=LU(Dm.UNKNOWN,e=>({ok:!0,value:e}));function Vjd(e,t){let r={parse:(i,n)=>Ujd({value:i,isKeyNumeric:e.getType()===Dm.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Ujd({value:i,isKeyNumeric:e.getType()===Dm.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>Dm.RECORD};return{...SN(r),...zE(r)}}function Ujd({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return YLr(e)?Q7n(e).reduce((a,[u,l])=>{if(l==null)return a;let f=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(f.ok&&o.ok&&c.ok)return{ok:!0,value:{...f.value,[o.value]:c.value}};let b=[];return f.ok||b.push(...f.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:qD(e,"object")}]}}function Wjd(e){let t=fWa(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:qD(i,"Set")}]},getType:()=>Dm.SET};return{...SN(r),...zE(r)}}function Hjd(e){let t={parse:(r,i)=>$jd((n,a)=>n.parse(r,a),e,i),json:(r,i)=>$jd((n,a)=>n.json(r,a),e,i),getType:()=>Dm.UNDISCRIMINATED_UNION};return{...SN(t),...zE(t)}}function $jd(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function Qjd(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Gjd(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=cWa(G7n(t)),a={parse:(u,l)=>Jjd({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>Jjd({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>Dm.UNION};return{...SN(a),...zE(a),...NIt(a)}}function Jjd({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!YLr(e))return{ok:!1,errors:[{path:l,message:qD(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(f);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:f,...b.value}}:b}var MLt=ep.objectWithoutOptionalProperties({docs:ep.string().optional()});var mJu={};$n(mJu,{ConjureServiceName:()=>dWa,DefinitionFile:()=>Kjd});var dWa=ep.string();var pWa=ep.enum_(["rid","string","safelong","integer","double","boolean"]);var ZLr=ep.undiscriminatedUnion([pWa,ep.string()]);var _Wa=ep.objectWithoutOptionalProperties({alias:ZLr,docs:ep.string().optional()});var hWa=ep.objectWithoutOptionalProperties({type:ZLr,docs:ep.string().optional()});var kLr=ep.undiscriminatedUnion([ZLr,hWa]);var yWa=ep.objectWithoutOptionalProperties({union:ep.record(ep.string(),kLr)});var vWa=ep.objectWithoutOptionalProperties({fields:ep.record(ep.string(),kLr)});var bWa=ep.objectWithoutOptionalProperties({value:ep.string()}).extend(MLt);var gWa=ep.undiscriminatedUnion([ep.string(),bWa]);var OWa=ep.objectWithoutOptionalProperties({values:ep.list(gWa)});var mWa=ep.undiscriminatedUnion([_Wa,yWa,vWa,OWa]);var PWa=ep.objectWithoutOptionalProperties({objects:ep.record(ep.string(),mWa).optional()});var jWa=ep.objectWithoutOptionalProperties({conjureImports:ep.property("conjure-imports",ep.record(ep.string(),ep.string()).optional()),definitions:PWa.optional()});var wWa=ep.enum_(["path","query","body"]);var SWa=ep.objectWithoutOptionalProperties({paramType:ep.property("param-type",wWa),type:ep.string()}).extend(MLt);var DWa=ep.undiscriminatedUnion([ep.string(),SWa]);var EWa=ep.objectWithoutOptionalProperties({http:ep.string(),args:ep.record(ep.string(),DWa).optional(),returns:kLr.optional()}).extend(MLt);var MWa=ep.objectWithoutOptionalProperties({name:ep.string().optional(),package:ep.string().optional(),basePath:ep.property("base-path",ep.string().optional()),endpoints:ep.record(ep.string(),EWa).optional()}).extend(MLt);var Kjd=ep.objectWithoutOptionalProperties({types:jWa.optional(),services:ep.record(dWa,MWa).optional()});var PJu={};$n(PJu,{ConjureArgument:()=>DWa,ConjureArgumentWithParamType:()=>SWa,ConjureEndpoint:()=>EWa,ConjureParamType:()=>wWa,ConjureService:()=>MWa});var jJu={};$n(jJu,{ConjureAliasDeclaration:()=>_Wa,ConjureDefinitions:()=>PWa,ConjureEnumDeclaration:()=>OWa,ConjureEnumVariant:()=>gWa,ConjureEnumWithDocs:()=>bWa,ConjureObjectDeclaration:()=>vWa,ConjurePrimitive:()=>pWa,ConjureType:()=>ZLr,ConjureTypeDeclaration:()=>mWa,ConjureTypeReference:()=>kLr,ConjureTypeWithDocs:()=>hWa,ConjureTypes:()=>jWa,ConjureUnionDeclaration:()=>yWa});async function Xjd(e,t){let r=[];for(let i of await DH(e,t))r.push(await ob1({relativeFilepath:wA(e,i),absoluteFilepath:i}));return r}async function ob1({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,Yjd.readFile)(t)).toString().replaceAll(": rid",": string").replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:AWa.DefinitionFile.parseOrThrow(Vd.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function Zjd(e,t){if(ub1(e))return t.alias(e);if(sb1(e))return t.enum(e);if(cb1(e))return t.object(e);if(lb1(e))return t.union(e);Ho(e)}function ub1(e){return e?.alias!=null}function sb1(e){return e?.values!=null}function cb1(e){return e?.fields!=null}function lb1(e){return e?.union!=null}var K7n=class extends kxn{fernDefinitionBuilder=new Mli(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){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(i!=null){for(let[a,u]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await kjd(t,(a,u,l)=>{for(let[o,c]of Object.entries(l.services??{})){let b=Nva({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=Lo.of(`${b}/__package__.yml`);return}let s=Hju(u)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[u]=Lo.of(`${s}/__package__.yml`))}),await kjd(t,(a,u,l)=>{if(l.services==null||Object.keys(l.services??{}).length===0){let f=this.conjureFilepathToFernFilepath[u];if(f==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[s,o]of Object.entries(l.types?.conjureImports??{})){let c=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Lo.of(o)});this.fernDefinitionBuilder.addImport({file:f,fileToImport:Lo.of(c),alias:s})}this.importAllTypes({conjureFile:l,fernFilePath:f});return}for(let[f,s]of Object.entries(l.services)){let o=Nva({value:f,suffix:"Service"}),c=Lo.of(`${o}/__package__.yml`),b={};s.basePath!=null&&(b["base-path"]=s.basePath),s.docs!=null&&(b.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(c,b),this.importAllTypes({conjureFile:l,fernFilePath:c});for(let[g,O]of Object.entries(l.types?.conjureImports??{})){let m=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Lo.of(O)});this.fernDefinitionBuilder.addImport({file:c,fileToImport:Lo.of(m),alias:g})}for(let[g,O]of Object.entries(s.endpoints??{})){let m=tOu(O.http);if(m.type==="failure"){this.context?.logger.error(`Failed to parse ${O.http}. Skipping.`);continue}let S={auth:!0,path:m.path,method:m.method,response:O.returns==="binary"?"file":O.returns};O.docs!=null&&(S.docs=O.docs);let E={};if(O.args!=null)for(let A of m.pathParameters){let M=O.args[A];if(M==null)throw new Error(`Failed to find path parameter ${A} in ${O.http}`);E[A]=typeof M=="string"?M:{type:M.type}}Object.entries(E).length>0&&(S["path-parameters"]=E);for(let[A,M]of Object.entries(O.args??{}))if(E[A]==null)if(typeof M=="string")S.request?typeof S.request=="string"&&(S.request={body:S.request}):S.request={},S.request.body=M==="binary"?"bytes":M;else switch(M.paramType){case"body":S.request={body:M.type==="binary"?"bytes":M.type};break;case"query":S.request==null?S.request={"query-parameters":{[A]:M.type}}:typeof S.request!="string"&&S.request?.["query-parameters"]==null?S.request["query-parameters"]={[A]:M.type}:typeof S.request!="string"&&S.request?.["query-parameters"]!=null&&(S.request["query-parameters"][A]=M.type)}S.request!=null&&typeof S.request!="string"&&S.request?.["query-parameters"]!=null&&(S.request.name=`${g}Request`),this.fernDefinitionBuilder.addEndpoint(c,{name:g,schema:S,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))Zjd(n,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,l])=>[u,{type:typeof l=="string"?l:l.type,docs:typeof l=="string"?void 0:l.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=ys(Zp(t),Lo.of(r)),a=m4t(i,n),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function kjd(e,t){for(let r of await Xjd(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function ewd(e,t){return md(e,t)}var qWa=class extends vIt{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=ys(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new JOe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let n=await new K7n(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:Zl.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:Vd.dump(n.rootApiFile)},namedDefinitionFiles:{...ewd(n.definitionFiles,a=>({absoluteFilepath:Zl.of("/DUMMY_PATH"),rawContents:Vd.dump(a),contents:a})),[Lo.of(gw)]:{absoluteFilepath:Zl.of("/DUMMY_PATH"),rawContents:Vd.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function wJu(e,t){for(let[r,i]of Rz(e.failures))fb1({relativeFilepath:r,failure:i,logger:t})}function fb1({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case LO.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 LO.FILE_READ:r.error("Failed to open file: "+e);break;case LO.FILE_MISSING:r.error("Missing file: "+e);break;case LO.FILE_PARSE:t.error instanceof BAn?r.error(yAe({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case LO.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of db1(i))r.error(yAe({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case LO.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case LO.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${jba}: `+t.dependencyName);break;case LO.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case LO.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case LO.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(yAe({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));break;default:Ho(t)}}function db1(e){switch(e.code){case Dl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${ju.underline(e.expected)} but received ${ju.underline(e.received)}`}];case Dl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${ju.underline(t)}`}));case Dl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>ju.underline(t)).join(", ")}`}];case Dl.invalid_union:case Dl.invalid_arguments:case Dl.invalid_return_type:case Dl.invalid_date:case Dl.invalid_string:case Dl.too_small:case Dl.too_big:case Dl.invalid_intersection_types:case Dl.not_multiple_of:case Dl.custom:default:return[{title:e.message}]}}var twd=require("fs/promises");async function rwd(e,t){let r=[];for(let i of await DH(e,t))r.push(await pb1({relativeFilepath:wA(e,i),absoluteFilepath:i}));return r}async function pb1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,twd.readFile)(t)).toString()}}async function iwd({absolutePathToWorkspace:e}){let t=ys(e,Lo.of(uxl));if(!await If(t))return;let i=await rwd(t,"{md,mdx}");return{files:await Promise.all(i.map(n=>({absoluteFilepath:n.absoluteFilepath,contents:n.fileContents})))}}async function SJu({absolutePathToWorkspace:e,namespace:t,definitions:r}){let i=[];for(let n of r){let a=n.overrides!=null?ys(e,Lo.of(n.overrides)):void 0;if(n.schema.type==="protobuf"){let l=ys(e,Lo.of(n.schema.root));if(!await If(l))return{didSucceed:!1,failures:{[Lo.of(n.schema.root)]:{type:LO.FILE_MISSING}}};let f=ys(e,Lo.of(n.schema.target));if(!await If(f))return{didSucceed:!1,failures:{[Lo.of(n.schema.target)]:{type:LO.FILE_MISSING}}};i.push({type:"protobuf",absoluteFilepathToProtobufRoot:l,absoluteFilepathToProtobufTarget:f,absoluteFilepathToOverrides:a,generateLocally:n.schema.localGeneration,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:void 0}});continue}let u=ys(e,Lo.of(n.schema.path));if(!await If(u))return{didSucceed:!1,failures:{[Lo.of(n.schema.path)]:{type:LO.FILE_MISSING}}};if(n.overrides!=null&&a!=null&&!await If(a))return{didSucceed:!1,failures:{[Lo.of(n.overrides)]:{type:LO.FILE_MISSING}}};i.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:n.settings?.exampleGeneration},source:{type:"openapi",file:u},namespace:t})}return i}async function Y7n({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:i}){let n=await Fzt({absolutePathToWorkspace:e,context:t}),a;try{a=await iwd({absolutePathToWorkspace:e})}catch{}if(n?.api!=null&&n?.api.type==="conjure")return{didSucceed:!0,workspace:new qWa({workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Lo.of(n.api.pathToConjureDefinition)})};if(n?.api!=null&&(n.api.type==="singleNamespace"&&n.api.definitions.length>0||n.api.type==="multiNamespace")){let u=[];if(n.api.type==="singleNamespace"){let l=await SJu({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.definitions});if(!Array.isArray(l))return l;u.push(...l)}else{for(let[l,f]of Object.entries(n.api.definitions)){let s=await SJu({absolutePathToWorkspace:e,namespace:l,definitions:f});if(!Array.isArray(s))return s;u.push(...s)}if(n.api.rootDefinitions!=null){let l=await SJu({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.rootDefinitions});if(!Array.isArray(l))return l;u.push(...l)}}return{didSucceed:!0,workspace:new nR({specs:u,workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r})}}return await If(ys(e,Lo.of(V2)))?{didSucceed:!0,workspace:new KLr({absoluteFilePath:e,generatorsConfiguration:n,workspaceName:i,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:Y7n})}:{didSucceed:!1,failures:{[Lo.of(Moi)]:{type:LO.MISCONFIGURED_DIRECTORY}}}}var nwd=require("fs/promises");var awd=Ji(require("path"),1);async function DJu({fernDirectory:e,context:t}){let r=ys(e,Lo.of(Zxt));if(!await If(r))return;let i=await _b1({absolutePathToDocsDefinition:e,context:t});if(i!=null)return{type:"docs",absoluteFilePath:e,config:i,workspaceName:void 0,absoluteFilepathToDocsConfig:ys(e,Lo.of(Zxt))}}async function _b1({absolutePathToDocsDefinition:e,context:t}){if(!await If(e))return;let r=ys(e,Lo.of(Zxt));return await hb1({absolutePathOfConfiguration:r,context:t})}async function hb1({absolutePathOfConfiguration:e,context:t}){let r=await(0,nwd.readFile)(e),i=Vd.load(r.toString());return await yb1({value:i,context:t,filepathBeingParsed:e})}async function yb1({value:e,context:t,filepathBeingParsed:r}){let i=await tEe.RawSchemas.Serializer.DocsConfiguration.parse(e);if(i.ok)return i.value;let n=i.errors.map(u=>{let l=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return _H({content:l,prefix:" - "})}),a=[`Failed to parse file: ${awd.default.relative(process.cwd(),r)}`,...n].join(`
|
|
1733
|
+
`)),{ok:!0,value:t}):i}}function sWa(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var NJi=class e extends Error{errors;constructor(t){super(t.map(sWa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var FJi=class e extends Error{errors;constructor(t){super(t.map(sWa).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function zE(e){return{optional:()=>yJu(e),transform:t=>vJu(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new FJi(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new NJi(i.errors)}}}function yJu(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>Dm.OPTIONAL};return{...t,...zE(t)}}function vJu(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...zE(r)}}function jjd(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:qD(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:qD(t,"bigint")}]},getType:()=>Dm.BIGINT};return{...SN(e),...zE(e)}}var nb1=/^([+-]?\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 wjd(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:qD(t,"string")}]}:nb1.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:qD(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:qD(t,"Date object")}]},getType:()=>Dm.DATE};return{...SN(e),...zE(e)}}function LU(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...SN(r),...zE(r)}}}function cWa(e){let t=new Set(e);return LU(Dm.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:qD(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:qD(i,"enum")}]}:{ok:!0,value:i})()}function Sjd(e){let t=bJu(e);return{...t,...zE(t)}}function bJu(e){return{parse:(t,r)=>LJi(e).parse(t,r),json:(t,r)=>LJi(e).json(t,r),getType:()=>LJi(e).getType()}}function LJi(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Q7n(e){return Object.entries(e)}function J7n(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function YLr(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 G7n(e){return Object.keys(e)}function Djd(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function NIt(e){return{withParsedProperties:t=>gJu(e,t)}}function gJu(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((l,[f,s])=>({...l,[f]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!YLr(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:qD(i,"object")}]};let a=new Set(Object.keys(t)),u=J7n(i,Object.keys(i).filter(l=>!a.has(l)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...zE(r),...NIt(r)}}function Ejd(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function XLr(e){return e.isProperty}function lWa(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>XLr(i)?i.rawKey:r),_getParsedProperties:()=>G7n(e),parse:(r,i)=>{let n={},a=[];for(let[u,l]of Q7n(e)){let f=XLr(l)?l.rawKey:u,s=XLr(l)?l.valueSchema:l,o={rawKey:f,parsedKey:u,valueSchema:s};n[f]=o,qjd(s)&&a.push(f)}return Mjd({value:r,requiredKeys:a,getProperty:u=>{let l=n[u];if(l!=null)return{transformedKey:l.parsedKey,transform:f=>l.valueSchema.parse(f,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of Q7n(e)){let l=XLr(u)?u.valueSchema:u;qjd(l)&&n.push(a)}return Mjd({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return XLr(u)?{transformedKey:u.rawKey,transform:l=>u.valueSchema.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:l=>u.json(l,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>Dm.OBJECT};return{...SN(t),...zE(t),...NIt(t),...Rfi(t)}}function Mjd({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!YLr(e))return{ok:!1,errors:[{path:a,message:qD(e,"object")}]};let u=new Set(t),l=[],f={};for(let[s,o]of Object.entries(e)){let c=r(s);if(c!=null){u.delete(s);let b=c.transform(o);b.ok?f[c.transformedKey]=b.value:(f[s]=o,l.push(...b.errors))}else switch(i){case"fail":l.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":f[s]=o;break}}return l.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),l.length===0||n?{ok:!0,value:f}:{ok:!1,errors:l}}function Rfi(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Ajd({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>Ajd({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>Dm.OBJECT};return{...r,...zE(r),...NIt(r),...Rfi(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>Dm.OBJECT};return{...t,...zE(t),...NIt(t),...Rfi(t)}}}}function Ajd({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=Djd(G7n(t),s=>n.has(s)),l=r(J7n(t,u)),f=i(J7n(t,a));return l.ok&&f.ok?{ok:!0,value:{...l.value,...f.value}}:{ok:!1,errors:[...l.ok?[]:l.errors,...f.ok?[]:f.errors]}}function qjd(e){return!ab1(e)}function ab1(e){switch(e.getType()){case Dm.ANY:case Dm.UNKNOWN:case Dm.OPTIONAL:return!0;default:return!1}}function Tjd(e){return lWa(e)}function Cjd(e){let t={...bJu(e),_getRawProperties:()=>LJi(e)._getRawProperties(),_getParsedProperties:()=>LJi(e)._getParsedProperties()};return{...t,...zE(t),...NIt(t),...Rfi(t)}}function fWa(e){let t={parse:(r,i)=>Bjd(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Bjd(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>Dm.LIST};return{...SN(t),...zE(t)}}function Bjd(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:qD(e,"list"),path:[]}]}}function xjd(e){return LU(Dm.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:qD(r,`"${e}"`)}]})()}function zjd(e){return LU(Dm.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:qD(r,`${e.toString()}`)}]})()}var Ijd=LU(Dm.ANY,e=>({ok:!0,value:e}));var Rjd=LU(Dm.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qD(e,"boolean")}]});var Njd=LU(Dm.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qD(e,"number")}]});var Fjd=LU(Dm.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:qD(e,"string")}]});var Ljd=LU(Dm.UNKNOWN,e=>({ok:!0,value:e}));function Vjd(e,t){let r={parse:(i,n)=>Ujd({value:i,isKeyNumeric:e.getType()===Dm.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Ujd({value:i,isKeyNumeric:e.getType()===Dm.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>Dm.RECORD};return{...SN(r),...zE(r)}}function Ujd({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return YLr(e)?Q7n(e).reduce((a,[u,l])=>{if(l==null)return a;let f=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),c=i(l,s);if(f.ok&&o.ok&&c.ok)return{ok:!0,value:{...f.value,[o.value]:c.value}};let b=[];return f.ok||b.push(...f.errors),o.ok||b.push(...o.errors),c.ok||b.push(...c.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:qD(e,"object")}]}}function Wjd(e){let t=fWa(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:qD(i,"Set")}]},getType:()=>Dm.SET};return{...SN(r),...zE(r)}}function Hjd(e){let t={parse:(r,i)=>$jd((n,a)=>n.parse(r,a),e,i),json:(r,i)=>$jd((n,a)=>n.json(r,a),e,i),getType:()=>Dm.UNDISCRIMINATED_UNION};return{...SN(t),...zE(t)}}function $jd(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let l of u.errors)i.push({path:l.path,message:`[Variant ${n}] ${l.message}`})}return{ok:!1,errors:i}}function Qjd(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function Gjd(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=cWa(G7n(t)),a={parse:(u,l)=>Jjd({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:f=>n.parse(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.parse(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),json:(u,l)=>Jjd({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:f=>n.json(f,{allowUnrecognizedEnumValues:l?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...l?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:f=>t[f],allowUnrecognizedUnionMembers:l?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(f,s)=>s.json(f,l),breadcrumbsPrefix:l?.breadcrumbsPrefix}),getType:()=>Dm.UNION};return{...SN(a),...zE(a),...NIt(a)}}function Jjd({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:l=[]}){if(!YLr(e))return{ok:!1,errors:[{path:l,message:qD(e,"object")}]};let{[t]:f,...s}=e;if(f==null)return{ok:!1,errors:[{path:l,message:`Missing discriminant ("${t}")`}]};let o=i(f);if(!o.ok)return{ok:!1,errors:o.errors};let c=n(o.value);if(c==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...l,t],message:"Unexpected discriminant value"}]};let b=u(s,c);return b.ok?{ok:!0,value:{[r]:f,...b.value}}:b}var MLt=ep.objectWithoutOptionalProperties({docs:ep.string().optional()});var mJu={};$n(mJu,{ConjureServiceName:()=>dWa,DefinitionFile:()=>Kjd});var dWa=ep.string();var pWa=ep.enum_(["rid","string","safelong","integer","double","boolean"]);var ZLr=ep.undiscriminatedUnion([pWa,ep.string()]);var _Wa=ep.objectWithoutOptionalProperties({alias:ZLr,docs:ep.string().optional()});var hWa=ep.objectWithoutOptionalProperties({type:ZLr,docs:ep.string().optional()});var kLr=ep.undiscriminatedUnion([ZLr,hWa]);var yWa=ep.objectWithoutOptionalProperties({union:ep.record(ep.string(),kLr)});var vWa=ep.objectWithoutOptionalProperties({fields:ep.record(ep.string(),kLr)});var bWa=ep.objectWithoutOptionalProperties({value:ep.string()}).extend(MLt);var gWa=ep.undiscriminatedUnion([ep.string(),bWa]);var OWa=ep.objectWithoutOptionalProperties({values:ep.list(gWa)});var mWa=ep.undiscriminatedUnion([_Wa,yWa,vWa,OWa]);var PWa=ep.objectWithoutOptionalProperties({objects:ep.record(ep.string(),mWa).optional()});var jWa=ep.objectWithoutOptionalProperties({conjureImports:ep.property("conjure-imports",ep.record(ep.string(),ep.string()).optional()),definitions:PWa.optional()});var wWa=ep.enum_(["path","query","body"]);var SWa=ep.objectWithoutOptionalProperties({paramType:ep.property("param-type",wWa),type:ep.string()}).extend(MLt);var DWa=ep.undiscriminatedUnion([ep.string(),SWa]);var EWa=ep.objectWithoutOptionalProperties({http:ep.string(),args:ep.record(ep.string(),DWa).optional(),returns:kLr.optional()}).extend(MLt);var MWa=ep.objectWithoutOptionalProperties({name:ep.string().optional(),package:ep.string().optional(),basePath:ep.property("base-path",ep.string().optional()),endpoints:ep.record(ep.string(),EWa).optional()}).extend(MLt);var Kjd=ep.objectWithoutOptionalProperties({types:jWa.optional(),services:ep.record(dWa,MWa).optional()});var PJu={};$n(PJu,{ConjureArgument:()=>DWa,ConjureArgumentWithParamType:()=>SWa,ConjureEndpoint:()=>EWa,ConjureParamType:()=>wWa,ConjureService:()=>MWa});var jJu={};$n(jJu,{ConjureAliasDeclaration:()=>_Wa,ConjureDefinitions:()=>PWa,ConjureEnumDeclaration:()=>OWa,ConjureEnumVariant:()=>gWa,ConjureEnumWithDocs:()=>bWa,ConjureObjectDeclaration:()=>vWa,ConjurePrimitive:()=>pWa,ConjureType:()=>ZLr,ConjureTypeDeclaration:()=>mWa,ConjureTypeReference:()=>kLr,ConjureTypeWithDocs:()=>hWa,ConjureTypes:()=>jWa,ConjureUnionDeclaration:()=>yWa});async function Xjd(e,t){let r=[];for(let i of await DH(e,t))r.push(await ob1({relativeFilepath:wA(e,i),absoluteFilepath:i}));return r}async function ob1({relativeFilepath:e,absoluteFilepath:t}){let r=(await(0,Yjd.readFile)(t)).toString().replaceAll(": rid",": string").replaceAll("<rid>","<string>").replaceAll("rid>","string>").replaceAll(": safelong",": long").replaceAll("<safelong>","<long>").replaceAll("safelong>","long>").replaceAll(": any",": unknown").replaceAll("<any>","<unknown>").replaceAll("any>","unknown>");return{relativeFilepath:e,absoluteFilepath:t,fileContents:AWa.DefinitionFile.parseOrThrow(Vd.load(r),{unrecognizedObjectKeys:"passthrough",allowUnrecognizedEnumValues:!0,allowUnrecognizedUnionMembers:!0})}}function Zjd(e,t){if(ub1(e))return t.alias(e);if(sb1(e))return t.enum(e);if(cb1(e))return t.object(e);if(lb1(e))return t.union(e);Ho(e)}function ub1(e){return e?.alias!=null}function sb1(e){return e?.values!=null}function cb1(e){return e?.fields!=null}function lb1(e){return e?.union!=null}var K7n=class extends kxn{fernDefinitionBuilder=new Mli(!1);conjureFilepathToFernFilepath={};async import({absolutePathToConjureFolder:t,authOverrides:r,environmentOverrides:i,globalHeaderOverrides:n}){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(i!=null){for(let[a,u]of Object.entries(i.environments??{}))this.fernDefinitionBuilder.addEnvironment({name:a,schema:u});i["default-environment"]!=null&&this.fernDefinitionBuilder.setDefaultEnvironment(i["default-environment"]),i["default-url"]!=null&&this.fernDefinitionBuilder.setDefaultUrl(i["default-url"])}return await kjd(t,(a,u,l)=>{for(let[o,c]of Object.entries(l.services??{})){let b=Nva({value:o,suffix:"Service"});this.conjureFilepathToFernFilepath[u]=Lo.of(`${b}/__package__.yml`);return}let s=Hju(u)?.split(".")[0];s!=null&&(this.conjureFilepathToFernFilepath[u]=Lo.of(`${s}/__package__.yml`))}),await kjd(t,(a,u,l)=>{if(l.services==null||Object.keys(l.services??{}).length===0){let f=this.conjureFilepathToFernFilepath[u];if(f==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${u}`);for(let[s,o]of Object.entries(l.types?.conjureImports??{})){let c=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Lo.of(o)});this.fernDefinitionBuilder.addImport({file:f,fileToImport:Lo.of(c),alias:s})}this.importAllTypes({conjureFile:l,fernFilePath:f});return}for(let[f,s]of Object.entries(l.services)){let o=Nva({value:f,suffix:"Service"}),c=Lo.of(`${o}/__package__.yml`),b={};s.basePath!=null&&(b["base-path"]=s.basePath),s.docs!=null&&(b.docs=s.docs),this.fernDefinitionBuilder.setServiceInfo(c,b),this.importAllTypes({conjureFile:l,fernFilePath:c});for(let[g,O]of Object.entries(l.types?.conjureImports??{})){let m=this.getFernFileToImport({absoluteFilePathToConjureFile:a,absoluteFilePathToConjureFolder:t,importFilePath:Lo.of(O)});this.fernDefinitionBuilder.addImport({file:c,fileToImport:Lo.of(m),alias:g})}for(let[g,O]of Object.entries(s.endpoints??{})){let m=tOu(O.http);if(m.type==="failure"){this.context?.logger.error(`Failed to parse ${O.http}. Skipping.`);continue}let S={auth:!0,path:m.path,method:m.method,response:O.returns==="binary"?"file":O.returns};O.docs!=null&&(S.docs=O.docs);let E={};if(O.args!=null)for(let A of m.pathParameters){let M=O.args[A];if(M==null)throw new Error(`Failed to find path parameter ${A} in ${O.http}`);E[A]=typeof M=="string"?M:{type:M.type}}Object.entries(E).length>0&&(S["path-parameters"]=E);for(let[A,M]of Object.entries(O.args??{}))if(E[A]==null)if(typeof M=="string")S.request?typeof S.request=="string"&&(S.request={body:S.request}):S.request={},S.request.body=M==="binary"?"bytes":M;else switch(M.paramType){case"body":S.request={body:M.type==="binary"?"bytes":M.type};break;case"query":S.request==null?S.request={"query-parameters":{[A]:M.type}}:typeof S.request!="string"&&S.request?.["query-parameters"]==null?S.request["query-parameters"]={[A]:M.type}:typeof S.request!="string"&&S.request?.["query-parameters"]!=null&&(S.request["query-parameters"][A]=M.type)}S.request!=null&&typeof S.request!="string"&&S.request?.["query-parameters"]!=null&&(S.request.name=`${g}Request`),this.fernDefinitionBuilder.addEndpoint(c,{name:g,schema:S,source:void 0})}}}),this.fernDefinitionBuilder.build()}importAllTypes({conjureFile:t,fernFilePath:r}){for(let[i,n]of Object.entries(t.types?.definitions?.objects??{}))Zjd(n,{alias:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{type:a.alias,docs:a.docs}})},object:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{properties:a.fields}})},enum:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{enum:a.values}})},union:a=>{this.fernDefinitionBuilder.addType(r,{name:i,schema:{union:Object.fromEntries(Object.entries(a.union).map(([u,l])=>[u,{type:typeof l=="string"?l:l.type,docs:typeof l=="string"?void 0:l.docs,key:u}]))}})}})}getFernFileToImport({absoluteFilePathToConjureFile:t,importFilePath:r,absoluteFilePathToConjureFolder:i}){let n=ys(Zp(t),Lo.of(r)),a=m4t(i,n),u=this.conjureFilepathToFernFilepath[a];if(u==null)throw new Error(`Failed to find corresponding fern filepath for conjure file ${a}`);return u}};async function kjd(e,t){for(let r of await Xjd(e,"{yml,yaml}"))await t(r.absoluteFilepath,r.relativeFilepath,r.fileContents)}function ewd(e,t){return md(e,t)}var qWa=class extends vIt{absolutePathToConjureFolder;constructor({relativePathToConjureDirectory:t,...r}){super(r),this.absolutePathToConjureFolder=ys(r.absoluteFilePath,t)}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new JOe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion,sources:void 0})}async getDefinition({context:t},r){let n=await new K7n(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:Zl.of("/DUMMY_PATH"),rootApiFile:{defaultUrl:n.rootApiFile["default-url"],contents:n.rootApiFile,rawContents:Vd.dump(n.rootApiFile)},namedDefinitionFiles:{...ewd(n.definitionFiles,a=>({absoluteFilepath:Zl.of("/DUMMY_PATH"),rawContents:Vd.dump(a),contents:a})),[Lo.of(gw)]:{absoluteFilepath:Zl.of("/DUMMY_PATH"),rawContents:Vd.dump(n.packageMarkerFile),contents:n.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}getAbsoluteFilePaths(){return[this.absolutePathToConjureFolder]}};function wJu(e,t){for(let[r,i]of Rz(e.failures))fb1({relativeFilepath:r,failure:i,logger:t})}function fb1({relativeFilepath:e,failure:t,logger:r}){switch(t.type){case LO.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 LO.FILE_READ:r.error("Failed to open file: "+e);break;case LO.FILE_MISSING:r.error("Missing file: "+e);break;case LO.FILE_PARSE:t.error instanceof BAn?r.error(yAe({title:`Failed to parse ${e}: ${t.error.reason}`,subtitle:t.error.mark.snippet})):r.error("Failed to parse file: "+e);break;case LO.STRUCTURE_VALIDATION:for(let i of t.error.issues)for(let{title:n,subtitle:a}of db1(i))r.error(yAe({title:n,subtitle:a,breadcrumbs:[e,...i.path]}));break;case LO.FAILED_TO_LOAD_DEPENDENCY:r.error("Failed to load dependency: "+t.dependencyName);break;case LO.DEPENDENCY_NOT_LISTED:r.error(`Dependency is not listed in ${jba}: `+t.dependencyName);break;case LO.EXPORT_PACKAGE_HAS_DEFINITIONS:r.error("Exported package contains API definitions: "+t.pathToPackage);break;case LO.EXPORTING_PACKAGE_MARKER_OTHER_KEYS:r.error(`${t.pathOfPackageMarker} has an export so it cannot define other keys.`);break;case LO.JSONSCHEMA_VALIDATION:t.error.error!=null&&r.error(yAe({title:t.error.error.message??"Unknown error",breadcrumbs:[e,...t.error.error.instancePath.split("/").filter(i=>i!=="")]}));break;default:Ho(t)}}function db1(e){switch(e.code){case Dl.invalid_type:return[{title:"Incorrect type",subtitle:`Expected ${ju.underline(e.expected)} but received ${ju.underline(e.received)}`}];case Dl.unrecognized_keys:return e.keys.map(t=>({title:"Unexpected key",subtitle:`Encountered unexpected key ${ju.underline(t)}`}));case Dl.invalid_enum_value:return[{title:"Unrecognized value",subtitle:`Allowed values: ${e.options.map(t=>ju.underline(t)).join(", ")}`}];case Dl.invalid_union:case Dl.invalid_arguments:case Dl.invalid_return_type:case Dl.invalid_date:case Dl.invalid_string:case Dl.too_small:case Dl.too_big:case Dl.invalid_intersection_types:case Dl.not_multiple_of:case Dl.custom:default:return[{title:e.message}]}}var twd=require("fs/promises");async function rwd(e,t){let r=[];for(let i of await DH(e,t))r.push(await pb1({relativeFilepath:wA(e,i),absoluteFilepath:i}));return r}async function pb1({relativeFilepath:e,absoluteFilepath:t}){return{relativeFilepath:e,absoluteFilepath:t,fileContents:(await(0,twd.readFile)(t)).toString()}}async function iwd({absolutePathToWorkspace:e}){let t=ys(e,Lo.of(uxl));if(!await If(t))return;let i=await rwd(t,"{md,mdx}");return{files:await Promise.all(i.map(n=>({absoluteFilepath:n.absoluteFilepath,contents:n.fileContents})))}}async function SJu({absolutePathToWorkspace:e,namespace:t,definitions:r}){let i=[];for(let n of r){let a=n.overrides!=null?ys(e,Lo.of(n.overrides)):void 0;if(n.schema.type==="protobuf"){let l=ys(e,Lo.of(n.schema.root));if(!await If(l))return{didSucceed:!1,failures:{[Lo.of(n.schema.root)]:{type:LO.FILE_MISSING}}};let f=ys(e,Lo.of(n.schema.target));if(!await If(f))return{didSucceed:!1,failures:{[Lo.of(n.schema.target)]:{type:LO.FILE_MISSING}}};i.push({type:"protobuf",absoluteFilepathToProtobufRoot:l,absoluteFilepathToProtobufTarget:f,absoluteFilepathToOverrides:a,generateLocally:n.schema.localGeneration,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:void 0}});continue}let u=ys(e,Lo.of(n.schema.path));if(!await If(u))return{didSucceed:!1,failures:{[Lo.of(n.schema.path)]:{type:LO.FILE_MISSING}}};if(n.overrides!=null&&a!=null&&!await If(a))return{didSucceed:!1,failures:{[Lo.of(n.overrides)]:{type:LO.FILE_MISSING}}};i.push({type:"openapi",absoluteFilepath:u,absoluteFilepathToOverrides:a,settings:{audiences:n.audiences??[],useTitlesAsName:n.settings?.shouldUseTitleAsName??!0,shouldUseUndiscriminatedUnionsWithLiterals:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,optionalAdditionalProperties:n.settings?.shouldUseOptionalAdditionalProperties??!0,cooerceEnumsToLiterals:n.settings?.coerceEnumsToLiterals??!0,objectQueryParameters:n.settings?.objectQueryParameters??!1,respectReadonlySchemas:n.settings?.respectReadonlySchemas??!1,onlyIncludeReferencedSchemas:n.settings?.onlyIncludeReferencedSchemas??!1,inlinePathParameters:n.settings?.inlinePathParameters??!1,disableExamples:!1,discriminatedUnionV2:n.settings?.shouldUseUndiscriminatedUnionsWithLiterals??!1,preserveSchemaIds:!1,asyncApiNaming:n.settings?.asyncApiMessageNaming??"v1",filter:n.settings?.filter,exampleGeneration:n.settings?.exampleGeneration},source:{type:"openapi",file:u},namespace:t})}return i}async function Y7n({absolutePathToWorkspace:e,context:t,cliVersion:r,workspaceName:i}){let n=await Fzt({absolutePathToWorkspace:e,context:t}),a;try{a=await iwd({absolutePathToWorkspace:e})}catch{}if(n?.api!=null&&n?.api.type==="conjure")return{didSucceed:!0,workspace:new qWa({workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r,context:t,relativePathToConjureDirectory:Lo.of(n.api.pathToConjureDefinition)})};if(n?.api!=null&&(n.api.type==="singleNamespace"&&n.api.definitions.length>0||n.api.type==="multiNamespace")){let u=[];if(n.api.type==="singleNamespace"){let l=await SJu({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.definitions});if(!Array.isArray(l))return l;u.push(...l)}else{for(let[l,f]of Object.entries(n.api.definitions)){let s=await SJu({absolutePathToWorkspace:e,namespace:l,definitions:f});if(!Array.isArray(s))return s;u.push(...s)}if(n.api.rootDefinitions!=null){let l=await SJu({absolutePathToWorkspace:e,namespace:void 0,definitions:n.api.rootDefinitions});if(!Array.isArray(l))return l;u.push(...l)}}return{didSucceed:!0,workspace:new nR({specs:u,workspaceName:i,absoluteFilePath:e,generatorsConfiguration:n,changelog:a,cliVersion:r})}}return await If(ys(e,Lo.of(V2)))?{didSucceed:!0,workspace:new KLr({absoluteFilePath:e,generatorsConfiguration:n,workspaceName:i,changelog:a,context:t,cliVersion:r,loadAPIWorkspace:Y7n})}:{didSucceed:!1,failures:{[Lo.of(Moi)]:{type:LO.MISCONFIGURED_DIRECTORY}}}}var nwd=require("fs/promises");var awd=Ji(require("path"),1);async function DJu({fernDirectory:e,context:t}){let r=ys(e,Lo.of(Zxt));if(!await If(r))return;let i=await _b1({absolutePathToDocsDefinition:e,context:t});if(i!=null)return{type:"docs",absoluteFilePath:e,config:i,workspaceName:void 0,absoluteFilepathToDocsConfig:ys(e,Lo.of(Zxt))}}async function _b1({absolutePathToDocsDefinition:e,context:t}){if(!await If(e))return;let r=ys(e,Lo.of(Zxt));return await hb1({absolutePathOfConfiguration:r,context:t})}async function hb1({absolutePathOfConfiguration:e,context:t}){let r=await(0,nwd.readFile)(e),i=Vd.load(r.toString());return await yb1({value:i,context:t,filepathBeingParsed:e})}async function yb1({value:e,context:t,filepathBeingParsed:r}){let i=await tEe.RawSchemas.Serializer.DocsConfiguration.parse(e);if(i.ok)return i.value;let n=i.errors.map(u=>{let l=u.path.length>0?`${u.message} at "${u.path.join(" -> ")}"`:u.message;return _H({content:l,prefix:" - "})}),a=[`Failed to parse file: ${awd.default.relative(process.cwd(),r)}`,...n].join(`
|
|
1734
1734
|
`);return t.failAndThrow(a)}async function EJu({context:e,nameOverride:t,...r}){let i=await Y4r(t);return i==null?e.failAndThrow(`Directory "${t??mH}" not found.`):await uwd({absolutePathToFernDirectory:i,context:e,nameOverride:t,...r})}async function uwd({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n,context:a}){let u=[];return(await If(ys(e,Lo.of(m4r)))||await If(ys(e,Lo.of(V2)))||await If(ys(e,Lo.of(v6)))||await If(ys(e,Lo.of(Moi)))||await If(ys(e,Lo.of(sxl))))&&(u=await swd({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n})),{config:await IFr({directory:e,context:a}),apiWorkspaces:u,docsWorkspaces:await DJu({fernDirectory:e,context:a}),loadAPIWorkspace:l=>l==null?u[0]:u.find(f=>f.workspaceName===l)}}async function swd({cliName:e,fernDirectory:t,context:r,cliVersion:i,commandLineApiWorkspace:n,defaultToAllApiWorkspaces:a}){let u=ys(t,Lo.of(m4r));if(await If(u)){let o=(await(0,owd.readdir)(u,{withFileTypes:!0})).reduce((g,O)=>(O.isDirectory()&&g.push(O.name),g),[]);if(n!=null){if(!o.includes(n))return r.failAndThrow("API does not exist: "+n)}else{if(o.length===0)return r.failAndThrow("No APIs found.");if(o.length>1&&!a){let g=`There are multiple workspaces. You must specify one with --api:
|
|
1735
1735
|
`,O=Math.max(...o.map(m=>m.length));return g+=o.map(m=>{let S=`${e} ${process.argv.slice(2).join(" ")} --api ${m}`;return` \u203A ${ju.bold(m.padEnd(O))} ${ju.dim(S)}`}).join(`
|
|
1736
1736
|
`),r.failAndThrow(g)}}let c=[],b=n!=null?o.filter(g=>g===n):o;return await Promise.all(b.map(async g=>{let O=await Y7n({absolutePathToWorkspace:ys(u,Lo.of(g)),context:r,cliVersion:i,workspaceName:g});O.didSucceed?c.push(O.workspace):(wJu(O,r.logger),r.failAndThrow())})),c}let f=await Y7n({absolutePathToWorkspace:t,context:r,cliVersion:i,workspaceName:void 0});return f.didSucceed?[f.workspace]:(wJu(f,r.logger),[])}async function mM(e,t,r=!1){let i=e.addTask().start(),n=await EJu({...t,cliName:e.environment.cliName,cliVersion:e.environment.packageVersion,context:i});return i.finish(),r&&n.docsWorkspaces!=null?e.registerWorkspaces([...n.apiWorkspaces,n.docsWorkspaces]):e.registerWorkspaces(n.apiWorkspaces),e.registerProject(n),n}var ywd=require("fs/promises");var vwd=Ji(Vqn(),1);var lwd=require("fs/promises");var UJi={GitHub:"github",Local:"local-file-system",PackageRegistry:"publish"};async function fwd({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:i,apiKeyFallback:n="FERN_DEFAULT",project:{apiWorkspaces:a},outputLocation:u,excludedModes:l,includedModes:f}){let s={};await Promise.all(a.map(async c=>{await e.runTaskForWorkspace(c,async b=>{if(i!=null&&(c.workspaceName==null||!i.has(c.workspaceName)))return;let g=await Fzt({absolutePathToWorkspace:c.absoluteFilePath,context:b});if(g==null||g.groups==null)return;let O=c.workspaceName??n;s[O]={};for(let m of g.groups)r!=null&&!r.has(m.groupName)||(s[O][m.groupName]=m.generators.filter(S=>{let E=!0;return f!=null&&(E=cwd(S,f)),l!=null&&(E=!cwd(S,l)),E}).filter(S=>t==null||t.has(S.name)).map(S=>S.name))})}));let o=Vd.dump(s);if(u==null){process.stdout.write(o);return}try{await(0,lwd.writeFile)(u,o)}catch(c){e.failAndThrow(`Could not write file to the specified location: ${u}`,c)}}function cwd(e,t){let r,i=e.outputMode.type;switch(i){case"downloadFiles":r=UJi.Local;break;case"github":case"githubV2":r=UJi.GitHub;break;case"publish":case"publishV2":r=UJi.PackageRegistry;break;default:Ho(i)}return t.has(r)}async function dwd({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:i,project:{apiWorkspaces:n}}){let a;return await Promise.all(n.map(async u=>{await e.runTaskForWorkspace(u,async l=>{if(i!=null&&(u.workspaceName==null||i!==u.workspaceName))return;let f=await Fzt({absolutePathToWorkspace:u.absoluteFilePath,context:l});if(!(f==null||f.groups==null)){for(let s of f.groups)if(r===s.groupName)for(let o of s.generators)t===o.name&&(a=o)}})})),a}var pwd=require("fs/promises");async function _wd({project:e,outputLocation:t,context:r}){let i=e.config.organization;if(t==null){process.stdout.write(i);return}try{await(0,pwd.writeFile)(t,i)}catch(n){r.failAndThrow(`Could not write file to the specified location: ${t}`,n)}}var TWa=require("fs/promises"),X7n=Ji(require("path"),1),VJi=Ji(OZ(),1);async function vb1({absolutePathToWorkspace:e,context:t,generatorFilter:r,groupFilter:i,includeMajor:n,channel:a,cliVersion:u}){let l=await V8r({absolutePathToWorkspace:e});if(l==null||!await If(l)){t.logger.debug("Generators configuration file was not found, no generators to upgrade.");return}let f=await(0,TWa.readFile)(l);t.logger.debug(`Found generators: ${f.toString()}`);let s=VJi.default.parseDocument(f.toString()),o=s.get("groups");if(o==null){t.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}if(!VJi.default.isMap(o)){t.failAndThrow(`Expected 'groups' to be a map in ${X7n.default.relative(process.cwd(),l)}`);return}t.logger.debug(`Groups found: ${o.toString()}`);for(let c of o.items){let b=c.key.value,g=c.value;if(!VJi.default.isMap(g)){t.failAndThrow(`Expected group ${b} to be a map in ${X7n.default.relative(process.cwd(),l)}`);continue}if(i!=null&&i!==b){t.logger.debug(`Skipping group ${b} as it does not match the filter: ${i}`);continue}let O=g.get("generators");if(!VJi.default.isSeq(O)){t.failAndThrow(`Expected group ${b} to have a 'generators' key in ${X7n.default.relative(process.cwd(),l)}`);continue}t.logger.debug(`Generators found: ${O.toString()}`);for(let m of O.items){VJi.default.isMap(m)||t.failAndThrow(`Expected generator in group ${b} to be a map in ${X7n.default.relative(process.cwd(),l)}`);let S=m.get("name");if(r!=null&&S!==r){t.logger.debug(`Skipping generator ${S} as it does not match the filter: ${r}`);continue}let E=RFr(S,t),A=m.get("version"),M=await n8t({generatorName:E,cliVersion:u,currentGeneratorVersion:A,channel:a,includeMajor:n,context:t});M!=null&&(t.logger.debug(ju.green(`Upgrading ${S} from ${A} to ${M}`)),m.set("version",M))}}return s.toString()}async function hwd({cliContext:e,generator:t,group:r,project:{apiWorkspaces:i},includeMajor:n,channel:a}){await Promise.all(i.map(async u=>{await e.runTaskForWorkspace(u,async l=>{let f=await DUi({absolutePathToWorkspace:u.absoluteFilePath,context:l})??{};if(f==null||f.groups==null){l.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}u.workspaceName==null?l.logger.info("Upgrading generators."):l.logger.info(`Upgrading generators in workspace: ${u.workspaceName}.`);let s=await vb1({absolutePathToWorkspace:u.absoluteFilePath,context:l,generatorFilter:t,groupFilter:r,includeMajor:n,channel:a,cliVersion:e.environment.packageVersion}),o=await V8r({absolutePathToWorkspace:u.absoluteFilePath});o!=null&&s!=null&&await(0,TWa.writeFile)(o,s)})}))}function bwd(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 _wd({project:await mM(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),context:t,outputLocation:r.output})})}function gwd(e,t){e.command("generator","Operate on the generators within your Fern configuration",r=>{r.command("list",!1,i=>i.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(UJi),type:"array",description:"The generator output modes to include within the outputted list."}).option("exclude-mode",{choices:Object.values(UJi),type:"array",description:"The generator output modes to exclude within the outputted list."}),async i=>{await t.instrumentPostHogEvent({command:"fern generator list",properties:{outputLocation:i.output}}),await fwd({project:await mM(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),generatorFilter:i.generators?new Set(i.generators):void 0,groupFilter:i.groups?new Set(i.groups):void 0,apiFilter:i.apis?new Set(i.apis):void 0,apiKeyFallback:i.apiFallback,cliContext:t,outputLocation:i.output,includedModes:i["include-mode"]?new Set(i["include-mode"]):void 0,excludedModes:i["exclude-mode"]?new Set(i["exclude-mode"]):void 0})}).command("upgrade",`Upgrades the specified generator in ${v6} to the latest stable version.`,i=>i.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(vwd.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 i=>{await t.instrumentPostHogEvent({command:"fern generator upgrade",properties:{generator:i.generator,version:i.version,api:i.api,group:i.group,includeMajor:i.includeMajor,rc:i.rc}});let n=await mM(t,{commandLineApiWorkspace:i.api,defaultToAllApiWorkspaces:!0});if(i.list){t.suppressUpgradeMessage();let a=await FNa({cliContext:t,project:n,generatorFilter:i.generator,groupFilter:i.group,includeMajor:i.includeMajor,channel:i.channel}),u=await bFu({generatorUpgradeInfo:a,header:`Generator Upgrades
|