fern-api 0.115.1 → 0.115.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +4 -4
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -2430,7 +2430,7 @@ ${hAy.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&X0f(th
2430
2430
  `+Bua.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Bua.default.cyan(wAy(t,this.opt.mask)):Bua.default.italic(Bua.default.dim("[hidden]")):this.opt.mask?wAy(t,this.opt.mask):Bua.default.italic(Bua.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 KSu=$i(mse(),1);var wPy=$i(Bmf(),1),HSu=require("child_process"),RZa=require("fs"),GSu=$i(require("path"),1),jPy=$i(require("os"),1),EPy=require("crypto"),yOf=$i(APy(),1);var USu=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var p$o=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var VSu=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var WSu=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function JSu(e="",t,r){let n=new vOf(e,r);n.runAsync((i,a)=>{if(i)setImmediate(t,i,void 0);else try{n.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function PPy(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function rDC(e){let t=[],r="";for(let n=0;n<e.length;n++){let i=e.charAt(n);n>0&&i===" "&&e[n-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${i}`}return r.length>0&&t.push(r),t}var vOf=class{text="";tempFile;editor;lastExitStatus=0;fileOptions={};get temp_file(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile}get last_exit_status(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus}constructor(t="",r){this.text=t,r&&(this.fileOptions=r),this.determineEditor(),this.createTemporaryFile()}run(){return this.launchEditor(),this.readTemporaryFile(),this.text}runAsync(t){try{this.launchEditorAsync(()=>{try{this.readTemporaryFile(),setImmediate(t,void 0,this.text)}catch(r){setImmediate(t,r,void 0)}})}catch(r){setImmediate(t,r,void 0)}}cleanup(){this.removeTemporaryFile()}determineEditor(){let t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:process.platform.startsWith("win")?"notepad":"vim",r=rDC(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??jPy.default.tmpdir(),r=(0,EPy.randomUUID)(),n=PPy(this.fileOptions.prefix),i=PPy(this.fileOptions.postfix),a=`${n}${r}${i}`,o=GSu.default.resolve(t,a),c=GSu.default.resolve(t)+GSu.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let f={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(f.mode=this.fileOptions.mode),(0,RZa.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new USu(t)}}readTemporaryFile(){try{let t=(0,RZa.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,wPy.detect)(t)??"utf8";yOf.default.encodingExists(r)||(r="utf8"),this.text=yOf.default.decode(t,r)}}catch(t){throw new VSu(t)}}removeTemporaryFile(){try{(0,RZa.unlinkSync)(this.tempFile)}catch(t){throw new WSu(t)}}launchEditor(){try{let t=(0,HSu.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new p$o(t)}}launchEditorAsync(t){try{(0,HSu.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new p$o(r)}}};var SPy=$i(Nrt(),1);var _$o=class extends Ose{_run(t){this.done=t,this.editorResult=new SPy.Subject;let r=Hve(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?KSu.default.dim("Received"):KSu.default.dim("Press <enter> to launch your preferred editor."),t&&(r=KSu.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),JSu(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 BPy=require("stream");var IPy=$i(require("readline"),1),MPy=$i(CPy(),1),Nua=class{constructor(t){this.rl||=IPy.default.createInterface(iDC(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 iDC(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new MPy.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var h$o=class extends Nua{constructor(t={}){super(t),this.log=new BPy.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return ZKo(this.rl,this.bottomBar.split(`
2431
2431
  `).length),this}updateBottomBar(t){return ZKo(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+`
2432
2432
  `}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&&ySu(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var W4=$i(Nrt(),1),RPy=$i(gKo(),1);var $Su=$i(Nrt(),1),TPy=$i(gKo(),1),YSu=function(e,t,r){return typeof e[t]!="function"?(0,$Su.of)(e):(0,$Su.from)((0,TPy.default)(e[t])(r).then(n=>(e[t]=n,e)))};var qPy={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,a,o)=>{i==="__proto__"||i==="constructor"||(a===o.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},NZa=class extends Nua{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let n;return Array.isArray(t)?n=(0,W4.from)(t):(0,W4.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,W4.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,W4.from)([t]),this.process=n.pipe((0,W4.concatMap)(this.processQuestion.bind(this)),(0,W4.publish)()),this.process.connect(),this.process.pipe((0,W4.reduce)((i,a)=>(qPy.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,W4.defer)(()=>(0,W4.of)(t).pipe((0,W4.concatMap)(this.setDefaultType.bind(this)),(0,W4.concatMap)(this.filterIfRunnable.bind(this)),(0,W4.concatMap)(()=>YSu(t,"message",this.answers)),(0,W4.concatMap)(()=>YSu(t,"default",this.answers)),(0,W4.concatMap)(()=>YSu(t,"choices",this.answers)),(0,W4.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,W4.defer)(()=>(0,W4.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,W4.defer)(()=>(0,W4.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&qPy.get(this.answers,t.name)!==void 0)return W4.EMPTY;if(t.when===!1)return W4.EMPTY;if(typeof t.when!="function")return(0,W4.of)(t);let{answers:r}=this;return(0,W4.defer)(()=>(0,W4.from)((0,RPy.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,W4.filter)(n=>n!=null)))}};function NPy(e){let t=function(r,n){let i;try{i=new NZa(t.prompts,e)}catch(o){return Promise.reject(o)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",e$o),this.registerPrompt("input",Mua),this.registerPrompt("number",t$o),this.registerPrompt("confirm",r$o),this.registerPrompt("rawlist",n$o),this.registerPrompt("expand",i$o),this.registerPrompt("checkbox",a$o),this.registerPrompt("password",o$o),this.registerPrompt("editor",_$o)},t.restoreDefaultPrompts(),t}var gOf=NPy();function oDC(e,t){gOf.registerPrompt(e,t)}function sDC(){gOf.restoreDefaultPrompts()}var uDC={prompt:gOf,ui:{BottomBar:h$o,Prompt:NZa},createPromptModule:NPy,registerPrompt:oDC,restoreDefaultPrompts:sDC,Separator:oxe},XSu=uDC;var $Za=require("path"),hjy=require("fs"),yjy=require("readline"),Qwy="posthog-node";function RIC(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"]}={}){return a=>{if(!(i==="*"||i.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[vDu.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=u;let s=a.exception?.values||[],l=s.map(O=>({...O,stacktrace:O.stacktrace?{...O.stacktrace,type:"raw",frames:(O.stacktrace.frames||[]).map(P=>({...P,platform:"node:javascript"}))}:void 0})),m={$exception_message:s[0]?.value||a.message,$exception_type:s[0]?.type,$exception_personURL:u,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:s[0]?.value||a.message,$sentry_exception_type:s[0]?.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:m}),a}}var vDu=class{constructor(t,r,n,i){this.name=Qwy,this.name=Qwy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(RIC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};vDu.POSTHOG_ID_TAG="posthog_distinct_id";var dDu="0123456789abcdef",bDu=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=dDu.charAt(this.bytes[r]>>>4),t+=dDu.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+=dDu.charAt(this.bytes[r]>>>4),t+=dDu.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},nAf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??NIC()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return bDu.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,bDu.ofInner(t)}},NIC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Lwy,iAf=()=>FIC().toString(),FIC=()=>(Lwy||(Lwy=new nAf)).generate();function xIC(e,t){let r=!1;return Object.assign(n=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function zIC(e,t){global.process.on("uncaughtException",xIC(e,t))}function QIC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var pDu,Uwy,_Du;function LIC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return _Du&&r.length===Uwy||(Uwy=r.length,_Du=r.reduce((n,i)=>{pDu||(pDu={});let a=pDu[i];if(a)n[a[0]]=a[1];else{let o=e(i);for(let c=o.length-1;c>=0;c--){let u=o[c]?.filename,s=t[i];if(u&&s){n[u]=s,pDu[i]=[u,s];break}}}return n},{})),_Du}function UIC(e){return typeof Event<"u"&&vjy(e,Event)}function VIC(e){return bjy(e,"Object")}function dAf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return vjy(e,Error)}}function vjy(e,t){try{return e instanceof t}catch{return!1}}function WIC(e){return bjy(e,"ErrorEvent")}function bjy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function GIC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=gjy(a,r,n);return{$exception_list:await Promise.all(o.map(async u=>{let s=await ZIC(e,t,u);return s.value=s.value||"",s.type=s.type||"Error",s.mechanism=a,s}))}}function gjy(e,t,r){let n=HIC(e,t,r);return n.cause?[n,...gjy(e,n.cause,r)]:[n]}function HIC(e,t,r){if(dAf(t))return t;if(e.synthetic=!0,VIC(t)){let i=JIC(t);if(i)return i;let a=KIC(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let n=r?.syntheticException||new Error(t);return n.message=`${t}`,n}function JIC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(dAf(r))return r}}function KIC(e){if("name"in e&&typeof e.name=="string"){let n=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(n+=` with message '${e.message}'`),n}else if("message"in e&&typeof e.message=="string")return e.message;let t=YIC(e);if(WIC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=$IC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function $IC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function YIC(e,t=40){let r=Object.keys(XIC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return Vwy(n,t);for(let i=r.length;i>0;i--){let a=r.slice(0,i).join(", ");if(!(a.length>t))return i===r.length?a:Vwy(a,t)}return""}function Vwy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function XIC(e){return dAf(e)?{message:e.message,name:e.name,stack:e.stack,...Wwy(e)}:UIC(e)?{type:e.type,target:Gwy(e.target),currentTarget:Gwy(e.currentTarget),...Wwy(e)}:e}function Wwy(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 Gwy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function ZIC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=kIC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function kIC(e,t){return eMC(e(t.stack||"",1),e)}function eMC(e,t){let r=LIC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var tMC=2e3,HZa=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await GIC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||iAf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(zIC(this.onException.bind(this),this.onFatalError.bind(this)),QIC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(tMC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function rMC(e=process.argv[1]?(0,$Za.dirname)(process.argv[1]):process.cwd(),t=$Za.sep==="\\"){let r=t?Hwy(e):e;return n=>{if(!n)return;let i=t?Hwy(n):n,{dir:a,base:o,ext:c}=$Za.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let u=a.lastIndexOf("/node_modules");if(u>-1)return`${a.slice(u+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let s=a.slice(r.length+1).replace(/\//g,".");return s?`${s}:${f}`:f}return f}}function Hwy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var gDu=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)}}},yDu=new gDu(25),mjy=new gDu(20),pAf=7,nMC=1e3,iMC=1e4;async function aMC(e){let t={};for(let i=e.length-1;i>=0;i--){let a=e[i],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||cMC(o)||lMC(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(mjy.get(i))continue;let a=t[i];if(!a)continue;a.sort((f,u)=>f-u);let o=dMC(a);if(o.every(f=>fMC(i,f)))continue;let c=pMC(yDu,i,{});n.push(oMC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&sMC(e,yDu),yDu.reduce(),e}function oMC(e,t,r){return new Promise(n=>{let i=(0,hjy.createReadStream)(e),a=(0,yjy.createInterface)({input:i});function o(){i.destroy(),n()}let c=0,f=0,u=t[f];if(u===void 0){o();return}let s=u[0],l=u[1];function m(){mjy.set(e,1),a.close(),a.removeAllListeners(),o()}i.on("error",m),a.on("error",m),a.on("close",o),a.on("line",O=>{if(c++,!(c<s)&&(r[c]=_MC(O,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let P=t[f];if(P===void 0){a.close(),a.removeAllListeners();return}s=P[0],l=P[1]}})})}function sMC(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;uMC(r.lineno,r,n)}}function uMC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=Ojy(e);i<e;i++){let a=r[i];if(a===void 0){Jwy(t);return}t.pre_context.push(a)}if(r[e]===void 0){Jwy(t);return}t.context_line=r[e];let n=Ajy(e);t.post_context=[];for(let i=e+1;i<=n;i++){let a=r[i];if(a===void 0)break;t.post_context.push(a)}}function Jwy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function cMC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function lMC(e){return e.lineno!==void 0&&e.lineno>iMC||e.colno!==void 0&&e.colno>nMC}function fMC(e,t){let r=yDu.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function dMC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=Kwy(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let a=e[t+1];if(typeof a!="number")break;a<=n[1]?n[1]=a+pAf:(i.push(n),n=Kwy(a)),t++}return i}function Kwy(e){return[Ojy(e),Ajy(e)]}function Ojy(e){return Math.max(1,e-pAf)}function Ajy(e){return e+pAf}function pMC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function _MC(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,n);return a>n-5&&(a=n),a===n&&(i=Math.max(a-140,0)),r=r.slice(i,a),i>0&&(r=`...${r}`),a<n&&(r+="..."),r}var hMC="4.18.0",fxe;(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"})(fxe||(fxe={}));var $wy;(function(e){e.Left="left",e.Right="right",e.Center="center"})($wy||($wy={}));var Ywy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(Ywy||(Ywy={}));var Xwy;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(Xwy||(Xwy={}));var Zwy;(function(e){e.Html="html",e.Text="text"})(Zwy||(Zwy={}));var kwy;(function(e){e.Number="number",e.Emoji="emoji"})(kwy||(kwy={}));var ejy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(ejy||(ejy={}));var tjy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(tjy||(tjy={}));var rjy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(rjy||(rjy={}));var njy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(njy||(njy={}));var yMC=e=>{if("flags"in e){let t=bMC(e.flags),r=gMC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,Pjy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,vMC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function vMC(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 bMC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,_Af(r)]).filter(([,t])=>t!==void 0)),gMC=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let n=t[r];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(r=>{let n=t[r].metadata?.payload;return[r,n?Pjy(n):void 0]}))},_Af=e=>e===void 0?void 0:e.variant??e.enabled,Pjy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},mMC=1,OMC=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"]),AMC="utf8";function PMC(e,t){if(!e||typeof e!="string"||wMC(e))throw new Error(t)}function wMC(e){return e.trim().length===0}function jMC(e){return e?.replace(/\/+$/,"")}async function EMC(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function ijy(){return new Date().getTime()}function tAf(){return new Date().toISOString()}function mDu(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function SMC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function DMC(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 CMC(e,t=0,r){let n=DMC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function ajy(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var j$o=String.fromCharCode,ojy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",hDu={};function IMC(e,t){if(!hDu[e]){hDu[e]={};for(let r=0;r<e.length;r++)hDu[e][e.charAt(r)]=r}return hDu[e][t]}var WZa={compressToBase64:function(e){if(e==null)return"";let t=WZa._compress(e,6,function(r){return ojy.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:WZa._decompress(e.length,32,function(t){return IMC(ojy,e.charAt(t))})},compress:function(e){return WZa._compress(e,16,function(t){return j$o(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],o,c,f="",u="",s="",l=2,m=3,O=2,P=0,C=0,I;for(I=0;I<e.length;I+=1)if(f=e.charAt(I),Object.prototype.hasOwnProperty.call(n,f)||(n[f]=m++,i[f]=!0),u=s+f,Object.prototype.hasOwnProperty.call(n,u))s=u;else{if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<O;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<O;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[s]}else for(c=n[s],o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[u]=m++,s=String(f)}if(s!==""){if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<O;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<O;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[s]}else for(c=n[s],o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(c=2,o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;for(;;)if(P=P<<1,C==t-1){a.push(r(P));break}else C++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:WZa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,u="",s,l,m,O,P,C,I;for(s=0;s<3;s+=1)n[s]=s;for(m=0,P=Math.pow(2,2),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;switch(m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;I=j$o(m);break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;I=j$o(m);break;case 2:return""}for(n[3]=I,l=I,i.push(I);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,f),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;switch(I=m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;n[c++]=j$o(m),I=c-1,o--;break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;n[c++]=j$o(m),I=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,f),f++),n[I])u=n[I];else if(I===c)u=l+l.charAt(0);else return null;i.push(u),n[c++]=l+u.charAt(0),o--,l=u,o==0&&(o=Math.pow(2,f),f++)}}},aAf=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}},JZa=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()}},E$o=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function sjy(e){if(e instanceof JZa){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 rAf(e){return typeof e=="object"&&(e instanceof JZa||e instanceof E$o)}function ujy(e){return typeof e=="object"&&e instanceof JZa&&e.status===413}var oAf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(oAf||(oAf={}));var sAf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new aAf,this._isInitialized=!1,PMC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=jMC(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:rAf},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(fxe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(fxe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(fxe.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=iAf();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}async identifyStatelessImmediate(t,r,n){let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",i,n)}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}async captureStatelessImmediate(t,r,n,i){let a=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",a,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}async aliasStatelessImmediate(t,r,n,i){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,i)}groupIdentifyStateless(t,r,n,i,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...o||{}}});this.enqueue("capture",c,i)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(i=>i.json()).catch(i=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",i)),this._events.emit("error",i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let c=CMC(this.apiKey,mMC,OMC)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(u=>u.json()).then(u=>yMC(u)).catch(u=>{this._events.emit("error",u)})}async getFeatureFlagStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,n,i,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=_Af(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,n,i,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,n,i,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,n,i,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,n,i,c);if(f!==void 0)return f.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),f.quotaLimited?.includes(oAf.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},i=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return i&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(i))),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(fxe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(fxe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(fxe.Props,this.props)})}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i=this.prepareMessage(t,r,n),a=this.getPersistedProperty(fxe.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:i}),this.setPersistedProperty(fxe.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=mDu(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={api_key:this.apiKey,batch:[this.prepareMessage(t,r,n)],sent_at:tAf()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${ijy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,c=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(WZa.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:tAf(),uuid:n?.uuid?n.uuid:iAf()};return(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId),i}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await sjy(t)})}async flush(){let t=ajy([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),ajy([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(fxe.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),a=i.map(m=>m.message),o=()=>{let O=(this.getPersistedProperty(fxe.Queue)||[]).slice(i.length);this.setPersistedProperty(fxe.Queue,O),t=O},c={api_key:this.apiKey,batch:a,sent_at:tAf()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${ijy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,s=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(WZa.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:m=>ujy(m)?!1:rAf(m)};try{await this.fetchWithRetry(u,s,l)}catch(m){if(ujy(m)&&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 m instanceof E$o||o(),this._events.emit("error",m),m}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(u){let s=new AbortController;return setTimeout(()=>s.abort(),u),s.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,AMC)}catch{c=new TextEncoder().encode(o).length}return await EMC(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(s){throw new E$o(s)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new JZa(f,c);return f},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(fxe.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!rAf(i))throw i;await sjy(i)}};return Promise.race([new Promise((i,a)=>{mDu(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},uAf=SMC();if(!uAf){let e=zwy();uAf=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var wjy=uAf,ODu=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()}},jjy=new ODu(async()=>{try{return await import("crypto")}catch{return}});async function MMC(){return await jjy.getValue()}var BMC=new ODu(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await jjy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function TMC(){return await BMC.getValue()}async function qMC(e){let t=await MMC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await TMC();if(r){let n=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var RMC=60*1e3,NMC=1152921504606847e3,FMC=["is_not"],GZa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},Ase=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},cAf=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=c.fetch||wjy,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof Ase?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let u=await this.computeFlagLocally(f,t,r,n,i);a[f.key]=u;let s=await this.computeFeatureFlagPayloadLocally(f.key,u);s&&(o[f.key]=s)}catch(u){u instanceof Ase||u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${u}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new Ase("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let f=this.groupTypeMapping[String(c)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new Ase("Flag has unknown group type index");if(!(f in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[f];return await this.matchFeatureFlagProperties(t,n[f],u)}else return await this.matchFeatureFlagProperties(t,r,i)}async matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],o=!1,c,f=[...a].sort((u,s)=>{let l=!!u.variant,m=!!s.variant;return l&&m?0:l?-1:m?1:0});for(let u of f)try{if(await this.isConditionMatch(t,r,u,n)){let s=u.variant,l=i.multivariate?.variants||[];s&&l.some(m=>m.key===s)?c=s:c=await this.getMatchingVariant(t,r)||!0;break}}catch(s){if(s instanceof Ase)o=!0;else throw s}if(c!==void 0)return c;if(o)throw new Ase("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i){let a=n.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let f=c.type,u=!1;if(f==="cohort"?u=Sjy(c,i,this.cohorts,this.debugMode):u=Ejy(c,i,o),!u)return!1}if(a==null)return!0}return!(a!=null&&await cjy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await cjy(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{i=n+c.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:c.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(RMC,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 GZa(`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 GZa(`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 GZa(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof GZa&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=mDu(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,n=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;i=mDu(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function cjy(e,t,r=""){let n=await qMC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/NMC}function Ejy(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new Ase("Operator is_not_set is not supported")}else throw new Ase(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!FMC.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(u,s){return Array.isArray(u)?u.map(l=>String(l).toLowerCase()).includes(String(s).toLowerCase()):String(u).toLowerCase()===String(s).toLowerCase()}function f(u,s,l){if(l==="gt")return u>s;if(l==="gte")return u>=s;if(l==="lt")return u<s;if(l==="lte")return u<=s;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(i,o);case"is_not":return!c(i,o);case"is_set":return n in t;case"icontains":return String(o).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(i).toLowerCase());case"regex":return ljy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return ljy(String(i))&&String(o).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let u=typeof i=="number"?i:null;if(typeof i=="string")try{u=parseFloat(i)}catch{}return u!=null&&o!=null?typeof o=="string"?f(o,String(i),a):f(o,u,a):f(String(o),String(i),a)}case"is_date_after":case"is_date_before":{let u=xMC(String(i));if(u==null&&(u=fjy(i)),u==null)throw new Ase(`Invalid date: ${i}`);let s=fjy(o);return["is_date_before"].includes(a)?s<u:s>u}default:throw new Ase(`Unknown operator: ${a}`)}}function Sjy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new Ase("can't match cohort without a given cohort property value");let a=r[i];return Djy(a,t,r,n)}function Djy(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=Djy(c,t,r,n);if(i==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof Ase)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new Ase("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=Sjy(c,t,r,n):f=Ejy(c,t);let u=c.negation||!1;if(i==="AND"){if(!f&&!u||f&&u)return!1}else if(f&&!u||!f&&u)return!0}catch(f){if(f instanceof Ase)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new Ase("can't match cohort without a given cohort property value");return i==="AND"}}function ljy(e){try{return new RegExp(e),!0}catch{return!1}}function fjy(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 Ase(`${e} is in an invalid date format`)}else throw new Ase(`The date provided ${e} must be a string, number, or date object`)}function xMC(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var lAf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},zMC=100,djy=30*1e3,QMC=50*1e3,fAf=class extends sAf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new lAf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,zMC):djy,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 cAf({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new HZa(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||QMC}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):wjy(t,r)}getLibraryVersion(){return hMC}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=O=>{super.captureStateless(r,n,O,{timestamp:c,disableGeoip:f,uuid:u})},l=async(O,P,C)=>(await super.getFeatureFlagsStateless(O,P,void 0,void 0,C)).flags,m=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let O={};for(let[P,C]of Object.entries(a||{}))O[P]=String(C);return await this.getAllFlags(r,{groups:O,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(O=>{let P={};if(O)for(let[I,T]of Object.entries(O))P[`$feature/${I}`]=T;let C=Object.keys(O||{}).filter(I=>O?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(O=>{s({...O,...i,$groups:a})});this.addPendingPromise(m)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=O=>super.captureStatelessImmediate(r,n,O,{timestamp:c,disableGeoip:f,uuid:u}),l=async(O,P,C)=>(await super.getFeatureFlagsStateless(O,P,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let O={};for(let[P,C]of Object.entries(a||{}))O[P]=String(C);return await this.getAllFlags(r,{groups:O,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(O=>{let P={};if(O)for(let[I,T]of Object.entries(O))P[`$feature/${I}`]=T;let C=Object.keys(O||{}).filter(I=>O?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(O=>{s({...O,...i,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:i},{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=djy){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(n),i(),r(a>0)})})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:u}=n||{},s=this.addLocalPersonAndGroupProperties(r,i,f,u);f=s.allPersonProperties,u=s.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,f,u),m=l!==void 0,O,P;if(!m&&!o){let I=await super.getFeatureFlagDetailStateless(t,r,i,f,u,a);if(I===void 0)return;P=I.response,l=_Af(P),O=I?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id:O},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:o}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:u,groupProperties:s}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,u,s);u=l.allPersonProperties,s=l.allGroupProperties;let m;return this.featureFlagsPoller!==void 0&&(n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(m!==void 0)&&!c&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,u,s,o)),m}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,n,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,o,c),s={},l={},m=!0;if(u&&(s=u.response,l=u.payloads,m=u.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,n,o,c,i);s={...s,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:s,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...i?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,n){let i=new Error("PostHog syntheticException");HZa.captureException(this,t,{syntheticException:i},r,n)}},pjy=/\(error: (.*)\)/,Cjy=50,Ijy="?";function LMC(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return n=>{let i=n.match(r);if(i){let a,o,c,f,u;if(i[1]){c=i[1];let m=c.lastIndexOf(".");if(c[m-1]==="."&&m--,m>0){a=c.slice(0,m),o=c.slice(m+1);let O=a.indexOf(".Module");O>0&&(c=c.slice(O+1),a=a.slice(0,O))}f=void 0}o&&(f=a,u=o),o==="<anonymous>"&&(u=void 0,c=void 0),c===void 0&&(u=u||Ijy,c=f?`${f}.${u}`:u);let s=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return s?.match(/\/[A-Z]:/)&&(s=s.slice(1)),!s&&i[5]&&!l&&(s=i[5]),{filename:s?decodeURI(s):void 0,module:e?e(s):void 0,function:c,lineno:_jy(i[3]),colno:_jy(i[4]),in_app:UMC(s||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function UMC(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 _jy(e){return parseInt(e||"",10)||void 0}function VMC(e){return[90,LMC(e)]}function WMC(e){let r=[VMC(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],o=n.split(`
2433
- `);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=pjy.test(f)?f.replace(pjy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=Cjy)break}}return GMC(a)}}function GMC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,Cjy).map(r=>({...r,filename:r.filename||HMC(t).filename,function:r.function||Ijy}))}function HMC(e){return e[e.length-1]||{}}HZa.stackParser=WMC(rMC());HZa.frameModifiers=[aMC];var KZa=class extends fAf{getLibraryId(){return"posthog-node"}};var ADu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new KZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.115.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var S$o=class{async sendEvent(){}async identify(){}async flush(){}};var YZa=require("fs/promises"),qjy=require("os"),Rjy=require("path");var Mjy=$i(require("crypto")),wDu=new Uint8Array(256),PDu=wDu.length;function hAf(){return PDu>wDu.length-16&&(Mjy.default.randomFillSync(wDu),PDu=0),wDu.slice(PDu,PDu+=16)}var Kve=[];for(let e=0;e<256;++e)Kve.push((e+256).toString(16).slice(1));function Bjy(e,t=0){return Kve[e[t+0]]+Kve[e[t+1]]+Kve[e[t+2]]+Kve[e[t+3]]+"-"+Kve[e[t+4]]+Kve[e[t+5]]+"-"+Kve[e[t+6]]+Kve[e[t+7]]+"-"+Kve[e[t+8]]+Kve[e[t+9]]+"-"+Kve[e[t+10]]+Kve[e[t+11]]+Kve[e[t+12]]+Kve[e[t+13]]+Kve[e[t+14]]+Kve[e[t+15]]}var Tjy=$i(require("crypto")),yAf={randomUUID:Tjy.default.randomUUID};function JMC(e,t,r){if(yAf.randomUUID&&!t&&!e)return yAf.randomUUID();e=e||{};let n=e.random||(e.rng||hAf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Bjy(n)}var xrt=JMC;var KMC="id",$MC=".fern",D$o=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new KZa(r),this.userId=t==null?void 0:Fhf(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.115.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ql(F_.of((0,qjy.homedir)()),ru.of($MC),ru.of(KMC));await Vv(t)||(await(0,YZa.mkdir)((0,Rjy.dirname)(t),{recursive:!0}),await(0,YZa.writeFile)(t,xrt())),this.persistedDistinctId=(await(0,YZa.readFile)(t)).toString()}return this.persistedDistinctId}};var vAf;async function XZa(){return vAf==null&&(vAf=await YMC()),vAf}async function YMC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new S$o;let r=await LAu();return r!=null?new D$o({token:r,posthogApiKey:e}):await eXa()!=null?new ADu({posthogApiKey:e}):new D$o({token:void 0,posthogApiKey:e})}catch{return new S$o}}function C$o(e,t){return function(){return e.apply(t,arguments)}}var{toString:XMC}=Object.prototype,{getPrototypeOf:gAf}=Object,{iterator:EDu,toStringTag:Fjy}=Symbol,SDu=(e=>t=>{let r=XMC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),YTr=e=>(e=e.toLowerCase(),t=>SDu(t)===e),DDu=e=>t=>typeof t===e,{isArray:kZa}=Array,ZZa=DDu("undefined");function I$o(e){return e!==null&&!ZZa(e)&&e.constructor!==null&&!ZZa(e.constructor)&&dxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var xjy=YTr("ArrayBuffer");function ZMC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xjy(e.buffer),t}var kMC=DDu("string"),dxe=DDu("function"),zjy=DDu("number"),M$o=e=>e!==null&&typeof e=="object",eBC=e=>e===!0||e===!1,jDu=e=>{if(SDu(e)!=="object")return!1;let t=gAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Fjy in e)&&!(EDu in e)},tBC=e=>{if(!M$o(e)||I$o(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rBC=YTr("Date"),nBC=YTr("File"),iBC=YTr("Blob"),aBC=YTr("FileList"),oBC=e=>M$o(e)&&dxe(e.pipe),sBC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||dxe(e.append)&&((t=SDu(e))==="formdata"||t==="object"&&dxe(e.toString)&&e.toString()==="[object FormData]"))},uBC=YTr("URLSearchParams"),[cBC,lBC,fBC,dBC]=["ReadableStream","Request","Response","Headers"].map(YTr),pBC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function B$o(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),kZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(I$o(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function Qjy(e,t){if(I$o(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Uua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ljy=e=>!ZZa(e)&&e!==Uua;function bAf(){let{caseless:e,skipUndefined:t}=Ljy(this)&&this||{},r={},n=(i,a)=>{let o=e&&Qjy(r,a)||a;jDu(r[o])&&jDu(i)?r[o]=bAf(r[o],i):jDu(i)?r[o]=bAf({},i):kZa(i)?r[o]=i.slice():(!t||!ZZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&B$o(arguments[i],n);return r}var _BC=(e,t,r,{allOwnKeys:n}={})=>(B$o(t,(i,a)=>{r&&dxe(i)?e[a]=C$o(i,r):e[a]=i},{allOwnKeys:n}),e),hBC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),yBC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},vBC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&gAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},bBC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},gBC=e=>{if(!e)return null;if(kZa(e))return e;let t=e.length;if(!zjy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},mBC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&gAf(Uint8Array)),OBC=(e,t)=>{let n=(e&&e[EDu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ABC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},PBC=YTr("HTMLFormElement"),wBC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),Njy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),jBC=YTr("RegExp"),Ujy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};B$o(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},EBC=e=>{Ujy(e,(t,r)=>{if(dxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(dxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},SBC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return kZa(e)?n(e):n(String(e).split(t)),r},DBC=()=>{},CBC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function IBC(e){return!!(e&&dxe(e.append)&&e[Fjy]==="FormData"&&e[EDu])}var MBC=e=>{let t=new Array(10),r=(n,i)=>{if(M$o(n)){if(t.indexOf(n)>=0)return;if(I$o(n))return n;if(!("toJSON"in n)){t[i]=n;let a=kZa(n)?[]:{};return B$o(n,(o,c)=>{let f=r(o,i+1);!ZZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},BBC=YTr("AsyncFunction"),TBC=e=>e&&(M$o(e)||dxe(e))&&dxe(e.then)&&dxe(e.catch),Vjy=((e,t)=>e?setImmediate:t?((r,n)=>(Uua.addEventListener("message",({source:i,data:a})=>{i===Uua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Uua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",dxe(Uua.postMessage)),qBC=typeof queueMicrotask<"u"?queueMicrotask.bind(Uua):typeof process<"u"&&process.nextTick||Vjy,RBC=e=>e!=null&&dxe(e[EDu]),Zf={isArray:kZa,isArrayBuffer:xjy,isBuffer:I$o,isFormData:sBC,isArrayBufferView:ZMC,isString:kMC,isNumber:zjy,isBoolean:eBC,isObject:M$o,isPlainObject:jDu,isEmptyObject:tBC,isReadableStream:cBC,isRequest:lBC,isResponse:fBC,isHeaders:dBC,isUndefined:ZZa,isDate:rBC,isFile:nBC,isBlob:iBC,isRegExp:jBC,isFunction:dxe,isStream:oBC,isURLSearchParams:uBC,isTypedArray:mBC,isFileList:aBC,forEach:B$o,merge:bAf,extend:_BC,trim:pBC,stripBOM:hBC,inherits:yBC,toFlatObject:vBC,kindOf:SDu,kindOfTest:YTr,endsWith:bBC,toArray:gBC,forEachEntry:OBC,matchAll:ABC,isHTMLForm:PBC,hasOwnProperty:Njy,hasOwnProp:Njy,reduceDescriptors:Ujy,freezeMethods:EBC,toObjectSet:SBC,toCamelCase:wBC,noop:DBC,toFiniteNumber:CBC,findKey:Qjy,global:Uua,isContextDefined:Ljy,isSpecCompliantForm:IBC,toJSONObject:MBC,isAsyncFn:BBC,isThenable:TBC,setImmediate:Vjy,asap:qBC,isIterable:RBC};function eka(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(eka,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:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var Wjy=eka.prototype,Gjy={};["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=>{Gjy[e]={value:e}});Object.defineProperties(eka,Gjy);Object.defineProperty(Wjy,"isAxiosError",{value:!0});eka.from=(e,t,r,n,i,a)=>{let o=Object.create(Wjy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return eka.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Lm=eka;var Hjy=$i(Esa(),1),CDu=Hjy.default;function mAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function Kjy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function Jjy(e,t,r){return e?e.concat(t).map(function(i,a){return i=Kjy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function NBC(e){return Zf.isArray(e)&&!e.some(mAf)}var FBC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function xBC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(CDu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new Lm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&NBC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=Kjy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?Jjy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return mAf(P)?!0:(t.append(Jjy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(FBC,{defaultVisitor:s,convertValue:u,isVisitable:mAf});function O(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&O(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return O(e),t}var S4i=xBC;function $jy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Yjy(e,t){this._pairs=[],e&&S4i(e,this,t)}var Xjy=Yjy.prototype;Xjy.append=function(t,r){this._pairs.push([t,r])};Xjy.toString=function(t){let r=t?function(n){return t.call(this,n,$jy)}:$jy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var Zjy=Yjy;function zBC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Vua(e,t,r){if(!t)return e;let n=r&&r.encode||zBC;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new Zjy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var OAf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},AAf=OAf;var tka={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var r1y=$i(require("crypto"),1);var kjy=$i(require("url"),1),e1y=kjy.default.URLSearchParams;var PAf="abcdefghijklmnopqrstuvwxyz",t1y="0123456789",n1y={DIGIT:t1y,ALPHA:PAf,ALPHA_DIGIT:PAf+PAf.toUpperCase()+t1y},QBC=(e=16,t=n1y.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);r1y.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},i1y={isNode:!0,classes:{URLSearchParams:e1y,FormData:CDu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:n1y,generateString:QBC,protocols:["http","https","file","data"]};var EAf={};yf(EAf,{hasBrowserEnv:()=>jAf,hasStandardBrowserEnv:()=>LBC,hasStandardBrowserWebWorkerEnv:()=>UBC,navigator:()=>wAf,origin:()=>VBC});var jAf=typeof window<"u"&&typeof document<"u",wAf=typeof navigator=="object"&&navigator||void 0,LBC=jAf&&(!wAf||["ReactNative","NativeScript","NS"].indexOf(wAf.product)<0),UBC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VBC=jAf&&window.location.href||"http://localhost";var G7={...EAf,...i1y};function SAf(e,t){return S4i(e,new G7.classes.URLSearchParams,{visitor:function(r,n,i,a){return G7.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function WBC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GBC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function HBC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=GBC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(WBC(n),i,r,0)}),r}return null}var IDu=HBC;function JBC(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var DAf={transitional:tka,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(IDu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return SAf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return S4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),JBC(t)):t}],transformResponse:[function(t){let r=this.transitional||DAf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Lm.from(c,Lm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:G7.classes.FormData,Blob:G7.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{DAf.headers[e]={}});var rka=DAf;var KBC=Zf.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"]),a1y=e=>{let t={},r,n,i;return e&&e.split(`
2433
+ `);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=pjy.test(f)?f.replace(pjy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=Cjy)break}}return GMC(a)}}function GMC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,Cjy).map(r=>({...r,filename:r.filename||HMC(t).filename,function:r.function||Ijy}))}function HMC(e){return e[e.length-1]||{}}HZa.stackParser=WMC(rMC());HZa.frameModifiers=[aMC];var KZa=class extends fAf{getLibraryId(){return"posthog-node"}};var ADu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new KZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.115.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var S$o=class{async sendEvent(){}async identify(){}async flush(){}};var YZa=require("fs/promises"),qjy=require("os"),Rjy=require("path");var Mjy=$i(require("crypto")),wDu=new Uint8Array(256),PDu=wDu.length;function hAf(){return PDu>wDu.length-16&&(Mjy.default.randomFillSync(wDu),PDu=0),wDu.slice(PDu,PDu+=16)}var Kve=[];for(let e=0;e<256;++e)Kve.push((e+256).toString(16).slice(1));function Bjy(e,t=0){return Kve[e[t+0]]+Kve[e[t+1]]+Kve[e[t+2]]+Kve[e[t+3]]+"-"+Kve[e[t+4]]+Kve[e[t+5]]+"-"+Kve[e[t+6]]+Kve[e[t+7]]+"-"+Kve[e[t+8]]+Kve[e[t+9]]+"-"+Kve[e[t+10]]+Kve[e[t+11]]+Kve[e[t+12]]+Kve[e[t+13]]+Kve[e[t+14]]+Kve[e[t+15]]}var Tjy=$i(require("crypto")),yAf={randomUUID:Tjy.default.randomUUID};function JMC(e,t,r){if(yAf.randomUUID&&!t&&!e)return yAf.randomUUID();e=e||{};let n=e.random||(e.rng||hAf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Bjy(n)}var xrt=JMC;var KMC="id",$MC=".fern",D$o=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new KZa(r),this.userId=t==null?void 0:Fhf(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.115.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ql(F_.of((0,qjy.homedir)()),ru.of($MC),ru.of(KMC));await Vv(t)||(await(0,YZa.mkdir)((0,Rjy.dirname)(t),{recursive:!0}),await(0,YZa.writeFile)(t,xrt())),this.persistedDistinctId=(await(0,YZa.readFile)(t)).toString()}return this.persistedDistinctId}};var vAf;async function XZa(){return vAf==null&&(vAf=await YMC()),vAf}async function YMC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new S$o;let r=await LAu();return r!=null?new D$o({token:r,posthogApiKey:e}):await eXa()!=null?new ADu({posthogApiKey:e}):new D$o({token:void 0,posthogApiKey:e})}catch{return new S$o}}function C$o(e,t){return function(){return e.apply(t,arguments)}}var{toString:XMC}=Object.prototype,{getPrototypeOf:gAf}=Object,{iterator:EDu,toStringTag:Fjy}=Symbol,SDu=(e=>t=>{let r=XMC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),YTr=e=>(e=e.toLowerCase(),t=>SDu(t)===e),DDu=e=>t=>typeof t===e,{isArray:kZa}=Array,ZZa=DDu("undefined");function I$o(e){return e!==null&&!ZZa(e)&&e.constructor!==null&&!ZZa(e.constructor)&&dxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var xjy=YTr("ArrayBuffer");function ZMC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xjy(e.buffer),t}var kMC=DDu("string"),dxe=DDu("function"),zjy=DDu("number"),M$o=e=>e!==null&&typeof e=="object",eBC=e=>e===!0||e===!1,jDu=e=>{if(SDu(e)!=="object")return!1;let t=gAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Fjy in e)&&!(EDu in e)},tBC=e=>{if(!M$o(e)||I$o(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rBC=YTr("Date"),nBC=YTr("File"),iBC=YTr("Blob"),aBC=YTr("FileList"),oBC=e=>M$o(e)&&dxe(e.pipe),sBC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||dxe(e.append)&&((t=SDu(e))==="formdata"||t==="object"&&dxe(e.toString)&&e.toString()==="[object FormData]"))},uBC=YTr("URLSearchParams"),[cBC,lBC,fBC,dBC]=["ReadableStream","Request","Response","Headers"].map(YTr),pBC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function B$o(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),kZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(I$o(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function Qjy(e,t){if(I$o(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Uua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ljy=e=>!ZZa(e)&&e!==Uua;function bAf(){let{caseless:e,skipUndefined:t}=Ljy(this)&&this||{},r={},n=(i,a)=>{let o=e&&Qjy(r,a)||a;jDu(r[o])&&jDu(i)?r[o]=bAf(r[o],i):jDu(i)?r[o]=bAf({},i):kZa(i)?r[o]=i.slice():(!t||!ZZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&B$o(arguments[i],n);return r}var _BC=(e,t,r,{allOwnKeys:n}={})=>(B$o(t,(i,a)=>{r&&dxe(i)?e[a]=C$o(i,r):e[a]=i},{allOwnKeys:n}),e),hBC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),yBC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},vBC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&gAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},bBC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},gBC=e=>{if(!e)return null;if(kZa(e))return e;let t=e.length;if(!zjy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},mBC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&gAf(Uint8Array)),OBC=(e,t)=>{let n=(e&&e[EDu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ABC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},PBC=YTr("HTMLFormElement"),wBC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),Njy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),jBC=YTr("RegExp"),Ujy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};B$o(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},EBC=e=>{Ujy(e,(t,r)=>{if(dxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(dxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},SBC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return kZa(e)?n(e):n(String(e).split(t)),r},DBC=()=>{},CBC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function IBC(e){return!!(e&&dxe(e.append)&&e[Fjy]==="FormData"&&e[EDu])}var MBC=e=>{let t=new Array(10),r=(n,i)=>{if(M$o(n)){if(t.indexOf(n)>=0)return;if(I$o(n))return n;if(!("toJSON"in n)){t[i]=n;let a=kZa(n)?[]:{};return B$o(n,(o,c)=>{let f=r(o,i+1);!ZZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},BBC=YTr("AsyncFunction"),TBC=e=>e&&(M$o(e)||dxe(e))&&dxe(e.then)&&dxe(e.catch),Vjy=((e,t)=>e?setImmediate:t?((r,n)=>(Uua.addEventListener("message",({source:i,data:a})=>{i===Uua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Uua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",dxe(Uua.postMessage)),qBC=typeof queueMicrotask<"u"?queueMicrotask.bind(Uua):typeof process<"u"&&process.nextTick||Vjy,RBC=e=>e!=null&&dxe(e[EDu]),Zf={isArray:kZa,isArrayBuffer:xjy,isBuffer:I$o,isFormData:sBC,isArrayBufferView:ZMC,isString:kMC,isNumber:zjy,isBoolean:eBC,isObject:M$o,isPlainObject:jDu,isEmptyObject:tBC,isReadableStream:cBC,isRequest:lBC,isResponse:fBC,isHeaders:dBC,isUndefined:ZZa,isDate:rBC,isFile:nBC,isBlob:iBC,isRegExp:jBC,isFunction:dxe,isStream:oBC,isURLSearchParams:uBC,isTypedArray:mBC,isFileList:aBC,forEach:B$o,merge:bAf,extend:_BC,trim:pBC,stripBOM:hBC,inherits:yBC,toFlatObject:vBC,kindOf:SDu,kindOfTest:YTr,endsWith:bBC,toArray:gBC,forEachEntry:OBC,matchAll:ABC,isHTMLForm:PBC,hasOwnProperty:Njy,hasOwnProp:Njy,reduceDescriptors:Ujy,freezeMethods:EBC,toObjectSet:SBC,toCamelCase:wBC,noop:DBC,toFiniteNumber:CBC,findKey:Qjy,global:Uua,isContextDefined:Ljy,isSpecCompliantForm:IBC,toJSONObject:MBC,isAsyncFn:BBC,isThenable:TBC,setImmediate:Vjy,asap:qBC,isIterable:RBC};function eka(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(eka,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:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var Wjy=eka.prototype,Gjy={};["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=>{Gjy[e]={value:e}});Object.defineProperties(eka,Gjy);Object.defineProperty(Wjy,"isAxiosError",{value:!0});eka.from=(e,t,r,n,i,a)=>{let o=Object.create(Wjy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return eka.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Lm=eka;var Hjy=$i(Esa(),1),CDu=Hjy.default;function mAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function Kjy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function Jjy(e,t,r){return e?e.concat(t).map(function(i,a){return i=Kjy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function NBC(e){return Zf.isArray(e)&&!e.some(mAf)}var FBC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function xBC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(CDu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new Lm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&NBC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=Kjy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?Jjy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return mAf(P)?!0:(t.append(Jjy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(FBC,{defaultVisitor:s,convertValue:u,isVisitable:mAf});function O(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&O(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return O(e),t}var S4i=xBC;function $jy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Yjy(e,t){this._pairs=[],e&&S4i(e,this,t)}var Xjy=Yjy.prototype;Xjy.append=function(t,r){this._pairs.push([t,r])};Xjy.toString=function(t){let r=t?function(n){return t.call(this,n,$jy)}:$jy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var Zjy=Yjy;function zBC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Vua(e,t,r){if(!t)return e;let n=r&&r.encode||zBC;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new Zjy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var OAf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},AAf=OAf;var tka={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var r1y=$i(require("crypto"),1);var kjy=$i(require("url"),1),e1y=kjy.default.URLSearchParams;var PAf="abcdefghijklmnopqrstuvwxyz",t1y="0123456789",n1y={DIGIT:t1y,ALPHA:PAf,ALPHA_DIGIT:PAf+PAf.toUpperCase()+t1y},QBC=(e=16,t=n1y.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);r1y.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},i1y={isNode:!0,classes:{URLSearchParams:e1y,FormData:CDu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:n1y,generateString:QBC,protocols:["http","https","file","data"]};var EAf={};yf(EAf,{hasBrowserEnv:()=>jAf,hasStandardBrowserEnv:()=>LBC,hasStandardBrowserWebWorkerEnv:()=>UBC,navigator:()=>wAf,origin:()=>VBC});var jAf=typeof window<"u"&&typeof document<"u",wAf=typeof navigator=="object"&&navigator||void 0,LBC=jAf&&(!wAf||["ReactNative","NativeScript","NS"].indexOf(wAf.product)<0),UBC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VBC=jAf&&window.location.href||"http://localhost";var G7={...EAf,...i1y};function SAf(e,t){return S4i(e,new G7.classes.URLSearchParams,{visitor:function(r,n,i,a){return G7.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function WBC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GBC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function HBC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=GBC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(WBC(n),i,r,0)}),r}return null}var IDu=HBC;function JBC(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var DAf={transitional:tka,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(IDu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return SAf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return S4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),JBC(t)):t}],transformResponse:[function(t){let r=this.transitional||DAf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Lm.from(c,Lm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:G7.classes.FormData,Blob:G7.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{DAf.headers[e]={}});var rka=DAf;var KBC=Zf.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"]),a1y=e=>{let t={},r,n,i;return e&&e.split(`
2434
2434
  `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&KBC[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var o1y=Symbol("internals");function T$o(e){return e&&String(e).trim().toLowerCase()}function MDu(e){return e===!1||e==null?e:Zf.isArray(e)?e.map(MDu):String(e)}function $BC(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var YBC=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function CAf(e,t,r,n,i){if(Zf.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Zf.isString(t)){if(Zf.isString(n))return t.indexOf(n)!==-1;if(Zf.isRegExp(n))return n.test(t)}}function XBC(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function ZBC(e,t){let r=Zf.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,o){return this[n].call(this,t,i,a,o)},configurable:!0})})}var nka=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,f,u){let s=T$o(f);if(!s)throw new Error("header name must be a non-empty string");let l=Zf.findKey(i,s);(!l||i[l]===void 0||u===!0||u===void 0&&i[l]!==!1)&&(i[l||f]=MDu(c))}let o=(c,f)=>Zf.forEach(c,(u,s)=>a(u,s,f));if(Zf.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(Zf.isString(t)&&(t=t.trim())&&!YBC(t))o(a1y(t),r);else if(Zf.isObject(t)&&Zf.isIterable(t)){let c={},f,u;for(let s of t){if(!Zf.isArray(s))throw TypeError("Object iterator must return a key-value pair");c[u=s[0]]=(f=c[u])?Zf.isArray(f)?[...f,s[1]]:[f,s[1]]:s[1]}o(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=T$o(t),t){let n=Zf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return $BC(i);if(Zf.isFunction(r))return r.call(this,i,n);if(Zf.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=T$o(t),t){let n=Zf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||CAf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=T$o(o),o){let c=Zf.findKey(n,o);c&&(!r||CAf(n,n[c],c,r))&&(delete n[c],i=!0)}}return Zf.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||CAf(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Zf.forEach(this,(i,a)=>{let o=Zf.findKey(n,a);if(o){r[o]=MDu(i),delete r[a];return}let c=t?XBC(a):String(a).trim();c!==a&&delete r[a],r[c]=MDu(i),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Zf.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Zf.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
2435
2435
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[o1y]=this[o1y]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=T$o(o);n[c]||(ZBC(i,o),n[c]=!0)}return Zf.isArray(t)?t.forEach(a):a(t),this}};nka.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Zf.reduceDescriptors(nka.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Zf.freezeMethods(nka);var b$=nka;function q$o(e,t){let r=this||rka,n=t||r,i=b$.from(n.headers),a=n.data;return Zf.forEach(e,function(c){a=c.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function R$o(e){return!!(e&&e.__CANCEL__)}function s1y(e,t,r){Lm.call(this,e??"canceled",Lm.ERR_CANCELED,t,r),this.name="CanceledError"}Zf.inherits(s1y,Lm,{__CANCEL__:!0});var zrt=s1y;function IUr(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Lm("Request failed with status code "+r.status,[Lm.ERR_BAD_REQUEST,Lm.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function IAf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function MAf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Wua(e,t,r){let n=!IAf(t);return e&&(n||r==!1)?MAf(e,t):t}var P1y=$i(ZSu(),1),w1y=$i(require("http"),1),j1y=$i(require("https"),1),E1y=$i(require("util"),1),S1y=$i(BOf(),1),zAi=$i(require("zlib"),1);var Gua="1.12.2";function N$o(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var kBC=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function BAf(e,t,r){let n=r&&r.Blob||G7.classes.Blob,i=N$o(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=kBC.exec(e);if(!a)throw new Lm("Invalid URL",Lm.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],u=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!n)throw new Lm("Blob is not supported",Lm.ERR_NOT_SUPPORT);return new n([u],{type:o})}return u}throw new Lm("Unsupported protocol "+i,Lm.ERR_NOT_SUPPORT)}var Jua=$i(require("stream"),1);var u1y=$i(require("stream"),1);var TAf=Symbol("internals"),qAf=class extends u1y.default.Transform{constructor(t){t=Zf.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Zf.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[TAf]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[TAf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[TAf],a=i.maxRate,o=this.readableHighWaterMark,c=i.timeWindow,f=1e3/c,u=a/f,s=i.minChunkSize!==!1?Math.max(i.minChunkSize,u*.01):0,l=(O,P)=>{let C=Buffer.byteLength(O);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(O)?process.nextTick(P):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(P)}},m=(O,P)=>{let C=Buffer.byteLength(O),I=null,T=o,z,U=0;if(a){let q=Date.now();(!i.ts||(U=q-i.ts)>=c)&&(i.ts=q,z=u-i.bytes,i.bytes=z<0?-z:0,U=0),z=u-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,O)},c-U);z<T&&(T=z)}T&&C>T&&C-T>s&&(I=O.subarray(T),O=O.subarray(0,T)),l(O,I?()=>{process.nextTick(P,null,I)}:P)};m(t,function O(P,C){if(P)return n(P);C?m(C,O):n(null)})}},RAf=qAf;var D1y=require("events");var l1y=$i(require("util"),1),f1y=require("stream");var{asyncIterator:c1y}=Symbol,eTC=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[c1y]?yield*e[c1y]():yield e},BDu=eTC;var tTC=G7.ALPHABET.ALPHA_DIGIT+"-_",F$o=typeof TextEncoder=="function"?new TextEncoder:new l1y.default.TextEncoder,Hua=`\r
2436
2436
  `,rTC=F$o.encode(Hua),nTC=2,NAf=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Zf.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${Hua}`;i?r=F$o.encode(String(r).replace(/\r?\n|\r\n?/g,Hua)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Hua}`,this.headers=F$o.encode(a+Hua),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+nTC,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Zf.isTypedArray(t)?yield t:yield*BDu(t),yield rTC}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},iTC=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+G7.generateString(i,tTC)}=r||{};if(!Zf.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=F$o.encode("--"+a+Hua),c=F$o.encode("--"+a+"--"+Hua),f=c.byteLength,u=Array.from(e.entries()).map(([l,m])=>{let O=new NAf(l,m);return f+=O.size,O});f+=o.byteLength*u.length,f=Zf.toFiniteNumber(f);let s={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(s["Content-Length"]=f),t&&t(s),f1y.Readable.from((async function*(){for(let l of u)yield o,yield*l.encode();yield c})())},d1y=iTC;var p1y=$i(require("stream"),1),FAf=class extends p1y.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},_1y=FAf;var aTC=(e,t)=>Zf.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,h1y=aTC;function oTC(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let u=Date.now(),s=n[a];o||(o=u),r[i]=f,n[i]=u;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),u-o<t)return;let O=s&&u-s;return O?Math.round(m*1e3/O):void 0}}var y1y=oTC;function sTC(e,t){let r=0,n=1e3/t,i,a,o=(u,s=Date.now())=>{r=s,i=null,a&&(clearTimeout(a),a=null),e(...u)};return[(...u)=>{let s=Date.now(),l=s-r;l>=n?o(u,s):(i=u,a||(a=setTimeout(()=>{a=null,o(i)},n-l)))},()=>i&&o(i)]}var v1y=sTC;var xAi=(e,t,r=3)=>{let n=0,i=y1y(50,250);return v1y(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-n,u=i(f),s=o<=c;n=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:u||void 0,estimated:u&&c&&s?(c-o)/u:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},ika=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},aka=e=>(...t)=>Zf.asap(()=>e(...t));function xAf(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let m=0;m<o;m++)if(n.charCodeAt(m)===37&&m+2<o){let O=n.charCodeAt(m+1),P=n.charCodeAt(m+2);(O>=48&&O<=57||O>=65&&O<=70||O>=97&&O<=102)&&(P>=48&&P<=57||P>=65&&P<=70||P>=97&&P<=102)&&(a-=2,m+=2)}let c=0,f=o-1,u=m=>m>=2&&n.charCodeAt(m-2)===37&&n.charCodeAt(m-1)===51&&(n.charCodeAt(m)===68||n.charCodeAt(m)===100);f>=0&&(n.charCodeAt(f)===61?(c++,f--):u(f)&&(c++,f-=3)),c===1&&f>=0&&(n.charCodeAt(f)===61||u(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var b1y={flush:zAi.default.constants.Z_SYNC_FLUSH,finishFlush:zAi.default.constants.Z_SYNC_FLUSH},uTC={flush:zAi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:zAi.default.constants.BROTLI_OPERATION_FLUSH},g1y=Zf.isFunction(zAi.default.createBrotliDecompress),{http:cTC,https:lTC}=S1y.default,fTC=/https:?/,m1y=G7.protocols.map(e=>e+":"),O1y=(e,[t,r])=>(e.on("end",r).on("error",r),t);function dTC(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function C1y(e,t,r){let n=t;if(!n&&n!==!1){let i=P1y.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){C1y(a,t,a.href)}}var pTC=typeof process<"u"&&Zf.kindOf(process)==="process",_TC=e=>new Promise((t,r)=>{let n,i,a=(f,u)=>{i||(i=!0,n&&n(f,u))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>n=f).catch(c)}),hTC=({address:e,family:t})=>{if(!Zf.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},A1y=(e,t)=>hTC(Zf.isObject(e)?e:{address:e,family:t}),I1y=pTC&&function(t){return _TC(async function(n,i,a){let{data:o,lookup:c,family:f}=t,{responseType:u,responseEncoding:s}=t,l=t.method.toUpperCase(),m,O=!1,P;if(c){let Ee=h1y(c,Ot=>Zf.isArray(Ot)?Ot:[Ot]);c=(Ot,vt,xe)=>{Ee(Ot,vt,(Be,Jt,pt)=>{if(Be)return xe(Be);let vr=Zf.isArray(Jt)?Jt.map(Gt=>A1y(Gt)):[A1y(Jt,pt)];vt.all?xe(Be,vr):xe(Be,vr[0].address,vr[0].family)})}}let C=new D1y.EventEmitter,I=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Ee,Ot)=>{m=!0,Ot&&(O=!0,I())});function T(Ee){C.emit("abort",!Ee||Ee.type?new zrt(null,t,P):Ee)}C.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(T),t.signal&&(t.signal.aborted?T():t.signal.addEventListener("abort",T)));let z=Wua(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,G7.hasBrowserEnv?G7.origin:void 0),q=U.protocol||m1y[0];if(q==="data:"){if(t.maxContentLength>-1){let Ot=String(t.url||z||"");if(xAf(Ot)>t.maxContentLength)return i(new Lm("maxContentLength size of "+t.maxContentLength+" exceeded",Lm.ERR_BAD_RESPONSE,t))}let Ee;if(l!=="GET")return IUr(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Ee=BAf(t.url,u==="blob",{Blob:t.env&&t.env.Blob})}catch(Ot){throw Lm.from(Ot,Lm.ERR_BAD_REQUEST,t)}return u==="text"?(Ee=Ee.toString(s),(!s||s==="utf8")&&(Ee=Zf.stripBOM(Ee))):u==="stream"&&(Ee=Jua.default.Readable.from(Ee)),IUr(n,i,{data:Ee,status:200,statusText:"OK",headers:new b$,config:t})}if(m1y.indexOf(q)===-1)return i(new Lm("Unsupported protocol "+q,Lm.ERR_BAD_REQUEST,t));let V=b$.from(t.headers).normalize();V.set("User-Agent","axios/"+Gua,!1);let{onUploadProgress:$,onDownloadProgress:re}=t,Y=t.maxRate,k,ne;if(Zf.isSpecCompliantForm(o)){let Ee=V.getContentType(/boundary=([-_\w\d]{10,70})/i);o=d1y(o,Ot=>{V.set(Ot)},{tag:`axios-${Gua}-boundary`,boundary:Ee&&Ee[1]||void 0})}else if(Zf.isFormData(o)&&Zf.isFunction(o.getHeaders)){if(V.set(o.getHeaders()),!V.hasContentLength())try{let Ee=await E1y.default.promisify(o.getLength).call(o);Number.isFinite(Ee)&&Ee>=0&&V.setContentLength(Ee)}catch{}}else if(Zf.isBlob(o)||Zf.isFile(o))o.size&&V.setContentType(o.type||"application/octet-stream"),V.setContentLength(o.size||0),o=Jua.default.Readable.from(BDu(o));else if(o&&!Zf.isStream(o)){if(!Buffer.isBuffer(o))if(Zf.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(Zf.isString(o))o=Buffer.from(o,"utf-8");else return i(new Lm("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Lm.ERR_BAD_REQUEST,t));if(V.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return i(new Lm("Request body larger than maxBodyLength limit",Lm.ERR_BAD_REQUEST,t))}let me=Zf.toFiniteNumber(V.getContentLength());Zf.isArray(Y)?(k=Y[0],ne=Y[1]):k=ne=Y,o&&($||k)&&(Zf.isStream(o)||(o=Jua.default.Readable.from(o,{objectMode:!1})),o=Jua.default.pipeline([o,new RAf({maxRate:Zf.toFiniteNumber(k)})],Zf.noop),$&&o.on("progress",O1y(o,ika(me,xAi(aka($),!1,3)))));let _e;if(t.auth){let Ee=t.auth.username||"",Ot=t.auth.password||"";_e=Ee+":"+Ot}if(!_e&&U.username){let Ee=U.username,Ot=U.password;_e=Ee+":"+Ot}_e&&V.delete("authorization");let ve;try{ve=Vua(U.pathname+U.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Ee){let Ot=new Error(Ee.message);return Ot.config=t,Ot.url=t.url,Ot.exists=!0,i(Ot)}V.set("Accept-Encoding","gzip, compress, deflate"+(g1y?", br":""),!1);let pe={path:ve,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:_e,protocol:q,family:f,beforeRedirect:dTC,beforeRedirects:{}};!Zf.isUndefined(c)&&(pe.lookup=c),t.socketPath?pe.socketPath=t.socketPath:(pe.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,pe.port=U.port,C1y(pe,t.proxy,q+"//"+U.hostname+(U.port?":"+U.port:"")+pe.path));let De,Ce=fTC.test(pe.protocol);if(pe.agent=Ce?t.httpsAgent:t.httpAgent,t.transport?De=t.transport:t.maxRedirects===0?De=Ce?j1y.default:w1y.default:(t.maxRedirects&&(pe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(pe.beforeRedirects.config=t.beforeRedirect),De=Ce?lTC:cTC),t.maxBodyLength>-1?pe.maxBodyLength=t.maxBodyLength:pe.maxBodyLength=1/0,t.insecureHTTPParser&&(pe.insecureHTTPParser=t.insecureHTTPParser),P=De.request(pe,function(Ot){if(P.destroyed)return;let vt=[Ot],xe=+Ot.headers["content-length"];if(re||ne){let Gt=new RAf({maxRate:Zf.toFiniteNumber(ne)});re&&Gt.on("progress",O1y(Gt,ika(xe,xAi(aka(re),!0,3)))),vt.push(Gt)}let Be=Ot,Jt=Ot.req||P;if(t.decompress!==!1&&Ot.headers["content-encoding"])switch((l==="HEAD"||Ot.statusCode===204)&&delete Ot.headers["content-encoding"],(Ot.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":vt.push(zAi.default.createUnzip(b1y)),delete Ot.headers["content-encoding"];break;case"deflate":vt.push(new _1y),vt.push(zAi.default.createUnzip(b1y)),delete Ot.headers["content-encoding"];break;case"br":g1y&&(vt.push(zAi.default.createBrotliDecompress(uTC)),delete Ot.headers["content-encoding"])}Be=vt.length>1?Jua.default.pipeline(vt,Zf.noop):vt[0];let pt=Jua.default.finished(Be,()=>{pt(),I()}),vr={status:Ot.statusCode,statusText:Ot.statusMessage,headers:new b$(Ot.headers),config:t,request:Jt};if(u==="stream")vr.data=Be,IUr(n,i,vr);else{let Gt=[],Xe=0;Be.on("data",function(kt){Gt.push(kt),Xe+=kt.length,t.maxContentLength>-1&&Xe>t.maxContentLength&&(O=!0,Be.destroy(),i(new Lm("maxContentLength size of "+t.maxContentLength+" exceeded",Lm.ERR_BAD_RESPONSE,t,Jt)))}),Be.on("aborted",function(){if(O)return;let kt=new Lm("stream has been aborted",Lm.ERR_BAD_RESPONSE,t,Jt);Be.destroy(kt),i(kt)}),Be.on("error",function(kt){P.destroyed||i(Lm.from(kt,null,t,Jt))}),Be.on("end",function(){try{let kt=Gt.length===1?Gt[0]:Buffer.concat(Gt);u!=="arraybuffer"&&(kt=kt.toString(s),(!s||s==="utf8")&&(kt=Zf.stripBOM(kt))),vr.data=kt}catch(kt){return i(Lm.from(kt,null,t,vr.request,vr))}IUr(n,i,vr)})}C.once("abort",Gt=>{Be.destroyed||(Be.emit("error",Gt),Be.destroy())})}),C.once("abort",Ee=>{i(Ee),P.destroy(Ee)}),P.on("error",function(Ot){i(Lm.from(Ot,null,t,P))}),P.on("socket",function(Ot){Ot.setKeepAlive(!0,1e3*60)}),t.timeout){let Ee=parseInt(t.timeout,10);if(Number.isNaN(Ee)){i(new Lm("error trying to parse `config.timeout` to int",Lm.ERR_BAD_OPTION_VALUE,t,P));return}P.setTimeout(Ee,function(){if(m)return;let vt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",xe=t.transitional||tka;t.timeoutErrorMessage&&(vt=t.timeoutErrorMessage),i(new Lm(vt,xe.clarifyTimeoutError?Lm.ETIMEDOUT:Lm.ECONNABORTED,t,P)),T()})}if(Zf.isStream(o)){let Ee=!1,Ot=!1;o.on("end",()=>{Ee=!0}),o.once("error",vt=>{Ot=!0,P.destroy(vt)}),o.on("close",()=>{!Ee&&!Ot&&T(new zrt("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var M1y=G7.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,G7.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(G7.origin),G7.navigator&&/(msie|trident)/i.test(G7.navigator.userAgent)):()=>!0;var B1y=G7.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let o=[e+"="+encodeURIComponent(t)];Zf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Zf.isString(n)&&o.push("path="+n),Zf.isString(i)&&o.push("domain="+i),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var T1y=e=>e instanceof b$?{...e}:e;function XTr(e,t){t=t||{};let r={};function n(u,s,l,m){return Zf.isPlainObject(u)&&Zf.isPlainObject(s)?Zf.merge.call({caseless:m},u,s):Zf.isPlainObject(s)?Zf.merge({},s):Zf.isArray(s)?s.slice():s}function i(u,s,l,m){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u,l,m)}else return n(u,s,l,m)}function a(u,s){if(!Zf.isUndefined(s))return n(void 0,s)}function o(u,s){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u)}else return n(void 0,s)}function c(u,s,l){if(l in t)return n(u,s);if(l in e)return n(void 0,u)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,s,l)=>i(T1y(u),T1y(s),l,!0)};return Zf.forEach(Object.keys({...e,...t}),function(s){let l=f[s]||i,m=l(e[s],t[s],s);Zf.isUndefined(m)&&l!==c||(r[s]=m)}),r}var TDu=e=>{let t=XTr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=b$.from(o),t.url=Vua(Wua(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Zf.isFormData(r)){if(G7.hasStandardBrowserEnv||G7.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Zf.isFunction(r.getHeaders)){let f=r.getHeaders(),u=["content-type","content-length"];Object.entries(f).forEach(([s,l])=>{u.includes(s.toLowerCase())&&o.set(s,l)})}}if(G7.hasStandardBrowserEnv&&(n&&Zf.isFunction(n)&&(n=n(t)),n||n!==!1&&M1y(t.url))){let f=i&&a&&B1y.read(a);f&&o.set(i,f)}return t};var yTC=typeof XMLHttpRequest<"u",q1y=yTC&&function(e){return new Promise(function(r,n){let i=TDu(e),a=i.data,o=b$.from(i.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:u}=i,s,l,m,O,P;function C(){O&&O(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(s),i.signal&&i.signal.removeEventListener("abort",s)}let I=new XMLHttpRequest;I.open(i.method.toUpperCase(),i.url,!0),I.timeout=i.timeout;function T(){if(!I)return;let U=b$.from("getAllResponseHeaders"in I&&I.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?I.responseText:I.response,status:I.status,statusText:I.statusText,headers:U,config:e,request:I};IUr(function(re){r(re),C()},function(re){n(re),C()},V),I=null}"onloadend"in I?I.onloadend=T:I.onreadystatechange=function(){!I||I.readyState!==4||I.status===0&&!(I.responseURL&&I.responseURL.indexOf("file:")===0)||setTimeout(T)},I.onabort=function(){I&&(n(new Lm("Request aborted",Lm.ECONNABORTED,e,I)),I=null)},I.onerror=function(q){let V=q&&q.message?q.message:"Network Error",$=new Lm(V,Lm.ERR_NETWORK,e,I);$.event=q||null,n($),I=null},I.ontimeout=function(){let q=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||tka;i.timeoutErrorMessage&&(q=i.timeoutErrorMessage),n(new Lm(q,V.clarifyTimeoutError?Lm.ETIMEDOUT:Lm.ECONNABORTED,e,I)),I=null},a===void 0&&o.setContentType(null),"setRequestHeader"in I&&Zf.forEach(o.toJSON(),function(q,V){I.setRequestHeader(V,q)}),Zf.isUndefined(i.withCredentials)||(I.withCredentials=!!i.withCredentials),c&&c!=="json"&&(I.responseType=i.responseType),u&&([m,P]=xAi(u,!0),I.addEventListener("progress",m)),f&&I.upload&&([l,O]=xAi(f),I.upload.addEventListener("progress",l),I.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(s=U=>{I&&(n(!U||U.type?new zrt(null,e,I):U),I.abort(),I=null)},i.cancelToken&&i.cancelToken.subscribe(s),i.signal&&(i.signal.aborted?s():i.signal.addEventListener("abort",s)));let z=N$o(i.url);if(z&&G7.protocols.indexOf(z)===-1){n(new Lm("Unsupported protocol "+z+":",Lm.ERR_BAD_REQUEST,e));return}I.send(a||null)})};var vTC=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(u){if(!i){i=!0,c();let s=u instanceof Error?u:this.reason;n.abort(s instanceof Lm?s:new zrt(s instanceof Error?s.message:s))}},o=t&&setTimeout(()=>{o=null,a(new Lm(`timeout ${t} of ms exceeded`,Lm.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(a):u.removeEventListener("abort",a)}),e=null)};e.forEach(u=>u.addEventListener("abort",a));let{signal:f}=n;return f.unsubscribe=()=>Zf.asap(c),f}},R1y=vTC;var bTC=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},gTC=async function*(e,t){for await(let r of mTC(e))yield*bTC(r,t)},mTC=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},zAf=(e,t,r,n)=>{let i=gTC(e,t),a=0,o,c=f=>{o||(o=!0,n&&n(f))};return new ReadableStream({async pull(f){try{let{done:u,value:s}=await i.next();if(u){c(),f.close();return}let l=s.byteLength;if(r){let m=a+=l;r(m)}f.enqueue(new Uint8Array(s))}catch(u){throw c(u),u}},cancel(f){return c(f),i.return()}},{highWaterMark:2})};var N1y=64*1024,{isFunction:qDu}=Zf,OTC=(({Request:e,Response:t})=>({Request:e,Response:t}))(Zf.global),{ReadableStream:F1y,TextEncoder:x1y}=Zf.global,z1y=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ATC=e=>{e=Zf.merge.call({skipUndefined:!0},OTC,e);let{fetch:t,Request:r,Response:n}=e,i=t?qDu(t):typeof fetch=="function",a=qDu(r),o=qDu(n);if(!i)return!1;let c=i&&qDu(F1y),f=i&&(typeof x1y=="function"?(P=>C=>P.encode(C))(new x1y):async P=>new Uint8Array(await new r(P).arrayBuffer())),u=a&&c&&z1y(()=>{let P=!1,C=new r(G7.origin,{body:new F1y,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),s=o&&c&&z1y(()=>Zf.isReadableStream(new n("").body)),l={stream:s&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,I)=>{let T=C&&C[P];if(T)return T.call(C);throw new Lm(`Response type '${P}' is not supported`,Lm.ERR_NOT_SUPPORT,I)})});let m=async P=>{if(P==null)return 0;if(Zf.isBlob(P))return P.size;if(Zf.isSpecCompliantForm(P))return(await new r(G7.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(Zf.isArrayBufferView(P)||Zf.isArrayBuffer(P))return P.byteLength;if(Zf.isURLSearchParams(P)&&(P=P+""),Zf.isString(P))return(await f(P)).byteLength},O=async(P,C)=>{let I=Zf.toFiniteNumber(P.getContentLength());return I??m(C)};return async P=>{let{url:C,method:I,data:T,signal:z,cancelToken:U,timeout:q,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:Y,withCredentials:k="same-origin",fetchOptions:ne}=TDu(P),me=t||fetch;re=re?(re+"").toLowerCase():"text";let _e=R1y([z,U&&U.toAbortSignal()],q),ve=null,pe=_e&&_e.unsubscribe&&(()=>{_e.unsubscribe()}),De;try{if($&&u&&I!=="get"&&I!=="head"&&(De=await O(Y,T))!==0){let Be=new r(C,{method:"POST",body:T,duplex:"half"}),Jt;if(Zf.isFormData(T)&&(Jt=Be.headers.get("content-type"))&&Y.setContentType(Jt),Be.body){let[pt,vr]=ika(De,xAi(aka($)));T=zAf(Be.body,N1y,pt,vr)}}Zf.isString(k)||(k=k?"include":"omit");let Ce=a&&"credentials"in r.prototype,Ee={...ne,signal:_e,method:I.toUpperCase(),headers:Y.normalize().toJSON(),body:T,duplex:"half",credentials:Ce?k:void 0};ve=a&&new r(C,Ee);let Ot=await(a?me(ve,ne):me(C,Ee)),vt=s&&(re==="stream"||re==="response");if(s&&(V||vt&&pe)){let Be={};["status","statusText","headers"].forEach(Gt=>{Be[Gt]=Ot[Gt]});let Jt=Zf.toFiniteNumber(Ot.headers.get("content-length")),[pt,vr]=V&&ika(Jt,xAi(aka(V),!0))||[];Ot=new n(zAf(Ot.body,N1y,pt,()=>{vr&&vr(),pe&&pe()}),Be)}re=re||"text";let xe=await l[Zf.findKey(l,re)||"text"](Ot,P);return!vt&&pe&&pe(),await new Promise((Be,Jt)=>{IUr(Be,Jt,{data:xe,headers:b$.from(Ot.headers),status:Ot.status,statusText:Ot.statusText,config:P,request:ve})})}catch(Ce){throw pe&&pe(),Ce&&Ce.name==="TypeError"&&/Load failed|fetch/i.test(Ce.message)?Object.assign(new Lm("Network Error",Lm.ERR_NETWORK,P,ve),{cause:Ce.cause||Ce}):Lm.from(Ce,Ce&&Ce.code,P,ve)}}},PTC=new Map,QAf=e=>{let t=e?e.env:{},{fetch:r,Request:n,Response:i}=t,a=[n,i,r],o=a.length,c=o,f,u,s=PTC;for(;c--;)f=a[c],u=s.get(f),u===void 0&&s.set(f,u=c?new Map:ATC(t)),s=u;return u},fdU=QAf();var LAf={http:I1y,xhr:q1y,fetch:{get:QAf}};Zf.forEach(LAf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var Q1y=e=>`- ${e}`,jTC=e=>Zf.isFunction(e)||e===null||e===!1,RDu={getAdapter:(e,t)=>{e=Zf.isArray(e)?e:[e];let{length:r}=e,n,i,a={};for(let o=0;o<r;o++){n=e[o];let c;if(i=n,!jTC(n)&&(i=LAf[(c=String(n)).toLowerCase()],i===void 0))throw new Lm(`Unknown adapter '${c}'`);if(i&&(Zf.isFunction(i)||(i=i.get(t))))break;a[c||"#"+o]=i}if(!i){let o=Object.entries(a).map(([f,u])=>`adapter ${f} `+(u===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
@@ -2671,7 +2671,7 @@ ${q}${z}${V}${xro}`});function kFu({message:e,error:t,logger:r,logLevel:n=uE.Err
2671
2671
  Run ${Mf.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
2672
2672
  Run ${Mf.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),ska(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function JNf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!kGy(e))return;let i=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)i+=`
2673
2673
  ${await VpI(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Mf.dim(c.currentVersion)+Mf.reset(" \u2192 ")+Mf.green(c.latestVersion);return i+=`
2674
- `,n?ska(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function VpI(e){let r=await new ZGy.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 WpI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=d3i(s.name,l),O=await bTr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});O!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=d3i(u.name,s),m=await bTr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await CTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function rHy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=Dxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function nxu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await WpI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...rHy(u,f,t.logger));else o.push(...rHy(c.versions,void 0,t.logger))}return o}var Ako=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var Uro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var KNf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),nHy=typeof globalThis.AbortController=="function",iHy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",aHy=typeof globalThis.ReadableStream=="function",oHy=typeof globalThis.FormData=="function",ixu=["get","post","put","patch","head","delete"],GpI=()=>{};GpI();var sHy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},axu=2147483647,uHy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,oxu=Symbol("stop"),cHy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},lHy={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 HpI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=uHy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},fHy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},dHy=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(fHy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},pHy=(e,t,r)=>{if(!e.body)return e;let n=HpI(r??e.body);return new Request(e,{duplex:"half",body:fHy(e.body,n,t)})};var Vro=e=>e!==null&&typeof e=="object";var Pko=(...e)=>{for(let t of e)if((!Vro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return XNf({},...e)},$Nf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function sxu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:XNf(e[r]??[],t[r]??[])}var YNf=(e={},t={})=>({beforeRequest:sxu(e,t,"beforeRequest"),beforeRetry:sxu(e,t,"beforeRetry"),afterResponse:sxu(e,t,"afterResponse"),beforeError:sxu(e,t,"beforeError")}),XNf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(Vro(i)){for(let[a,o]of Object.entries(i))Vro(o)&&a in t&&(o=XNf(t[a],o)),t={...t,[a]:o};Vro(i.hooks)&&(n=YNf(n,i.hooks),t.hooks=n),Vro(i.headers)&&(r=$Nf(r,i.headers),t.headers=r)}return t};var hHy=e=>ixu.includes(e)?e.toUpperCase():e,JpI=["get","put","head","delete","options","trace"],KpI=[408,413,429,500,502,503,504],$pI=[413,429,503],_Hy={limit:2,methods:JpI,statusCodes:KpI,afterStatusCodes:$pI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},yHy=(e={})=>{if(typeof e=="number")return{..._Hy,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{..._Hy,...e}};async function ZNf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Uro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function kNf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var vHy=(e,t)=>{let r={};for(let n in t)!(n in lHy)&&!(n in cHy)&&!(n in e)&&(r[n]=t[n]);return r},bHy=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var wko=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>axu)throw new RangeError(`The \`timeout\` option cannot be greater than ${axu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new Ako(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!aHy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return dHy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(sHy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:$Nf(this._input.headers,r.headers),hooks:YNf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:hHy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:yHy(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(nHy&&iHy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(KNf&&(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),bHy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(oHy&&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(!KNf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=pHy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Uro)throw t;if(t instanceof Ako){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),axu);if(this._retryCount<1)throw r;await kNf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===oxu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=vHy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):ZNf(this._originalRequest,t,this.abortController,this._options)}};var eFf=e=>{let t=(r,n)=>wko.create(r,Pko(e,n));for(let r of ixu)t[r]=(n,i)=>wko.create(n,Pko(e,i,{method:r}));return t.create=r=>eFf(Pko(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),eFf(Pko(e,r))),t.stop=oxu,t},YpI=eFf(),gHy=YpI;var UHy=$i(LHy(),1);function aFf(e){let t=(0,UHy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var NJy=$i(RJy(),1),FJy=$i(pqu(),1),bFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},gFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function mFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??aFf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,NJy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await gHy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new bFf(e):l}if(t.allVersions)return u;let s=new gFf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[O,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[O];if(!l){let O=Object.keys(u.versions);if(r=FJy.default.maxSatisfying(O,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function tfa(e,t){let{version:r}=await mFf(e.toLowerCase(),t);return r}async function Y6i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:tfa(e.packageName,{version:t?"prerelease":"latest"})}var xJy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],gxu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=uE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new rxu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.115.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Mf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Pne}failWithoutThrowing(t,r){this.didSucceed=!1,kFu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await XZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await eHy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2674
+ `,n?ska(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function VpI(e){let r=await new ZGy.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 WpI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=d3i(s.name,l),O=await bTr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});O!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=d3i(u.name,s),m=await bTr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await CTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function rHy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=Dxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function nxu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await WpI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...rHy(u,f,t.logger));else o.push(...rHy(c.versions,void 0,t.logger))}return o}var Ako=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var Uro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var KNf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),nHy=typeof globalThis.AbortController=="function",iHy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",aHy=typeof globalThis.ReadableStream=="function",oHy=typeof globalThis.FormData=="function",ixu=["get","post","put","patch","head","delete"],GpI=()=>{};GpI();var sHy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},axu=2147483647,uHy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,oxu=Symbol("stop"),cHy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},lHy={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 HpI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=uHy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},fHy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},dHy=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(fHy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},pHy=(e,t,r)=>{if(!e.body)return e;let n=HpI(r??e.body);return new Request(e,{duplex:"half",body:fHy(e.body,n,t)})};var Vro=e=>e!==null&&typeof e=="object";var Pko=(...e)=>{for(let t of e)if((!Vro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return XNf({},...e)},$Nf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function sxu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:XNf(e[r]??[],t[r]??[])}var YNf=(e={},t={})=>({beforeRequest:sxu(e,t,"beforeRequest"),beforeRetry:sxu(e,t,"beforeRetry"),afterResponse:sxu(e,t,"afterResponse"),beforeError:sxu(e,t,"beforeError")}),XNf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(Vro(i)){for(let[a,o]of Object.entries(i))Vro(o)&&a in t&&(o=XNf(t[a],o)),t={...t,[a]:o};Vro(i.hooks)&&(n=YNf(n,i.hooks),t.hooks=n),Vro(i.headers)&&(r=$Nf(r,i.headers),t.headers=r)}return t};var hHy=e=>ixu.includes(e)?e.toUpperCase():e,JpI=["get","put","head","delete","options","trace"],KpI=[408,413,429,500,502,503,504],$pI=[413,429,503],_Hy={limit:2,methods:JpI,statusCodes:KpI,afterStatusCodes:$pI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},yHy=(e={})=>{if(typeof e=="number")return{..._Hy,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{..._Hy,...e}};async function ZNf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Uro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function kNf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var vHy=(e,t)=>{let r={};for(let n in t)!(n in lHy)&&!(n in cHy)&&!(n in e)&&(r[n]=t[n]);return r},bHy=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var wko=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>axu)throw new RangeError(`The \`timeout\` option cannot be greater than ${axu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new Ako(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!aHy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return dHy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(sHy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:$Nf(this._input.headers,r.headers),hooks:YNf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:hHy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:yHy(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(nHy&&iHy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(KNf&&(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),bHy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(oHy&&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(!KNf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=pHy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Uro)throw t;if(t instanceof Ako){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),axu);if(this._retryCount<1)throw r;await kNf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===oxu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=vHy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):ZNf(this._originalRequest,t,this.abortController,this._options)}};var eFf=e=>{let t=(r,n)=>wko.create(r,Pko(e,n));for(let r of ixu)t[r]=(n,i)=>wko.create(n,Pko(e,i,{method:r}));return t.create=r=>eFf(Pko(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),eFf(Pko(e,r))),t.stop=oxu,t},YpI=eFf(),gHy=YpI;var UHy=$i(LHy(),1);function aFf(e){let t=(0,UHy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var NJy=$i(RJy(),1),FJy=$i(pqu(),1),bFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},gFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function mFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??aFf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,NJy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await gHy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new bFf(e):l}if(t.allVersions)return u;let s=new gFf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[O,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[O];if(!l){let O=Object.keys(u.versions);if(r=FJy.default.maxSatisfying(O,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function tfa(e,t){let{version:r}=await mFf(e.toLowerCase(),t);return r}async function Y6i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:tfa(e.packageName,{version:t?"prerelease":"latest"})}var xJy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],gxu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=uE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new rxu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.115.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Mf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Pne}failWithoutThrowing(t,r){this.didSucceed=!1,kFu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await XZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await eHy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2675
2675
  `)||(r+=`
2676
2676
  `),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=fKl(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new yko(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new Pne}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await XZa()).sendEvent(t)}logger=G2r((t,...r)=>this.log(t,...r));stderr=G2r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=zJy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?zJy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=xJy[this.numTasks++%xJy.length],o=Mf.hex(a)(i);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===yV.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let n=t.filter(i=>Mxi.indexOf(i.level)>=Mxi.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===uE.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 Y6i({cliEnvironment:this.environment,includePreReleases:t}),n=Dxe(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await nxu({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await NNf({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Mf.yellow("?"),style:{answer:i=>Mf.cyan(i),message:i=>Mf.bold(i),highlight:i=>Mf.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
2677
2677
  Cancelled by user.`),new Pne):n}}async getInput(t){return await BNf({message:t.message,default:t.default})}};function zJy(e){return`[${e}]:`}var mqr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};function mxu(e,t,r,n){if(typeof r!="function")throw new Error("method for before hook must be a function");return n||(n={}),Array.isArray(t)?t.reverse().reduce((i,a)=>mxu.bind(null,e,a,i,n),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((i,a)=>a.hook.bind(null,i,n),r)():r(n))}function QJy(e,t,r,n){let i=n;e.registry[r]||(e.registry[r]=[]),t==="before"&&(n=(a,o)=>Promise.resolve().then(i.bind(null,o)).then(a.bind(null,o))),t==="after"&&(n=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,i(c,o))).then(()=>c)}),t==="error"&&(n=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>i(c,o))),e.registry[r].push({hook:n,orig:i})}function LJy(e,t,r){if(!e.registry[t])return;let n=e.registry[t].map(i=>i.orig).indexOf(r);n!==-1&&e.registry[t].splice(n,1)}var UJy=Function.bind,VJy=UJy.bind(UJy);function WJy(e,t,r){let n=VJy(LJy,null).apply(null,r?[t,r]:[t]);e.api={remove:n},e.remove=n,["before","error","after","wrap"].forEach(i=>{let a=r?[t,i,r]:[t,i];e[i]=e.api[i]=VJy(QJy,null).apply(null,a)})}function rhI(){let e=Symbol("Singular"),t={registry:{}},r=mxu.bind(null,t,e);return WJy(r,t,e),r}function nhI(){let e={registry:{}},t=mxu.bind(null,e);return WJy(t,e),t}var GJy={Singular:rhI,Collection:nhI};var ihI="0.0.0-development",ahI=`octokit-endpoint.js/${ihI} ${Nfe()}`,ohI={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":ahI},mediaType:{format:""}};function shI(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function uhI(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function KJy(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{uhI(t[n])?n in e?r[n]=KJy(e[n],t[n]):Object.assign(r,{[n]:t[n]}):Object.assign(r,{[n]:t[n]})}),r}function HJy(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function AFf(e,t,r){if(typeof t=="string"){let[i,a]=t.split(" ");r=Object.assign(a?{method:i,url:a}:{url:i},r)}else r=Object.assign({},t);r.headers=shI(r.headers),HJy(r),HJy(r.headers);let n=KJy(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(n.mediaType.previews=e.mediaType.previews.filter(i=>!n.mediaType.previews.includes(i)).concat(n.mediaType.previews)),n.mediaType.previews=(n.mediaType.previews||[]).map(i=>i.replace(/-preview/,""))),n}function chI(e,t){let r=/\?/.test(e)?"&":"?",n=Object.keys(t);return n.length===0?e:e+r+n.map(i=>i==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${i}=${encodeURIComponent(t[i])}`).join("&")}var lhI=/\{[^{}}]+\}/g;function fhI(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function dhI(e){let t=e.match(lhI);return t?t.map(fhI).reduce((r,n)=>r.concat(n),[]):[]}function JJy(e,t){let r={__proto__:null};for(let n of Object.keys(e))t.indexOf(n)===-1&&(r[n]=e[n]);return r}function $Jy(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function Xro(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Iko(e,t,r){return t=e==="+"||e==="#"?$Jy(t):Xro(t),r?Xro(r)+"="+t:t}function Yro(e){return e!=null}function OFf(e){return e===";"||e==="&"||e==="?"}function phI(e,t,r,n){var i=e[r],a=[];if(Yro(i)&&i!=="")if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")i=i.toString(),n&&n!=="*"&&(i=i.substring(0,parseInt(n,10))),a.push(Iko(t,i,OFf(t)?r:""));else if(n==="*")Array.isArray(i)?i.filter(Yro).forEach(function(o){a.push(Iko(t,o,OFf(t)?r:""))}):Object.keys(i).forEach(function(o){Yro(i[o])&&a.push(Iko(t,i[o],o))});else{let o=[];Array.isArray(i)?i.filter(Yro).forEach(function(c){o.push(Iko(t,c))}):Object.keys(i).forEach(function(c){Yro(i[c])&&(o.push(Xro(c)),o.push(Iko(t,i[c].toString())))}),OFf(t)?a.push(Xro(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?Yro(i)&&a.push(Xro(r)):i===""&&(t==="&"||t==="?")?a.push(Xro(r)+"="):i===""&&a.push("");return a}function _hI(e){return{expand:hhI.bind(null,e)}}function hhI(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(n,i,a){if(i){let c="",f=[];if(r.indexOf(i.charAt(0))!==-1&&(c=i.charAt(0),i=i.substr(1)),i.split(/,/g).forEach(function(u){var s=/([^:\*]*)(?::(\d+)|(\*))?/.exec(u);f.push(phI(t,c,s[1],s[2]||s[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return $Jy(a)}),e==="/"?e:e.replace(/\/$/,"")}function YJy(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),n=Object.assign({},e.headers),i,a=JJy(e,["method","baseUrl","url","headers","request","mediaType"]),o=dhI(r);r=_hI(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(s=>o.includes(s)).concat("baseUrl"),f=JJy(a,c);if(!/application\/octet-stream/i.test(n.accept)&&(e.mediaType.format&&(n.accept=n.accept.split(/,/).map(s=>s.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let s=n.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];n.accept=s.concat(e.mediaType.previews).map(l=>{let m=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${m}`}).join(",")}return["GET","HEAD"].includes(t)?r=chI(r,f):"data"in f?i=f.data:Object.keys(f).length&&(i=f),!n["content-type"]&&typeof i<"u"&&(n["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof i>"u"&&(i=""),Object.assign({method:t,url:r,headers:n},typeof i<"u"?{body:i}:null,e.request?{request:e.request}:null)}function yhI(e,t,r){return YJy(AFf(e,t,r))}function XJy(e,t){let r=AFf(e,t),n=yhI.bind(null,r);return Object.assign(n,{DEFAULTS:r,defaults:XJy.bind(null,r),merge:AFf.bind(null,r),parse:YJy})}var ZJy=XJy(null,ohI);var iKy=$i(rKy(),1);var Oqr=class extends Error{name;status;request;response;constructor(t,r,n){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in n&&(this.response=n.response);let i=Object.assign({},n.request);n.request.headers.authorization&&(i.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),i.url=i.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=i}};var vhI="10.0.6",bhI={headers:{"user-agent":`octokit-request.js/${vhI} ${Nfe()}`}};function ghI(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function nKy(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,n=e.request?.parseSuccessResponseBody!==!1,i=ghI(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,m])=>[l,String(m)])),o;try{o=await t(e.url,{method:e.method,body:i,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let m="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;m=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?m=l.cause.message:typeof l.cause=="string"&&(m=l.cause))}let O=new Oqr(m,500,{request:e});throw O.cause=l,O}let c=o.status,f=o.url,u={};for(let[l,m]of o.headers)u[l]=m;let s={url:f,status:c,headers:u,data:""};if("deprecation"in u){let l=u.link&&u.link.match(/<([^<>]+)>; rel="deprecation"/),m=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${u.sunset}${m?`. See ${m}`:""}`)}if(c===204||c===205)return s;if(e.method==="HEAD"){if(c<400)return s;throw new Oqr(o.statusText,c,{response:s,request:e})}if(c===304)throw s.data=await PFf(o),new Oqr("Not modified",c,{response:s,request:e});if(c>=400)throw s.data=await PFf(o),new Oqr(OhI(s.data),c,{response:s,request:e});return s.data=n?await PFf(o):o.body,s}async function PFf(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,iKy.safeParse)(t);if(mhI(r)){let n="";try{return n=await e.text(),JSON.parse(n)}catch{return n}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function mhI(e){return e.type==="application/json"||e.type==="application/scim+json"}function OhI(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function wFf(e,t){let r=e.defaults(t);return Object.assign(function(i,a){let o=r.merge(i,a);if(!o.request||!o.request.hook)return nKy(r.parse(o));let c=(f,u)=>nKy(r.parse(r.merge(f,u)));return Object.assign(c,{endpoint:r,defaults:wFf.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:wFf.bind(null,r)})}var V6=wFf(ZJy,bhI);var AhI="0.0.0-development";function PhI(e){return`Request failed due to following response errors:
@@ -2741,7 +2741,7 @@ For more information:
2741
2741
  `,P=Math.max(...s.map(C=>C.length));return O+=s.map(C=>{let I=`${e} ${process.argv.slice(2).join(" ")} --api ${C}`;return` \u203A ${Mf.bold(C.padEnd(P))} ${Mf.dim(I)}`}).join(`
2742
2742
  `),r.failAndThrow(O)}}let l=[],m=i!=null?s.filter(O=>O===i):s;return await Promise.all(m.map(async O=>{let P=await Hrs({absolutePathToWorkspace:Ql(o,ru.of(O)),context:r,cliVersion:n,workspaceName:O});P.didSucceed?l.push(P.workspace):(OLf(P,r.logger),r.failAndThrow())})),l}let f=await Hrs({absolutePathToWorkspace:t,context:r,cliVersion:n,workspaceName:void 0});return f.didSucceed?[f.workspace]:(OLf(f,r.logger),[])}async function G6(e,t,r=!1){let n=e.addTask().start(),i=await jLf({...t,cliName:e.environment.cliName,cliVersion:e.environment.packageVersion,context:n});return n.finish(),r&&i.docsWorkspaces!=null?e.registerWorkspaces([...i.apiWorkspaces,i.docsWorkspaces]):e.registerWorkspaces(i.apiWorkspaces),e.registerProject(i),i}var Kvv=$i(BHo(),1),$vv=require("fs/promises");var Uvv=require("fs/promises");var Vao={GitHub:"github",Local:"local-file-system",PackageRegistry:"publish"};async function Vvv({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,apiKeyFallback:i="FERN_DEFAULT",project:{apiWorkspaces:a},outputLocation:o,excludedModes:c,includedModes:f}){let u={};await Promise.all(a.map(async l=>{await e.runTaskForWorkspace(l,async m=>{if(n!=null&&(l.workspaceName==null||!n.has(l.workspaceName)))return;let O=await CTr({absolutePathToWorkspace:l.absoluteFilePath,context:m});if(O==null||O.groups==null)return;let P=l.workspaceName??i;u[P]={};for(let C of O.groups)r!=null&&!r.has(C.groupName)||(u[P][C.groupName]=C.generators.filter(I=>{let T=!0;return f!=null&&(T=Lvv(I,f)),c!=null&&(T=!Lvv(I,c)),T}).filter(I=>t==null||t.has(I.name)).map(I=>I.name))})}));let s=jg.dump(u);if(o==null){process.stdout.write(s);return}try{await(0,Uvv.writeFile)(o,s)}catch(l){e.failAndThrow(`Could not write file to the specified location: ${o}`,l)}}function Lvv(e,t){let r,n=e.outputMode.type;switch(n){case"downloadFiles":r=Vao.Local;break;case"github":case"githubV2":r=Vao.GitHub;break;case"publish":case"publishV2":r=Vao.PackageRegistry;break;default:ku(n)}return t.has(r)}async function Wvv({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:n,project:{apiWorkspaces:i}}){let a;return await Promise.all(i.map(async o=>{await e.runTaskForWorkspace(o,async c=>{if(n!=null&&(o.workspaceName==null||n!==o.workspaceName))return;let f=await CTr({absolutePathToWorkspace:o.absoluteFilePath,context:c});if(!(f==null||f.groups==null)){for(let u of f.groups)if(r===u.groupName)for(let s of u.generators)t===s.name&&(a=s)}})})),a}var Gvv=require("fs/promises");async function Hvv({project:e,outputLocation:t,context:r}){let n=e.config.organization;if(t==null){process.stdout.write(n);return}try{await(0,Gvv.writeFile)(t,n)}catch(i){r.failAndThrow(`Could not write file to the specified location: ${t}`,i)}}var zLu=require("fs/promises"),Jrs=$i(require("path"),1),ELf=$i(emi(),1),Wao=$i(FPe(),1);function aHI(e){return{"fernapi/fern-typescript-sdk":"https://buildwithfern.com/learn/sdks/generators/typescript/changelog","fernapi/fern-typescript-node-sdk":"https://buildwithfern.com/learn/sdks/generators/typescript/changelog","fernapi/fern-python-sdk":"https://buildwithfern.com/learn/sdks/generators/python/changelog","fernapi/fern-go-sdk":"https://buildwithfern.com/learn/sdks/generators/go/changelog","fernapi/fern-java-sdk":"https://buildwithfern.com/learn/sdks/generators/java/changelog","fernapi/fern-csharp-sdk":"https://buildwithfern.com/learn/sdks/generators/csharp/changelog","fernapi/fern-php-sdk":"https://buildwithfern.com/learn/sdks/generators/php/changelog","fernapi/fern-ruby-sdk":"https://buildwithfern.com/learn/sdks/generators/ruby/changelog","fernapi/fern-swift-sdk":"https://buildwithfern.com/learn/sdks/generators/swift/changelog"}[e]}async function oHI({absolutePathToWorkspace:e,context:t,generatorFilter:r,groupFilter:n,includeMajor:i,channel:a,cliVersion:o}){let c=await Dzi({absolutePathToWorkspace:e});if(c==null||!await Vv(c))return t.logger.debug("Generators configuration file was not found, no generators to upgrade."),{updatedConfiguration:void 0,skippedMajorUpgrades:[]};let f=await(0,zLu.readFile)(c);t.logger.debug(`Found generators: ${f.toString()}`);let u=Wao.default.parseDocument(f.toString()),s=u.get("groups");if(s==null)return t.logger.debug("No groups were found within the generators configuration, no generators to upgrade."),{updatedConfiguration:void 0,skippedMajorUpgrades:[]};if(!Wao.default.isMap(s))return t.failAndThrow(`Expected 'groups' to be a map in ${Jrs.default.relative(process.cwd(),c)}`),{updatedConfiguration:void 0,skippedMajorUpgrades:[]};t.logger.debug(`Groups found: ${s.toString()}`);let l=[];for(let m of s.items){let O=m.key.value,P=m.value;if(!Wao.default.isMap(P)){t.failAndThrow(`Expected group ${O} to be a map in ${Jrs.default.relative(process.cwd(),c)}`);continue}if(n!=null&&n!==O){t.logger.debug(`Skipping group ${O} as it does not match the filter: ${n}`);continue}let C=P.get("generators");if(!Wao.default.isSeq(C)){t.failAndThrow(`Expected group ${O} to have a 'generators' key in ${Jrs.default.relative(process.cwd(),c)}`);continue}t.logger.debug(`Generators found: ${C.toString()}`);for(let I of C.items){Wao.default.isMap(I)||t.failAndThrow(`Expected generator in group ${O} to be a map in ${Jrs.default.relative(process.cwd(),c)}`);let T=I.get("name");if(r!=null&&T!==r){t.logger.debug(`Skipping generator ${T} as it does not match the filter: ${r}`);continue}let z=d3i(T,t),U=I.get("version"),q=await bTr({generatorName:z,cliVersion:o,currentGeneratorVersion:U,channel:a,includeMajor:i,context:t}),V=q??U;if(q!=null&&(t.logger.debug(Mf.green(`Upgrading ${T} from ${U} to ${q}`)),I.set("version",q)),!i){let $=await bTr({generatorName:z,cliVersion:o,currentGeneratorVersion:V,channel:a,includeMajor:!0,context:t});if($!=null){let re=ELf.default.parse(V),Y=ELf.default.parse($);re!=null&&Y!=null&&Y.major>re.major&&l.push({generatorName:T,currentVersion:V,latestMajorVersion:$})}}}}return{updatedConfiguration:u.toString(),skippedMajorUpgrades:l}}async function Jvv({cliContext:e,generator:t,group:r,project:{apiWorkspaces:n},includeMajor:i,channel:a}){let o=[];if(await Promise.all(n.map(async c=>{await e.runTaskForWorkspace(c,async f=>{let u=await UYa({absolutePathToWorkspace:c.absoluteFilePath,context:f})??{};if(u==null||u.groups==null){f.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}c.workspaceName==null?f.logger.info("Upgrading generators."):f.logger.info(`Upgrading generators in workspace: ${c.workspaceName}.`);let s=await oHI({absolutePathToWorkspace:c.absoluteFilePath,context:f,generatorFilter:t,groupFilter:r,includeMajor:i,channel:a,cliVersion:e.environment.packageVersion}),l=await Dzi({absolutePathToWorkspace:c.absoluteFilePath});l!=null&&s.updatedConfiguration!=null&&await(0,zLu.writeFile)(l,s.updatedConfiguration),o.push(...s.skippedMajorUpgrades)})})),o.length>0){e.logger.info(""),e.logger.info(Mf.yellow("Major version upgrades available:"));for(let c of o){e.logger.info(Mf.yellow(` - ${c.generatorName}: ${c.currentVersion} \u2192 ${c.latestMajorVersion}`));let f=t!=null?`fern generator upgrade --generator ${c.generatorName} --include-major`:"fern generator upgrade --include-major";e.logger.info(Mf.yellow(` Run: ${f}`));let u=aHI(c.generatorName);u!=null&&e.logger.info(Mf.yellow(` Changelog: ${u}`))}}}function Yvv(e,t){e.command("organization",!1,r=>r.option("output",{string:!0,alias:"o",description:"The location to output the organization name as a text file, defaults to standard out."}),async r=>{await t.instrumentPostHogEvent({command:"fern organization",properties:{outputLocation:r.output}}),await Hvv({project:await G6(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),context:t,outputLocation:r.output})})}function Xvv(e,t){e.command("generator","Operate on the generators within your Fern configuration",r=>{r.command("list",!1,n=>n.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generators",{string:!0,type:"array",description:"The type of generator to include in the list, ex: `fern-typescript-node-sdk`. If omitted, all generators will be listed."}).option("groups",{type:"array",string:!0,description:"The groups to include generators from, if group is not specified, the all generators of the specified type will be listed."}).option("apis",{type:"array",string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("api-fallback",{string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("include-mode",{choices:Object.values(Vao),type:"array",description:"The generator output modes to include within the outputted list."}).option("exclude-mode",{choices:Object.values(Vao),type:"array",description:"The generator output modes to exclude within the outputted list."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator list",properties:{outputLocation:n.output}}),await Vvv({project:await G6(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),generatorFilter:n.generators?new Set(n.generators):void 0,groupFilter:n.groups?new Set(n.groups):void 0,apiFilter:n.apis?new Set(n.apis):void 0,apiKeyFallback:n.apiFallback,cliContext:t,outputLocation:n.output,includedModes:n["include-mode"]?new Set(n["include-mode"]):void 0,excludedModes:n["exclude-mode"]?new Set(n["exclude-mode"]):void 0})}).command("upgrade",`Upgrades the specified generator in ${u$} to the latest stable version.`,n=>n.option("generator",{string:!0,description:"The type of generator to upgrade, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,description:"The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."}).option("api",{string:!0,description:"The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."}).option("include-major",{boolean:!0,default:!1,description:"Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."}).option("channel",{demandOption:!1,choices:Object.values(Kvv.FernRegistry.generators.ReleaseType)}).option("list",{demandOption:!1,boolean:!0,default:!1,description:"When specified, a list of available upgrades will be displayed, but no upgrade will be taken."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator upgrade",properties:{generator:n.generator,version:n.version,api:n.api,group:n.group,includeMajor:n.includeMajor,rc:n.rc}});let i=await G6(t,{commandLineApiWorkspace:n.api,defaultToAllApiWorkspaces:!0});if(n.list){t.suppressUpgradeMessage();let a=await nxu({cliContext:t,project:i,generatorFilter:n.generator,groupFilter:n.group,includeMajor:n.includeMajor,channel:n.channel}),o=await JNf({generatorUpgradeInfo:a,header:`Generator Upgrades
2743
2743
  `,includeBoxen:!0});o!=null&&t.logger.info(o)}else await Jvv({cliContext:t,generator:n.generator,group:n.group,project:await G6(t,{commandLineApiWorkspace:n.api,defaultToAllApiWorkspaces:!0}),includeMajor:n.includeMajor,channel:n.channel})}).command("get",!1,n=>n.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generator",{string:!0,demandOption:!0,description:"The name of the generator to get, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,demandOption:!0,description:"The group in which the generator is located."}).option("api",{string:!0,description:"The API in which the generator is located."}).option("version",{boolean:!0,default:!1,description:"Get the version of the specified generator."}).option("language",{boolean:!0,default:!1,description:"Get the language of the specified generator."}).option("repository",{boolean:!0,default:!1,description:"Get repository for the generator invocation, if one is specified."}),async n=>{await t.instrumentPostHogEvent({command:"fern generator get",properties:{generator:n.generator,version:n.version,api:n.api,group:n.group,includeMajor:n.includeMajor}});let i=await Wvv({cliContext:t,generatorFilter:n.generator,groupFilter:n.group,apiFilter:n.api,project:await G6(t,{commandLineApiWorkspace:n.api,defaultToAllApiWorkspaces:!0})});if(i==null){let o=n.api?` for API ${n.api}`:"";t.failAndThrow(`Generator ${n.generator}, in group ${n.group}${o} was not found.`)}let a={};if(n.version&&(a.version=i.version,n.output==null)){process.stdout.write(i.version);return}if(n.language)if(i.language!=null){if(a.language=i.language,n.output==null){process.stdout.write(i.language);return}}else t.logger.warn(`Language information is not available for generator ${i.name} in group ${n.group}`);if(n.repository){let o=i.outputMode.type==="github"?i.outputMode.repo:i.outputMode.type==="githubV2"?i.outputMode.githubV2.repo:void 0;if(o!=null){if(a.repository=o,n.output==null){process.stdout.write(a.repository);return}}else t.logger.warn(`Repository information is not available for generator ${i.name} in group ${n.group}`)}if(n.output)try{await(0,$vv.writeFile)(n.output,JSON.stringify(a,null,2))}catch(o){t.failAndThrow(`Could not write file to the specified location: ${n.output}`,o)}})})}var Zvv=require("fs/promises");async function kvv({project:{apiWorkspaces:e},generatorName:t,groupName:r,cliContext:n}){await Promise.all(e.map(async i=>{await n.runTaskForWorkspace(i,async a=>{let o=await UYa({absolutePathToWorkspace:i.absoluteFilePath,context:a})??{},c=await alf({generatorName:t,generatorsConfiguration:o,groupName:r,context:a,cliVersion:n.environment.packageVersion}),f=i.generatorsConfiguration?.absolutePathToConfiguration??await Dzi({absolutePathToWorkspace:i.absoluteFilePath});f!=null&&(await(0,Zvv.writeFile)(f,`# yaml-language-server: $schema=https://schema.buildwithfern.dev/generators-yml.json
2744
- `+jg.dump(c)),a.logger.info(Mf.green(`Added ${t} generator`)))})}))}var tbv=require("fs/promises"),rbv=$i(emi(),1);async function nbv({context:e,from:t,to:r,fromVersion:n,generatorVersions:i}){let a=new YZo,o=sHI(await a.check({from:await ebv({context:e,filepath:t,flagName:"from"}),to:await ebv({context:e,filepath:r,flagName:"to"})})),c=lHI(e,i),{bump:f,errors:u}=uHI(o,c);if(n==null)return{bump:f??"patch",errors:u};if(f==="no_change")return{bump:"no_change",nextVersion:n,errors:u};let s=f??"patch",l=rbv.default.inc(n,s);if(!l)throw e.failWithoutThrowing(`Invalid current version: ${n}`),new Pne;return{bump:s,nextVersion:l,errors:u}}async function ebv({context:e,filepath:t,flagName:r}){let n=F_.of(p1(hV(),t));if(!await Vv(n,"file"))throw e.failWithoutThrowing(`File not found: ${n}`),new Pne;let i=await(0,tbv.readFile)(n,"utf-8"),a=V0.IntermediateRepresentation.parse(JSON.parse(i));if(!a.ok)throw e.failWithoutThrowing(`Invalid --${r}; expected a filepath containing a valid IR`),new Pne;return a.value}function sHI(e){return{bump:e.bump,errors:e.errors.map(t=>t.message)}}function uHI(e,t){return{bump:cHI(e.bump,t.bump),errors:[...e.errors,...t.errors]}}function cHI(e,t){if(!(e===void 0&&t===void 0))return e==="no_change"&&(t===void 0||t==="no_change")||t==="no_change"&&(e===void 0||e==="no_change")?"no_change":e===void 0?t:t===void 0?e:e==="no_change"?t:t==="no_change"?e:e==="major"||t==="major"?"major":e==="minor"||t==="minor"?"minor":"patch"}function lHI(e,t){if(t===void 0)return{bump:void 0,errors:[]};let{from:r,to:n}=t;try{let i=fHI(UKl(r,n)),a=[];return i==="major"&&a.push("Generator version changed by major version."),{bump:i,errors:a}}catch(i){throw e.failWithoutThrowing(`Error diffing generator versions ${r} and ${n}: ${i}`),new Pne}}function fHI(e){if(e!==null)switch(e){case"major":case"minor":case"patch":return e;default:return}}var ibv=require("fs"),QLu=class{parse({absoluteFilePath:t}){let r=(0,ibv.readFileSync)(t,"utf-8"),n=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),i=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:n?.[1],packageName:i?.[1],serviceName:a?.[1]}}};var FG=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let n=this.resolveSource({source:t});if(n==null){if(jLr(t))throw new Error(`Cannot resolve source ${t.proto} from file ${r}`);this.context.logger.warn(`Cannot resolve source ${t.openapi} from file ${r}`)}return n}resolveSource({source:t}){return jLr(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let i=new QLu().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ru.of(t.proto),csharpNamespace:i.csharpNamespace,packageName:i.packageName,serviceName:i.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let n={type:"openapi",absoluteFilePath:r,relativeFilePath:ru.of(t.openapi)};return this.sourceCache.set(r,n),n}};var Krs=class{constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:t=>this.replacement=t}}replace(t,r,n,i){t&&r&&(n!=null?t[r][n]=i:t[r]=i)}remove(t,r,n){t&&r&&(n!=null?t[r].splice(n,1):delete t[r])}};var LLu=class extends Krs{constructor(t,r){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:n=>this.replacement=n},this.enter=t,this.leave=r}visit(t,r,n,i){if(t){if(this.enter){let o=this.should_skip,c=this.should_remove,f=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,r,n,i),this.replacement&&(t=this.replacement,this.replace(r,n,i,t)),this.should_remove&&this.remove(r,n,i);let u=this.should_skip,s=this.should_remove;if(this.should_skip=o,this.should_remove=c,this.replacement=f,u)return t;if(s)return null}let a;for(a in t){let o=t[a];if(o&&typeof o=="object")if(Array.isArray(o)){let c=o;for(let f=0;f<c.length;f+=1){let u=c[f];abv(u)&&(this.visit(u,t,a,f)||f--)}}else abv(o)&&this.visit(o,t,a,null)}if(this.leave){let o=this.replacement,c=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,r,n,i),this.replacement&&(t=this.replacement,this.replace(r,n,i,t)),this.should_remove&&this.remove(r,n,i);let f=this.should_remove;if(this.replacement=o,this.should_remove=c,f)return null}}return t}};function abv(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function uie(e,{enter:t,leave:r}){return new LLu(t,r).visit(e,null)}function Pwi(e){if(e==null)return;let t=[],r=!1;if(uie(e,{enter(n){(n.type==="FunctionDeclaration"||n.type==="ArrowFunctionExpression"||n.type==="JSXOpeningElement"||n.type==="JSXOpeningFragment"||n.type==="Identifier")&&(r=!0,this.skip()),n.type==="Literal"&&t.push(n.value)}}),!r)return t.length===1?t[0]:void 0}function C8i(e){if(typeof e=="string")return e;if(e?.type==="mdxJsxAttributeValueExpression")return Pwi(e.data?.estree)}function SLf(e){let t=Y9o(e);if(t==null)throw new Error(`Filepath ${e} does not have a filename`);let r=t.endsWith(".mdx")?"mdx":t.endsWith(".md")?"md":void 0;if(r==null)throw new Error(`Filepath ${e} does not have a markdown extension`);return r}function ULu(e){return e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement"}function VLu(e){return e.type==="mdxFlowExpression"||e.type==="mdxTextExpression"}function wwi(e){return e.type==="mdxJsxAttribute"}function WLu(e){return e.type==="mdxJsxExpressionAttribute"}var ans=$i(Art(),1),Ygv=require("path");var $gv=$i(Art(),1);var obv={tokenize:dHI};function dHI(e){let t=e.attempt(this.parser.constructs.contentInitial,n,i),r;return t;function n(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),gw(e,t,"linePrefix")}function i(c){return e.enter("paragraph"),a(c)}function a(c){let f=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=f),r=f,o(c)}function o(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return kb(c)?(e.consume(c),e.exit("chunkText"),a):(e.consume(c),o)}}var ubv={tokenize:pHI},sbv={tokenize:_HI};function pHI(e){let t=this,r=[],n=0,i,a,o;return c;function c(U){if(n<r.length){let q=r[n];return t.containerState=q[1],e.attempt(q[0].continuation,f,u)(U)}return u(U)}function f(U){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&z();let q=t.events.length,V=q,$;for(;V--;)if(t.events[V][0]==="exit"&&t.events[V][1].type==="chunkFlow"){$=t.events[V][1].end;break}T(n);let re=q;for(;re<t.events.length;)t.events[re][1].end={...$},re++;return pee(t.events,V+1,0,t.events.slice(q)),t.events.length=re,u(U)}return c(U)}function u(U){if(n===r.length){if(!i)return m(U);if(i.currentConstruct&&i.currentConstruct.concrete)return P(U);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(sbv,s,l)(U)}function s(U){return i&&z(),T(n),m(U)}function l(U){return t.parser.lazy[t.now().line]=n!==r.length,o=t.now().offset,P(U)}function m(U){return t.containerState={},e.attempt(sbv,O,P)(U)}function O(U){return n++,r.push([t.currentConstruct,t.containerState]),m(U)}function P(U){if(U===null){i&&z(),T(0),e.consume(U);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),C(U)}function C(U){if(U===null){I(e.exit("chunkFlow"),!0),T(0),e.consume(U);return}return kb(U)?(e.consume(U),I(e.exit("chunkFlow")),n=0,t.interrupt=void 0,c):(e.consume(U),C)}function I(U,q){let V=t.sliceStream(U);if(q&&V.push(null),U.previous=a,a&&(a.next=U),a=U,i.defineSkip(U.start),i.write(V),t.parser.lazy[U.start.line]){let $=i.events.length;for(;$--;)if(i.events[$][1].start.offset<o&&(!i.events[$][1].end||i.events[$][1].end.offset>o))return;let re=t.events.length,Y=re,k,ne;for(;Y--;)if(t.events[Y][0]==="exit"&&t.events[Y][1].type==="chunkFlow"){if(k){ne=t.events[Y][1].end;break}k=!0}for(T(n),$=re;$<t.events.length;)t.events[$][1].end={...ne},$++;pee(t.events,Y+1,0,t.events.slice(re)),t.events.length=$}}function T(U){let q=r.length;for(;q-- >U;){let V=r[q];t.containerState=V[1],V[0].exit.call(t,e)}r.length=U}function z(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function _HI(e,t,r){return gw(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var cbv={tokenize:hHI};function hHI(e){let t=this,r=e.attempt(q_t,n,e.attempt(this.parser.constructs.flowInitial,i,gw(e,e.attempt(this.parser.constructs.flow,i,e.attempt(djf,i)),"linePrefix")));return r;function n(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,r}}var lbv={resolveAll:_bv()},fbv=pbv("string"),dbv=pbv("text");function pbv(e){return{resolveAll:_bv(e==="text"?yHI:void 0),tokenize:t};function t(r){let n=this,i=this.parser.constructs[e],a=r.attempt(i,o,c);return o;function o(s){return u(s)?a(s):c(s)}function c(s){if(s===null){r.consume(s);return}return r.enter("data"),r.consume(s),f}function f(s){return u(s)?(r.exit("data"),a(s)):(r.consume(s),f)}function u(s){if(s===null)return!0;let l=i[s],m=-1;if(l)for(;++m<l.length;){let O=l[m];if(!O.previous||O.previous.call(n,n.previous))return!0}return!1}}}function _bv(e){return t;function t(r,n){let i=-1,a;for(;++i<=r.length;)a===void 0?r[i]&&r[i][1].type==="data"&&(a=i,i++):(!r[i]||r[i][1].type!=="data")&&(i!==a+2&&(r[a][1].end=r[i-1][1].end,r.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(r,n):r}}function yHI(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){let n=e[r-1][1],i=t.sliceStream(n),a=i.length,o=-1,c=0,f;for(;a--;){let u=i[a];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)c++,o--;if(o)break;o=-1}else if(u===-2)f=!0,c++;else if(u!==-1){a++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let u={type:r===e.length||f||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:n.start._bufferIndex+o,_index:n.start._index+a,line:n.end.line,column:n.end.column-c,offset:n.end.offset-c},end:{...n.end}};n.end={...u.start},n.start.offset===n.end.offset?Object.assign(n,u):(e.splice(r,0,["enter",u,t],["exit",u,t]),r+=2)}r++}return e}var DLf={};yf(DLf,{attentionMarkers:()=>wHI,contentInitial:()=>bHI,disable:()=>jHI,document:()=>vHI,flow:()=>mHI,flowInitial:()=>gHI,insideSpan:()=>PHI,string:()=>OHI,text:()=>AHI});var vHI={42:XAe,43:XAe,45:XAe,48:XAe,49:XAe,50:XAe,51:XAe,52:XAe,53:XAe,54:XAe,55:XAe,56:XAe,57:XAe,62:DCu},bHI={91:pjf},gHI={[-2]:oYo,[-1]:oYo,32:oYo},mHI={35:hjf,42:lca,45:[FCu,lca],60:vjf,61:FCu,95:lca,96:MCu,126:MCu},OHI={38:ICu,92:CCu},AHI={[-5]:uYo,[-4]:uYo,[-3]:uYo,33:gjf,38:ICu,42:aYo,60:[ljf,bjf],91:mjf,92:[_jf,CCu],93:cca,95:aYo,96:fjf},PHI={null:[aYo,lbv]},wHI={null:[42,95]},jHI={null:[]};function hbv(e,t,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},i={},a=[],o=[],c=[],f=!0,u={attempt:k(re),check:k(Y),consume:q,enter:V,exit:$,interrupt:k(Y,{interrupt:!0})},s={code:null,containerState:{},defineSkip:T,events:[],now:I,parser:e,previous:null,sliceSerialize:P,sliceStream:C,write:O},l=t.tokenize.call(s,u),m;return t.resolveAll&&a.push(t),s;function O(ve){return o=sCe(o,ve),z(),o[o.length-1]!==null?[]:(ne(t,0),s.events=x4i(a,s.events,s),s.events)}function P(ve,pe){return SHI(C(ve),pe)}function C(ve){return EHI(o,ve)}function I(){let{_bufferIndex:ve,_index:pe,line:De,column:Ce,offset:Ee}=n;return{_bufferIndex:ve,_index:pe,line:De,column:Ce,offset:Ee}}function T(ve){i[ve.line]=ve.column,_e()}function z(){let ve;for(;n._index<o.length;){let pe=o[n._index];if(typeof pe=="string")for(ve=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===ve&&n._bufferIndex<pe.length;)U(pe.charCodeAt(n._bufferIndex));else U(pe)}}function U(ve){f=void 0,m=ve,l=l(ve)}function q(ve){kb(ve)?(n.line++,n.column=1,n.offset+=ve===-3?2:1,_e()):ve!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===o[n._index].length&&(n._bufferIndex=-1,n._index++)),s.previous=ve,f=!0}function V(ve,pe){let De=pe||{};return De.type=ve,De.start=I(),s.events.push(["enter",De,s]),c.push(De),De}function $(ve){let pe=c.pop();return pe.end=I(),s.events.push(["exit",pe,s]),pe}function re(ve,pe){ne(ve,pe.from)}function Y(ve,pe){pe.restore()}function k(ve,pe){return De;function De(Ce,Ee,Ot){let vt,xe,Be,Jt;return Array.isArray(Ce)?vr(Ce):"tokenize"in Ce?vr([Ce]):pt(Ce);function pt(kt){return pr;function pr(xn){let dr=xn!==null&&kt[xn],_n=xn!==null&&kt.null,Mt=[...Array.isArray(dr)?dr:dr?[dr]:[],...Array.isArray(_n)?_n:_n?[_n]:[]];return vr(Mt)(xn)}}function vr(kt){return vt=kt,xe=0,kt.length===0?Ot:Gt(kt[xe])}function Gt(kt){return pr;function pr(xn){return Jt=me(),Be=kt,kt.partial||(s.currentConstruct=kt),kt.name&&s.parser.constructs.disable.null.includes(kt.name)?dt(xn):kt.tokenize.call(pe?Object.assign(Object.create(s),pe):s,u,Xe,dt)(xn)}}function Xe(kt){return f=!0,ve(Be,Jt),Ee}function dt(kt){return f=!0,Jt.restore(),++xe<vt.length?Gt(vt[xe]):Ot}}}function ne(ve,pe){ve.resolveAll&&!a.includes(ve)&&a.push(ve),ve.resolve&&pee(s.events,pe,s.events.length-pe,ve.resolve(s.events.slice(pe),s)),ve.resolveTo&&(s.events=ve.resolveTo(s.events,s))}function me(){let ve=I(),pe=s.previous,De=s.currentConstruct,Ce=s.events.length,Ee=Array.from(c);return{from:Ce,restore:Ot};function Ot(){n=ve,s.previous=pe,s.currentConstruct=De,s.events.length=Ce,c=Ee,_e()}}function _e(){n.line in i&&n.column<2&&(n.column=i[n.line],n.offset+=i[n.line]-1)}}function EHI(e,t){let r=t.start._index,n=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(r===i)o=[e[r].slice(n,a)];else{if(o=e.slice(r,i),n>-1){let c=o[0];typeof c=="string"?o[0]=c.slice(n):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function SHI(e,t){let r=-1,n=[],i;for(;++r<e.length;){let a=e[r],o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
2744
+ `+jg.dump(c)),a.logger.info(Mf.green(`Added ${t} generator`)))})}))}var tbv=require("fs/promises"),rbv=$i(emi(),1);async function nbv({context:e,from:t,to:r,fromVersion:n,generatorVersions:i}){let a=new YZo,o=sHI(await a.check({from:await ebv({context:e,filepath:t,flagName:"from"}),to:await ebv({context:e,filepath:r,flagName:"to"})})),c=lHI(e,i),{bump:f,errors:u}=uHI(o,c);if(n==null)return{bump:f??"patch",errors:u};if(f==="no_change")return{bump:"no_change",nextVersion:n,errors:u};let s=f??"patch",l=rbv.default.inc(n,s);if(!l)throw e.failWithoutThrowing(`Invalid current version: ${n}`),new Pne;return{bump:s,nextVersion:l,errors:u}}async function ebv({context:e,filepath:t,flagName:r}){let n=F_.of(p1(hV(),t));if(!await Vv(n,"file"))throw e.failWithoutThrowing(`File not found: ${n}`),new Pne;let i=await(0,tbv.readFile)(n,"utf-8"),a=V0.IntermediateRepresentation.parse(JSON.parse(i));if(!a.ok)throw e.failWithoutThrowing(`Invalid --${r}; expected a filepath containing a valid IR`),new Pne;return a.value}function sHI(e){return{bump:e.bump,errors:e.errors.map(t=>t.message)}}function uHI(e,t){return{bump:cHI(e.bump,t.bump),errors:[...e.errors,...t.errors]}}function cHI(e,t){if(!(e===void 0&&t===void 0))return e==="no_change"&&(t===void 0||t==="no_change")||t==="no_change"&&(e===void 0||e==="no_change")?"no_change":e===void 0?t:t===void 0?e:e==="no_change"?t:t==="no_change"?e:e==="major"||t==="major"?"major":e==="minor"||t==="minor"?"minor":"patch"}function lHI(e,t){if(t===void 0)return{bump:void 0,errors:[]};let{from:r,to:n}=t;try{let i=fHI(UKl(r,n)),a=[];return i==="major"&&a.push("Generator version changed by major version."),{bump:i,errors:a}}catch(i){throw e.failWithoutThrowing(`Error diffing generator versions ${r} and ${n}: ${i}`),new Pne}}function fHI(e){if(e!==null)switch(e){case"major":case"minor":case"patch":return e;default:return}}var ibv=require("fs"),QLu=class{parse({absoluteFilePath:t}){let r=(0,ibv.readFileSync)(t,"utf-8"),n=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),i=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:n?.[1],packageName:i?.[1],serviceName:a?.[1]}}};var FG=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let n=this.resolveSource({source:t});return n==null&&(jLr(t)?this.context.logger.warn(`Cannot resolve source ${t.proto} from file ${r}`):this.context.logger.warn(`Cannot resolve source ${t.openapi} from file ${r}`)),n}resolveSource({source:t}){return jLr(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let i=new QLu().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ru.of(t.proto),csharpNamespace:i.csharpNamespace,packageName:i.packageName,serviceName:i.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let n={type:"openapi",absoluteFilePath:r,relativeFilePath:ru.of(t.openapi)};return this.sourceCache.set(r,n),n}};var Krs=class{constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:t=>this.replacement=t}}replace(t,r,n,i){t&&r&&(n!=null?t[r][n]=i:t[r]=i)}remove(t,r,n){t&&r&&(n!=null?t[r].splice(n,1):delete t[r])}};var LLu=class extends Krs{constructor(t,r){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:()=>this.should_skip=!0,remove:()=>this.should_remove=!0,replace:n=>this.replacement=n},this.enter=t,this.leave=r}visit(t,r,n,i){if(t){if(this.enter){let o=this.should_skip,c=this.should_remove,f=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,r,n,i),this.replacement&&(t=this.replacement,this.replace(r,n,i,t)),this.should_remove&&this.remove(r,n,i);let u=this.should_skip,s=this.should_remove;if(this.should_skip=o,this.should_remove=c,this.replacement=f,u)return t;if(s)return null}let a;for(a in t){let o=t[a];if(o&&typeof o=="object")if(Array.isArray(o)){let c=o;for(let f=0;f<c.length;f+=1){let u=c[f];abv(u)&&(this.visit(u,t,a,f)||f--)}}else abv(o)&&this.visit(o,t,a,null)}if(this.leave){let o=this.replacement,c=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,r,n,i),this.replacement&&(t=this.replacement,this.replace(r,n,i,t)),this.should_remove&&this.remove(r,n,i);let f=this.should_remove;if(this.replacement=o,this.should_remove=c,f)return null}}return t}};function abv(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function uie(e,{enter:t,leave:r}){return new LLu(t,r).visit(e,null)}function Pwi(e){if(e==null)return;let t=[],r=!1;if(uie(e,{enter(n){(n.type==="FunctionDeclaration"||n.type==="ArrowFunctionExpression"||n.type==="JSXOpeningElement"||n.type==="JSXOpeningFragment"||n.type==="Identifier")&&(r=!0,this.skip()),n.type==="Literal"&&t.push(n.value)}}),!r)return t.length===1?t[0]:void 0}function C8i(e){if(typeof e=="string")return e;if(e?.type==="mdxJsxAttributeValueExpression")return Pwi(e.data?.estree)}function SLf(e){let t=Y9o(e);if(t==null)throw new Error(`Filepath ${e} does not have a filename`);let r=t.endsWith(".mdx")?"mdx":t.endsWith(".md")?"md":void 0;if(r==null)throw new Error(`Filepath ${e} does not have a markdown extension`);return r}function ULu(e){return e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement"}function VLu(e){return e.type==="mdxFlowExpression"||e.type==="mdxTextExpression"}function wwi(e){return e.type==="mdxJsxAttribute"}function WLu(e){return e.type==="mdxJsxExpressionAttribute"}var ans=$i(Art(),1),Ygv=require("path");var $gv=$i(Art(),1);var obv={tokenize:dHI};function dHI(e){let t=e.attempt(this.parser.constructs.contentInitial,n,i),r;return t;function n(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),gw(e,t,"linePrefix")}function i(c){return e.enter("paragraph"),a(c)}function a(c){let f=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=f),r=f,o(c)}function o(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return kb(c)?(e.consume(c),e.exit("chunkText"),a):(e.consume(c),o)}}var ubv={tokenize:pHI},sbv={tokenize:_HI};function pHI(e){let t=this,r=[],n=0,i,a,o;return c;function c(U){if(n<r.length){let q=r[n];return t.containerState=q[1],e.attempt(q[0].continuation,f,u)(U)}return u(U)}function f(U){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&z();let q=t.events.length,V=q,$;for(;V--;)if(t.events[V][0]==="exit"&&t.events[V][1].type==="chunkFlow"){$=t.events[V][1].end;break}T(n);let re=q;for(;re<t.events.length;)t.events[re][1].end={...$},re++;return pee(t.events,V+1,0,t.events.slice(q)),t.events.length=re,u(U)}return c(U)}function u(U){if(n===r.length){if(!i)return m(U);if(i.currentConstruct&&i.currentConstruct.concrete)return P(U);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(sbv,s,l)(U)}function s(U){return i&&z(),T(n),m(U)}function l(U){return t.parser.lazy[t.now().line]=n!==r.length,o=t.now().offset,P(U)}function m(U){return t.containerState={},e.attempt(sbv,O,P)(U)}function O(U){return n++,r.push([t.currentConstruct,t.containerState]),m(U)}function P(U){if(U===null){i&&z(),T(0),e.consume(U);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),C(U)}function C(U){if(U===null){I(e.exit("chunkFlow"),!0),T(0),e.consume(U);return}return kb(U)?(e.consume(U),I(e.exit("chunkFlow")),n=0,t.interrupt=void 0,c):(e.consume(U),C)}function I(U,q){let V=t.sliceStream(U);if(q&&V.push(null),U.previous=a,a&&(a.next=U),a=U,i.defineSkip(U.start),i.write(V),t.parser.lazy[U.start.line]){let $=i.events.length;for(;$--;)if(i.events[$][1].start.offset<o&&(!i.events[$][1].end||i.events[$][1].end.offset>o))return;let re=t.events.length,Y=re,k,ne;for(;Y--;)if(t.events[Y][0]==="exit"&&t.events[Y][1].type==="chunkFlow"){if(k){ne=t.events[Y][1].end;break}k=!0}for(T(n),$=re;$<t.events.length;)t.events[$][1].end={...ne},$++;pee(t.events,Y+1,0,t.events.slice(re)),t.events.length=$}}function T(U){let q=r.length;for(;q-- >U;){let V=r[q];t.containerState=V[1],V[0].exit.call(t,e)}r.length=U}function z(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function _HI(e,t,r){return gw(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var cbv={tokenize:hHI};function hHI(e){let t=this,r=e.attempt(q_t,n,e.attempt(this.parser.constructs.flowInitial,i,gw(e,e.attempt(this.parser.constructs.flow,i,e.attempt(djf,i)),"linePrefix")));return r;function n(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,r}}var lbv={resolveAll:_bv()},fbv=pbv("string"),dbv=pbv("text");function pbv(e){return{resolveAll:_bv(e==="text"?yHI:void 0),tokenize:t};function t(r){let n=this,i=this.parser.constructs[e],a=r.attempt(i,o,c);return o;function o(s){return u(s)?a(s):c(s)}function c(s){if(s===null){r.consume(s);return}return r.enter("data"),r.consume(s),f}function f(s){return u(s)?(r.exit("data"),a(s)):(r.consume(s),f)}function u(s){if(s===null)return!0;let l=i[s],m=-1;if(l)for(;++m<l.length;){let O=l[m];if(!O.previous||O.previous.call(n,n.previous))return!0}return!1}}}function _bv(e){return t;function t(r,n){let i=-1,a;for(;++i<=r.length;)a===void 0?r[i]&&r[i][1].type==="data"&&(a=i,i++):(!r[i]||r[i][1].type!=="data")&&(i!==a+2&&(r[a][1].end=r[i-1][1].end,r.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(r,n):r}}function yHI(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){let n=e[r-1][1],i=t.sliceStream(n),a=i.length,o=-1,c=0,f;for(;a--;){let u=i[a];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)c++,o--;if(o)break;o=-1}else if(u===-2)f=!0,c++;else if(u!==-1){a++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let u={type:r===e.length||f||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:n.start._bufferIndex+o,_index:n.start._index+a,line:n.end.line,column:n.end.column-c,offset:n.end.offset-c},end:{...n.end}};n.end={...u.start},n.start.offset===n.end.offset?Object.assign(n,u):(e.splice(r,0,["enter",u,t],["exit",u,t]),r+=2)}r++}return e}var DLf={};yf(DLf,{attentionMarkers:()=>wHI,contentInitial:()=>bHI,disable:()=>jHI,document:()=>vHI,flow:()=>mHI,flowInitial:()=>gHI,insideSpan:()=>PHI,string:()=>OHI,text:()=>AHI});var vHI={42:XAe,43:XAe,45:XAe,48:XAe,49:XAe,50:XAe,51:XAe,52:XAe,53:XAe,54:XAe,55:XAe,56:XAe,57:XAe,62:DCu},bHI={91:pjf},gHI={[-2]:oYo,[-1]:oYo,32:oYo},mHI={35:hjf,42:lca,45:[FCu,lca],60:vjf,61:FCu,95:lca,96:MCu,126:MCu},OHI={38:ICu,92:CCu},AHI={[-5]:uYo,[-4]:uYo,[-3]:uYo,33:gjf,38:ICu,42:aYo,60:[ljf,bjf],91:mjf,92:[_jf,CCu],93:cca,95:aYo,96:fjf},PHI={null:[aYo,lbv]},wHI={null:[42,95]},jHI={null:[]};function hbv(e,t,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},i={},a=[],o=[],c=[],f=!0,u={attempt:k(re),check:k(Y),consume:q,enter:V,exit:$,interrupt:k(Y,{interrupt:!0})},s={code:null,containerState:{},defineSkip:T,events:[],now:I,parser:e,previous:null,sliceSerialize:P,sliceStream:C,write:O},l=t.tokenize.call(s,u),m;return t.resolveAll&&a.push(t),s;function O(ve){return o=sCe(o,ve),z(),o[o.length-1]!==null?[]:(ne(t,0),s.events=x4i(a,s.events,s),s.events)}function P(ve,pe){return SHI(C(ve),pe)}function C(ve){return EHI(o,ve)}function I(){let{_bufferIndex:ve,_index:pe,line:De,column:Ce,offset:Ee}=n;return{_bufferIndex:ve,_index:pe,line:De,column:Ce,offset:Ee}}function T(ve){i[ve.line]=ve.column,_e()}function z(){let ve;for(;n._index<o.length;){let pe=o[n._index];if(typeof pe=="string")for(ve=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===ve&&n._bufferIndex<pe.length;)U(pe.charCodeAt(n._bufferIndex));else U(pe)}}function U(ve){f=void 0,m=ve,l=l(ve)}function q(ve){kb(ve)?(n.line++,n.column=1,n.offset+=ve===-3?2:1,_e()):ve!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===o[n._index].length&&(n._bufferIndex=-1,n._index++)),s.previous=ve,f=!0}function V(ve,pe){let De=pe||{};return De.type=ve,De.start=I(),s.events.push(["enter",De,s]),c.push(De),De}function $(ve){let pe=c.pop();return pe.end=I(),s.events.push(["exit",pe,s]),pe}function re(ve,pe){ne(ve,pe.from)}function Y(ve,pe){pe.restore()}function k(ve,pe){return De;function De(Ce,Ee,Ot){let vt,xe,Be,Jt;return Array.isArray(Ce)?vr(Ce):"tokenize"in Ce?vr([Ce]):pt(Ce);function pt(kt){return pr;function pr(xn){let dr=xn!==null&&kt[xn],_n=xn!==null&&kt.null,Mt=[...Array.isArray(dr)?dr:dr?[dr]:[],...Array.isArray(_n)?_n:_n?[_n]:[]];return vr(Mt)(xn)}}function vr(kt){return vt=kt,xe=0,kt.length===0?Ot:Gt(kt[xe])}function Gt(kt){return pr;function pr(xn){return Jt=me(),Be=kt,kt.partial||(s.currentConstruct=kt),kt.name&&s.parser.constructs.disable.null.includes(kt.name)?dt(xn):kt.tokenize.call(pe?Object.assign(Object.create(s),pe):s,u,Xe,dt)(xn)}}function Xe(kt){return f=!0,ve(Be,Jt),Ee}function dt(kt){return f=!0,Jt.restore(),++xe<vt.length?Gt(vt[xe]):Ot}}}function ne(ve,pe){ve.resolveAll&&!a.includes(ve)&&a.push(ve),ve.resolve&&pee(s.events,pe,s.events.length-pe,ve.resolve(s.events.slice(pe),s)),ve.resolveTo&&(s.events=ve.resolveTo(s.events,s))}function me(){let ve=I(),pe=s.previous,De=s.currentConstruct,Ce=s.events.length,Ee=Array.from(c);return{from:Ce,restore:Ot};function Ot(){n=ve,s.previous=pe,s.currentConstruct=De,s.events.length=Ce,c=Ee,_e()}}function _e(){n.line in i&&n.column<2&&(n.column=i[n.line],n.offset+=i[n.line]-1)}}function EHI(e,t){let r=t.start._index,n=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(r===i)o=[e[r].slice(n,a)];else{if(o=e.slice(r,i),n>-1){let c=o[0];typeof c=="string"?o[0]=c.slice(n):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function SHI(e,t){let r=-1,n=[],i;for(;++r<e.length;){let a=e[r],o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
2745
2745
  `;break}case-3:{o=`\r
2746
2746
  `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(a)}i=a===-2,n.push(o)}return n.join("")}function CLf(e){let n={constructs:Dka([DLf,...(e||{}).extensions||[]]),content:i(obv),defined:[],document:i(ubv),flow:i(cbv),lazy:{},string:i(fbv),text:i(dbv)};return n;function i(a){return o;function o(c){return hbv(n,a,c)}}}function ILf(e){for(;!TCu(e););return e}var ybv=/[\0\t\n\r]/g;function MLf(){let e=1,t="",r=!0,n;return i;function i(a,o,c){let f=[],u,s,l,m,O;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(o||void 0).decode(a)),l=0,t="",r&&(a.charCodeAt(0)===65279&&l++,r=void 0);l<a.length;){if(ybv.lastIndex=l,u=ybv.exec(a),m=u&&u.index!==void 0?u.index:a.length,O=a.charCodeAt(m),!u){t=a.slice(l);break}if(O===10&&l===m&&n)f.push(-3),n=void 0;else switch(n&&(f.push(-5),n=void 0),l<m&&(f.push(a.slice(l,m)),e+=m-l),O){case 0:{f.push(65533),e++;break}case 9:{for(s=Math.ceil(e/4)*4,f.push(-2);e++<s;)f.push(-1);break}case 10:{f.push(-4),e=1;break}default:n=!0,e=1}l=m+1}return c&&(n&&f.push(-5),t&&f.push(t),f.push(null)),f}}var bbv={}.hasOwnProperty;function dda(e,t,r){return typeof t!="string"&&(r=t,t=void 0),DHI(r)(ILf(CLf(r).document().write(MLf()(e,t,!0))))}function DHI(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Dr),autolinkProtocol:k,autolinkEmail:k,atxHeading:a(rr),blockQuote:a(xn),characterEscape:k,characterReference:k,codeFenced:a(dr),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(dr,o),codeText:a(_n,o),codeTextData:k,data:k,codeFlowValue:k,definition:a(Mt),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(Hi),hardBreakEscape:a(Ir),hardBreakTrailing:a(Ir),htmlFlow:a(tn,o),htmlFlowData:k,htmlText:a(tn,o),htmlTextData:k,image:a(un),label:o,link:a(Dr),listItem:a(Gn),listItemValue:m,listOrdered:a(zi,l),listUnordered:a(zi),paragraph:a(Xn),reference:pt,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(rr),strong:a(pa),thematicBreak:a(Ta)},exit:{atxHeading:f(),atxHeadingSequence:V,autolink:f(),autolinkEmail:pr,autolinkProtocol:kt,blockQuote:f(),characterEscapeValue:ne,characterReferenceMarkerHexadecimal:Gt,characterReferenceMarkerNumeric:Gt,characterReferenceValue:Xe,characterReference:dt,codeFenced:f(I),codeFencedFence:C,codeFencedFenceInfo:O,codeFencedFenceMeta:P,codeFlowValue:ne,codeIndented:f(T),codeText:f(De),codeTextData:ne,data:ne,definition:f(),definitionDestinationString:q,definitionLabelString:z,definitionTitleString:U,emphasis:f(),hardBreakEscape:f(_e),hardBreakTrailing:f(_e),htmlFlow:f(ve),htmlFlowData:ne,htmlText:f(pe),htmlTextData:ne,image:f(Ee),label:vt,labelText:Ot,lineEnding:me,link:f(Ce),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:vr,resourceDestinationString:xe,resourceTitleString:Be,resource:Jt,setextHeading:f(Y),setextHeadingLineSequence:re,setextHeadingText:$,strong:f(),thematicBreak:f()}};gbv(t,(e||{}).mdastExtensions||[]);let r={};return n;function n(xr){let dn={type:"root",children:[]},rt={stack:[dn],tokenStack:[],config:t,enter:c,exit:u,buffer:o,resume:s,data:r},gt=[],bt=-1;for(;++bt<xr.length;)if(xr[bt][1].type==="listOrdered"||xr[bt][1].type==="listUnordered")if(xr[bt][0]==="enter")gt.push(bt);else{let St=gt.pop();bt=i(xr,St,bt)}for(bt=-1;++bt<xr.length;){let St=t[xr[bt][0]];bbv.call(St,xr[bt][1].type)&&St[xr[bt][1].type].call(Object.assign({sliceSerialize:xr[bt][2].sliceSerialize},rt),xr[bt][1])}if(rt.tokenStack.length>0){let St=rt.tokenStack[rt.tokenStack.length-1];(St[1]||vbv).call(rt,void 0,St[0])}for(dn.position={start:I8i(xr.length>0?xr[0][1].start:{line:1,column:1,offset:0}),end:I8i(xr.length>0?xr[xr.length-2][1].end:{line:1,column:1,offset:0})},bt=-1;++bt<t.transforms.length;)dn=t.transforms[bt](dn)||dn;return dn}function i(xr,dn,rt){let gt=dn-1,bt=-1,St=!1,qr,Ln,vi,On;for(;++gt<=rt;){let Qt=xr[gt];switch(Qt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Qt[0]==="enter"?bt++:bt--,On=void 0;break}case"lineEndingBlank":{Qt[0]==="enter"&&(qr&&!On&&!bt&&!vi&&(vi=gt),On=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:On=void 0}if(!bt&&Qt[0]==="enter"&&Qt[1].type==="listItemPrefix"||bt===-1&&Qt[0]==="exit"&&(Qt[1].type==="listUnordered"||Qt[1].type==="listOrdered")){if(qr){let Je=gt;for(Ln=void 0;Je--;){let ie=xr[Je];if(ie[1].type==="lineEnding"||ie[1].type==="lineEndingBlank"){if(ie[0]==="exit")continue;Ln&&(xr[Ln][1].type="lineEndingBlank",St=!0),ie[1].type="lineEnding",Ln=Je}else if(!(ie[1].type==="linePrefix"||ie[1].type==="blockQuotePrefix"||ie[1].type==="blockQuotePrefixWhitespace"||ie[1].type==="blockQuoteMarker"||ie[1].type==="listItemIndent"))break}vi&&(!Ln||vi<Ln)&&(qr._spread=!0),qr.end=Object.assign({},Ln?xr[Ln][1].start:Qt[1].end),xr.splice(Ln||gt,0,["exit",qr,Qt[2]]),gt++,rt++}if(Qt[1].type==="listItemPrefix"){let Je={type:"listItem",_spread:!1,start:Object.assign({},Qt[1].start),end:void 0};qr=Je,xr.splice(gt,0,["enter",Je,Qt[2]]),gt++,rt++,vi=void 0,On=!0}}}return xr[dn][1]._spread=St,rt}function a(xr,dn){return rt;function rt(gt){c.call(this,xr(gt),gt),dn&&dn.call(this,gt)}}function o(){this.stack.push({type:"fragment",children:[]})}function c(xr,dn,rt){this.stack[this.stack.length-1].children.push(xr),this.stack.push(xr),this.tokenStack.push([dn,rt||void 0]),xr.position={start:I8i(dn.start),end:void 0}}function f(xr){return dn;function dn(rt){xr&&xr.call(this,rt),u.call(this,rt)}}function u(xr,dn){let rt=this.stack.pop(),gt=this.tokenStack.pop();if(gt)gt[0].type!==xr.type&&(dn?dn.call(this,xr,gt[0]):(gt[1]||vbv).call(this,xr,gt[0]));else throw new Error("Cannot close `"+xr.type+"` ("+Kfe({start:xr.start,end:xr.end})+"): it\u2019s not open");rt.position.end=I8i(xr.end)}function s(){return UAi(this.stack.pop())}function l(){this.data.expectingFirstListItemValue=!0}function m(xr){if(this.data.expectingFirstListItemValue){let dn=this.stack[this.stack.length-2];dn.start=Number.parseInt(this.sliceSerialize(xr),10),this.data.expectingFirstListItemValue=void 0}}function O(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.lang=xr}function P(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.meta=xr}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function I(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.value=xr.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function T(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.value=xr.replace(/(\r?\n|\r)$/g,"")}function z(xr){let dn=this.resume(),rt=this.stack[this.stack.length-1];rt.label=dn,rt.identifier=YAe(this.sliceSerialize(xr)).toLowerCase()}function U(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.title=xr}function q(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.url=xr}function V(xr){let dn=this.stack[this.stack.length-1];if(!dn.depth){let rt=this.sliceSerialize(xr).length;dn.depth=rt}}function $(){this.data.setextHeadingSlurpLineEnding=!0}function re(xr){let dn=this.stack[this.stack.length-1];dn.depth=this.sliceSerialize(xr).codePointAt(0)===61?1:2}function Y(){this.data.setextHeadingSlurpLineEnding=void 0}function k(xr){let rt=this.stack[this.stack.length-1].children,gt=rt[rt.length-1];(!gt||gt.type!=="text")&&(gt=bo(),gt.position={start:I8i(xr.start),end:void 0},rt.push(gt)),this.stack.push(gt)}function ne(xr){let dn=this.stack.pop();dn.value+=this.sliceSerialize(xr),dn.position.end=I8i(xr.end)}function me(xr){let dn=this.stack[this.stack.length-1];if(this.data.atHardBreak){let rt=dn.children[dn.children.length-1];rt.position.end=I8i(xr.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(dn.type)&&(k.call(this,xr),ne.call(this,xr))}function _e(){this.data.atHardBreak=!0}function ve(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.value=xr}function pe(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.value=xr}function De(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.value=xr}function Ce(){let xr=this.stack[this.stack.length-1];if(this.data.inReference){let dn=this.data.referenceType||"shortcut";xr.type+="Reference",xr.referenceType=dn,delete xr.url,delete xr.title}else delete xr.identifier,delete xr.label;this.data.referenceType=void 0}function Ee(){let xr=this.stack[this.stack.length-1];if(this.data.inReference){let dn=this.data.referenceType||"shortcut";xr.type+="Reference",xr.referenceType=dn,delete xr.url,delete xr.title}else delete xr.identifier,delete xr.label;this.data.referenceType=void 0}function Ot(xr){let dn=this.sliceSerialize(xr),rt=this.stack[this.stack.length-2];rt.label=SCu(dn),rt.identifier=YAe(dn).toLowerCase()}function vt(){let xr=this.stack[this.stack.length-1],dn=this.resume(),rt=this.stack[this.stack.length-1];if(this.data.inReference=!0,rt.type==="link"){let gt=xr.children;rt.children=gt}else rt.alt=dn}function xe(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.url=xr}function Be(){let xr=this.resume(),dn=this.stack[this.stack.length-1];dn.title=xr}function Jt(){this.data.inReference=void 0}function pt(){this.data.referenceType="collapsed"}function vr(xr){let dn=this.resume(),rt=this.stack[this.stack.length-1];rt.label=dn,rt.identifier=YAe(this.sliceSerialize(xr)).toLowerCase(),this.data.referenceType="full"}function Gt(xr){this.data.characterReferenceType=xr.type}function Xe(xr){let dn=this.sliceSerialize(xr),rt=this.data.characterReferenceType,gt;rt?(gt=ECu(dn,rt==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):gt=VAi(dn);let bt=this.stack[this.stack.length-1];bt.value+=gt}function dt(xr){let dn=this.stack.pop();dn.position.end=I8i(xr.end)}function kt(xr){ne.call(this,xr);let dn=this.stack[this.stack.length-1];dn.url=this.sliceSerialize(xr)}function pr(xr){ne.call(this,xr);let dn=this.stack[this.stack.length-1];dn.url="mailto:"+this.sliceSerialize(xr)}function xn(){return{type:"blockquote",children:[]}}function dr(){return{type:"code",lang:null,meta:null,value:""}}function _n(){return{type:"inlineCode",value:""}}function Mt(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Hi(){return{type:"emphasis",children:[]}}function rr(){return{type:"heading",depth:0,children:[]}}function Ir(){return{type:"break"}}function tn(){return{type:"html",value:""}}function un(){return{type:"image",title:null,url:"",alt:null}}function Dr(){return{type:"link",title:null,url:"",children:[]}}function zi(xr){return{type:"list",ordered:xr.type==="listOrdered",start:null,spread:xr._spread,children:[]}}function Gn(xr){return{type:"listItem",spread:xr._spread,checked:null,children:[]}}function Xn(){return{type:"paragraph",children:[]}}function pa(){return{type:"strong",children:[]}}function bo(){return{type:"text",value:""}}function Ta(){return{type:"thematicBreak"}}}function I8i(e){return{line:e.line,column:e.column,offset:e.offset}}function gbv(e,t){let r=-1;for(;++r<t.length;){let n=t[r];Array.isArray(n)?gbv(e,n):CHI(e,n)}}function CHI(e,t){let r;for(r in t)if(bbv.call(t,r))switch(r){case"canContainEols":{let n=t[r];n&&e[r].push(...n);break}case"transforms":{let n=t[r];n&&e[r].push(...n);break}case"enter":case"exit":{let n=t[r];n&&Object.assign(e[r],n);break}}}function vbv(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Kfe({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Kfe({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Kfe({start:t.start,end:t.end})+") is still open")}function pda(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:n,mathFlowFenceMeta:r,mathFlowValue:c,mathText:o,mathTextData:c}};function e(f){let u={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[u]}},f)}function t(){this.buffer()}function r(){let f=this.resume(),u=this.stack[this.stack.length-1];u.type,u.meta=f}function n(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function i(f){let u=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),s=this.stack[this.stack.length-1];s.type,this.exit(f),s.value=u;let l=s.data.hChildren[0];l.type,l.tagName,l.children.push({type:"text",value:u}),this.data.mathFlowInside=void 0}function a(f){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-inline"]},hChildren:[]}},f),this.buffer()}function o(f){let u=this.resume(),s=this.stack[this.stack.length-1];s.type,this.exit(f),s.value=u,s.data.hChildren.push({type:"text",value:u})}function c(f){this.config.enter.data.call(this,f),this.config.exit.data.call(this,f)}}function BLf(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),n.peek=i,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:`
2747
2747
  `,inConstruct:"mathFlowMeta"},{character:"$",after:t?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:r,inlineMath:n}};function r(a,o,c,f){let u=a.value||"",s=c.createTracker(f),l="$".repeat(Math.max(PCu(u,"$")+1,2)),m=c.enter("mathFlow"),O=s.move(l);if(a.meta){let P=c.enter("mathFlowMeta");O+=s.move(c.safe(a.meta,{after:`
@@ -3084,7 +3084,7 @@ ${n?`
3084
3084
  `+n+`
3085
3085
  `:""}
3086
3086
  More information: https://mdxjs.com/docs/troubleshooting-mdx`);return i.stack="",i}var BGu=(function(e){if(e==null)return VfM;if(typeof e=="string")return UfM(e);if(typeof e=="object")return Array.isArray(e)?QfM(e):LfM(e);if(typeof e=="function")return TGu(e);throw new Error("Expected function, string, or object as test")});function QfM(e){let t=[],r=-1;for(;++r<e.length;)t[r]=BGu(e[r]);return TGu(n);function n(...i){let a=-1;for(;++a<t.length;)if(t[a].call(this,...i))return!0;return!1}}function LfM(e){return TGu(t);function t(r){let n;for(n in e)if(r[n]!==e[n])return!1;return!0}}function UfM(e){return TGu(t);function t(r){return r&&r.type===e}}function TGu(e){return t;function t(r,...n){return!!(r&&typeof r=="object"&&"type"in r&&e.call(this,r,...n))}}function VfM(){return!0}var WfM=[],BHf=(function(e,t,r){let n=BGu(r||t),i=!t||t.cascade===void 0||t.cascade===null?!0:t.cascade;return a(e);function a(o,c,f){let u=o.children||WfM,s=-1,l=0;if(n(o,c,f))return null;if(u.length>0){for(;++s<u.length;)a(u[s],s,o)&&(u[l++]=u[s]);if(i&&!l)return null;u.length=l}return o}});function sNv(){return e=>BHf(e,"mdxjsEsm")}function GfM(e={},t=!1){let r=e.useDynamicImport??!1,n=[...e.remarkPlugins||[],...r?[]:[sNv]];return{...e,remarkPlugins:n,outputFormat:"function-body",providerImportSource:t?void 0:"@mdx-js/react",development:process.env.NODE_ENV!=="production"}}async function THf(e,{scope:t={},mdxOptions:r={},parseFrontmatter:n=!1}={},i=!1){let a=new Q_t(e);n&&MHf(a,{strip:!0});let o;try{o=await IHf(a,GfM(r,i))}catch(f){throw oNv(f,String(a))}return{compiledSource:String(o),frontmatter:a.data.matter??{},scope:t}}function qHf(e,t){let n=(t||{}).force||!1;Wv(e,i);function i(a){n?delete a.position:a.position=void 0}}function RHf(e,t){let r=xYo(e,t);return qHf(r,{force:!0}),delete r.data,r}var HfM={},JfM=[];function qGu(e){let t=e||HfM;return function(r,n){tca(r,"element",function(i,a){let o=Array.isArray(i.properties.className)?i.properties.className:JfM,c=o.includes("language-math"),f=o.includes("math-display"),u=o.includes("math-inline"),s=f;if(!c&&!f&&!u)return;let l=a[a.length-1],m=i;if(i.tagName==="code"&&c&&l&&l.type==="element"&&l.tagName==="pre"&&(m=l,l=a[a.length-2],s=!0),!l)return;let O=Jrt(m,{whitespace:"pre"}),P;try{P=A9f.renderToString(O,{...t,displayMode:s,throwOnError:!0})}catch(I){let T=I,z=T.name.toLowerCase();n.message("Could not render math with KaTeX",{ancestors:[...a,i],cause:T,place:i.position,ruleId:z,source:"rehype-katex"});try{P=A9f.renderToString(O,{...t,displayMode:s,strict:"ignore",throwOnError:!1})}catch{P=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(I)},children:[{type:"text",value:O}]}]}}typeof P=="string"&&(P=RHf(P,{fragment:!0}).children);let C=l.children.indexOf(m);return l.children.splice(C,1,...P),Wrt})}}var KfM={};function RGu(e){let t=this,r=e||KfM,n=t.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),o=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push(_da(r)),a.push(pda()),o.push(BLf(r))}var uNv={name:"valid-markdown",create:({logger:e,workspace:t})=>({markdownPage:async({content:r,absoluteFilepath:n})=>{let i;try{i=SLf(n)}catch(o){return[{severity:"error",message:`Markdown file does not have a valid extension: ${String(o)}`}]}let a=await ZfM({markdown:r,absoluteFilepath:n,absolutePathToFernFolder:Tg(t.absoluteFilepathToDocsConfig),logger:e});return a.type==="failure"?[{severity:"fatal",message:a.message!=null?`Markdown failed to parse: ${a.message}`:"Markdown failed to parse"}]:[]}})},$fM=[Mka,RGu],YfM=[qGu],XfM=nl.object({title:nl.optional(nl.string(),{description:"Renders as the page title."}),"og:title":nl.optional(nl.string(),{description:"Renders as the og:title tag."}),"og:description":nl.optional(nl.string(),{description:"Renders as the og:description tag."}),subtitle:nl.optional(nl.string(),{description:"Renders as a subtitle on the page, and is also used in the meta description tag if description is not set."}),description:nl.optional(nl.string(),{description:"Renders as the meta description tag."}),image:nl.optional(nl.string(),{description:"Renders as the og:image tag."}),slug:nl.optional(nl.string(),{description:"The full slug path for the page, starting from root `/` (or basepath)."}),redirects:nl.optional(nl.array(nl.string()),{description:"A list of URLs to redirect to this page."}),editThisPageUrl:nl.optional(nl.string()),excerpt:nl.optional(nl.string(),{description:"Deprecated. Use `subtitle` instead."})});async function ZfM({markdown:e,absoluteFilepath:t,absolutePathToFernFolder:r,logger:n}){try{n.trace(`Starting markdown parse for file: ${t}`),gda(e,{absolutePathToMarkdownFile:t,absolutePathToFernFolder:r}),n.trace("Serializing markdown with MDX");let i=await THf(e,{scope:{},mdxOptions:{remarkPlugins:$fM,rehypePlugins:YfM,format:"detect"},parseFrontmatter:!0});n.trace("Validating frontmatter");let a=XfM.safeParse(i.frontmatter);return a.success?(n.trace("Markdown parse completed successfully"),{type:"success"}):(n.trace(`Frontmatter validation failed: ${a.error.errors.map(o=>o.message).join(", ")}`),{type:"failure",message:`Failed to parse frontmatter: ${a.error.errors.map(o=>o.message).join(`
3087
- `)}`})}catch(i){return n.trace(`Markdown parse failed with error: ${i instanceof Error?i.message:String(i)}`),{type:"failure",message:i instanceof Error?i.message:void 0}}}var cNv=require("fs/promises"),lNv=$i(Art(),1);var fNv={name:"valid-markdown-file-references",create:e=>({filepath:async({absoluteFilepath:t})=>{if(!t.endsWith(".md")&&!t.endsWith(".mdx"))return[];try{let r=await(0,cNv.readFile)(t,"utf-8"),{content:n}=(0,lNv.default)(r,{}),i=N8i(n),a=[];return Wv(i,o=>{if(o.type==="link"){let c=b9u({href:Int(o.url),metadata:{absolutePathToFernFolder:t,absolutePathToMarkdownFile:t},markdownFilesToPathName:{}});if(c?.type==="missing-reference")try{let f=hBr(F_.of(c.path));a.push({severity:"error",message:f?`File ${c.href} does not exit`:`File ${c.href} exists but is not specified in docs.yml`})}catch{}}}),a}catch{return[]}}})};var ENv=require("crypto"),VHf=$i(require("path"),1);var dNv=require("fs"),NGu=class{parse({absoluteFilePath:t}){let r=(0,dNv.readFileSync)(t,"utf-8"),n=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),i=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:n?.[1],packageName:i?.[1],serviceName:a?.[1]}}};var FGu=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let n=this.resolveSource({source:t});if(n==null){if(jLr(t))throw new Error(`Cannot resolve source ${t.proto} from file ${r}`);this.context.logger.warn(`Cannot resolve source ${t.openapi} from file ${r}`)}return n}resolveSource({source:t}){return jLr(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let i=new NGu().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ru.of(t.proto),csharpNamespace:i.csharpNamespace,packageName:i.packageName,serviceName:i.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let n={type:"openapi",absoluteFilePath:r,relativeFilePath:ru.of(t.openapi)};return this.sourceCache.set(r,n),n}};function kfM(e){for(var t=[],r=0;r<e.length;){var n=e[r];if(n==="*"||n==="+"||n==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(n==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(n==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(n==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(n===":"){for(var i="",a=r+1;a<e.length;){var o=e.charCodeAt(a);if(o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122||o===95){i+=e[a++];continue}break}if(!i)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:i}),r=a;continue}if(n==="("){var c=1,f="",a=r+1;if(e[a]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(a));for(;a<e.length;){if(e[a]==="\\"){f+=e[a++]+e[a++];continue}if(e[a]===")"){if(c--,c===0){a++;break}}else if(e[a]==="("&&(c++,e[a+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(a));f+=e[a++]}if(c)throw new TypeError("Unbalanced pattern at ".concat(r));if(!f)throw new TypeError("Missing pattern at ".concat(r));t.push({type:"PATTERN",index:r,value:f}),r=a;continue}t.push({type:"CHAR",index:r,value:e[r++]})}return t.push({type:"END",index:r,value:""}),t}function pNv(e,t){t===void 0&&(t={});for(var r=kfM(e),n=t.prefixes,i=n===void 0?"./":n,a=t.delimiter,o=a===void 0?"/#?":a,c=[],f=0,u=0,s="",l=function(k){if(u<r.length&&r[u].type===k)return r[u++].value},m=function(k){var ne=l(k);if(ne!==void 0)return ne;var me=r[u],_e=me.type,ve=me.index;throw new TypeError("Unexpected ".concat(_e," at ").concat(ve,", expected ").concat(k))},O=function(){for(var k="",ne;ne=l("CHAR")||l("ESCAPED_CHAR");)k+=ne;return k},P=function(k){for(var ne=0,me=o;ne<me.length;ne++){var _e=me[ne];if(k.indexOf(_e)>-1)return!0}return!1},C=function(k){var ne=c[c.length-1],me=k||(ne&&typeof ne=="string"?ne:"");if(ne&&!me)throw new TypeError('Must have text between two parameters, missing text after "'.concat(ne.name,'"'));return!me||P(me)?"[^".concat(y2i(o),"]+?"):"(?:(?!".concat(y2i(me),")[^").concat(y2i(o),"])+?")};u<r.length;){var I=l("CHAR"),T=l("NAME"),z=l("PATTERN");if(T||z){var U=I||"";i.indexOf(U)===-1&&(s+=U,U=""),s&&(c.push(s),s=""),c.push({name:T||f++,prefix:U,suffix:"",pattern:z||C(U),modifier:l("MODIFIER")||""});continue}var q=I||l("ESCAPED_CHAR");if(q){s+=q;continue}s&&(c.push(s),s="");var V=l("OPEN");if(V){var U=O(),$=l("NAME")||"",re=l("PATTERN")||"",Y=O();m("CLOSE"),c.push({name:$||(re?f++:""),pattern:$&&!re?C(U):re,prefix:U,suffix:Y,modifier:l("MODIFIER")||""});continue}m("END")}return c}function _Nv(e,t){return edM(pNv(e,t),t)}function edM(e,t){t===void 0&&(t={});var r=NHf(t),n=t.encode,i=n===void 0?function(f){return f}:n,a=t.validate,o=a===void 0?!0:a,c=e.map(function(f){if(typeof f=="object")return new RegExp("^(?:".concat(f.pattern,")$"),r)});return function(f){for(var u="",s=0;s<e.length;s++){var l=e[s];if(typeof l=="string"){u+=l;continue}var m=f?f[l.name]:void 0,O=l.modifier==="?"||l.modifier==="*",P=l.modifier==="*"||l.modifier==="+";if(Array.isArray(m)){if(!P)throw new TypeError('Expected "'.concat(l.name,'" to not repeat, but got an array'));if(m.length===0){if(O)continue;throw new TypeError('Expected "'.concat(l.name,'" to not be empty'))}for(var C=0;C<m.length;C++){var I=i(m[C],l);if(o&&!c[s].test(I))throw new TypeError('Expected all "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(I,'"'));u+=l.prefix+I+l.suffix}continue}if(typeof m=="string"||typeof m=="number"){var I=i(String(m),l);if(o&&!c[s].test(I))throw new TypeError('Expected "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(I,'"'));u+=l.prefix+I+l.suffix;continue}if(!O){var T=P?"an array":"a string";throw new TypeError('Expected "'.concat(l.name,'" to be ').concat(T))}}return u}}function hNv(e,t){var r=[],n=yNv(e,r,t);return tdM(n,r,t)}function tdM(e,t,r){r===void 0&&(r={});var n=r.decode,i=n===void 0?function(a){return a}:n;return function(a){var o=e.exec(a);if(!o)return!1;for(var c=o[0],f=o.index,u=Object.create(null),s=function(m){if(o[m]===void 0)return"continue";var O=t[m-1];O.modifier==="*"||O.modifier==="+"?u[O.name]=o[m].split(O.prefix+O.suffix).map(function(P){return i(P,O)}):u[O.name]=i(o[m],O)},l=1;l<o.length;l++)s(l);return{path:c,index:f,params:u}}}function y2i(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function NHf(e){return e&&e.sensitive?"":"i"}function rdM(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,i=r.exec(e.source);i;)t.push({name:i[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),i=r.exec(e.source);return e}function ndM(e,t,r){var n=e.map(function(i){return yNv(i,t,r).source});return new RegExp("(?:".concat(n.join("|"),")"),NHf(r))}function idM(e,t,r){return adM(pNv(e,r),t,r)}function adM(e,t,r){r===void 0&&(r={});for(var n=r.strict,i=n===void 0?!1:n,a=r.start,o=a===void 0?!0:a,c=r.end,f=c===void 0?!0:c,u=r.encode,s=u===void 0?function(ne){return ne}:u,l=r.delimiter,m=l===void 0?"/#?":l,O=r.endsWith,P=O===void 0?"":O,C="[".concat(y2i(P),"]|$"),I="[".concat(y2i(m),"]"),T=o?"^":"",z=0,U=e;z<U.length;z++){var q=U[z];if(typeof q=="string")T+=y2i(s(q));else{var V=y2i(s(q.prefix)),$=y2i(s(q.suffix));if(q.pattern)if(t&&t.push(q),V||$)if(q.modifier==="+"||q.modifier==="*"){var re=q.modifier==="*"?"?":"";T+="(?:".concat(V,"((?:").concat(q.pattern,")(?:").concat($).concat(V,"(?:").concat(q.pattern,"))*)").concat($,")").concat(re)}else T+="(?:".concat(V,"(").concat(q.pattern,")").concat($,")").concat(q.modifier);else{if(q.modifier==="+"||q.modifier==="*")throw new TypeError('Can not repeat "'.concat(q.name,'" without a prefix and suffix'));T+="(".concat(q.pattern,")").concat(q.modifier)}else T+="(?:".concat(V).concat($,")").concat(q.modifier)}}if(f)i||(T+="".concat(I,"?")),T+=r.endsWith?"(?=".concat(C,")"):"$";else{var Y=e[e.length-1],k=typeof Y=="string"?I.indexOf(Y[Y.length-1])>-1:Y===void 0;i||(T+="(?:".concat(I,"(?=").concat(C,"))?")),k||(T+="(?=".concat(I,"|").concat(C,")"))}return new RegExp(T,NHf(r))}function yNv(e,t,r){return e instanceof RegExp?rdM(e,t):Array.isArray(e)?ndM(e,t,r):idM(e,t,r)}var mNv=$i(CE(),1);function vNv(e){return e.split(/[?#]/)[0]??""}function Hda(e){return e.startsWith("/")?e.slice(1):e}function FHf(e){return e.startsWith("/")?e:`/${e}`}function xGu(e){return e.endsWith("/")?e.slice(0,-1):e}function bNv(e){let t=[];return e.config.instances.forEach(r=>{t.push(r.url),typeof r.customDomain=="string"?t.push(r.customDomain):Array.isArray(r.customDomain)&&t.push(...r.customDomain)}),t}function gNv(e){let t=new URL(Qse(e));return{domain:t.host,basePath:t.pathname==="/"||t.pathname===""?void 0:t.pathname}}function odM(e,t){if(e===t)return{params:{},path:t,index:0};try{return hNv(e)(t)}catch(r){return console.error(r,{pattern:e,path:t}),!1}}function sdM(e,t){try{return _Nv(e)(t.params)}catch(r){return console.error(r,{match:t,destination:e}),e}}function ONv(e,t,r=[]){for(let n of r){let i=xGu(udM(n.source,t.basePath)),a=odM(i,e);if(a){let o=sdM(n.destination,a);if(!o.startsWith("/"))try{new URL(o)}catch{console.error("Invalid redirect destination:",o);return}return{redirect:{destination:encodeURI(o),permanent:n.permanent??!1}}}}}function udM(e,t){return t==null||e.startsWith(t)?e:(0,mNv.default)(t,e)}async function QHf({pathname:e,markdown:t,absoluteFilepath:r,workspaceAbsoluteFilePath:n,pageSlugs:i,absoluteFilePathsToSlugs:a,redirects:o=[],baseUrl:c}){e=xGu(e);let f=r!=null?a.get(r)??[]:[];if(e.trim()==="")return!0;if(e=zHf(e),e.startsWith("/")){let s=zHf(xHf(e,c,o));for(let m=0;m<5;++m){let O=zHf(xHf(s,c,o));if(s===O)break;s=O}if(t&&i.has(Hda(s)))return!0;let l=Ql(n,ru.of(Hda(e)));return await Vv(l,"file")?!0:f.map(m=>FHf(m))}if(r!=null){if(e==="."){let l=Tg(r);if(await Vv(l,"directory"))return!0}let s=Ql(Tg(r),ru.of(e));if(await Vv(s,"file"))return!0}if(!t)return f.map(s=>FHf(s));let u=[];for(let s of f){let l=new URL(`/${s}`,Qse(c.domain)),m=xHf(new URL(e,l).pathname,c,o);i.has(Hda(m))||u.push(s)}return u.length>0?u:!0}function xHf(e,t,r){let n=ONv(e,t,r);return n==null?e:n.redirect.destination}function zHf(e){let t=e.indexOf("#");return t===-1?e:e.substring(0,t)}var ANv=require("fs");var cdM=["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"];function ldM({readFile:e=r=>(0,ANv.readFileSync)(r,"utf-8"),...t}){let r=new Set,n=[t],i=[],a=[],o=1e3,c=0;do{if(c++,c>o)throw new Error("Infinite loop detected while collecting links and sources");let f=n.shift();if(f==null)break;let{content:u,absoluteFilepath:s}=f;if(s!=null){if(r.has(s))throw new Error(`Circular import detected: ${s}`);r.add(s)}let l=N8i(u),m=tso(l,{allowDangerousHtml:!0,passThrough:[...cdM]});Wv(m,O=>{if(O.type==="mdxjsEsm"&&s!=null)return O.data?.estree&&uie(O.data.estree,{enter:C=>{if(C.type==="ImportDeclaration"&&C.source.type==="Literal"&&typeof C.source.value=="string"){let I=ru.of(C.source.value),T=p1(Tg(s),I);(T.endsWith(".mdx")||T.endsWith(".md"))&&n.push({content:e(T),absoluteFilepath:T})}}}),"skip";if(O.type==="element"){let C=O.properties.href;typeof C=="string"&&i.push({href:C,sourceFilepath:s,position:O.position});let I=O.properties.src;typeof I=="string"&&a.push({src:I,sourceFilepath:s,position:O.position})}function P(C,I){Yao(C,{src:T=>{let z=Pwi(T.value);typeof z=="string"&&a.push({src:z,sourceFilepath:s,position:I})},href:T=>{let z=Pwi(T.value);typeof z=="string"&&i.push({href:z,sourceFilepath:s,position:I})}})}if(O.type==="mdxJsxFlowElement"||O.type==="mdxJsxTextElement"){let C=C8i(O.attributes.filter(wwi).find(T=>T.name==="href")?.value),I=C8i(O.attributes.filter(wwi).find(T=>T.name==="src")?.value);if(O.name==="Markdown"){if(s&&typeof I=="string"){let T=p1(Tg(s),I);n.push({content:e(T),absoluteFilepath:T})}return"skip"}typeof C=="string"&&i.push({href:C,sourceFilepath:s,position:O.position}),typeof I=="string"&&a.push({src:I,sourceFilepath:s,position:O.position}),O.attributes.forEach(T=>{T.type==="mdxJsxAttribute"&&typeof T.value!="string"&&T.value!=null&&T.value.data?.estree?P(T.value.data.estree,T.position):T.type==="mdxJsxExpressionAttribute"&&T.data?.estree&&P(T.data.estree,T.position)})}(O.type==="mdxFlowExpression"||O.type==="mdxTextExpression")&&O.data?.estree&&P(O.data.estree,O.position)})}while(n.length>0);return{links:i,sources:a}}function PNv({content:e,absoluteFilepath:t}){try{return ldM({content:e,absoluteFilepath:t})}catch{return{links:[],sources:[]}}}var wNv=/^(?:[a-z+]+:)/gi;function fdM(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);return r?(r[0].match(/\n/g)||[]).length+1:0}function LHf(e,t){return e&&{...e,start:{...e.start,line:e.start.line+t},end:{...e.end,line:e.end.line+t}}}function UHf(e,{absoluteFilepath:t,instanceUrls:r}){let n=[],i=[],a=fdM(e),{links:o,sources:c}=PNv({content:e,absoluteFilepath:t});return o.forEach(f=>{if(f.href.trimStart().match(wNv)){if(!f.href.trimStart().startsWith("http"))return;try{let s=new URL(f.href);if(!r.some(l=>f.href.includes(l)))return;i.push({pathname:s.pathname,sourceFilepath:f.sourceFilepath,position:LHf(f.position,a),markdown:!0})}catch{n.push({severity:"warning",message:`Invalid URL: ${f.href}`})}return}let u=vNv(f.href);u.trim()!==""&&i.push({pathname:u,sourceFilepath:f.sourceFilepath,position:LHf(f.position,a),markdown:!0})}),c.forEach(f=>{if(f.src.match(wNv))try{new URL(f.src)}catch{n.push({severity:"warning",message:`Invalid URL: ${f.src}`});return}else i.push({pathname:f.src,sourceFilepath:f.sourceFilepath,position:LHf(f.position,a),markdown:!1})}),{pathnamesToCheck:i,violations:n}}var qis=VZl({logger:G2r(Tc)}),v2i={name:"valid-markdown-links",create:async({workspace:e,apiWorkspaces:t,ossWorkspaces:r})=>{let n=bNv(e),i=n[0]??"http://localhost",a=gNv(n[0]??"http://localhost"),c=await new Hqr({domain:i,docsWorkspace:e,ossWorkspaces:r,apiWorkspaces:t,taskContext:qis,editThisPage:void 0,uploadFiles:void 0,registerApi:void 0,targetAudiences:void 0}).resolve();if(!c.config.root)throw new Error("Root node not found");let f=fl.migrate.FernNavigationV1ToLatest.create().root(c.config.root),u=fl.NodeCollector.collect(f),s=new Set,l=new Map,m=[];u.slugMap.forEach((P,C)=>{if(s.add(C),P==null||!fl.isPage(P))return;fl.isApiLeaf(P)&&m.push(P);let I=fl.getPageId(P);if(I==null)return;let T=Ql(e.absoluteFilePath,ru.of(I)),z=l.get(T)??[];z.push(C),l.set(T,z)});let O=["/llms-full.txt","/llms.txt"];for(let P of O){let C=a.basePath?`${Hda(a.basePath)}${P}`:Hda(P);s.add(C)}return{markdownPage:async({content:P,absoluteFilepath:C})=>{let I=l.get(C);if(!I||I.length===0)return[];let{pathnamesToCheck:T,violations:z}=UHf(P,{absoluteFilepath:C,instanceUrls:n}),U=await Promise.all(T.map(async q=>{let V=await QHf({pathname:q.pathname,markdown:q.markdown,absoluteFilepath:C,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:s,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return V===!0?[]:V.map($=>{let[re,Y]=jNv({pathnameToCheck:q,targetPathname:$,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:v2i.name,severity:"error",message:re,relativeFilepath:Y}})}));return[...z,...U.flat()]},apiSection:async({workspace:P,config:C})=>{let I=await P.toFernWorkspace({context:qis},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1}),T=xG({workspace:I,audiences:C.audiences?{type:"select",audiences:Array.isArray(C.audiences)?C.audiences:[C.audiences]}:{type:"all"},generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1},readme:void 0,version:void 0,packageName:void 0,context:qis,sourceResolver:new FGu(qis,I)}),z=ddM(bns({ir:T,apiDefinitionId:(0,ENv.randomUUID)(),context:qis})),U=[];for(let q of m){let V=await pdM(FJa.prune(z,q));for(let $ of V){let{pathnamesToCheck:re,violations:Y}=UHf($,{instanceUrls:n});U.push(...Y);let k=await Promise.all(re.map(async ne=>{let me=await QHf({pathname:ne.pathname,markdown:ne.markdown,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:s,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return me===!0?[]:me.map(_e=>{let[ve,pe]=jNv({pathnameToCheck:ne,targetPathname:_e,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:v2i.name,severity:"error",message:ve,relFilepath:pe}})}));U.push(...k.flat())}}return U}}}};function jNv({pathnameToCheck:e,targetPathname:t,absoluteFilepathToWorkspace:r}){let n=`${t} links to non-existent page ${Mf.bold(e.pathname)}`,{position:i,sourceFilepath:a}=e;if(a==null||i==null)return[n,ru.of("")];n=`broken link to ${Mf.bold(e.pathname)}`,e.pathname.length>0&&!VHf.default.isAbsolute(e.pathname)&&(n+=` (resolved path: ${VHf.default.join(t,e.pathname)})`);let o=A3(r,a);return n+=`
3087
+ `)}`})}catch(i){return n.trace(`Markdown parse failed with error: ${i instanceof Error?i.message:String(i)}`),{type:"failure",message:i instanceof Error?i.message:void 0}}}var cNv=require("fs/promises"),lNv=$i(Art(),1);var fNv={name:"valid-markdown-file-references",create:e=>({filepath:async({absoluteFilepath:t})=>{if(!t.endsWith(".md")&&!t.endsWith(".mdx"))return[];try{let r=await(0,cNv.readFile)(t,"utf-8"),{content:n}=(0,lNv.default)(r,{}),i=N8i(n),a=[];return Wv(i,o=>{if(o.type==="link"){let c=b9u({href:Int(o.url),metadata:{absolutePathToFernFolder:t,absolutePathToMarkdownFile:t},markdownFilesToPathName:{}});if(c?.type==="missing-reference")try{let f=hBr(F_.of(c.path));a.push({severity:"error",message:f?`File ${c.href} does not exit`:`File ${c.href} exists but is not specified in docs.yml`})}catch{}}}),a}catch{return[]}}})};var ENv=require("crypto"),VHf=$i(require("path"),1);var dNv=require("fs"),NGu=class{parse({absoluteFilePath:t}){let r=(0,dNv.readFileSync)(t,"utf-8"),n=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),i=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:n?.[1],packageName:i?.[1],serviceName:a?.[1]}}};var FGu=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let n=this.resolveSource({source:t});return n==null&&(jLr(t)?this.context.logger.warn(`Cannot resolve source ${t.proto} from file ${r}`):this.context.logger.warn(`Cannot resolve source ${t.openapi} from file ${r}`)),n}resolveSource({source:t}){return jLr(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let i=new NGu().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ru.of(t.proto),csharpNamespace:i.csharpNamespace,packageName:i.packageName,serviceName:i.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Ql(this.workspace.absoluteFilePath,ru.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!hBr(r))return;let n={type:"openapi",absoluteFilePath:r,relativeFilePath:ru.of(t.openapi)};return this.sourceCache.set(r,n),n}};function kfM(e){for(var t=[],r=0;r<e.length;){var n=e[r];if(n==="*"||n==="+"||n==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(n==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(n==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(n==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(n===":"){for(var i="",a=r+1;a<e.length;){var o=e.charCodeAt(a);if(o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122||o===95){i+=e[a++];continue}break}if(!i)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:i}),r=a;continue}if(n==="("){var c=1,f="",a=r+1;if(e[a]==="?")throw new TypeError('Pattern cannot start with "?" at '.concat(a));for(;a<e.length;){if(e[a]==="\\"){f+=e[a++]+e[a++];continue}if(e[a]===")"){if(c--,c===0){a++;break}}else if(e[a]==="("&&(c++,e[a+1]!=="?"))throw new TypeError("Capturing groups are not allowed at ".concat(a));f+=e[a++]}if(c)throw new TypeError("Unbalanced pattern at ".concat(r));if(!f)throw new TypeError("Missing pattern at ".concat(r));t.push({type:"PATTERN",index:r,value:f}),r=a;continue}t.push({type:"CHAR",index:r,value:e[r++]})}return t.push({type:"END",index:r,value:""}),t}function pNv(e,t){t===void 0&&(t={});for(var r=kfM(e),n=t.prefixes,i=n===void 0?"./":n,a=t.delimiter,o=a===void 0?"/#?":a,c=[],f=0,u=0,s="",l=function(k){if(u<r.length&&r[u].type===k)return r[u++].value},m=function(k){var ne=l(k);if(ne!==void 0)return ne;var me=r[u],_e=me.type,ve=me.index;throw new TypeError("Unexpected ".concat(_e," at ").concat(ve,", expected ").concat(k))},O=function(){for(var k="",ne;ne=l("CHAR")||l("ESCAPED_CHAR");)k+=ne;return k},P=function(k){for(var ne=0,me=o;ne<me.length;ne++){var _e=me[ne];if(k.indexOf(_e)>-1)return!0}return!1},C=function(k){var ne=c[c.length-1],me=k||(ne&&typeof ne=="string"?ne:"");if(ne&&!me)throw new TypeError('Must have text between two parameters, missing text after "'.concat(ne.name,'"'));return!me||P(me)?"[^".concat(y2i(o),"]+?"):"(?:(?!".concat(y2i(me),")[^").concat(y2i(o),"])+?")};u<r.length;){var I=l("CHAR"),T=l("NAME"),z=l("PATTERN");if(T||z){var U=I||"";i.indexOf(U)===-1&&(s+=U,U=""),s&&(c.push(s),s=""),c.push({name:T||f++,prefix:U,suffix:"",pattern:z||C(U),modifier:l("MODIFIER")||""});continue}var q=I||l("ESCAPED_CHAR");if(q){s+=q;continue}s&&(c.push(s),s="");var V=l("OPEN");if(V){var U=O(),$=l("NAME")||"",re=l("PATTERN")||"",Y=O();m("CLOSE"),c.push({name:$||(re?f++:""),pattern:$&&!re?C(U):re,prefix:U,suffix:Y,modifier:l("MODIFIER")||""});continue}m("END")}return c}function _Nv(e,t){return edM(pNv(e,t),t)}function edM(e,t){t===void 0&&(t={});var r=NHf(t),n=t.encode,i=n===void 0?function(f){return f}:n,a=t.validate,o=a===void 0?!0:a,c=e.map(function(f){if(typeof f=="object")return new RegExp("^(?:".concat(f.pattern,")$"),r)});return function(f){for(var u="",s=0;s<e.length;s++){var l=e[s];if(typeof l=="string"){u+=l;continue}var m=f?f[l.name]:void 0,O=l.modifier==="?"||l.modifier==="*",P=l.modifier==="*"||l.modifier==="+";if(Array.isArray(m)){if(!P)throw new TypeError('Expected "'.concat(l.name,'" to not repeat, but got an array'));if(m.length===0){if(O)continue;throw new TypeError('Expected "'.concat(l.name,'" to not be empty'))}for(var C=0;C<m.length;C++){var I=i(m[C],l);if(o&&!c[s].test(I))throw new TypeError('Expected all "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(I,'"'));u+=l.prefix+I+l.suffix}continue}if(typeof m=="string"||typeof m=="number"){var I=i(String(m),l);if(o&&!c[s].test(I))throw new TypeError('Expected "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(I,'"'));u+=l.prefix+I+l.suffix;continue}if(!O){var T=P?"an array":"a string";throw new TypeError('Expected "'.concat(l.name,'" to be ').concat(T))}}return u}}function hNv(e,t){var r=[],n=yNv(e,r,t);return tdM(n,r,t)}function tdM(e,t,r){r===void 0&&(r={});var n=r.decode,i=n===void 0?function(a){return a}:n;return function(a){var o=e.exec(a);if(!o)return!1;for(var c=o[0],f=o.index,u=Object.create(null),s=function(m){if(o[m]===void 0)return"continue";var O=t[m-1];O.modifier==="*"||O.modifier==="+"?u[O.name]=o[m].split(O.prefix+O.suffix).map(function(P){return i(P,O)}):u[O.name]=i(o[m],O)},l=1;l<o.length;l++)s(l);return{path:c,index:f,params:u}}}function y2i(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function NHf(e){return e&&e.sensitive?"":"i"}function rdM(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,i=r.exec(e.source);i;)t.push({name:i[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),i=r.exec(e.source);return e}function ndM(e,t,r){var n=e.map(function(i){return yNv(i,t,r).source});return new RegExp("(?:".concat(n.join("|"),")"),NHf(r))}function idM(e,t,r){return adM(pNv(e,r),t,r)}function adM(e,t,r){r===void 0&&(r={});for(var n=r.strict,i=n===void 0?!1:n,a=r.start,o=a===void 0?!0:a,c=r.end,f=c===void 0?!0:c,u=r.encode,s=u===void 0?function(ne){return ne}:u,l=r.delimiter,m=l===void 0?"/#?":l,O=r.endsWith,P=O===void 0?"":O,C="[".concat(y2i(P),"]|$"),I="[".concat(y2i(m),"]"),T=o?"^":"",z=0,U=e;z<U.length;z++){var q=U[z];if(typeof q=="string")T+=y2i(s(q));else{var V=y2i(s(q.prefix)),$=y2i(s(q.suffix));if(q.pattern)if(t&&t.push(q),V||$)if(q.modifier==="+"||q.modifier==="*"){var re=q.modifier==="*"?"?":"";T+="(?:".concat(V,"((?:").concat(q.pattern,")(?:").concat($).concat(V,"(?:").concat(q.pattern,"))*)").concat($,")").concat(re)}else T+="(?:".concat(V,"(").concat(q.pattern,")").concat($,")").concat(q.modifier);else{if(q.modifier==="+"||q.modifier==="*")throw new TypeError('Can not repeat "'.concat(q.name,'" without a prefix and suffix'));T+="(".concat(q.pattern,")").concat(q.modifier)}else T+="(?:".concat(V).concat($,")").concat(q.modifier)}}if(f)i||(T+="".concat(I,"?")),T+=r.endsWith?"(?=".concat(C,")"):"$";else{var Y=e[e.length-1],k=typeof Y=="string"?I.indexOf(Y[Y.length-1])>-1:Y===void 0;i||(T+="(?:".concat(I,"(?=").concat(C,"))?")),k||(T+="(?=".concat(I,"|").concat(C,")"))}return new RegExp(T,NHf(r))}function yNv(e,t,r){return e instanceof RegExp?rdM(e,t):Array.isArray(e)?ndM(e,t,r):idM(e,t,r)}var mNv=$i(CE(),1);function vNv(e){return e.split(/[?#]/)[0]??""}function Hda(e){return e.startsWith("/")?e.slice(1):e}function FHf(e){return e.startsWith("/")?e:`/${e}`}function xGu(e){return e.endsWith("/")?e.slice(0,-1):e}function bNv(e){let t=[];return e.config.instances.forEach(r=>{t.push(r.url),typeof r.customDomain=="string"?t.push(r.customDomain):Array.isArray(r.customDomain)&&t.push(...r.customDomain)}),t}function gNv(e){let t=new URL(Qse(e));return{domain:t.host,basePath:t.pathname==="/"||t.pathname===""?void 0:t.pathname}}function odM(e,t){if(e===t)return{params:{},path:t,index:0};try{return hNv(e)(t)}catch(r){return console.error(r,{pattern:e,path:t}),!1}}function sdM(e,t){try{return _Nv(e)(t.params)}catch(r){return console.error(r,{match:t,destination:e}),e}}function ONv(e,t,r=[]){for(let n of r){let i=xGu(udM(n.source,t.basePath)),a=odM(i,e);if(a){let o=sdM(n.destination,a);if(!o.startsWith("/"))try{new URL(o)}catch{console.error("Invalid redirect destination:",o);return}return{redirect:{destination:encodeURI(o),permanent:n.permanent??!1}}}}}function udM(e,t){return t==null||e.startsWith(t)?e:(0,mNv.default)(t,e)}async function QHf({pathname:e,markdown:t,absoluteFilepath:r,workspaceAbsoluteFilePath:n,pageSlugs:i,absoluteFilePathsToSlugs:a,redirects:o=[],baseUrl:c}){e=xGu(e);let f=r!=null?a.get(r)??[]:[];if(e.trim()==="")return!0;if(e=zHf(e),e.startsWith("/")){let s=zHf(xHf(e,c,o));for(let m=0;m<5;++m){let O=zHf(xHf(s,c,o));if(s===O)break;s=O}if(t&&i.has(Hda(s)))return!0;let l=Ql(n,ru.of(Hda(e)));return await Vv(l,"file")?!0:f.map(m=>FHf(m))}if(r!=null){if(e==="."){let l=Tg(r);if(await Vv(l,"directory"))return!0}let s=Ql(Tg(r),ru.of(e));if(await Vv(s,"file"))return!0}if(!t)return f.map(s=>FHf(s));let u=[];for(let s of f){let l=new URL(`/${s}`,Qse(c.domain)),m=xHf(new URL(e,l).pathname,c,o);i.has(Hda(m))||u.push(s)}return u.length>0?u:!0}function xHf(e,t,r){let n=ONv(e,t,r);return n==null?e:n.redirect.destination}function zHf(e){let t=e.indexOf("#");return t===-1?e:e.substring(0,t)}var ANv=require("fs");var cdM=["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"];function ldM({readFile:e=r=>(0,ANv.readFileSync)(r,"utf-8"),...t}){let r=new Set,n=[t],i=[],a=[],o=1e3,c=0;do{if(c++,c>o)throw new Error("Infinite loop detected while collecting links and sources");let f=n.shift();if(f==null)break;let{content:u,absoluteFilepath:s}=f;if(s!=null){if(r.has(s))throw new Error(`Circular import detected: ${s}`);r.add(s)}let l=N8i(u),m=tso(l,{allowDangerousHtml:!0,passThrough:[...cdM]});Wv(m,O=>{if(O.type==="mdxjsEsm"&&s!=null)return O.data?.estree&&uie(O.data.estree,{enter:C=>{if(C.type==="ImportDeclaration"&&C.source.type==="Literal"&&typeof C.source.value=="string"){let I=ru.of(C.source.value),T=p1(Tg(s),I);(T.endsWith(".mdx")||T.endsWith(".md"))&&n.push({content:e(T),absoluteFilepath:T})}}}),"skip";if(O.type==="element"){let C=O.properties.href;typeof C=="string"&&i.push({href:C,sourceFilepath:s,position:O.position});let I=O.properties.src;typeof I=="string"&&a.push({src:I,sourceFilepath:s,position:O.position})}function P(C,I){Yao(C,{src:T=>{let z=Pwi(T.value);typeof z=="string"&&a.push({src:z,sourceFilepath:s,position:I})},href:T=>{let z=Pwi(T.value);typeof z=="string"&&i.push({href:z,sourceFilepath:s,position:I})}})}if(O.type==="mdxJsxFlowElement"||O.type==="mdxJsxTextElement"){let C=C8i(O.attributes.filter(wwi).find(T=>T.name==="href")?.value),I=C8i(O.attributes.filter(wwi).find(T=>T.name==="src")?.value);if(O.name==="Markdown"){if(s&&typeof I=="string"){let T=p1(Tg(s),I);n.push({content:e(T),absoluteFilepath:T})}return"skip"}typeof C=="string"&&i.push({href:C,sourceFilepath:s,position:O.position}),typeof I=="string"&&a.push({src:I,sourceFilepath:s,position:O.position}),O.attributes.forEach(T=>{T.type==="mdxJsxAttribute"&&typeof T.value!="string"&&T.value!=null&&T.value.data?.estree?P(T.value.data.estree,T.position):T.type==="mdxJsxExpressionAttribute"&&T.data?.estree&&P(T.data.estree,T.position)})}(O.type==="mdxFlowExpression"||O.type==="mdxTextExpression")&&O.data?.estree&&P(O.data.estree,O.position)})}while(n.length>0);return{links:i,sources:a}}function PNv({content:e,absoluteFilepath:t}){try{return ldM({content:e,absoluteFilepath:t})}catch{return{links:[],sources:[]}}}var wNv=/^(?:[a-z+]+:)/gi;function fdM(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);return r?(r[0].match(/\n/g)||[]).length+1:0}function LHf(e,t){return e&&{...e,start:{...e.start,line:e.start.line+t},end:{...e.end,line:e.end.line+t}}}function UHf(e,{absoluteFilepath:t,instanceUrls:r}){let n=[],i=[],a=fdM(e),{links:o,sources:c}=PNv({content:e,absoluteFilepath:t});return o.forEach(f=>{if(f.href.trimStart().match(wNv)){if(!f.href.trimStart().startsWith("http"))return;try{let s=new URL(f.href);if(!r.some(l=>f.href.includes(l)))return;i.push({pathname:s.pathname,sourceFilepath:f.sourceFilepath,position:LHf(f.position,a),markdown:!0})}catch{n.push({severity:"warning",message:`Invalid URL: ${f.href}`})}return}let u=vNv(f.href);u.trim()!==""&&i.push({pathname:u,sourceFilepath:f.sourceFilepath,position:LHf(f.position,a),markdown:!0})}),c.forEach(f=>{if(f.src.match(wNv))try{new URL(f.src)}catch{n.push({severity:"warning",message:`Invalid URL: ${f.src}`});return}else i.push({pathname:f.src,sourceFilepath:f.sourceFilepath,position:LHf(f.position,a),markdown:!1})}),{pathnamesToCheck:i,violations:n}}var qis=VZl({logger:G2r(Tc)}),v2i={name:"valid-markdown-links",create:async({workspace:e,apiWorkspaces:t,ossWorkspaces:r})=>{let n=bNv(e),i=n[0]??"http://localhost",a=gNv(n[0]??"http://localhost"),c=await new Hqr({domain:i,docsWorkspace:e,ossWorkspaces:r,apiWorkspaces:t,taskContext:qis,editThisPage:void 0,uploadFiles:void 0,registerApi:void 0,targetAudiences:void 0}).resolve();if(!c.config.root)throw new Error("Root node not found");let f=fl.migrate.FernNavigationV1ToLatest.create().root(c.config.root),u=fl.NodeCollector.collect(f),s=new Set,l=new Map,m=[];u.slugMap.forEach((P,C)=>{if(s.add(C),P==null||!fl.isPage(P))return;fl.isApiLeaf(P)&&m.push(P);let I=fl.getPageId(P);if(I==null)return;let T=Ql(e.absoluteFilePath,ru.of(I)),z=l.get(T)??[];z.push(C),l.set(T,z)});let O=["/llms-full.txt","/llms.txt"];for(let P of O){let C=a.basePath?`${Hda(a.basePath)}${P}`:Hda(P);s.add(C)}return{markdownPage:async({content:P,absoluteFilepath:C})=>{let I=l.get(C);if(!I||I.length===0)return[];let{pathnamesToCheck:T,violations:z}=UHf(P,{absoluteFilepath:C,instanceUrls:n}),U=await Promise.all(T.map(async q=>{let V=await QHf({pathname:q.pathname,markdown:q.markdown,absoluteFilepath:C,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:s,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return V===!0?[]:V.map($=>{let[re,Y]=jNv({pathnameToCheck:q,targetPathname:$,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:v2i.name,severity:"error",message:re,relativeFilepath:Y}})}));return[...z,...U.flat()]},apiSection:async({workspace:P,config:C})=>{let I=await P.toFernWorkspace({context:qis},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1}),T=xG({workspace:I,audiences:C.audiences?{type:"select",audiences:Array.isArray(C.audiences)?C.audiences:[C.audiences]}:{type:"all"},generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1},readme:void 0,version:void 0,packageName:void 0,context:qis,sourceResolver:new FGu(qis,I)}),z=ddM(bns({ir:T,apiDefinitionId:(0,ENv.randomUUID)(),context:qis})),U=[];for(let q of m){let V=await pdM(FJa.prune(z,q));for(let $ of V){let{pathnamesToCheck:re,violations:Y}=UHf($,{instanceUrls:n});U.push(...Y);let k=await Promise.all(re.map(async ne=>{let me=await QHf({pathname:ne.pathname,markdown:ne.markdown,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:s,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return me===!0?[]:me.map(_e=>{let[ve,pe]=jNv({pathnameToCheck:ne,targetPathname:_e,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:v2i.name,severity:"error",message:ve,relFilepath:pe}})}));U.push(...k.flat())}}return U}}}};function jNv({pathnameToCheck:e,targetPathname:t,absoluteFilepathToWorkspace:r}){let n=`${t} links to non-existent page ${Mf.bold(e.pathname)}`,{position:i,sourceFilepath:a}=e;if(a==null||i==null)return[n,ru.of("")];n=`broken link to ${Mf.bold(e.pathname)}`,e.pathname.length>0&&!VHf.default.isAbsolute(e.pathname)&&(n+=` (resolved path: ${VHf.default.join(t,e.pathname)})`);let o=A3(r,a);return n+=`
3088
3088
  fix here: ${o}:${i.start.line}:${i.start.column}`,[n,o]}function ddM(e){return FJa.ApiDefinitionV1ToLatest.from(e).migrate()}async function pdM(e){let t=[];return FJa.Transformer.descriptions(r=>(typeof r=="string"&&t.push(r),r)).apiDefinition(e),t}var zGu={name:"validate-product-file",create:()=>({productFile:async({path:e,content:t})=>{let r=await oGu({value:t});return r.type==="success"?[]:[{severity:"fatal",message:`${r.message}`}]}})};var QGu={name:"validate-version-file",create:()=>({versionFile:async({path:e,content:t})=>{let r=await aGu({value:t});return r.type==="success"?[]:[{severity:"fatal",message:`${r.message}`}]}})};function SNv({relativeFilepath:e,allRuleVisitors:t,addViolations:r}){function n(i){let a=async(o,c)=>{for(let f of t){let u=f[i];if(u!=null){let s=await u(o);r(s.map(l=>({name:l.name,severity:l.severity,relativeFilepath:l.relativeFilepath??ru.of(""),nodePath:c,message:l.message})))}}};return{[i]:a}}return{...n("file"),...n("filepath"),...n("markdownPage"),...n("versionFile"),...n("apiSection"),...n("permissions"),...n("productFile")}}var DNv=require("fs/promises"),WHf={name:"no-non-component-refs",create:({ossWorkspaces:e,logger:t,workspace:r})=>({file:async()=>{let n=[],i=new Set;for(let a of e)for(let o of a.specs)if(o.type==="openapi"&&!i.has(o.absoluteFilepath)){i.add(o.absoluteFilepath);try{let c=(await(0,DNv.readFile)(o.absoluteFilepath)).toString(),f=A3(r.absoluteFilePath,o.absoluteFilepath);if(c.includes("swagger:")&&(c.includes('swagger: "2.0"')||c.includes("swagger: '2.0'")||c.includes("swagger: 2.0")))continue;let s=c.matchAll(/["']?\$ref["']?\s*:\s*["']([^"']+)["']/g);for(let l of s){let m=l[1];m&&m.startsWith("#/")&&!m.startsWith("#/components/")&&n.push({severity:"error",name:"Invalid OpenAPI reference",message:`Reference "${m}" points to a non-component location. OpenAPI references should point to reusable components under #/components/ (e.g., #/components/schemas/MySchema, #/components/responses/MyResponse). Direct references to paths, operations, or other spec sections are not supported.`,relativeFilepath:f})}}catch{t.warn(`Could not read OpenAPI spec file: ${o.absoluteFilepath}`);continue}}return n}})};var CNv=require("fs/promises"),GHf={name:"no-openapi-v2-in-docs",create:({ossWorkspaces:e,logger:t,workspace:r})=>({file:async()=>{let n=[],i=new Set;for(let a of e)for(let o of a.specs)if(o.type==="openapi"&&!i.has(o.absoluteFilepath)){i.add(o.absoluteFilepath);try{let c=(await(0,CNv.readFile)(o.absoluteFilepath)).toString(),f=A3(r.absoluteFilePath,o.absoluteFilepath);c.includes("swagger:")&&(c.includes('swagger: "2.0"')||c.includes("swagger: '2.0'")||c.includes("swagger: 2.0"))&&n.push({severity:"error",name:"OpenAPI v2.0 not supported",message:"OpenAPI version 2.0 (Swagger) is not supported in docs generation. Please upgrade to OpenAPI 3.0 or later.",relativeFilepath:f})}catch{t.warn(`Could not read OpenAPI spec file: ${o.absoluteFilepath}`);continue}}return n}})};var INv=require("fs/promises");function _dM(e,t){let r=e.replace(/^#\//,"").split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~")),n=t;for(let i of r)if(n==null||typeof n!="object"||(n=n[i],n===void 0))return!1;return n!=null}function hdM(e){let t=new Map;for(let n of e){let i=n.replace(/^#\//,"").split("/"),a="Other";i.length>=2&&(i[0]==="components"?a=`components/${i[1]??"unknown"}`:a=i[0]??"unknown"),t.has(a)||t.set(a,[]);let o=t.get(a);o&&o.push(n)}let r=`Found ${e.length} invalid OpenAPI reference${e.length===1?"":"s"}:
3089
3089
 
3090
3090
  `;for(let[n,i]of t){r+=`${n}:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.115.1",
3
+ "version": "0.115.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",