fern-api 0.64.18 → 0.64.19
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
|
@@ -1711,7 +1711,7 @@ ${aqp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&mQs(th
|
|
|
1711
1711
|
`+EHi.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?EHi.default.cyan(_qp(t,this.opt.mask)):EHi.default.italic(EHi.default.dim("[hidden]")):this.opt.mask?_qp(t,this.opt.mask):EHi.default.italic(EHi.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var UFo=ai(z2(),1),FTp=ai(pJs(),1),LTp=ai(VEe(),1);var XDa=class extends x2{_run(t){this.done=t,this.editorResult=new LTp.Subject;let r=jW(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"?UFo.default.dim("Received"):UFo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=UFo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,FTp.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 $Tp=require("stream");var WTp=ai(require("readline"),1),HTp=ai(VTp(),1),zHi=class{constructor(t){this.rl||=WTp.default.createInterface(w_D(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 w_D(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 HTp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var ZDa=class extends zHi{constructor(t={}){super(t),this.log=new $Tp.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return BDa(this.rl,this.bottomBar.split(`
|
|
1712
1712
|
`).length),this}updateBottomBar(t){return BDa(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+`
|
|
1713
1713
|
`}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&&hFo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var UE=ai(VEe(),1),JTp=ai(tDa(),1);var VFo=ai(VEe(),1),GTp=ai(tDa(),1),WFo=function(e,t,r){return typeof e[t]!="function"?(0,VFo.of)(e):(0,VFo.from)((0,GTp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var QTp={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,u)=>{n==="__proto__"||n==="constructor"||(a===u.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((u,l)=>u!=null?u[l]:u,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},YNn=class extends zHi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,UE.from)(t):(0,UE.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,UE.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,UE.from)([t]),this.process=i.pipe((0,UE.concatMap)(this.processQuestion.bind(this)),(0,UE.publish)()),this.process.connect(),this.process.pipe((0,UE.reduce)((n,a)=>(QTp.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,UE.defer)(()=>(0,UE.of)(t).pipe((0,UE.concatMap)(this.setDefaultType.bind(this)),(0,UE.concatMap)(this.filterIfRunnable.bind(this)),(0,UE.concatMap)(()=>WFo(t,"message",this.answers)),(0,UE.concatMap)(()=>WFo(t,"default",this.answers)),(0,UE.concatMap)(()=>WFo(t,"choices",this.answers)),(0,UE.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,UE.defer)(()=>(0,UE.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,UE.defer)(()=>(0,UE.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&QTp.get(this.answers,t.name)!==void 0)return UE.EMPTY;if(t.when===!1)return UE.EMPTY;if(typeof t.when!="function")return(0,UE.of)(t);let{answers:r}=this;return(0,UE.defer)(()=>(0,UE.from)((0,JTp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,UE.filter)(i=>i!=null)))}};function KTp(e){let t=function(r,i){let n;try{n=new YNn(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",zDa),this.registerPrompt("input",DHi),this.registerPrompt("number",xDa),this.registerPrompt("confirm",RDa),this.registerPrompt("rawlist",NDa),this.registerPrompt("expand",FDa),this.registerPrompt("checkbox",LDa),this.registerPrompt("password",UDa),this.registerPrompt("editor",XDa)},t.restoreDefaultPrompts(),t}var hJs=KTp();function D_D(e,t){hJs.registerPrompt(e,t)}function E_D(){hJs.restoreDefaultPrompts()}var M_D={prompt:hJs,ui:{BottomBar:ZDa,Prompt:YNn},createPromptModule:KTp,registerPrompt:D_D,restoreDefaultPrompts:E_D,Separator:sae},HFo=M_D;var sFn=require("path"),ABp=require("fs"),qBp=require("readline"),eBp="posthog-node";function cvD(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let l=a.tags[d3o.POSTHOG_ID_TAG];if(l===void 0)return a;let d=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${l}`,d).toString();a.tags["PostHog Person URL"]=s;let o=a.exception?.values||[],c=o.map(g=>({...g,stacktrace:g.stacktrace?{...g.stacktrace,type:"raw",frames:(g.stacktrace.frames||[]).map(O=>({...O,platform:"node:javascript"}))}:void 0})),b={$exception_message:o[0]?.value||a.message,$exception_type:o[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:c,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:o[0]?.value||a.message,$sentry_exception_type:o[0]?.type,$sentry_tags:a.tags};return t&&r&&(b.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:l,properties:b}),a}}var d3o=class{constructor(t,r,i,n){this.name=eBp,this.name=eBp,this.setupOnce=function(a,u){let l=u()?.getClient()?.getDsn()?.projectId;a(cvD(t,{organization:r,projectId:l,prefix:i,severityAllowList:n}))}}};d3o.POSTHOG_ID_TAG="posthog_distinct_id";var u3o="0123456789abcdef",p3o=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+=u3o.charAt(this.bytes[r]>>>4),t+=u3o.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+=u3o.charAt(this.bytes[r]>>>4),t+=u3o.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}},nKs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??lvD()}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 p3o.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,p3o.ofInner(t)}},lvD=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),tBp,aKs=()=>fvD().toString(),fvD=()=>(tBp||(tBp=new nKs)).generate();function dvD(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(u=>u.name!=="domainUncaughtExceptionClear"&&u._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function pvD(e,t){global.process.on("uncaughtException",dvD(e,t))}function _vD(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var s3o,rBp,c3o;function hvD(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return c3o&&r.length===rBp||(rBp=r.length,c3o=r.reduce((i,n)=>{s3o||(s3o={});let a=s3o[n];if(a)i[a[0]]=a[1];else{let u=e(n);for(let l=u.length-1;l>=0;l--){let s=u[l]?.filename,o=t[n];if(s&&o){i[s]=o,s3o[n]=[s,o];break}}}return i},{})),c3o}function yvD(e){return typeof Event<"u"&&TBp(e,Event)}function vvD(e){return CBp(e,"Object")}function pKs(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return TBp(e,Error)}}function TBp(e,t){try{return e instanceof t}catch{return!1}}function bvD(e){return CBp(e,"ErrorEvent")}function CBp(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function gvD(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},u=BBp(a,r,i);return{$exception_list:await Promise.all(u.map(async s=>{let o=await DvD(e,t,s);return o.value=o.value||"",o.type=o.type||"Error",o.mechanism=a,o}))}}function BBp(e,t,r){let i=OvD(e,t,r);return i.cause?[i,...BBp(e,i.cause,r)]:[i]}function OvD(e,t,r){if(pKs(t))return t;if(e.synthetic=!0,vvD(t)){let n=mvD(t);if(n)return n;let a=PvD(t),u=r?.syntheticException||new Error(a);return u.message=a,u}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function mvD(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(pKs(r))return r}}function PvD(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message '${e.message}'`),i}else if("message"in e&&typeof e.message=="string")return e.message;let t=wvD(e);if(bvD(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=jvD(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function jvD(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function wvD(e,t=40){let r=Object.keys(SvD(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return iBp(i,t);for(let n=r.length;n>0;n--){let a=r.slice(0,n).join(", ");if(!(a.length>t))return n===r.length?a:iBp(a,t)}return""}function iBp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function SvD(e){return pKs(e)?{message:e.message,name:e.name,stack:e.stack,...nBp(e)}:yvD(e)?{type:e.type,target:aBp(e.target),currentTarget:aBp(e.currentTarget),...nBp(e)}:e}function nBp(e){if(typeof e=="object"&&e!==null){let t={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}else return{}}function aBp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function DvD(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=EvD(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function EvD(e,t){return MvD(e(t.stack||"",1),e)}function MvD(e,t){let r=hvD(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var AvD=2e3,aFn=class e{static async captureException(t,r,i,n,a){let u={...a};n||(u.$process_person_profile=!1);let l=await gvD(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||aKs(),properties:{...l,...u}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(pvD(this.onException.bind(this),this.onFatalError.bind(this)),_vD(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(AvD)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function qvD(e=process.argv[1]?(0,sFn.dirname)(process.argv[1]):process.cwd(),t=sFn.sep==="\\"){let r=t?oBp(e):e;return i=>{if(!i)return;let n=t?oBp(i):i,{dir:a,base:u,ext:l}=sFn.posix.parse(n);(l===".js"||l===".mjs"||l===".cjs")&&(u=u.slice(0,l.length*-1));let d=decodeURIComponent(u);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let o=a.slice(r.length+1).replace(/\//g,".");return o?`${o}:${d}`:d}return d}}function oBp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var _3o=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}},f3o=new _3o(25),IBp=new _3o(20),_Ks=7,TvD=1e3,CvD=1e4;async function BvD(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],u=a?.filename;if(!a||typeof u!="string"||typeof a.lineno!="number"||RvD(u)||NvD(a))continue;t[u]||(t[u]=[]),t[u].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(IBp.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let u=LvD(a);if(u.every(d=>FvD(n,d)))continue;let l=UvD(f3o,n,{});i.push(IvD(n,u,l))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&zvD(e,f3o),f3o.reduce(),e}function IvD(e,t,r){return new Promise(i=>{let n=(0,ABp.createReadStream)(e),a=(0,qBp.createInterface)({input:n});function u(){n.destroy(),i()}let l=0,d=0,s=t[d];if(s===void 0){u();return}let o=s[0],c=s[1];function b(){IBp.set(e,1),a.close(),a.removeAllListeners(),u()}n.on("error",b),a.on("error",b),a.on("close",u),a.on("line",g=>{if(l++,!(l<o)&&(r[l]=VvD(g,0),l>=c)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let O=t[d];if(O===void 0){a.close(),a.removeAllListeners();return}o=O[0],c=O[1]}})})}function zvD(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;xvD(r.lineno,r,i)}}function xvD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=zBp(e);n<e;n++){let a=r[n];if(a===void 0){uBp(t);return}t.pre_context.push(a)}if(r[e]===void 0){uBp(t);return}t.context_line=r[e];let i=xBp(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function uBp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function RvD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function NvD(e){return e.lineno!==void 0&&e.lineno>CvD||e.colno!==void 0&&e.colno>TvD}function FvD(e,t){let r=f3o.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function LvD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=sBp(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+_Ks:(n.push(i),i=sBp(a)),t++}return n}function sBp(e){return[zBp(e),xBp(e)]}function zBp(e){return Math.max(1,e-_Ks)}function xBp(e){return e+_Ks}function UvD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function VvD(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var WvD="4.18.0",_ae;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(_ae||(_ae={}));var cBp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(cBp||(cBp={}));var lBp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(lBp||(lBp={}));var fBp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(fBp||(fBp={}));var dBp;(function(e){e.Html="html",e.Text="text"})(dBp||(dBp={}));var pBp;(function(e){e.Number="number",e.Emoji="emoji"})(pBp||(pBp={}));var _Bp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(_Bp||(_Bp={}));var hBp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(hBp||(hBp={}));var yBp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(yBp||(yBp={}));var vBp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(vBp||(vBp={}));var HvD=e=>{if("flags"in e){let t=GvD(e.flags),r=QvD(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,RBp(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,$vD(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function $vD(e,t,r){return{key:e,enabled:typeof t=="string"?!0:t,variant:typeof t=="string"?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var GvD=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,hKs(r)]).filter(([,t])=>t!==void 0)),QvD=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?RBp(i):void 0]}))},hKs=e=>e===void 0?void 0:e.variant??e.enabled,RBp=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},JvD=1,KvD=new Set(["61be3dd8","96f6df5f","8cfdba9b","bf027177","e59430a8","7fa5500b","569798e9","04809ff7","0ebc61a5","32de7f98","3beeb69a","12d34ad9","733853ec","0645bb64","5dcbee21","b1f95fa3","2189e408","82b460c2","3a8cc979","29ef8843","2cdbf767","38084b54","50f9f8de","41d0df91","5c236689","c11aedd3","ada46672","f4331ee1","42fed62a","c957462c","d62f705a","e0162666","01b3e5cf","441cef7f","bb9cafee","8f348eb0","b2553f3a","97469d7d","39f21a76","03706dcc","27d50569","307584a7","6433e92e","150c7fbb","49f57f22","3772f65b","01eb8256","3c9e9234","f853c7f7","c0ac4b67","cd609d40","10ca9b1a","8a87f11b","8e8e5216","1f6b63b3","db7943dd","79b7164c","07f78e33","2d21b6fd","952db5ee","a7d3b43f","1924dd9c","84e1b8f6","dff631b6","c5aa8a79","fa133a95","498a4508","24748755","98f3d658","21bbda67","7dbfed69","be3ec24c","fc80b8e2","75cc0998"]),YvD="utf8";function XvD(e,t){if(!e||typeof e!="string"||ZvD(e))throw new Error(t)}function ZvD(e){return e.trim().length===0}function kvD(e){return e?.replace(/\/+$/,"")}async function ebD(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 bBp(){return new Date().getTime()}function rKs(){return new Date().toISOString()}function h3o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function tbD(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function rbD(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16).padStart(8,"0")}function ibD(e,t=0,r){let i=rbD(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function gBp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var sEa=String.fromCharCode,OBp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l3o={};function nbD(e,t){if(!l3o[e]){l3o[e]={};for(let r=0;r<e.length;r++)l3o[e][e.charAt(r)]=r}return l3o[e][t]}var iFn={compressToBase64:function(e){if(e==null)return"";let t=iFn._compress(e,6,function(r){return OBp.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:iFn._decompress(e.length,32,function(t){return nbD(OBp,e.charAt(t))})},compress:function(e){return iFn._compress(e,16,function(t){return sEa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,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(d)}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:iFn._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,d=3,s="",o,c,b,g,O,m,w;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;w=sEa(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;w=sEa(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),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(w=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++]=sEa(b),w=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++]=sEa(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===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,d),d++)}}},oKs=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)}},oFn=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},cEa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function mBp(e){if(e instanceof oFn){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function iKs(e){return typeof e=="object"&&(e instanceof oFn||e instanceof cEa)}function PBp(e){return typeof e=="object"&&e instanceof oFn&&e.status===413}var uKs;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(uKs||(uKs={}));var sKs=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new oKs,this._isInitialized=!1,XvD(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=kvD(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.preloadFeatureFlags=r?.preloadFeatureFlags??!0,this.defaultOptIn=r?.defaultOptIn??!0,this.disableSurveys=r?.disableSurveys??!1,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:iKs},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r?.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(_ae.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(_ae.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(_ae.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=aKs();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,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 getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let l=ibD(this.apiKey,JvD,KvD)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,d={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",l)),this.fetchWithRetry(l,d,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>HvD(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagDetailStateless(t,r,i,n,a,u);if(l===void 0)return{response:void 0,requestId:void 0};let d=hKs(l.response);return d===void 0&&(d=!1),{response:d,requestId:l.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagDetailsStateless(r,i,n,a,u,[t]);return l===void 0?void 0:{response:l.flags[t],requestId:l.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u,[t]);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,u){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,u){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,u){await this._initPromise;let l=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,u);return l?{flags:l.featureFlags,payloads:l.featureFlagPayloads,requestId:l.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,u){await this._initPromise;let l={};(a??this.disableGeoip)&&(l.geoip_disable=!0),u&&(l.flag_keys_to_evaluate=u);let d=await this.getDecide(t,r,i,n,l);if(d!==void 0)return d.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),d.quotaLimited?.includes(uKs.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:d?.requestId}):d}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let u=`Surveys API could not be loaded: ${a.status}`,l=new Error(u);this.logMsgIfDebug(()=>console.error(l)),this._events.emit("error",new Error(u));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(_ae.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(_ae.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(_ae.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(_ae.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(_ae.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=h3o(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:rKs()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${bBp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,l=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(iFn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(u,l)}catch(d){this._events.emit("error",d)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:rKs(),uuid:i?.uuid?i.uuid:aKs()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await mBp(t)})}async flush(){let t=gBp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),gBp([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(_ae.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(b=>b.message),u=()=>{let g=(this.getPersistedProperty(_ae.Queue)||[]).slice(n.length);this.setPersistedProperty(_ae.Queue,g),t=g},l={api_key:this.apiKey,batch:a,sent_at:rKs()};this.historicalMigration&&(l.historical_migration=!0);let d=JSON.stringify(l),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${bBp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,o=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(iFn.compressToBase64(d))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:d},c={retryCheck:b=>PBp(b)?!1:iKs(b)};try{await this.fetchWithRetry(s,o,c)}catch(b){if(PBp(b)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw b instanceof cEa||u(),this._events.emit("error",b),b}u(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let o=new AbortController;return setTimeout(()=>o.abort(),s),o.signal});let u=r.body?r.body:"",l=-1;try{l=Buffer.byteLength(u,YvD)}catch{l=new TextEncoder().encode(u).length}return await ebD(async()=>{let d=null;try{d=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(o){throw new cEa(o)}if(!(r.mode==="no-cors")&&(d.status<200||d.status>=400))throw new oFn(d,l);return d},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(_ae.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!iKs(n))throw n;await mBp(n)}};return Promise.race([new Promise((n,a)=>{h3o(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},cKs=tbD();if(!cKs){let e=kCp();cKs=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 NBp=cKs,y3o=class{constructor(t){this.factory=t}async getValue(){return this.value!==void 0?this.value:(this.initializationPromise===void 0&&(this.initializationPromise=(async()=>{try{let t=await this.factory();return this.value=t,t}finally{this.initializationPromise=void 0}})()),this.initializationPromise)}isInitialized(){return this.value!==void 0}async waitForInitialization(){this.isInitialized()||await this.getValue()}},FBp=new y3o(async()=>{try{return await import("crypto")}catch{return}});async function abD(){return await FBp.getValue()}var obD=new y3o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await FBp.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function ubD(){return await obD.getValue()}async function sbD(e){let t=await abD();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await ubD();if(r){let i=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var cbD=60*1e3,lbD=1152921504606847e3,fbD=["is_not"],nFn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},R2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},lKs=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=l.fetch||NBp,this.onError=l.onError,this.customHeaders=u,this.onLoad=l.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=await this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof R2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return 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 await Promise.all(this.featureFlags.map(async d=>{try{let s=await this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof R2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}})),{response:a,payloads:u,fallbackToDecide:l}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new R2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new R2("Flag has unknown group type index");if(!(d 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[d];return await this.matchFeatureFlagProperties(t,i[d],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(await this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=await this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof R2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new R2("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=UBp(l,n,this.cohorts,this.debugMode):s=LBp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&await jBp(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await jBp(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()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(cbD,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new nFn(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new nFn(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new nFn(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof nFn&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=h3o(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=h3o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function jBp(e,t,r=""){let i=await sbD(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/lbD}function LBp(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 R2("Operator is_not_set is not supported")}else throw new R2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!fbD.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 d(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 wBp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return wBp(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"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=dbD(String(n));if(s==null&&(s=SBp(n)),s==null)throw new R2(`Invalid date: ${n}`);let o=SBp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new R2(`Unknown operator: ${a}`)}}function UBp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new R2("can't match cohort without a given cohort property value");let a=r[n];return VBp(a,t,r,i)}function VBp(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 d=VBp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof R2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new R2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=UBp(l,t,r,i):d=LBp(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof R2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new R2("can't match cohort without a given cohort property value");return n==="AND"}}function wBp(e){try{return new RegExp(e),!0}catch{return!1}}function SBp(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 R2(`${e} is in an invalid date format`)}else throw new R2(`The date provided ${e} must be a string, number, or date object`)}function dbD(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 fKs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},pbD=100,DBp=30*1e3,_bD=50*1e3,dKs=class extends sKs{constructor(t,r={}){if(super(t,r),this._memoryStorage=new fKs,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,pbD):DBp,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');this.featureFlagsPoller=new lKs({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new aFn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||_bD}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):NBp(t,r)}getLibraryVersion(){return WvD}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:u,timestamp:l,disableGeoip:d,uuid:s}=t,o=g=>{super.captureStateless(r,i,g,{timestamp:l,disableGeoip:d,uuid:s})},c=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags,b=Promise.resolve().then(async()=>{if(u)return await c(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[w,E]of Object.entries(g))O[`$feature/${w}`]=E;let m=Object.keys(g||{}).filter(w=>g?.[w]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...n,$groups:a})});this.addPendingPromise(b)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:u,timestamp:l,disableGeoip:d,uuid:s}=t,o=g=>super.captureStatelessImmediate(r,i,g,{timestamp:l,disableGeoip:d,uuid:s}),c=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags;await Promise.resolve().then(async()=>{if(u)return await c(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[w,E]of Object.entries(g))O[`$feature/${w}`]=E;let m=Object.keys(g||{}).filter(w=>g?.[w]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=DBp){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0,g,O;if(!b&&!u){let w=await super.getFeatureFlagDetailStateless(t,r,n,d,s,a);if(w===void 0)return;O=w.response,c=hKs(O),g=w?.requestId}let m=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(m))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(m):this.distinctIdHasSentFlagCalls[r]=[m],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,$feature_flag_id:O?.metadata?.id,$feature_flag_version:O?.metadata?.version,$feature_flag_reason:O?.reason?.description??O?.reason?.code,locally_evaluated:b,[`$feature/${t}`]:c,$feature_flag_request_id:g},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.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}}captureException(t,r,i){let n=new Error("PostHog syntheticException");aFn.captureException(this,t,{syntheticException:n},r,i)}},EBp=/\(error: (.*)\)/,WBp=50,HBp="?";function hbD(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,u,l,d,s;if(n[1]){l=n[1];let b=l.lastIndexOf(".");if(l[b-1]==="."&&b--,b>0){a=l.slice(0,b),u=l.slice(b+1);let g=a.indexOf(".Module");g>0&&(l=l.slice(g+1),a=a.slice(0,g))}d=void 0}u&&(d=a,s=u),u==="<anonymous>"&&(s=void 0,l=void 0),l===void 0&&(s=s||HBp,l=d?`${d}.${s}`:s);let o=n[2]?.startsWith("file://")?n[2].slice(7):n[2],c=n[5]==="native";return o?.match(/\/[A-Z]:/)&&(o=o.slice(1)),!o&&n[5]&&!c&&(o=n[5]),{filename:o?decodeURI(o):void 0,module:e?e(o):void 0,function:l,lineno:MBp(n[3]),colno:MBp(n[4]),in_app:ybD(o||"",c),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function ybD(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes("node_modules/")}function MBp(e){return parseInt(e||"",10)||void 0}function vbD(e){return[90,hbD(e)]}function bbD(e){let r=[vbD(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],u=i.split(`
|
|
1714
|
-
`);for(let l=n;l<u.length;l++){let d=u[l];if(d.length>1024)continue;let s=EBp.test(d)?d.replace(EBp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let c=o(s);if(c){a.push(c);break}}if(a.length>=WBp)break}}return gbD(a)}}function gbD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,WBp).map(r=>({...r,filename:r.filename||ObD(t).filename,function:r.function||HBp}))}function ObD(e){return e[e.length-1]||{}}aFn.stackParser=bbD(qvD());aFn.frameModifiers=[BvD];var uFn=class extends dKs{getLibraryId(){return"posthog-node"}};var v3o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new uFn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.64.18",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var lEa=class{async sendEvent(){}async identify(){}async flush(){}};var cFn=require("fs/promises"),JBp=require("os"),KBp=require("path");var $Bp=ai(require("crypto")),g3o=new Uint8Array(256),b3o=g3o.length;function yKs(){return b3o>g3o.length-16&&($Bp.default.randomFillSync(g3o),b3o=0),g3o.slice(b3o,b3o+=16)}var DW=[];for(let e=0;e<256;++e)DW.push((e+256).toString(16).slice(1));function GBp(e,t=0){return DW[e[t+0]]+DW[e[t+1]]+DW[e[t+2]]+DW[e[t+3]]+"-"+DW[e[t+4]]+DW[e[t+5]]+"-"+DW[e[t+6]]+DW[e[t+7]]+"-"+DW[e[t+8]]+DW[e[t+9]]+"-"+DW[e[t+10]]+DW[e[t+11]]+DW[e[t+12]]+DW[e[t+13]]+DW[e[t+14]]+DW[e[t+15]]}var QBp=ai(require("crypto")),vKs={randomUUID:QBp.default.randomUUID};function mbD(e,t,r){if(vKs.randomUUID&&!t&&!e)return vKs.randomUUID();e=e||{};let i=e.random||(e.rng||yKs)();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 GBp(i)}var hae=mbD;var PbD="id",jbD=".fern",fEa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new uFn(r),this.userId=t==null?void 0:uVs(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.64.18",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Lu(hl.of((0,JBp.homedir)()),Ua.of(jbD),Ua.of(PbD));await mf(t)||(await(0,cFn.mkdir)((0,KBp.dirname)(t),{recursive:!0}),await(0,cFn.writeFile)(t,hae())),this.persistedDistinctId=(await(0,cFn.readFile)(t)).toString()}return this.persistedDistinctId}};var bKs;async function lFn(){return bKs==null&&(bKs=await wbD()),bKs}async function wbD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new lEa;let r=await NBo();return r!=null?new fEa({token:r,posthogApiKey:e}):await cRn()!=null?new v3o({posthogApiKey:e}):new fEa({token:void 0,posthogApiKey:e})}catch{return new lEa}}function dEa(e,t){return function(){return e.apply(t,arguments)}}var{toString:SbD}=Object.prototype,{getPrototypeOf:OKs}=Object,{iterator:m3o,toStringTag:XBp}=Symbol,P3o=(e=>t=>{let r=SbD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),lWt=e=>(e=e.toLowerCase(),t=>P3o(t)===e),j3o=e=>t=>typeof t===e,{isArray:fFn}=Array,pEa=j3o("undefined");function DbD(e){return e!==null&&!pEa(e)&&e.constructor!==null&&!pEa(e.constructor)&&yae(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var ZBp=lWt("ArrayBuffer");function EbD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ZBp(e.buffer),t}var MbD=j3o("string"),yae=j3o("function"),kBp=j3o("number"),w3o=e=>e!==null&&typeof e=="object",AbD=e=>e===!0||e===!1,O3o=e=>{if(P3o(e)!=="object")return!1;let t=OKs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(XBp in e)&&!(m3o in e)},qbD=lWt("Date"),TbD=lWt("File"),CbD=lWt("Blob"),BbD=lWt("FileList"),IbD=e=>w3o(e)&&yae(e.pipe),zbD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||yae(e.append)&&((t=P3o(e))==="formdata"||t==="object"&&yae(e.toString)&&e.toString()==="[object FormData]"))},xbD=lWt("URLSearchParams"),[RbD,NbD,FbD,LbD]=["ReadableStream","Request","Response","Headers"].map(lWt),UbD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _Ea(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),fFn(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 eIp(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 UHi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,tIp=e=>!pEa(e)&&e!==UHi;function gKs(){let{caseless:e}=tIp(this)&&this||{},t={},r=(i,n)=>{let a=e&&eIp(t,n)||n;O3o(t[a])&&O3o(i)?t[a]=gKs(t[a],i):O3o(i)?t[a]=gKs({},i):fFn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&_Ea(arguments[i],r);return t}var VbD=(e,t,r,{allOwnKeys:i}={})=>(_Ea(t,(n,a)=>{r&&yae(n)?e[a]=dEa(n,r):e[a]=n},{allOwnKeys:i}),e),WbD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),HbD=(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)},$bD=(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&&OKs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},GbD=(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},QbD=e=>{if(!e)return null;if(fFn(e))return e;let t=e.length;if(!kBp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},JbD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&OKs(Uint8Array)),KbD=(e,t)=>{let i=(e&&e[m3o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},YbD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},XbD=lWt("HTMLFormElement"),ZbD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),YBp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),kbD=lWt("RegExp"),rIp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};_Ea(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},e0D=e=>{rIp(e,(t,r)=>{if(yae(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(yae(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+"'")})}})},t0D=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return fFn(e)?i(e):i(String(e).split(t)),r},r0D=()=>{},i0D=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function n0D(e){return!!(e&&yae(e.append)&&e[XBp]==="FormData"&&e[m3o])}var a0D=e=>{let t=new Array(10),r=(i,n)=>{if(w3o(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=fFn(i)?[]:{};return _Ea(i,(u,l)=>{let d=r(u,n+1);!pEa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},o0D=lWt("AsyncFunction"),u0D=e=>e&&(w3o(e)||yae(e))&&yae(e.then)&&yae(e.catch),iIp=((e,t)=>e?setImmediate:t?((r,i)=>(UHi.addEventListener("message",({source:n,data:a})=>{n===UHi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),UHi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",yae(UHi.postMessage)),s0D=typeof queueMicrotask<"u"?queueMicrotask.bind(UHi):typeof process<"u"&&process.nextTick||iIp,c0D=e=>e!=null&&yae(e[m3o]),us={isArray:fFn,isArrayBuffer:ZBp,isBuffer:DbD,isFormData:zbD,isArrayBufferView:EbD,isString:MbD,isNumber:kBp,isBoolean:AbD,isObject:w3o,isPlainObject:O3o,isReadableStream:RbD,isRequest:NbD,isResponse:FbD,isHeaders:LbD,isUndefined:pEa,isDate:qbD,isFile:TbD,isBlob:CbD,isRegExp:kbD,isFunction:yae,isStream:IbD,isURLSearchParams:xbD,isTypedArray:JbD,isFileList:BbD,forEach:_Ea,merge:gKs,extend:VbD,trim:UbD,stripBOM:WbD,inherits:HbD,toFlatObject:$bD,kindOf:P3o,kindOfTest:lWt,endsWith:GbD,toArray:QbD,forEachEntry:KbD,matchAll:YbD,isHTMLForm:XbD,hasOwnProperty:YBp,hasOwnProp:YBp,reduceDescriptors:rIp,freezeMethods:e0D,toObjectSet:t0D,toCamelCase:ZbD,noop:r0D,toFiniteNumber:i0D,findKey:eIp,global:UHi,isContextDefined:tIp,isSpecCompliantForm:n0D,toJSONObject:a0D,isAsyncFn:o0D,isThenable:u0D,setImmediate:iIp,asap:s0D,isIterable:c0D};function dFn(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)}us.inherits(dFn,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:us.toJSONObject(this.config),code:this.code,status:this.status}}});var nIp=dFn.prototype,aIp={};["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=>{aIp[e]={value:e}});Object.defineProperties(dFn,aIp);Object.defineProperty(nIp,"isAxiosError",{value:!0});dFn.from=(e,t,r,i,n,a)=>{let u=Object.create(nIp);return us.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),dFn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Np=dFn;var oIp=ai($Fo(),1),S3o=oIp.default;function mKs(e){return us.isPlainObject(e)||us.isArray(e)}function sIp(e){return us.endsWith(e,"[]")?e.slice(0,-2):e}function uIp(e,t,r){return e?e.concat(t).map(function(n,a){return n=sIp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function l0D(e){return us.isArray(e)&&!e.some(mKs)}var f0D=us.toFlatObject(us,{},null,function(t){return/^is[A-Z]/.test(t)});function d0D(e,t,r){if(!us.isObject(e))throw new TypeError("target must be an object");t=t||new(S3o||FormData),r=us.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!us.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&us.isSpecCompliantForm(t);if(!us.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(us.isDate(O))return O.toISOString();if(us.isBoolean(O))return O.toString();if(!d&&us.isBlob(O))throw new Np("Blob is not supported. Use a Buffer instead.");return us.isArrayBuffer(O)||us.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(us.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(us.isArray(O)&&l0D(O)||(us.isFileList(O)||us.endsWith(m,"[]"))&&(E=us.toArray(O)))return m=sIp(m),E.forEach(function(A,D){!(us.isUndefined(A)||A===null)&&t.append(u===!0?uIp([m],D,a):u===null?m:m+"[]",s(A))}),!1}return mKs(O)?!0:(t.append(uIp(w,m,a),s(O)),!1)}let c=[],b=Object.assign(f0D,{defaultVisitor:o,convertValue:s,isVisitable:mKs});function g(O,m){if(!us.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),us.forEach(O,function(E,q){(!(us.isUndefined(E)||E===null)&&n.call(t,E,us.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!us.isObject(e))throw new TypeError("data must be an object");return g(e),t}var JSi=d0D;function cIp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function lIp(e,t){this._pairs=[],e&&JSi(e,this,t)}var fIp=lIp.prototype;fIp.append=function(t,r){this._pairs.push([t,r])};fIp.toString=function(t){let r=t?function(i){return t.call(this,i,cIp)}:cIp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var dIp=lIp;function p0D(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function VHi(e,t,r){if(!t)return e;let i=r&&r.encode||p0D;us.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=us.isURLSearchParams(t)?t.toString():new dIp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var PKs=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){us.forEach(this.handlers,function(i){i!==null&&t(i)})}},jKs=PKs;var pFn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var yIp=ai(require("crypto"),1);var pIp=ai(require("url"),1),_Ip=pIp.default.URLSearchParams;var wKs="abcdefghijklmnopqrstuvwxyz",hIp="0123456789",vIp={DIGIT:hIp,ALPHA:wKs,ALPHA_DIGIT:wKs+wKs.toUpperCase()+hIp},_0D=(e=16,t=vIp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);yIp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},bIp={isNode:!0,classes:{URLSearchParams:_Ip,FormData:S3o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:vIp,generateString:_0D,protocols:["http","https","file","data"]};var EKs={};Dn(EKs,{hasBrowserEnv:()=>DKs,hasStandardBrowserEnv:()=>h0D,hasStandardBrowserWebWorkerEnv:()=>y0D,navigator:()=>SKs,origin:()=>v0D});var DKs=typeof window<"u"&&typeof document<"u",SKs=typeof navigator=="object"&&navigator||void 0,h0D=DKs&&(!SKs||["ReactNative","NativeScript","NS"].indexOf(SKs.product)<0),y0D=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",v0D=DKs&&window.location.href||"http://localhost";var aA={...EKs,...bIp};function MKs(e,t){return JSi(e,new aA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return aA.isNode&&us.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function b0D(e){return us.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function g0D(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 O0D(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&us.isArray(n)?n.length:u,d?(us.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!us.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&us.isArray(n[u])&&(n[u]=g0D(n[u])),!l)}if(us.isFormData(e)&&us.isFunction(e.entries)){let r={};return us.forEachEntry(e,(i,n)=>{t(b0D(i),n,r,0)}),r}return null}var D3o=O0D;function m0D(e,t,r){if(us.isString(e))try{return(t||JSON.parse)(e),us.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var AKs={transitional:pFn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=us.isObject(t);if(a&&us.isHTMLForm(t)&&(t=new FormData(t)),us.isFormData(t))return n?JSON.stringify(D3o(t)):t;if(us.isArrayBuffer(t)||us.isBuffer(t)||us.isStream(t)||us.isFile(t)||us.isBlob(t)||us.isReadableStream(t))return t;if(us.isArrayBufferView(t))return t.buffer;if(us.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 MKs(t,this.formSerializer).toString();if((l=us.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return JSi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),m0D(t)):t}],transformResponse:[function(t){let r=this.transitional||AKs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(us.isResponse(t)||us.isReadableStream(t))return t;if(t&&us.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"?Np.from(l,Np.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:aA.classes.FormData,Blob:aA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};us.forEach(["delete","get","head","post","put","patch"],e=>{AKs.headers[e]={}});var _Fn=AKs;var P0D=us.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"]),gIp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1714
|
+
`);for(let l=n;l<u.length;l++){let d=u[l];if(d.length>1024)continue;let s=EBp.test(d)?d.replace(EBp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let c=o(s);if(c){a.push(c);break}}if(a.length>=WBp)break}}return gbD(a)}}function gbD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,WBp).map(r=>({...r,filename:r.filename||ObD(t).filename,function:r.function||HBp}))}function ObD(e){return e[e.length-1]||{}}aFn.stackParser=bbD(qvD());aFn.frameModifiers=[BvD];var uFn=class extends dKs{getLibraryId(){return"posthog-node"}};var v3o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new uFn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.64.19",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var lEa=class{async sendEvent(){}async identify(){}async flush(){}};var cFn=require("fs/promises"),JBp=require("os"),KBp=require("path");var $Bp=ai(require("crypto")),g3o=new Uint8Array(256),b3o=g3o.length;function yKs(){return b3o>g3o.length-16&&($Bp.default.randomFillSync(g3o),b3o=0),g3o.slice(b3o,b3o+=16)}var DW=[];for(let e=0;e<256;++e)DW.push((e+256).toString(16).slice(1));function GBp(e,t=0){return DW[e[t+0]]+DW[e[t+1]]+DW[e[t+2]]+DW[e[t+3]]+"-"+DW[e[t+4]]+DW[e[t+5]]+"-"+DW[e[t+6]]+DW[e[t+7]]+"-"+DW[e[t+8]]+DW[e[t+9]]+"-"+DW[e[t+10]]+DW[e[t+11]]+DW[e[t+12]]+DW[e[t+13]]+DW[e[t+14]]+DW[e[t+15]]}var QBp=ai(require("crypto")),vKs={randomUUID:QBp.default.randomUUID};function mbD(e,t,r){if(vKs.randomUUID&&!t&&!e)return vKs.randomUUID();e=e||{};let i=e.random||(e.rng||yKs)();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 GBp(i)}var hae=mbD;var PbD="id",jbD=".fern",fEa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new uFn(r),this.userId=t==null?void 0:uVs(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.64.19",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Lu(hl.of((0,JBp.homedir)()),Ua.of(jbD),Ua.of(PbD));await mf(t)||(await(0,cFn.mkdir)((0,KBp.dirname)(t),{recursive:!0}),await(0,cFn.writeFile)(t,hae())),this.persistedDistinctId=(await(0,cFn.readFile)(t)).toString()}return this.persistedDistinctId}};var bKs;async function lFn(){return bKs==null&&(bKs=await wbD()),bKs}async function wbD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new lEa;let r=await NBo();return r!=null?new fEa({token:r,posthogApiKey:e}):await cRn()!=null?new v3o({posthogApiKey:e}):new fEa({token:void 0,posthogApiKey:e})}catch{return new lEa}}function dEa(e,t){return function(){return e.apply(t,arguments)}}var{toString:SbD}=Object.prototype,{getPrototypeOf:OKs}=Object,{iterator:m3o,toStringTag:XBp}=Symbol,P3o=(e=>t=>{let r=SbD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),lWt=e=>(e=e.toLowerCase(),t=>P3o(t)===e),j3o=e=>t=>typeof t===e,{isArray:fFn}=Array,pEa=j3o("undefined");function DbD(e){return e!==null&&!pEa(e)&&e.constructor!==null&&!pEa(e.constructor)&&yae(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var ZBp=lWt("ArrayBuffer");function EbD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ZBp(e.buffer),t}var MbD=j3o("string"),yae=j3o("function"),kBp=j3o("number"),w3o=e=>e!==null&&typeof e=="object",AbD=e=>e===!0||e===!1,O3o=e=>{if(P3o(e)!=="object")return!1;let t=OKs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(XBp in e)&&!(m3o in e)},qbD=lWt("Date"),TbD=lWt("File"),CbD=lWt("Blob"),BbD=lWt("FileList"),IbD=e=>w3o(e)&&yae(e.pipe),zbD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||yae(e.append)&&((t=P3o(e))==="formdata"||t==="object"&&yae(e.toString)&&e.toString()==="[object FormData]"))},xbD=lWt("URLSearchParams"),[RbD,NbD,FbD,LbD]=["ReadableStream","Request","Response","Headers"].map(lWt),UbD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _Ea(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),fFn(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 eIp(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 UHi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,tIp=e=>!pEa(e)&&e!==UHi;function gKs(){let{caseless:e}=tIp(this)&&this||{},t={},r=(i,n)=>{let a=e&&eIp(t,n)||n;O3o(t[a])&&O3o(i)?t[a]=gKs(t[a],i):O3o(i)?t[a]=gKs({},i):fFn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&_Ea(arguments[i],r);return t}var VbD=(e,t,r,{allOwnKeys:i}={})=>(_Ea(t,(n,a)=>{r&&yae(n)?e[a]=dEa(n,r):e[a]=n},{allOwnKeys:i}),e),WbD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),HbD=(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)},$bD=(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&&OKs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},GbD=(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},QbD=e=>{if(!e)return null;if(fFn(e))return e;let t=e.length;if(!kBp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},JbD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&OKs(Uint8Array)),KbD=(e,t)=>{let i=(e&&e[m3o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},YbD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},XbD=lWt("HTMLFormElement"),ZbD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),YBp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),kbD=lWt("RegExp"),rIp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};_Ea(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},e0D=e=>{rIp(e,(t,r)=>{if(yae(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(yae(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+"'")})}})},t0D=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return fFn(e)?i(e):i(String(e).split(t)),r},r0D=()=>{},i0D=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function n0D(e){return!!(e&&yae(e.append)&&e[XBp]==="FormData"&&e[m3o])}var a0D=e=>{let t=new Array(10),r=(i,n)=>{if(w3o(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=fFn(i)?[]:{};return _Ea(i,(u,l)=>{let d=r(u,n+1);!pEa(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},o0D=lWt("AsyncFunction"),u0D=e=>e&&(w3o(e)||yae(e))&&yae(e.then)&&yae(e.catch),iIp=((e,t)=>e?setImmediate:t?((r,i)=>(UHi.addEventListener("message",({source:n,data:a})=>{n===UHi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),UHi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",yae(UHi.postMessage)),s0D=typeof queueMicrotask<"u"?queueMicrotask.bind(UHi):typeof process<"u"&&process.nextTick||iIp,c0D=e=>e!=null&&yae(e[m3o]),us={isArray:fFn,isArrayBuffer:ZBp,isBuffer:DbD,isFormData:zbD,isArrayBufferView:EbD,isString:MbD,isNumber:kBp,isBoolean:AbD,isObject:w3o,isPlainObject:O3o,isReadableStream:RbD,isRequest:NbD,isResponse:FbD,isHeaders:LbD,isUndefined:pEa,isDate:qbD,isFile:TbD,isBlob:CbD,isRegExp:kbD,isFunction:yae,isStream:IbD,isURLSearchParams:xbD,isTypedArray:JbD,isFileList:BbD,forEach:_Ea,merge:gKs,extend:VbD,trim:UbD,stripBOM:WbD,inherits:HbD,toFlatObject:$bD,kindOf:P3o,kindOfTest:lWt,endsWith:GbD,toArray:QbD,forEachEntry:KbD,matchAll:YbD,isHTMLForm:XbD,hasOwnProperty:YBp,hasOwnProp:YBp,reduceDescriptors:rIp,freezeMethods:e0D,toObjectSet:t0D,toCamelCase:ZbD,noop:r0D,toFiniteNumber:i0D,findKey:eIp,global:UHi,isContextDefined:tIp,isSpecCompliantForm:n0D,toJSONObject:a0D,isAsyncFn:o0D,isThenable:u0D,setImmediate:iIp,asap:s0D,isIterable:c0D};function dFn(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)}us.inherits(dFn,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:us.toJSONObject(this.config),code:this.code,status:this.status}}});var nIp=dFn.prototype,aIp={};["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=>{aIp[e]={value:e}});Object.defineProperties(dFn,aIp);Object.defineProperty(nIp,"isAxiosError",{value:!0});dFn.from=(e,t,r,i,n,a)=>{let u=Object.create(nIp);return us.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),dFn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Np=dFn;var oIp=ai($Fo(),1),S3o=oIp.default;function mKs(e){return us.isPlainObject(e)||us.isArray(e)}function sIp(e){return us.endsWith(e,"[]")?e.slice(0,-2):e}function uIp(e,t,r){return e?e.concat(t).map(function(n,a){return n=sIp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function l0D(e){return us.isArray(e)&&!e.some(mKs)}var f0D=us.toFlatObject(us,{},null,function(t){return/^is[A-Z]/.test(t)});function d0D(e,t,r){if(!us.isObject(e))throw new TypeError("target must be an object");t=t||new(S3o||FormData),r=us.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!us.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&us.isSpecCompliantForm(t);if(!us.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(us.isDate(O))return O.toISOString();if(us.isBoolean(O))return O.toString();if(!d&&us.isBlob(O))throw new Np("Blob is not supported. Use a Buffer instead.");return us.isArrayBuffer(O)||us.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(us.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(us.isArray(O)&&l0D(O)||(us.isFileList(O)||us.endsWith(m,"[]"))&&(E=us.toArray(O)))return m=sIp(m),E.forEach(function(A,D){!(us.isUndefined(A)||A===null)&&t.append(u===!0?uIp([m],D,a):u===null?m:m+"[]",s(A))}),!1}return mKs(O)?!0:(t.append(uIp(w,m,a),s(O)),!1)}let c=[],b=Object.assign(f0D,{defaultVisitor:o,convertValue:s,isVisitable:mKs});function g(O,m){if(!us.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),us.forEach(O,function(E,q){(!(us.isUndefined(E)||E===null)&&n.call(t,E,us.isString(q)?q.trim():q,m,b))===!0&&g(E,m?m.concat(q):[q])}),c.pop()}}if(!us.isObject(e))throw new TypeError("data must be an object");return g(e),t}var JSi=d0D;function cIp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function lIp(e,t){this._pairs=[],e&&JSi(e,this,t)}var fIp=lIp.prototype;fIp.append=function(t,r){this._pairs.push([t,r])};fIp.toString=function(t){let r=t?function(i){return t.call(this,i,cIp)}:cIp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var dIp=lIp;function p0D(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function VHi(e,t,r){if(!t)return e;let i=r&&r.encode||p0D;us.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=us.isURLSearchParams(t)?t.toString():new dIp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var PKs=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){us.forEach(this.handlers,function(i){i!==null&&t(i)})}},jKs=PKs;var pFn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var yIp=ai(require("crypto"),1);var pIp=ai(require("url"),1),_Ip=pIp.default.URLSearchParams;var wKs="abcdefghijklmnopqrstuvwxyz",hIp="0123456789",vIp={DIGIT:hIp,ALPHA:wKs,ALPHA_DIGIT:wKs+wKs.toUpperCase()+hIp},_0D=(e=16,t=vIp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);yIp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},bIp={isNode:!0,classes:{URLSearchParams:_Ip,FormData:S3o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:vIp,generateString:_0D,protocols:["http","https","file","data"]};var EKs={};Dn(EKs,{hasBrowserEnv:()=>DKs,hasStandardBrowserEnv:()=>h0D,hasStandardBrowserWebWorkerEnv:()=>y0D,navigator:()=>SKs,origin:()=>v0D});var DKs=typeof window<"u"&&typeof document<"u",SKs=typeof navigator=="object"&&navigator||void 0,h0D=DKs&&(!SKs||["ReactNative","NativeScript","NS"].indexOf(SKs.product)<0),y0D=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",v0D=DKs&&window.location.href||"http://localhost";var aA={...EKs,...bIp};function MKs(e,t){return JSi(e,new aA.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return aA.isNode&&us.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function b0D(e){return us.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function g0D(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 O0D(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&us.isArray(n)?n.length:u,d?(us.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!us.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&us.isArray(n[u])&&(n[u]=g0D(n[u])),!l)}if(us.isFormData(e)&&us.isFunction(e.entries)){let r={};return us.forEachEntry(e,(i,n)=>{t(b0D(i),n,r,0)}),r}return null}var D3o=O0D;function m0D(e,t,r){if(us.isString(e))try{return(t||JSON.parse)(e),us.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var AKs={transitional:pFn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=us.isObject(t);if(a&&us.isHTMLForm(t)&&(t=new FormData(t)),us.isFormData(t))return n?JSON.stringify(D3o(t)):t;if(us.isArrayBuffer(t)||us.isBuffer(t)||us.isStream(t)||us.isFile(t)||us.isBlob(t)||us.isReadableStream(t))return t;if(us.isArrayBufferView(t))return t.buffer;if(us.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 MKs(t,this.formSerializer).toString();if((l=us.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return JSi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),m0D(t)):t}],transformResponse:[function(t){let r=this.transitional||AKs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(us.isResponse(t)||us.isReadableStream(t))return t;if(t&&us.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"?Np.from(l,Np.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:aA.classes.FormData,Blob:aA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};us.forEach(["delete","get","head","post","put","patch"],e=>{AKs.headers[e]={}});var _Fn=AKs;var P0D=us.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"]),gIp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1715
1715
|
`).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&P0D[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var OIp=Symbol("internals");function hEa(e){return e&&String(e).trim().toLowerCase()}function E3o(e){return e===!1||e==null?e:us.isArray(e)?e.map(E3o):String(e)}function j0D(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 w0D=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function qKs(e,t,r,i,n){if(us.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!us.isString(t)){if(us.isString(i))return t.indexOf(i)!==-1;if(us.isRegExp(i))return i.test(t)}}function S0D(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function D0D(e,t){let r=us.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 hFn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,d,s){let o=hEa(d);if(!o)throw new Error("header name must be a non-empty string");let c=us.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||d]=E3o(l))}let u=(l,d)=>us.forEach(l,(s,o)=>a(s,o,d));if(us.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(us.isString(t)&&(t=t.trim())&&!w0D(t))u(gIp(t),r);else if(us.isObject(t)&&us.isIterable(t)){let l={},d,s;for(let o of t){if(!us.isArray(o))throw TypeError("Object iterator must return a key-value pair");l[s=o[0]]=(d=l[s])?us.isArray(d)?[...d,o[1]]:[d,o[1]]:o[1]}u(l,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=hEa(t),t){let i=us.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return j0D(n);if(us.isFunction(r))return r.call(this,n,i);if(us.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=hEa(t),t){let i=us.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||qKs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=hEa(u),u){let l=us.findKey(i,u);l&&(!r||qKs(i,i[l],l,r))&&(delete i[l],n=!0)}}return us.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||qKs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return us.forEach(this,(n,a)=>{let u=us.findKey(i,a);if(u){r[u]=E3o(n),delete r[a];return}let l=t?S0D(a):String(a).trim();l!==a&&delete r[a],r[l]=E3o(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return us.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&us.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(`
|
|
1716
1716
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[OIp]=this[OIp]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=hEa(u);i[l]||(D0D(n,u),i[l]=!0)}return us.isArray(t)?t.forEach(a):a(t),this}};hFn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);us.reduceDescriptors(hFn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});us.freezeMethods(hFn);var rR=hFn;function yEa(e,t){let r=this||_Fn,i=t||r,n=rR.from(i.headers),a=i.data;return us.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function vEa(e){return!!(e&&e.__CANCEL__)}function mIp(e,t,r){Np.call(this,e??"canceled",Np.ERR_CANCELED,t,r),this.name="CanceledError"}us.inherits(mIp,Np,{__CANCEL__:!0});var HEe=mIp;function $tr(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new Np("Request failed with status code "+r.status,[Np.ERR_BAD_REQUEST,Np.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function TKs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function CKs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function WHi(e,t,r){let i=!TKs(t);return e&&(i||r==!1)?CKs(e,t):t}var RIp=ai(kDa(),1),NIp=ai(require("http"),1),FIp=ai(require("https"),1),LIp=ai(require("util"),1),UIp=ai(CJs(),1),lfi=ai(require("zlib"),1);var HHi="1.10.0";function bEa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var E0D=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function BKs(e,t,r){let i=r&&r.Blob||aA.classes.Blob,n=bEa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=E0D.exec(e);if(!a)throw new Np("Invalid URL",Np.ERR_INVALID_URL);let u=a[1],l=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),l?"base64":"utf8");if(t){if(!i)throw new Np("Blob is not supported",Np.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new Np("Unsupported protocol "+n,Np.ERR_NOT_SUPPORT)}var GHi=ai(require("stream"),1);var PIp=ai(require("stream"),1);var IKs=Symbol("internals"),zKs=class extends PIp.default.Transform{constructor(t){t=us.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!us.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[IKs]={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[IKs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[IKs],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,d=1e3/l,s=a/d,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),w=null,E=u,q,A=0;if(a){let D=Date.now();(!n.ts||(A=D-n.ts)>=l)&&(n.ts=D,q=s-n.bytes,n.bytes=q<0?-q:0,A=0),q=s-n.bytes}if(a){if(q<=0)return setTimeout(()=>{O(null,g)},l-A);q<E&&(E=q)}E&&m>E&&m-E>o&&(w=g.subarray(E),g=g.subarray(0,E)),c(g,w?()=>{process.nextTick(O,null,w)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},xKs=zKs;var VIp=require("events");var wIp=ai(require("util"),1),SIp=require("stream");var{asyncIterator:jIp}=Symbol,M0D=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[jIp]?yield*e[jIp]():yield e},M3o=M0D;var A0D=aA.ALPHABET.ALPHA_DIGIT+"-_",gEa=typeof TextEncoder=="function"?new TextEncoder:new wIp.default.TextEncoder,$Hi=`\r
|
|
1717
1717
|
`,q0D=gEa.encode($Hi),T0D=2,RKs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=us.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${$Hi}`;n?r=gEa.encode(String(r).replace(/\r?\n|\r\n?/g,$Hi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${$Hi}`,this.headers=gEa.encode(a+$Hi),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+T0D,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;us.isTypedArray(t)?yield t:yield*M3o(t),yield q0D}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},C0D=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+aA.generateString(n,A0D)}=r||{};if(!us.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=gEa.encode("--"+a+$Hi),l=gEa.encode("--"+a+"--"+$Hi),d=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new RKs(c,b);return d+=g.size,g});d+=u.byteLength*s.length,d=us.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),SIp.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},DIp=C0D;var EIp=ai(require("stream"),1),NKs=class extends EIp.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)}},MIp=NKs;var B0D=(e,t)=>us.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,AIp=B0D;function I0D(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(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,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 qIp=I0D;function z0D(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 TIp=z0D;var cfi=(e,t,r=3)=>{let i=0,n=qIp(50,250);return TIp(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:d,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)},yFn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},vFn=e=>(...t)=>us.asap(()=>e(...t));var CIp={flush:lfi.default.constants.Z_SYNC_FLUSH,finishFlush:lfi.default.constants.Z_SYNC_FLUSH},x0D={flush:lfi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:lfi.default.constants.BROTLI_OPERATION_FLUSH},BIp=us.isFunction(lfi.default.createBrotliDecompress),{http:R0D,https:N0D}=UIp.default,F0D=/https:?/,IIp=aA.protocols.map(e=>e+":"),zIp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function L0D(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function WIp(e,t,r){let i=t;if(!i&&i!==!1){let n=RIp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){WIp(a,t,a.href)}}var U0D=typeof process<"u"&&us.kindOf(process)==="process",V0D=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},l=d=>{a(d,!0),r(d)};e(u,l,d=>i=d).catch(l)}),W0D=({address:e,family:t})=>{if(!us.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},xIp=(e,t)=>W0D(us.isObject(e)?e:{address:e,family:t}),HIp=U0D&&function(t){return V0D(async function(i,n,a){let{data:u,lookup:l,family:d}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let Oe=AIp(l,Ue=>us.isArray(Ue)?Ue:[Ue]);l=(Ue,wt,De)=>{Oe(Ue,wt,(Te,xt,Pe)=>{if(Te)return De(Te);let ot=us.isArray(xt)?xt.map(at=>xIp(at)):[xIp(xt,Pe)];wt.all?De(Te,ot):De(Te,ot[0].address,ot[0].family)})}}let m=new VIp.EventEmitter,w=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((Oe,Ue)=>{b=!0,Ue&&(g=!0,w())});function E(Oe){m.emit("abort",!Oe||Oe.type?new HEe(null,t,O):Oe)}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 q=WHi(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(q,aA.hasBrowserEnv?aA.origin:void 0),D=A.protocol||IIp[0];if(D==="data:"){let Oe;if(c!=="GET")return $tr(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Oe=BKs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Ue){throw Np.from(Ue,Np.ERR_BAD_REQUEST,t)}return s==="text"?(Oe=Oe.toString(o),(!o||o==="utf8")&&(Oe=us.stripBOM(Oe))):s==="stream"&&(Oe=GHi.default.Readable.from(Oe)),$tr(i,n,{data:Oe,status:200,statusText:"OK",headers:new rR,config:t})}if(IIp.indexOf(D)===-1)return n(new Np("Unsupported protocol "+D,Np.ERR_BAD_REQUEST,t));let C=rR.from(t.headers).normalize();C.set("User-Agent","axios/"+HHi,!1);let{onUploadProgress:x,onDownloadProgress:$}=t,I=t.maxRate,L,V;if(us.isSpecCompliantForm(u)){let Oe=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=DIp(u,Ue=>{C.set(Ue)},{tag:`axios-${HHi}-boundary`,boundary:Oe&&Oe[1]||void 0})}else if(us.isFormData(u)&&us.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let Oe=await LIp.default.promisify(u.getLength).call(u);Number.isFinite(Oe)&&Oe>=0&&C.setContentLength(Oe)}catch{}}else if(us.isBlob(u)||us.isFile(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=GHi.default.Readable.from(M3o(u));else if(u&&!us.isStream(u)){if(!Buffer.isBuffer(u))if(us.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(us.isString(u))u=Buffer.from(u,"utf-8");else return n(new Np("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Np.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new Np("Request body larger than maxBodyLength limit",Np.ERR_BAD_REQUEST,t))}let K=us.toFiniteNumber(C.getContentLength());us.isArray(I)?(L=I[0],V=I[1]):L=V=I,u&&(x||L)&&(us.isStream(u)||(u=GHi.default.Readable.from(u,{objectMode:!1})),u=GHi.default.pipeline([u,new xKs({maxRate:us.toFiniteNumber(L)})],us.noop),x&&u.on("progress",zIp(u,yFn(K,cfi(vFn(x),!1,3)))));let Y;if(t.auth){let Oe=t.auth.username||"",Ue=t.auth.password||"";Y=Oe+":"+Ue}if(!Y&&A.username){let Oe=A.username,Ue=A.password;Y=Oe+":"+Ue}Y&&C.delete("authorization");let Z;try{Z=VHi(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Oe){let Ue=new Error(Oe.message);return Ue.config=t,Ue.url=t.url,Ue.exists=!0,n(Ue)}C.set("Accept-Encoding","gzip, compress, deflate"+(BIp?", br":""),!1);let oe={path:Z,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:Y,protocol:D,family:d,beforeRedirect:L0D,beforeRedirects:{}};!us.isUndefined(l)&&(oe.lookup=l),t.socketPath?oe.socketPath=t.socketPath:(oe.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,oe.port=A.port,WIp(oe,t.proxy,D+"//"+A.hostname+(A.port?":"+A.port:"")+oe.path));let _e,de=F0D.test(oe.protocol);if(oe.agent=de?t.httpsAgent:t.httpAgent,t.transport?_e=t.transport:t.maxRedirects===0?_e=de?FIp.default:NIp.default:(t.maxRedirects&&(oe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(oe.beforeRedirects.config=t.beforeRedirect),_e=de?N0D:R0D),t.maxBodyLength>-1?oe.maxBodyLength=t.maxBodyLength:oe.maxBodyLength=1/0,t.insecureHTTPParser&&(oe.insecureHTTPParser=t.insecureHTTPParser),O=_e.request(oe,function(Ue){if(O.destroyed)return;let wt=[Ue],De=+Ue.headers["content-length"];if($||V){let at=new xKs({maxRate:us.toFiniteNumber(V)});$&&at.on("progress",zIp(at,yFn(De,cfi(vFn($),!0,3)))),wt.push(at)}let Te=Ue,xt=Ue.req||O;if(t.decompress!==!1&&Ue.headers["content-encoding"])switch((c==="HEAD"||Ue.statusCode===204)&&delete Ue.headers["content-encoding"],(Ue.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":wt.push(lfi.default.createUnzip(CIp)),delete Ue.headers["content-encoding"];break;case"deflate":wt.push(new MIp),wt.push(lfi.default.createUnzip(CIp)),delete Ue.headers["content-encoding"];break;case"br":BIp&&(wt.push(lfi.default.createBrotliDecompress(x0D)),delete Ue.headers["content-encoding"])}Te=wt.length>1?GHi.default.pipeline(wt,us.noop):wt[0];let Pe=GHi.default.finished(Te,()=>{Pe(),w()}),ot={status:Ue.statusCode,statusText:Ue.statusMessage,headers:new rR(Ue.headers),config:t,request:xt};if(s==="stream")ot.data=Te,$tr(i,n,ot);else{let at=[],me=0;Te.on("data",function(jt){at.push(jt),me+=jt.length,t.maxContentLength>-1&&me>t.maxContentLength&&(g=!0,Te.destroy(),n(new Np("maxContentLength size of "+t.maxContentLength+" exceeded",Np.ERR_BAD_RESPONSE,t,xt)))}),Te.on("aborted",function(){if(g)return;let jt=new Np("stream has been aborted",Np.ERR_BAD_RESPONSE,t,xt);Te.destroy(jt),n(jt)}),Te.on("error",function(jt){O.destroyed||n(Np.from(jt,null,t,xt))}),Te.on("end",function(){try{let jt=at.length===1?at[0]:Buffer.concat(at);s!=="arraybuffer"&&(jt=jt.toString(o),(!o||o==="utf8")&&(jt=us.stripBOM(jt))),ot.data=jt}catch(jt){return n(Np.from(jt,null,t,ot.request,ot))}$tr(i,n,ot)})}m.once("abort",at=>{Te.destroyed||(Te.emit("error",at),Te.destroy())})}),m.once("abort",Oe=>{n(Oe),O.destroy(Oe)}),O.on("error",function(Ue){n(Np.from(Ue,null,t,O))}),O.on("socket",function(Ue){Ue.setKeepAlive(!0,1e3*60)}),t.timeout){let Oe=parseInt(t.timeout,10);if(Number.isNaN(Oe)){n(new Np("error trying to parse `config.timeout` to int",Np.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(Oe,function(){if(b)return;let wt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",De=t.transitional||pFn;t.timeoutErrorMessage&&(wt=t.timeoutErrorMessage),n(new Np(wt,De.clarifyTimeoutError?Np.ETIMEDOUT:Np.ECONNABORTED,t,O)),E()})}if(us.isStream(u)){let Oe=!1,Ue=!1;u.on("end",()=>{Oe=!0}),u.once("error",wt=>{Ue=!0,O.destroy(wt)}),u.on("close",()=>{!Oe&&!Ue&&E(new HEe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var $Ip=aA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,aA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(aA.origin),aA.navigator&&/(msie|trident)/i.test(aA.navigator.userAgent)):()=>!0;var GIp=aA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];us.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),us.isString(i)&&u.push("path="+i),us.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 QIp=e=>e instanceof rR?{...e}:e;function fWt(e,t){t=t||{};let r={};function i(s,o,c,b){return us.isPlainObject(s)&&us.isPlainObject(o)?us.merge.call({caseless:b},s,o):us.isPlainObject(o)?us.merge({},o):us.isArray(o)?o.slice():o}function n(s,o,c,b){if(us.isUndefined(o)){if(!us.isUndefined(s))return i(void 0,s,c,b)}else return i(s,o,c,b)}function a(s,o){if(!us.isUndefined(o))return i(void 0,o)}function u(s,o){if(us.isUndefined(o)){if(!us.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 d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o,c)=>n(QIp(s),QIp(o),c,!0)};return us.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=d[o]||n,b=c(e[o],t[o],o);us.isUndefined(b)&&c!==l||(r[o]=b)}),r}var A3o=e=>{let t=fWt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=rR.from(u),t.url=VHi(WHi(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(us.isFormData(r)){if(aA.hasStandardBrowserEnv||aA.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(aA.hasStandardBrowserEnv&&(i&&us.isFunction(i)&&(i=i(t)),i||i!==!1&&$Ip(t.url))){let s=n&&a&&GIp.read(a);s&&u.set(n,s)}return t};var H0D=typeof XMLHttpRequest<"u",JIp=H0D&&function(e){return new Promise(function(r,i){let n=A3o(e),a=n.data,u=rR.from(n.headers).normalize(),{responseType:l,onUploadProgress:d,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 w=new XMLHttpRequest;w.open(n.method.toUpperCase(),n.url,!0),w.timeout=n.timeout;function E(){if(!w)return;let A=rR.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:A,config:e,request:w};$tr(function($){r($),m()},function($){i($),m()},C),w=null}"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(E)},w.onabort=function(){w&&(i(new Np("Request aborted",Np.ECONNABORTED,e,w)),w=null)},w.onerror=function(){i(new Np("Network Error",Np.ERR_NETWORK,e,w)),w=null},w.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||pFn;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new Np(D,C.clarifyTimeoutError?Np.ETIMEDOUT:Np.ECONNABORTED,e,w)),w=null},a===void 0&&u.setContentType(null),"setRequestHeader"in w&&us.forEach(u.toJSON(),function(D,C){w.setRequestHeader(C,D)}),us.isUndefined(n.withCredentials)||(w.withCredentials=!!n.withCredentials),l&&l!=="json"&&(w.responseType=n.responseType),s&&([b,O]=cfi(s,!0),w.addEventListener("progress",b)),d&&w.upload&&([c,g]=cfi(d),w.upload.addEventListener("progress",c),w.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=A=>{w&&(i(!A||A.type?new HEe(null,e,w):A),w.abort(),w=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let q=bEa(n.url);if(q&&aA.protocols.indexOf(q)===-1){i(new Np("Unsupported protocol "+q+":",Np.ERR_BAD_REQUEST,e));return}w.send(a||null)})};var $0D=(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 Np?o:new HEe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new Np(`timeout ${t} of ms exceeded`,Np.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:d}=i;return d.unsubscribe=()=>us.asap(l),d}},KIp=$0D;var G0D=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},Q0D=async function*(e,t){for await(let r of J0D(e))yield*G0D(r,t)},J0D=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()}},FKs=(e,t,r,i)=>{let n=Q0D(e,t),a=0,u,l=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){l(),d.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(d){return l(d),n.return()}},{highWaterMark:2})};var T3o=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",XIp=T3o&&typeof ReadableStream=="function",K0D=T3o&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),ZIp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Y0D=XIp&&ZIp(()=>{let e=!1,t=new Request(aA.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),YIp=64*1024,LKs=XIp&&ZIp(()=>us.isReadableStream(new Response("").body)),q3o={stream:LKs&&(e=>e.body)};T3o&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!q3o[t]&&(q3o[t]=us.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new Np(`Response type '${t}' is not supported`,Np.ERR_NOT_SUPPORT,i)})})})(new Response);var X0D=async e=>{if(e==null)return 0;if(us.isBlob(e))return e.size;if(us.isSpecCompliantForm(e))return(await new Request(aA.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(us.isArrayBufferView(e)||us.isArrayBuffer(e))return e.byteLength;if(us.isURLSearchParams(e)&&(e=e+""),us.isString(e))return(await K0D(e)).byteLength},Z0D=async(e,t)=>{let r=us.toFiniteNumber(e.getContentLength());return r??X0D(t)},kIp=T3o&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:d,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=A3o(e);s=s?(s+"").toLowerCase():"text";let g=KIp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),w;try{if(d&&Y0D&&r!=="get"&&r!=="head"&&(w=await Z0D(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),x;if(us.isFormData(i)&&(x=C.headers.get("content-type"))&&o.setContentType(x),C.body){let[$,I]=yFn(w,cfi(vFn(d)));i=FKs(C.body,YIp,$,I)}}us.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 q=await fetch(O,b),A=LKs&&(s==="stream"||s==="response");if(LKs&&(l||A&&m)){let C={};["status","statusText","headers"].forEach(L=>{C[L]=q[L]});let x=us.toFiniteNumber(q.headers.get("content-length")),[$,I]=l&&yFn(x,cfi(vFn(l),!0))||[];q=new Response(FKs(q.body,YIp,$,()=>{I&&I(),m&&m()}),C)}s=s||"text";let D=await q3o[us.findKey(q3o,s)||"text"](q,e);return!A&&m&&m(),await new Promise((C,x)=>{$tr(C,x,{data:D,headers:rR.from(q.headers),status:q.status,statusText:q.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new Np("Network Error",Np.ERR_NETWORK,e,O),{cause:E.cause||E}):Np.from(E,E&&E.code,e,O)}});var UKs={http:HIp,xhr:JIp,fetch:kIp};us.forEach(UKs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var ezp=e=>`- ${e}`,k0D=e=>us.isFunction(e)||e===null||e===!1,C3o={getAdapter:e=>{e=us.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,!k0D(r)&&(i=UKs[(u=String(r)).toLowerCase()],i===void 0))throw new Np(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1952,7 +1952,7 @@ ${A}${q}${D}${vKp.default.cursorHide}`});var YTa=ai(Cwi(),1);function Eoc(e,t){i
|
|
|
1952
1952
|
Run ${Ds.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1953
1953
|
Run ${Ds.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),gFn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Noc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!UKp(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,d)=>l.generatorName.localeCompare(d.generatorName)||l.currentVersion.localeCompare(d.currentVersion));for(let l of u)n+=`
|
|
1954
1954
|
${await SUD(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Ds.dim(l.currentVersion)+Ds.reset(" \u2192 ")+Ds.green(l.latestVersion);return n+=`
|
|
1955
|
-
`,i?gFn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function SUD(e){let r=await new LKp.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 DUD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await WKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Twi(o.name,c),g=await kZt({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 WKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=Twi(s.name,o),b=await kZt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function WKp({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 RVt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function HKp(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 d=qae(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function RLo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await DUD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...HKp(s,d,t.logger));else u.push(...HKp(l.versions,void 0,t.logger))}return u}var nCa=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 Z6n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Foc=(()=>{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})(),$Kp=typeof globalThis.AbortController=="function",GKp=typeof globalThis.ReadableStream=="function",QKp=typeof globalThis.FormData=="function",NLo=["get","post","put","patch","head","delete"],EUD=()=>{};EUD();var JKp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},FLo=2147483647,KKp=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,LLo=Symbol("stop"),YKp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},XKp={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 MUD=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=KKp,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},ZKp=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:l,value:d}=await a.read();if(l){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},kKp=(e,t)=>{let r=MUD(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:l,value:d}=await a.read();if(l){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var k6n=e=>e!==null&&typeof e=="object";var aCa=(...e)=>{for(let t of e)if((!k6n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Voc({},...e)},Loc=(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 ULo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Voc(e[r]??[],t[r]??[])}var Uoc=(e={},t={})=>({beforeRequest:ULo(e,t,"beforeRequest"),beforeRetry:ULo(e,t,"beforeRetry"),afterResponse:ULo(e,t,"afterResponse"),beforeError:ULo(e,t,"beforeError")}),Voc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(k6n(n)){for(let[a,u]of Object.entries(n))k6n(u)&&a in t&&(u=Voc(t[a],u)),t={...t,[a]:u};k6n(n.hooks)&&(i=Uoc(i,n.hooks),t.hooks=i),k6n(n.headers)&&(r=Loc(r,n.headers),t.headers=r)}return t};var tYp=e=>NLo.includes(e)?e.toUpperCase():e,AUD=["get","put","head","delete","options","trace"],qUD=[408,413,429,500,502,503,504],TUD=[413,429,503],eYp={limit:2,methods:AUD,statusCodes:qUD,afterStatusCodes:TUD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},rYp=(e={})=>{if(typeof e=="number")return{...eYp,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{...eYp,...e}};async function Woc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Z6n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function Hoc(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 iYp=(e,t)=>{let r={};for(let i in t)!(i in XKp)&&!(i in YKp)&&!(i in e)&&(r[i]=t[i]);return r};var oCa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>FLo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FLo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new nCa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!GKp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return ZKp(l.clone(),i._options.onDownloadProgress)}return l},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[l,d]of Object.entries(JKp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(l==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Loc(this._input.headers,r.headers),hooks:Uoc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:tYp(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:rYp(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($Kp){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Foc&&(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);(QKp&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Foc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=kKp(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Z6n)throw t;if(t instanceof nCa){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),FLo);if(this._retryCount<1)throw r;await Hoc(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})===LLo)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=iYp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Woc(r,t,this.abortController,this._options)}};var $oc=e=>{let t=(r,i)=>oCa.create(r,aCa(e,i));for(let r of NLo)t[r]=(i,n)=>oCa.create(i,aCa(e,n,{method:r}));return t.create=r=>$oc(aCa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),$oc(aCa(e,r))),t.stop=LLo,t},CUD=$oc(),nYp=CUD;var EYp=ai(DYp(),1);function Yoc(e){let t=(0,EYp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var mXp=ai(OXp(),1),PXp=ai(Cwi(),1),cuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},luc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function fuc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Yoc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,mXp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await nYp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new cuc(e):c}if(t.allVersions)return s;let o=new luc(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=PXp.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 dCa(e,t){let{version:r}=await fuc(e.toLowerCase(),t);return r}async function bEi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:dCa(e.packageName,{version:t?"prerelease":"latest"})}var jXp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],kLo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=T0.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new xLo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.64.18"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ds.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new l9}failWithoutThrowing(t,r){this.didSucceed=!1,CLo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await lFn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await VKp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1955
|
+
`,i?gFn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function SUD(e){let r=await new LKp.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 DUD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await WKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Twi(o.name,c),g=await kZt({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 WKp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=Twi(s.name,o),b=await kZt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function WKp({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 RVt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function HKp(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 d=qae(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function RLo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await DUD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...HKp(s,d,t.logger));else u.push(...HKp(l.versions,void 0,t.logger))}return u}var nCa=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 Z6n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Foc=(()=>{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})(),$Kp=typeof globalThis.AbortController=="function",GKp=typeof globalThis.ReadableStream=="function",QKp=typeof globalThis.FormData=="function",NLo=["get","post","put","patch","head","delete"],EUD=()=>{};EUD();var JKp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},FLo=2147483647,KKp=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,LLo=Symbol("stop"),YKp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},XKp={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 MUD=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=KKp,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},ZKp=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:l,value:d}=await a.read();if(l){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},kKp=(e,t)=>{let r=MUD(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:l,value:d}=await a.read();if(l){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var k6n=e=>e!==null&&typeof e=="object";var aCa=(...e)=>{for(let t of e)if((!k6n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Voc({},...e)},Loc=(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 ULo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Voc(e[r]??[],t[r]??[])}var Uoc=(e={},t={})=>({beforeRequest:ULo(e,t,"beforeRequest"),beforeRetry:ULo(e,t,"beforeRetry"),afterResponse:ULo(e,t,"afterResponse"),beforeError:ULo(e,t,"beforeError")}),Voc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(k6n(n)){for(let[a,u]of Object.entries(n))k6n(u)&&a in t&&(u=Voc(t[a],u)),t={...t,[a]:u};k6n(n.hooks)&&(i=Uoc(i,n.hooks),t.hooks=i),k6n(n.headers)&&(r=Loc(r,n.headers),t.headers=r)}return t};var tYp=e=>NLo.includes(e)?e.toUpperCase():e,AUD=["get","put","head","delete","options","trace"],qUD=[408,413,429,500,502,503,504],TUD=[413,429,503],eYp={limit:2,methods:AUD,statusCodes:qUD,afterStatusCodes:TUD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},rYp=(e={})=>{if(typeof e=="number")return{...eYp,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{...eYp,...e}};async function Woc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new Z6n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function Hoc(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 iYp=(e,t)=>{let r={};for(let i in t)!(i in XKp)&&!(i in YKp)&&!(i in e)&&(r[i]=t[i]);return r};var oCa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>FLo)throw new RangeError(`The \`timeout\` option cannot be greater than ${FLo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new nCa(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!GKp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return ZKp(l.clone(),i._options.onDownloadProgress)}return l},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[l,d]of Object.entries(JKp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(l==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Loc(this._input.headers,r.headers),hooks:Uoc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:tYp(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:rYp(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($Kp){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(Foc&&(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);(QKp&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Foc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=kKp(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Z6n)throw t;if(t instanceof nCa){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),FLo);if(this._retryCount<1)throw r;await Hoc(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})===LLo)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=iYp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):Woc(r,t,this.abortController,this._options)}};var $oc=e=>{let t=(r,i)=>oCa.create(r,aCa(e,i));for(let r of NLo)t[r]=(i,n)=>oCa.create(i,aCa(e,n,{method:r}));return t.create=r=>$oc(aCa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),$oc(aCa(e,r))),t.stop=LLo,t},CUD=$oc(),nYp=CUD;var EYp=ai(DYp(),1);function Yoc(e){let t=(0,EYp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var mXp=ai(OXp(),1),PXp=ai(Cwi(),1),cuc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},luc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function fuc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Yoc(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,mXp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await nYp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new cuc(e):c}if(t.allVersions)return s;let o=new luc(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=PXp.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 dCa(e,t){let{version:r}=await fuc(e.toLowerCase(),t);return r}async function bEi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:dCa(e.packageName,{version:t?"prerelease":"latest"})}var jXp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],kLo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=T0.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new xLo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.64.19"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ds.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new l9}failWithoutThrowing(t,r){this.didSucceed=!1,CLo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await lFn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await VKp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1956
1956
|
`)||(r+=`
|
|
1957
1957
|
`),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=LBs(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 XTa(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 l9}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await lFn()).sendEvent(t)}logger=dXt((t,...r)=>this.log(t,...r));stderr=dXt((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=wXp(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?wXp(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=jXp[this.numTasks++%jXp.length],u=Ds.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===MB.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>Vji.indexOf(n.level)>=Vji.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===T0.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await bEi({cliEnvironment:this.environment,includePreReleases:t}),i=qae(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await RLo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await Poc({message:t,default:r})}async getInput(t){return await joc({message:t.message,default:t.default})}};function wXp(e){return`[${e}]:`}var cg_=require("fs/promises");function rFe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Ds.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Ds.dim(r)),i.join(`
|
|
1958
1958
|
`)}var kp_=require("fs/promises");var WWt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var cMe=class extends WWt{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var pCa=class{context;constructor(t){this.context=t}};var eUo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let d=n!=null?gy.of(`${n}${tVt}${u}`):gy.of(u);t[d]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${tVt}${u}`:u,d=i.directories[u];r(d,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(tVt))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[gy.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 XGi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new eUo,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 hkt(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"]))SXp(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(SXp(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}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??C_((yxe(r)+"/"+UUi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===gy.of(VF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=Tgo(yxe(OBn.of(`/${t}`)),OBn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=Tgo(yxe(OBn.of(`/${t}`)),OBn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===gy.of(VF))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>v2(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=EN(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:EN(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:EN(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===TS?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 SXp(e){return e?.header!=null}var Tae={openapi:e=>({...e,type:"openapi",_visit:function(t){return Tae._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Tae._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 o4n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return o4n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Q9={basic:e=>({...e,type:"basic",_visit:function(t){return Q9._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Q9._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Q9._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Q9._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Q9._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 OO={primitive:e=>({value:e,type:"primitive",_visit:function(t){return OO._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return OO._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return OO._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return OO._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return OO._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return OO._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return OO._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return OO._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 D_={int:e=>({value:e,type:"int",_visit:function(t){return D_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return D_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return D_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return D_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return D_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return D_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return D_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return D_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return D_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return D_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return D_._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 u4n={boolean:e=>({value:e,type:"boolean",_visit:function(t){return u4n._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return u4n._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 gEi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return gEi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return gEi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var RW={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case RW.GenerallyAvailable:return t.generallyAvailable();case RW.Beta:return t.beta();case RW.Deprecated:return t.deprecated();default:return t._other()}}};var iFe={cursor:e=>({...e,type:"cursor",_visit:function(t){return iFe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return iFe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return iFe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var kfi={language:e=>({...e,type:"language",_visit:function(t){return kfi._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return kfi._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 NW={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 NW.Curl:return t.curl();case NW.Python:return t.python();case NW.Javascript:return t.javascript();case NW.Typescript:return t.typescript();case NW.Go:return t.go();case NW.Ruby:return t.ruby();case NW.Csharp:return t.csharp();case NW.Java:return t.java();case NW.Js:return t.js();case NW.Node:return t.node();case NW.Ts:return t.ts();case NW.Nodets:return t.nodets();case NW.Golang:return t.golang();case NW.Dotnet:return t.dotnet();case NW.Jvm:return t.jvm();default:return t._other()}}};var HWt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return HWt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return HWt._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 $Wt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return $Wt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return $Wt._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 FW={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case FW.Get:return t.get();case FW.Post:return t.post();case FW.Put:return t.put();case FW.Patch:return t.patch();case FW.Delete:return t.delete();case FW.Head:return t.head();case FW.Options:return t.options();case FW.Trace:return t.trace();default:return t._other()}}};var OEi={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return OEi._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return OEi._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return OEi._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 edi={file:e=>({...e,type:"file",_visit:function(t){return edi._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return edi._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 GQ={file:e=>({...e,type:"file",_visit:function(t){return GQ._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return GQ._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return GQ._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return GQ._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return GQ._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return GQ._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return GQ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Hy={primitive:e=>({...e,type:"primitive",_visit:function(t){return Hy._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Hy._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Hy._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Hy._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Hy._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Hy._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Hy._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Hy._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Hy._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Hy._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Hy._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 Xj={int:e=>({...e,type:"int",_visit:function(t){return Xj._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Xj._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Xj._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Xj._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Xj._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Xj._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Xj._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Xj._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Xj._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Xj._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Xj._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 fz={boolean:e=>({value:e,type:"boolean",_visit:function(t){return fz._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return fz._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 tdi={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return tdi._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return tdi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var lMe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return lMe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return lMe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return lMe._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 bC={file:e=>({...e,type:"file",_visit:function(t){return bC._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return bC._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return bC._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return bC._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return bC._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return bC._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return bC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var zl={primitive:e=>({...e,type:"primitive",_visit:function(t){return zl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return zl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return zl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return zl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return zl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return zl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return zl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return zl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return zl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return zl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return zl._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 xZ={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return xZ._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return xZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var cp={int:e=>({...e,type:"int",_visit:function(t){return cp._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return cp._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return cp._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return cp._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return cp._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return cp._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return cp._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return cp._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return cp._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return cp._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return cp._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 Tv={};Dn(Tv,{AllOfPropertyConflict:()=>q4n,ArraySchema:()=>yVo,ArraySchemaWithExample:()=>HVo,Availability:()=>lUo,Base64WithExample:()=>FVo,BasicSecurityScheme:()=>pUo,BearerSecurityScheme:()=>_Uo,BooleanSchema:()=>lVo,BooleanWithExample:()=>LVo,BytesResponse:()=>m4n,CasingOverrides:()=>vUo,CommonProperty:()=>wVo,CommonPropertyWithExample:()=>kVo,CursorPagination:()=>QUo,CustomCodeSample:()=>$Uo,CustomCodeSampleLanguage:()=>VUo,CustomCodeSampleSdk:()=>HUo,CustomPagination:()=>KUo,DateWithExample:()=>NVo,DatetimeWithExample:()=>RVo,DiscriminatedOneOfSchema:()=>PVo,DiscriminatedOneOfSchemaWithExample:()=>XVo,DoubleSchema:()=>sVo,DoubleWithExample:()=>zVo,Encoding:()=>cUo,Endpoint:()=>YUo,EndpointExample:()=>S4n,EndpointResponseExample:()=>UUo,EndpointSdkName:()=>Brr,EndpointWithExample:()=>tZp,EnumSchema:()=>f4n,EnumSchemaWithExample:()=>VVo,EnumValue:()=>jEi,ErrorExample:()=>xUo,FernExample:()=>NUo,FileResponse:()=>g4n,FileSchema:()=>AUo,FloatWithExample:()=>IVo,FullEndpointExample:()=>GUo,FullExample:()=>Vq,FullObjectExample:()=>wUo,FullOneOfExample:()=>DUo,GlobalHeader:()=>dVo,Header:()=>SEi,HeaderExample:()=>w4n,HeaderSecurityScheme:()=>hUo,HeaderWithExample:()=>MEi,HttpEndpointServer:()=>P4n,HttpError:()=>RUo,HttpErrorWithExample:()=>AVo,HttpMethod:()=>_4n,IdempotencyHeader:()=>pVo,Int64WithExample:()=>TVo,IntSchema:()=>oVo,IntWithExample:()=>qVo,JsonRequest:()=>BUo,JsonRequestWithExample:()=>DVo,JsonResponse:()=>O4n,JsonResponseWithExample:()=>B4n,KeyValuePair:()=>SUo,LiteralExample:()=>jUo,LiteralSchema:()=>A4n,LiteralSchemaValue:()=>_Vo,LongSchema:()=>uVo,MapSchema:()=>vVo,MapSchemaWithExample:()=>$Vo,MultipartRequest:()=>b4n,MultipartRequestProperty:()=>CUo,MultipartRequestPropertyEncoding:()=>TUo,MultipartSchema:()=>qUo,NamedFullExample:()=>zrr,Namespace:()=>bUo,NamespaceId:()=>PUo,NullableSchema:()=>gVo,NullableSchemaWithExample:()=>QVo,OauthSecurityScheme:()=>OUo,ObjectProperty:()=>mVo,ObjectPropertyConflictInfo:()=>T4n,ObjectPropertyWithExample:()=>YVo,ObjectSchema:()=>hVo,ObjectSchemaWithExample:()=>JVo,OctetStreamRequest:()=>v4n,OffsetPagination:()=>JUo,OneOfSchema:()=>OVo,OneOfSchemaWithExample:()=>KVo,OpenApiIntermediateRepresentation:()=>kXp,OpenApiSource:()=>aUo,OptionalSchema:()=>bVo,OptionalSchemaWithExample:()=>GVo,Pagination:()=>D4n,PathParameter:()=>h4n,PathParameterExample:()=>FUo,PathParameterWithExample:()=>SVo,PrimitiveExample:()=>p4n,PrimitiveSchema:()=>EEi,PrimitiveSchemaValue:()=>fVo,PrimitiveSchemaValueWithExample:()=>UVo,PrimitiveSchemaWithExample:()=>I4n,PropertyKey:()=>d4n,ProtobufEncoding:()=>sUo,ProtobufSource:()=>oUo,QueryParameter:()=>y4n,QueryParameterExample:()=>j4n,QueryParameterWithExample:()=>C4n,QuerySecurityScheme:()=>yUo,ReferencedSchema:()=>Irr,Request:()=>IUo,RequestWithExample:()=>EVo,Response:()=>zUo,ResponseWithExample:()=>MVo,Schema:()=>jm,SchemaId:()=>RZ,SchemaWithExample:()=>lA,Schemas:()=>aVo,SdkGroup:()=>gUo,SdkGroupInfo:()=>EUo,SdkGroupName:()=>wEi,SecurityScheme:()=>mUo,SecuritySchemeId:()=>dUo,Server:()=>vCa,Source:()=>uUo,StatusCode:()=>Crr,StreamingResponseExample:()=>LUo,StringSchema:()=>cVo,StringSchemaWithExample:()=>xVo,SupportedSdkLanguage:()=>WUo,Tag:()=>fUo,TagId:()=>NZ,Tags:()=>MUo,TextResponse:()=>DEi,Uint64WithExample:()=>BVo,UintWithExample:()=>CVo,UnDiscriminatedOneOfSchema:()=>jVo,UnDiscriminatedOneOfSchemaWithExample:()=>ZVo,UnknownSchemaWithExample:()=>WVo,Webhook:()=>XUo,WebhookExampleCall:()=>M4n,WebhookHttpMethod:()=>E4n,WebhookWithExample:()=>rZp,WebsocketChannel:()=>nVo,WebsocketHandshake:()=>ZUo,WebsocketHandshakeWithExample:()=>eZp,WebsocketMessageExample:()=>rVo,WebsocketMessageOrigin:()=>kUo,WebsocketMessageSchema:()=>eVo,WebsocketServer:()=>tVo,WebsocketSessionExample:()=>iVo,WithAvailability:()=>Th,WithDescription:()=>gf,WithEncoding:()=>Cae,WithInline:()=>WE,WithName:()=>z0,WithNamespace:()=>i0,WithSdkGroupName:()=>um,WithSource:()=>Xh,WithStatusCode:()=>nFe,WithTitle:()=>om,commons:()=>yuc,example:()=>vuc,finalIr:()=>buc,parseIr:()=>guc});var yuc={};Dn(yuc,{BasicSecurityScheme:()=>pUo,BearerSecurityScheme:()=>_Uo,Encoding:()=>cUo,HeaderSecurityScheme:()=>hUo,Namespace:()=>bUo,NamespaceId:()=>PUo,OauthSecurityScheme:()=>OUo,OpenApiSource:()=>aUo,ProtobufEncoding:()=>sUo,ProtobufSource:()=>oUo,QuerySecurityScheme:()=>yUo,SchemaId:()=>RZ,SdkGroup:()=>gUo,SdkGroupName:()=>wEi,SecurityScheme:()=>mUo,SecuritySchemeId:()=>dUo,Server:()=>vCa,Source:()=>uUo,StatusCode:()=>Crr,Tag:()=>fUo,TagId:()=>NZ,WithAvailability:()=>Th,WithDescription:()=>gf,WithEncoding:()=>Cae,WithInline:()=>WE,WithName:()=>z0,WithNamespace:()=>i0,WithSdkGroupName:()=>um,WithSource:()=>Xh,WithStatusCode:()=>nFe,WithTitle:()=>om});var Mt={};Dn(Mt,{JsonError:()=>s4n,ParseError:()=>c4n,any:()=>LXp,bigint:()=>EXp,boolean:()=>UXp,booleanLiteral:()=>FXp,date:()=>MXp,discriminant:()=>YXp,enum_:()=>rUo,getObjectLikeUtils:()=>GWt,getObjectUtils:()=>ZGi,getSchemaUtils:()=>Uq,isProperty:()=>PEi,lazy:()=>AXp,lazyObject:()=>xXp,list:()=>nUo,number:()=>VXp,object:()=>iUo,objectWithoutOptionalProperties:()=>zXp,optional:()=>duc,property:()=>TXp,record:()=>GXp,set:()=>QXp,string:()=>WXp,stringLiteral:()=>NXp,transform:()=>puc,undiscriminatedUnion:()=>KXp,union:()=>ZXp,unknown:()=>HXp,withParsedProperties:()=>huc});var Mj={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 cA(e,t){return`Expected ${t}. Received ${NVD(e)}.`}function NVD(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 J9(e){return{...e,json:DXp(e.json),parse:DXp(e.parse)}}function DXp(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(`
|
|
@@ -2074,7 +2074,7 @@ error-discriminant: error`;await(0,ujs.writeFile)(r,n)}}};var Xf6={version:"0.0.
|
|
|
2074
2074
|
${Ds.dim(a.summary)}`}));r.push("Do you wish to continue?");let{[t]:i}=await HFo.prompt({name:t,type:"confirm",message:r.join(`
|
|
2075
2075
|
`)});return i}async function GNj({cliEnvironment:e,version:t}){try{return await dCa(e.packageName,{version:t}),!0}catch{return!1}}var eso="FERN_CWD";async function tso({version:e,cliContext:t,env:r}){t.suppressUpgradeMessage();let i=["--quiet","--yes",`${t.environment.packageName}@${e}`,...process.argv.slice(2)];t.logger.debug([`Re-running CLI at version ${e}.`,`${Ds.dim(`+ npx ${i.map(l=>`"${l}"`).join(" ")}`)}`].join(`
|
|
2076
2076
|
`));let{failed:n,stdout:a,stderr:u}=await XN(t.logger,"npx",["--quiet",...i],{stdio:"inherit",reject:!1,env:{...r,[eso]:process.env[eso]??process.cwd()}});if(a.includes("code EEXIST")||u.includes("code EEXIST"))return await tso({version:e,cliContext:t});n&&t.failWithoutThrowing()}var QNj="FERN_PRE_UPGRADE_VERSION";async function YNj({cliContext:e,includePreReleases:t,targetVersion:r}){r!=null&&(await GNj({cliEnvironment:e.environment,version:r})||e.failAndThrow(`Failed to upgrade to ${r} because it does not exist. See https://www.npmjs.com/package/${e.environment.packageName}?activeTab=versions.`),qae(r,e.environment.packageVersion)||e.failAndThrow(`Cannot upgrade because target version (${r}) is not ahead of existing version ${e.environment.packageVersion}`));let i=r!=null?{targetVersion:r,isUpgradeAvailable:!0}:void 0;if(i==null){let n=await e.isUpgradeAvailable({includePreReleases:t});n.cliUpgradeInfo!=null&&(i={targetVersion:n.cliUpgradeInfo.latestVersion,isUpgradeAvailable:n.cliUpgradeInfo.isUpgradeAvailable})}if(i&&!i.isUpgradeAvailable){let n=process.env[QNj];if(n==null){e.logger.info("No upgrade available.");return}await JNj({cliContext:e,previousVersion:n,newVersion:i.targetVersion})}else if(i!=null){let n=await uVt();if(n==null)return e.failAndThrow(`Directory "${HV}" not found.`);let a=await e.runTask(l=>lli({directory:n,context:l})),u=CBj(a.rawConfig,l=>{l.version=i.targetVersion});await(0,KNj.writeFile)(a._absolutePath,JSON.stringify(u,void 0,2)),e.logger.info(`Upgrading from ${Ds.dim(e.environment.packageVersion)} \u2192 ${Ds.green(i.targetVersion)}`),e.environment.packageVersion==="0.0.0"?await JNj({cliContext:e,previousVersion:a.version,newVersion:i.targetVersion}):(await XN(e.logger,"npm",["install","-g",`${e.environment.packageName}@${i.targetVersion}`]),await tso({version:i.targetVersion,cliContext:e,env:{[QNj]:e.environment.packageVersion}}))}}async function JNj({cliContext:e,previousVersion:t,newVersion:r}){await e.runTask(async i=>{await HXf({fromVersion:t,toVersion:r,context:i})}),await e.exitIfFailed()}async function XNj({project:e,cliContext:t,errorOnBrokenLinks:r}){let i=e.docsWorkspaces;if(i==null){t.failAndThrow("No docs workspace found");return}await t.runTaskForWorkspace(i,async n=>{let a=performance.now(),u=await Promise.all(e.apiWorkspaces.map(async o=>o.toFernWorkspace({context:n}))),l=await nH(e),d=await vNa(i,n,u,l,!0),s=performance.now()-a;cLn({violations:d,context:n,logWarnings:!0,logSummary:!0,logBreadcrumbs:!1,elapsedMillis:s}),d.length>0&&r&&n.failAndThrow()})}async function ZNj({project:e,cliContext:t,logWarnings:r,brokenLinks:i,errorOnBrokenLinks:n,isLocal:a,directFromOpenapi:u}){let l=e.docsWorkspaces;l!=null&&await t.runTaskForWorkspace(l,async d=>{let s=i||n?[]:["valid-markdown-links"];await uiu({workspace:l,context:d,logWarnings:r,apiWorkspaces:e.apiWorkspaces,ossWorkspaces:await nH(e),errorOnBrokenLinks:n,excludeRules:s})}),await Promise.all(e.apiWorkspaces.map(async d=>{d.generatorsConfiguration?.groups.length===0&&d.type!="fern"||await t.runTaskForWorkspace(d,async s=>{if(d instanceof fR&&u){await d.getIntermediateRepresentation({context:s,audiences:{type:"all"},enableUniqueErrorsPerEndpoint:!1,generateV1Examples:!1});return}let o=await d.toFernWorkspace({context:s});await Kir({workspace:o,context:s,logWarnings:r,ossWorkspace:d instanceof fR?d:void 0})})}))}var Oui=require("fs/promises");var $Xf=ai(require("path"),1);async function kNj({project:e,cliContext:t,sdkLanguage:r,preserveSchemaIds:i}){await Promise.all(e.apiWorkspaces.map(async n=>{await t.runTaskForWorkspace(n,async a=>{n instanceof cMe?await Kh6({workspace:n,context:a}):await Yh6({workspace:await n.toFernWorkspace({context:a},{preserveSchemaIds:i}),context:a})})}))}async function Kh6({workspace:e,context:t}){for(let[r,i]of Object.entries(e.definition.importedDefinitions)){let n=Lu(e.absoluteFilePath,Ua.of(n9),Ua.of(r),Ua.of(`.${n9}`));await eFj({definition:i.definition,absolutePathToOutputDirectory:n}),t.logger.info(Ds.green(`Wrote imported definition at ${$Xf.default.relative(process.cwd(),n)}`))}}async function Yh6({workspace:e,context:t}){let r=Lu(e.absoluteFilePath,Ua.of(`.${n9}`));await eFj({definition:e.definition,absolutePathToOutputDirectory:r}),t.logger.info(Ds.green(`Wrote definition to ${$Xf.default.relative(process.cwd(),r)}`))}async function eFj({definition:e,absolutePathToOutputDirectory:t}){let r=(i,n)=>{let a={imports:0,types:1,services:2},u=i in a?a[i]:Object.keys(a).length,l=n in a?a[n]:Object.keys(a).length;return u==null?-1:l==null?1:u!==l?u-l:i.localeCompare(n)};await mf(t)&&await(0,Oui.rmdir)(t,{recursive:!0}),await(0,Oui.mkdir)(t,{recursive:!0}),await(0,Oui.writeFile)(Lu(t,Ua.of(VF)),md.dump(e.rootApiFile.contents,{sortKeys:r}));for(let[i,n]of Object.entries(e.packageMarkers)){let a=Lu(t,Ua.of(i));await(0,Oui.mkdir)(Td(a),{recursive:!0}),await(0,Oui.writeFile)(a,md.dump(n.contents,{sortKeys:r}))}for(let[i,n]of Object.entries(e.namedDefinitionFiles)){let a=Lu(t,Ua.of(i));await(0,Oui.mkdir)(Td(a),{recursive:!0}),await(0,Oui.writeFile)(a,md.dump(n.contents,{sortKeys:r}))}}var tFj=require("fs/promises");async function rFj({project:e,outputPath:t,cliContext:r}){let i=e.docsWorkspaces;i!=null&&await r.runTaskForWorkspace(i,async n=>{let a=await nH(e),u=await Promise.all(e.apiWorkspaces.map(async s=>s.toFernWorkspace({context:n},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1}))),d=await new SHt(i.config.instances[0]?.url??"http://localhost:8080",i,a,u,n).resolve();await(0,tFj.writeFile)(hl.of(t),JSON.stringify(d,null,2)),n.logger.info(Ds.green(`Docs definition written to ${t}`))})}var mws=Xh6();function Xh6(){return typeof window<"u"&&typeof window.document<"u"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis<"u"&&globalThis?.navigator?.userAgent==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof self?.importScripts=="function"&&(self.constructor?.name==="DedicatedWorkerGlobalScope"||self.constructor?.name==="ServiceWorkerGlobalScope"||self.constructor?.name==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u"?{type:"deno",version:Deno.version.deno}:typeof Bun<"u"&&typeof Bun.version<"u"?{type:"bun",version:Bun.version}:typeof process<"u"&&"version"in process&&!!process.version&&"versions"in process&&!!process.versions?.node?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator<"u"&&navigator?.product==="ReactNative"?{type:"react-native"}:{type:"unknown"}}pE6();var dE6="The Fern CLI requires Node 18+ or above.";async function pE6(){let e=process.argv.includes("--local"),t=new kLo(process.stdout,process.stderr,{isLocal:e}),r=async()=>{await t.exit()};if(mws.type==="node"&&mws.parsedVersion!=null&&mws.parsedVersion>=18){let{setGlobalDispatcher:i,Agent:n}=await Promise.resolve().then(()=>ai(W5j(),1));i(new n({connect:{timeout:2147483647},bodyTimeout:0,headersTimeout:2147483647}))}process.on("SIGINT",async()=>{t.suppressUpgradeMessage(),await r()});try{let i=process.env[eso];i!=null&&process.chdir(i);let n=await hE6(t);t.environment.packageVersion===n?await _E6(t):await tso({version:n,cliContext:t})}catch(i){await t.instrumentPostHogEvent({command:process.argv.join(" "),properties:{failed:!0,error:i}}),i?.message.includes("globalThis")?(t.logger.error(dE6),t.failWithoutThrowing()):i instanceof l9?t.failWithoutThrowing():i instanceof Gci?t.logger.error(`Failed. ${i.log}`):t.failWithoutThrowing("Failed.",i)}await r()}async function _E6(e){let t=opd(jCs(process.argv)).scriptName(e.environment.cliName).version(!1).fail((r,i,n)=>{i==null&&(n.showHelp(),e.logger.error(r))}).strict().exitProcess(!1).command("$0",!1,r=>r.option("version",{describe:"Print current version",alias:"v"}).version(!1),r=>{r.version!=null?e.logger.info(e.environment.packageVersion):(t.showHelp(),e.failAndThrow())}).option("log-level",{default:T0.Info,choices:Vji}).demandCommand().recommendCommands();bE6(t,e),vE6(t,e),gE6(t,e),OE6(t,e),mE6(t,e),PE6(t,e),SE6(t,e),jE6(t,e),wE6(t,e),ME6(t,e),DE6(t,e),EE6(t,e),TE6(t,e),CE6(t,e),xE6(t,e),RE6(t,e),IE6(t,e),zE6(t,e),BE6(t,e),qE6(t,e),AE6({cli:t,cliContext:e,onRun:()=>{e.suppressUpgradeMessage()}}),LE6(t,e),UE6(t,e),VE6(t,e),mg_(t,e),Pg_(t,e),t.middleware(async r=>{e.setLogLevel(r["log-level"]),e.logDebugInfo()}),await t.parse()}async function hE6(e){if(process.env.FERN_NO_VERSION_REDIRECTION==="true")return e.environment.packageVersion;let t=await uVt();if(t!=null){let r=await e.runTask(i=>lli({directory:t,context:i}));return r.version==="*"?e.environment.packageVersion:r.version}return bEi({cliEnvironment:e.environment})}async function yE6(e){let t=await uVt();if(t!=null)return(await e.runTask(i=>lli({directory:t,context:i}))).organization}function vE6(e,t){e.command("init","Initialize a Fern API",r=>r.option("api",{boolean:!0,description:"Initialize an api."}).option("docs",{boolean:!0,description:"Initialize a docs website."}).option("organization",{alias:"org",type:"string",description:"Organization name"}).option("openapi",{type:"string",description:"Filepath or url to an existing OpenAPI spec"}).option("mintlify",{type:"string",description:"Migrate docs from Mintlify provided a path to a mint.json file"}).option("readme",{type:"string",description:"Migrate docs from Readme provided a URL to a Readme generated docs site"}),async r=>{if(r.organization==null){let i=await yE6(t);i!=null?r.organization=i:r.organization=await t.getInput({message:"Please enter your organization"})}if(r.api!=null&&r.docs!=null)return t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one.");if(r.readme!=null&&r.mintlify!=null)return t.failWithoutThrowing("Cannot specify both --readme and --mintlify. Please choose one.");if(r.readme!=null)await t.runTask(async i=>{await loc({readmeUrl:r.readme,organization:r.organization??"fern",taskContext:i,versionOfCli:await bEi({cliEnvironment:t.environment})})});else if(r.docs!=null)await t.runTask(async i=>{await IXs({organization:r.organization,versionOfCli:await bEi({cliEnvironment:t.environment}),taskContext:i})});else if(r.mintlify!=null)await t.runTask(async i=>{await tZs({pathToMintJson:r.mintlify,organization:r.organization??"fern",taskContext:i,versionOfCli:await bEi({cliEnvironment:t.environment})})});else{let i;if(r.openapi!=null){if(HUi(r.openapi)){let a=await VJp({url:r.openapi,logger:t.logger});a.status==="failure"&&t.failAndThrow(a.errorMessage);let u=a.filePath;i=hl.of(u)}else i=hl.of(Gv(kz(),r.openapi));await mf(i)||t.failAndThrow(`${i} does not exist`)}await t.runTask(async n=>{await CXs({organization:r.organization,versionOfCli:await bEi({cliEnvironment:t.environment}),context:n,openApiPath:i})})}})}function bE6(e,t){e.command("diff","Diff two versions of an API",r=>r.option("from",{string:!0,demandOption:!0,description:"The previous version of the API"}).option("to",{string:!0,demandOption:!0,description:"The next version of the API"}).option("from-version",{string:!0,description:"The previous version of the API (e.g. 1.1.0)"}).option("quiet",{boolean:!0,default:!1,alias:"q",description:"Whether to suppress output written to stderr"}),async r=>{let i=r.fromVersion!=null?r.fromVersion:void 0,n=await Mg_({context:t,from:r.from,to:r.to,fromVersion:i});if(i!=null){let{errors:u,...l}=n;t.logger.info(JSON.stringify(l))}!r.quiet&&n.errors.length>0&&t.stderr.info(n.errors.join(`
|
|
2077
|
-
`));let a=n.bump==="major"?1:0;await t.exit({code:a})})}function gE6(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async i=>{await yBj({orgId:r.organization??(await _A(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:i})})})}function OE6(e,t){e.command("add <generator>",`Add a code generator to ${WF}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await wg_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function mE6(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(QCj),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}).option("force",{boolean:!0,default:!1,description:"Ignore prompts to confirm generation, defaults to false"}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("disable-snippets",{boolean:!0,description:"Disable snippets in docs generation.",default:!1}).option("runner",{choices:["docker","podman"],description:"Choose the container runtime to use for local generation.",default:void 0}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.local&&r.preview?t.failWithoutThrowing("The --local flag is incompatible with --preview."):r.api!=null?await CYf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local||r.runner!=null,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await JCj({project:await _A(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview,brokenLinks:r.brokenLinks,strictBrokenLinks:r.strictBrokenLinks,disableTemplates:r.disableSnippets})):await CYf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner}))}function PE6(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}).option("disable-examples",{boolean:!0,description:"Whether to disable automatic example generation in the IR",default:!1}),async r=>{await I1j({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:Gv(kz(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,readme:void 0,directFromOpenapi:r.fromOpenapi,disableExamples:r.disableExamples})})}function jE6(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await R1j({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:Gv(kz(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function wE6(e,t){e.command("dynamic-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("disable-examples",{boolean:!0,description:"Whether to suppress examples from being included in the IR"}),async r=>{await o9_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:Gv(kz(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,disableDynamicExamples:r.disableExamples??!1})})}function SE6(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the FDR API definition for certain audiences"}).option("v2",{boolean:!0,description:"Use v2 format"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{r.v2?await RJf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:Gv(kz(),r.pathToOutput),directFromOpenapi:!1,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):r.fromOpenapi?await RJf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:Gv(kz(),r.pathToOutput),directFromOpenapi:!0,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):await s9_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:Gv(kz(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function DE6(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>mNe(a));await dBj({project:i,cliContext:t,token:n,version:r.version})})}function EE6(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>mNe(a));await pBj({project:i,cliContext:t,token:n})})}function ME6(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("local",{boolean:!0,description:"Run validation locally without sending data to Fern API.",default:!1}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{await ZNj({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings,brokenLinks:r.brokenLinks,errorOnBrokenLinks:r.strictBrokenLinks,directFromOpenapi:r.fromOpenapi})})}function AE6({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades version in ${Tie}. Also upgrades generators in ${WF} to their minimum-compatible versions.`,i=>i.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}),async i=>{await YNj({cliContext:t,includePreReleases:i.rc,targetVersion:i.version}),r()})}function qE6(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${WF} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await OBj({cliContext:t,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function TE6(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async i=>{await t.instrumentPostHogEvent({command:"fern login"}),await DEa(i,{useDeviceCodeFlow:r.deviceCode})})})}function CE6(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await n5_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function BE6(e,t){e.command("test","Runs tests specified in --command, this spins up a mock server in the background that is terminated upon completion of the tests.",r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await _Bj({cliContext:t,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function IE6(e,t){e.command("mock","Starts a mock server for an API.",r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await oBj({cliContext:t,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function zE6(e,t){e.command("write-overrides","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern generate-overrides"}),await F1j({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function xE6(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Write the definition for a particular SDK language"}).option("preserve-schemas",{string:!0,description:"Preserve potentially unsafe schema Ids in the generated fern definition"}),async r=>{let i=r.preserveSchemas!=null;await t.instrumentPostHogEvent({command:"fern write-definition"}),await kNj({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language,preserveSchemaIds:i}),cliContext:t,sdkLanguage:r.language,preserveSchemaIds:i})})}function RE6(e,t){e.command("docs","Commands for managing your docs",r=>(NE6(r,t),FE6(r,t),r))}function NE6(e,t){e.command("dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}).option("broken-links",{boolean:!0,default:!1,description:"Check for broken links in your docs"}).option("beta",{boolean:!0,default:!1,description:"Run the app router development server"}).option("legacy",{boolean:!0,default:!1,description:"Run the legacy development server"}).option("backend-port",{number:!0,description:"Run the development backend server on the following port"}),async r=>{r.beta&&t.logger.warn("--beta flag now accesses the same functionality as default and will be deprecated in a future release");let i;r.port!=null?i=r.port:i=await $Tn({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let n;r.backendPort!=null?n=r.backendPort:n=await $Tn({port:[3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011]});let a=r.bundlePath;await Y8_({loadProject:()=>_A(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:i,bundlePath:a,brokenLinks:r.brokenLinks,appPreview:r.beta,legacyPreview:r.legacy,backendPort:n})})}function FE6(e,t){e.command("broken-links","Check for broken links in your docs",r=>r.option("strict",{boolean:!0,default:!1,description:"Fail with non-zero exit status"}),async r=>{let i=await _A(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0});await XNj({project:i,cliContext:t,errorOnBrokenLinks:r.strict})})}function LE6(e,t){e.command("jsonschema <path-to-output>","Generate JSON Schema for a specific type",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).positional("path-to-output",{type:"string",description:"Path to write JSON Schema",demandOption:!0}).option("type",{string:!0,demandOption:!0,description:"The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"}),async r=>{await t.instrumentPostHogEvent({command:"fern jsonschema",properties:{output:r.output}}),await eBj({typeLocator:r.type,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),jsonschemaFilepath:Gv(kz(),r.pathToOutput),cliContext:t})})}function UE6(e,t){e.command("write-docs-definition <output-path>",!1,r=>r.positional("output-path",{type:"string",description:"Path to write the docs definition",demandOption:!0}),async r=>{await t.instrumentPostHogEvent({command:"fern write-docs-definition",properties:{outputPath:r.outputPath}}),await rFj({project:await _A(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),outputPath:Gv(kz(),r.outputPath),cliContext:t})})}function VE6(e,t){e.command("export <output-path>","Export your API to an OpenAPI spec",r=>r.positional("output-path",{type:"string",description:"Path to write the OpenAPI spec",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern export",properties:{outputPath:r.outputPath}}),await i5_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,outputPath:Gv(kz(),r.outputPath)})})}
|
|
2077
|
+
`));let a=n.bump==="major"?1:0;await t.exit({code:a})})}function gE6(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async i=>{await yBj({orgId:r.organization??(await _A(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:i})})})}function OE6(e,t){e.command("add <generator>",`Add a code generator to ${WF}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await wg_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function mE6(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(QCj),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}).option("force",{boolean:!0,default:!1,description:"Ignore prompts to confirm generation, defaults to false"}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("disable-snippets",{boolean:!0,description:"Disable snippets in docs generation.",default:!1}).option("runner",{choices:["docker","podman"],description:"Choose the container runtime to use for local generation.",default:void 0}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.local&&r.preview?t.failWithoutThrowing("The --local flag is incompatible with --preview."):r.api!=null?await CYf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local||r.runner!=null,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await JCj({project:await _A(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview,brokenLinks:r.brokenLinks,strictBrokenLinks:r.strictBrokenLinks,disableTemplates:r.disableSnippets})):await CYf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner}))}function PE6(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}).option("disable-examples",{boolean:!0,description:"Whether to disable automatic example generation in the IR",default:!1}),async r=>{await I1j({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:Gv(kz(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,readme:void 0,directFromOpenapi:r.fromOpenapi,disableExamples:r.disableExamples})})}function jE6(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await R1j({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:Gv(kz(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function wE6(e,t){e.command("dynamic-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("disable-examples",{boolean:!0,description:"Whether to suppress examples from being included in the IR"}),async r=>{await o9_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:Gv(kz(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,disableDynamicExamples:r.disableExamples??!1})})}function SE6(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:new Array,description:"Filter the FDR API definition for certain audiences"}).option("v2",{boolean:!0,description:"Use v2 format"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{r.v2?await RJf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:Gv(kz(),r.pathToOutput),directFromOpenapi:!1,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):r.fromOpenapi?await RJf({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:Gv(kz(),r.pathToOutput),directFromOpenapi:!0,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):await s9_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:Gv(kz(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function DE6(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>mNe(a));await dBj({project:i,cliContext:t,token:n,version:r.version})})}function EE6(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>mNe(a));await pBj({project:i,cliContext:t,token:n})})}function ME6(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("local",{boolean:!0,description:"Run validation locally without sending data to Fern API.",default:!1}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{await ZNj({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings,brokenLinks:r.brokenLinks,errorOnBrokenLinks:r.strictBrokenLinks,directFromOpenapi:r.fromOpenapi})})}function AE6({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades version in ${Tie}. Also upgrades generators in ${WF} to their minimum-compatible versions.`,i=>i.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}),async i=>{await YNj({cliContext:t,includePreReleases:i.rc,targetVersion:i.version}),r()})}function qE6(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${WF} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await OBj({cliContext:t,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function TE6(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async i=>{await t.instrumentPostHogEvent({command:"fern login"}),await DEa(i,{useDeviceCodeFlow:r.deviceCode})})})}function CE6(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await n5_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function BE6(e,t){e.command("test","Runs tests specified in --command, this spins up a mock server in the background that is terminated upon completion of the tests.",r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await _Bj({cliContext:t,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function IE6(e,t){e.command("mock","Starts a mock server for an API.",r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await oBj({cliContext:t,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function zE6(e,t){e.command("write-overrides","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern generate-overrides"}),await F1j({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function xE6(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(by.GenerationLanguage),description:"Write the definition for a particular SDK language"}).option("preserve-schemas",{string:!0,description:"Preserve potentially unsafe schema Ids in the generated fern definition"}),async r=>{let i=r.preserveSchemas!=null;await t.instrumentPostHogEvent({command:"fern write-definition"}),await kNj({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language,preserveSchemaIds:i}),cliContext:t,sdkLanguage:r.language,preserveSchemaIds:i})})}function RE6(e,t){e.command("docs","Commands for managing your docs",r=>(NE6(r,t),FE6(r,t),r))}function NE6(e,t){e.command("dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}).option("broken-links",{boolean:!0,default:!1,description:"Check for broken links in your docs"}).option("beta",{boolean:!0,default:!1,description:"Run the app router development server"}).option("legacy",{boolean:!0,default:!1,description:"Run the legacy development server"}).option("backend-port",{number:!0,description:"Run the development backend server on the following port"}),async r=>{r.beta&&t.logger.warn("--beta flag now accesses the same functionality as default and will be deprecated in a future release");let i;r.port!=null?i=r.port:i=await $Tn({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let n;r.backendPort!=null?n=r.backendPort:n=await $Tn({port:[3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011]});let a=r.bundlePath;await Y8_({loadProject:()=>_A(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:i,bundlePath:a,brokenLinks:r.brokenLinks,appPreview:r.beta,legacyPreview:r.legacy||process.platform==="win32",backendPort:n})})}function FE6(e,t){e.command("broken-links","Check for broken links in your docs",r=>r.option("strict",{boolean:!0,default:!1,description:"Fail with non-zero exit status"}),async r=>{let i=await _A(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0});await XNj({project:i,cliContext:t,errorOnBrokenLinks:r.strict})})}function LE6(e,t){e.command("jsonschema <path-to-output>","Generate JSON Schema for a specific type",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).positional("path-to-output",{type:"string",description:"Path to write JSON Schema",demandOption:!0}).option("type",{string:!0,demandOption:!0,description:"The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"}),async r=>{await t.instrumentPostHogEvent({command:"fern jsonschema",properties:{output:r.output}}),await eBj({typeLocator:r.type,project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),jsonschemaFilepath:Gv(kz(),r.pathToOutput),cliContext:t})})}function UE6(e,t){e.command("write-docs-definition <output-path>",!1,r=>r.positional("output-path",{type:"string",description:"Path to write the docs definition",demandOption:!0}),async r=>{await t.instrumentPostHogEvent({command:"fern write-docs-definition",properties:{outputPath:r.outputPath}}),await rFj({project:await _A(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),outputPath:Gv(kz(),r.outputPath),cliContext:t})})}function VE6(e,t){e.command("export <output-path>","Export your API to an OpenAPI spec",r=>r.positional("output-path",{type:"string",description:"Path to write the OpenAPI spec",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern export",properties:{outputPath:r.outputPath}}),await i5_({project:await _A(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,outputPath:Gv(kz(),r.outputPath)})})}
|
|
2078
2078
|
/*! Bundled license information:
|
|
2079
2079
|
|
|
2080
2080
|
tmp/lib/tmp.js:
|