fern-api 2.5.1 → 2.5.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.
- package/cli.cjs +4 -4
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1155,7 +1155,7 @@ ${tLp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&a7s(th
|
|
|
1155
1155
|
`+e6i.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?e6i.default.cyan(lLp(t,this.opt.mask)):e6i.default.italic(e6i.default.dim("[hidden]")):this.opt.mask?lLp(t,this.opt.mask):e6i.default.italic(e6i.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 NBo=ae(v1(),1);var l8p=ae(U7s(),1),RBo=require("child_process"),yRn=require("fs"),TBo=ae(require("path"),1),f8p=ae(require("os"),1),d8p=require("crypto"),jHs=ae(s8p(),1);var IBo=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var dOa=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var CBo=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var qBo=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function zBo(e="",t,r){let i=new wHs(e,r);i.runAsync((n,a)=>{if(n)setImmediate(t,n,void 0);else try{i.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function c8p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function CgS(e){let t=[],r="";for(let i=0;i<e.length;i++){let n=e.charAt(i);i>0&&n===" "&&e[i-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${n}`}return r.length>0&&t.push(r),t}var wHs=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=CgS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??f8p.default.tmpdir(),r=(0,d8p.randomUUID)(),i=c8p(this.fileOptions.prefix),n=c8p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=TBo.default.resolve(t,a),c=TBo.default.resolve(t)+TBo.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,yRn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new IBo(t)}}readTemporaryFile(){try{let t=(0,yRn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,l8p.detect)(t)??"utf8";jHs.default.encodingExists(r)||(r="utf8"),this.text=jHs.default.decode(t,r)}}catch(t){throw new CBo(t)}}removeTemporaryFile(){try{(0,yRn.unlinkSync)(this.tempFile)}catch(t){throw new qBo(t)}}launchEditor(){try{let t=(0,RBo.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new dOa(t)}}launchEditorAsync(t){try{(0,RBo.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new dOa(r)}}};var p8p=ae(ihe(),1);var pOa=class extends g1{_run(t){this.done=t,this.editorResult=new p8p.Subject;let r=FQ(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?NBo.default.dim("Received"):NBo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=NBo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),zBo(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 v8p=require("stream");var y8p=ae(require("readline"),1),b8p=ae(h8p(),1),n6i=class{constructor(t){this.rl||=y8p.default.createInterface(TgS(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 TgS(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new b8p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var _Oa=class extends n6i{constructor(t={}){super(t),this.log=new v8p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return Xga(this.rl,this.bottomBar.split(`
|
|
1156
1156
|
`).length),this}updateBottomBar(t){return Xga(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+`
|
|
1157
1157
|
`}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&&aBo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var dO=ae(ihe(),1),A8p=ae(vga(),1);var FBo=ae(ihe(),1),g8p=ae(vga(),1),QBo=function(e,t,r){return typeof e[t]!="function"?(0,FBo.of)(e):(0,FBo.from)((0,g8p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var O8p={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,o)=>{n==="__proto__"||n==="constructor"||(a===o.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},bRn=class extends n6i{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,dO.from)(t):(0,dO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,dO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,dO.from)([t]),this.process=i.pipe((0,dO.concatMap)(this.processQuestion.bind(this)),(0,dO.publish)()),this.process.connect(),this.process.pipe((0,dO.reduce)((n,a)=>(O8p.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,dO.defer)(()=>(0,dO.of)(t).pipe((0,dO.concatMap)(this.setDefaultType.bind(this)),(0,dO.concatMap)(this.filterIfRunnable.bind(this)),(0,dO.concatMap)(()=>QBo(t,"message",this.answers)),(0,dO.concatMap)(()=>QBo(t,"default",this.answers)),(0,dO.concatMap)(()=>QBo(t,"choices",this.answers)),(0,dO.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,dO.defer)(()=>(0,dO.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,dO.defer)(()=>(0,dO.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&O8p.get(this.answers,t.name)!==void 0)return dO.EMPTY;if(t.when===!1)return dO.EMPTY;if(typeof t.when!="function")return(0,dO.of)(t);let{answers:r}=this;return(0,dO.defer)(()=>(0,dO.from)((0,A8p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,dO.filter)(i=>i!=null)))}};function m8p(e){let t=function(r,i){let n;try{n=new bRn(t.prompts,e)}catch(o){return Promise.reject(o)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",kga),this.registerPrompt("input",kHi),this.registerPrompt("number",eOa),this.registerPrompt("confirm",tOa),this.registerPrompt("rawlist",rOa),this.registerPrompt("expand",iOa),this.registerPrompt("checkbox",nOa),this.registerPrompt("password",aOa),this.registerPrompt("editor",pOa)},t.restoreDefaultPrompts(),t}var SHs=m8p();function zgS(e,t){SHs.registerPrompt(e,t)}function NgS(){SHs.restoreDefaultPrompts()}var FgS={prompt:SHs,ui:{BottomBar:_Oa,Prompt:bRn},createPromptModule:m8p,registerPrompt:zgS,restoreDefaultPrompts:NgS,Separator:D6},UBo=FgS;var BRn=require("path"),t5p=require("fs"),r5p=require("readline"),EVp="posthog-node";function fmS(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[oIo.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(_=>({..._,stacktrace:_.stacktrace?{..._.stacktrace,type:"raw",frames:(_.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),p={$exception_message:u[0]?.value||a.message,$exception_type:u[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:u[0]?.value||a.message,$sentry_exception_type:u[0]?.type,$sentry_tags:a.tags};return t&&r&&(p.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:p}),a}}var oIo=class{constructor(t,r,i,n){this.name=EVp,this.name=EVp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(fmS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};oIo.POSTHOG_ID_TAG="posthog_distinct_id";var tIo="0123456789abcdef",uIo=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=tIo.charAt(this.bytes[r]>>>4),t+=tIo.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+=tIo.charAt(this.bytes[r]>>>4),t+=tIo.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},f6s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??dmS()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return uIo.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,uIo.ofInner(t)}},dmS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),SVp,d6s=()=>pmS().toString(),pmS=()=>(SVp||(SVp=new f6s)).generate();function _mS(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function hmS(e,t){global.process.on("uncaughtException",_mS(e,t))}function ymS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var rIo,MVp,iIo;function bmS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return iIo&&r.length===MVp||(MVp=r.length,iIo=r.reduce((i,n)=>{rIo||(rIo={});let a=rIo[n];if(a)i[a[0]]=a[1];else{let o=e(n);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[n];if(s&&u){i[s]=u,rIo[n]=[s,u];break}}}return i},{})),iIo}function vmS(e){return typeof Event<"u"&&i5p(e,Event)}function gmS(e){return n5p(e,"Object")}function O6s(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return i5p(e,Error)}}function i5p(e,t){try{return e instanceof t}catch{return!1}}function OmS(e){return n5p(e,"ErrorEvent")}function n5p(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function AmS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=a5p(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await MmS(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function a5p(e,t,r){let i=mmS(e,t,r);return i.cause?[i,...a5p(e,i.cause,r)]:[i]}function mmS(e,t,r){if(O6s(t))return t;if(e.synthetic=!0,gmS(t)){let n=PmS(t);if(n)return n;let a=jmS(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function PmS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(O6s(r))return r}}function jmS(e){if("name"in e&&typeof e.name=="string"){let i=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(i+=` with message '${e.message}'`),i}else if("message"in e&&typeof e.message=="string")return e.message;let t=EmS(e);if(OmS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=wmS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function wmS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function EmS(e,t=40){let r=Object.keys(SmS(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return DVp(i,t);for(let n=r.length;n>0;n--){let a=r.slice(0,n).join(", ");if(!(a.length>t))return n===r.length?a:DVp(a,t)}return""}function DVp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function SmS(e){return O6s(e)?{message:e.message,name:e.name,stack:e.stack,...BVp(e)}:vmS(e)?{type:e.type,target:IVp(e.target),currentTarget:IVp(e.currentTarget),...BVp(e)}:e}function BVp(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 IVp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function MmS(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=DmS(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function DmS(e,t){return BmS(e(t.stack||"",1),e)}function BmS(e,t){let r=bmS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var ImS=2e3,SRn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await AmS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||d6s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(hmS(this.onException.bind(this),this.onFatalError.bind(this)),ymS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(ImS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function CmS(e=process.argv[1]?(0,BRn.dirname)(process.argv[1]):process.cwd(),t=BRn.sep==="\\"){let r=t?CVp(e):e;return i=>{if(!i)return;let n=t?CVp(i):i,{dir:a,base:o,ext:c}=BRn.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${f}`:f}return f}}function CVp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var sIo=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)}}},aIo=new sIo(25),o5p=new sIo(20),A6s=7,qmS=1e3,TmS=1e4;async function RmS(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||QmS(o)||UmS(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(o5p.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=VmS(a);if(o.every(f=>LmS(n,f)))continue;let c=WmS(aIo,n,{});i.push(zmS(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&NmS(e,aIo),aIo.reduce(),e}function zmS(e,t,r){return new Promise(i=>{let n=(0,t5p.createReadStream)(e),a=(0,r5p.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,f=0,s=t[f];if(s===void 0){o();return}let u=s[0],l=s[1];function p(){o5p.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=xmS(_,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let h=t[f];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],l=h[1]}})})}function NmS(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;FmS(r.lineno,r,i)}}function FmS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=u5p(e);n<e;n++){let a=r[n];if(a===void 0){qVp(t);return}t.pre_context.push(a)}if(r[e]===void 0){qVp(t);return}t.context_line=r[e];let i=s5p(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function qVp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function QmS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function UmS(e){return e.lineno!==void 0&&e.lineno>TmS||e.colno!==void 0&&e.colno>qmS}function LmS(e,t){let r=aIo.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function VmS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=TVp(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+A6s:(n.push(i),i=TVp(a)),t++}return n}function TVp(e){return[u5p(e),s5p(e)]}function u5p(e){return Math.max(1,e-A6s)}function s5p(e){return e+A6s}function WmS(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function xmS(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var GmS="4.18.0",T6;(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"})(T6||(T6={}));var RVp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(RVp||(RVp={}));var zVp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(zVp||(zVp={}));var NVp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(NVp||(NVp={}));var FVp;(function(e){e.Html="html",e.Text="text"})(FVp||(FVp={}));var QVp;(function(e){e.Number="number",e.Emoji="emoji"})(QVp||(QVp={}));var UVp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(UVp||(UVp={}));var LVp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(LVp||(LVp={}));var VVp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(VVp||(VVp={}));var WVp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(WVp||(WVp={}));var HmS=e=>{if("flags"in e){let t=JmS(e.flags),r=$mS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,c5p(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,KmS(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function KmS(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 JmS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,m6s(r)]).filter(([,t])=>t!==void 0)),$mS=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?c5p(i):void 0]}))},m6s=e=>e===void 0?void 0:e.variant??e.enabled,c5p=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},YmS=1,XmS=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"]),ZmS="utf8";function kmS(e,t){if(!e||typeof e!="string"||e0S(e))throw new Error(t)}function e0S(e){return e.trim().length===0}function t0S(e){return e?.replace(/\/+$/,"")}async function r0S(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function xVp(){return new Date().getTime()}function c6s(){return new Date().toISOString()}function cIo(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function i0S(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function n0S(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 a0S(e,t=0,r){let i=n0S(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function GVp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var jOa=String.fromCharCode,HVp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",nIo={};function o0S(e,t){if(!nIo[e]){nIo[e]={};for(let r=0;r<e.length;r++)nIo[e][e.charAt(r)]=r}return nIo[e][t]}var wRn={compressToBase64:function(e){if(e==null)return"";let t=wRn._compress(e,6,function(r){return HVp.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:wRn._decompress(e.length,32,function(t){return o0S(HVp,e.charAt(t))})},compress:function(e){return wRn._compress(e,16,function(t){return jOa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],o,c,f="",s="",u="",l=2,p=3,_=2,h=0,y=0,b;for(b=0;b<e.length;b+=1)if(f=e.charAt(b),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=p++,n[f]=!0),s=u+f,Object.prototype.hasOwnProperty.call(i,s))u=s;else{if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++),i[s]=p++,u=String(f)}if(u!==""){if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++)}for(c=2,o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;for(;;)if(h=h<<1,y==t-1){a.push(r(h));break}else y++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:wRn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,s="",u,l,p,_,h,y,b;for(u=0;u<3;u+=1)i[u]=u;for(p=0,h=Math.pow(2,2),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=jOa(p);break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=jOa(p);break;case 2:return""}for(i[3]=b,l=b,n.push(b);;){if(a.index>e)return"";for(p=0,h=Math.pow(2,f),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(b=p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=jOa(p),b=c-1,o--;break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=jOa(p),b=c-1,o--;break;case 2:return n.join("")}if(o==0&&(o=Math.pow(2,f),f++),i[b])s=i[b];else if(b===c)s=l+l.charAt(0);else return null;n.push(s),i[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,f),f++)}}},p6s=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}},MRn=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()}},wOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function KVp(e){if(e instanceof MRn){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 l6s(e){return typeof e=="object"&&(e instanceof MRn||e instanceof wOa)}function JVp(e){return typeof e=="object"&&e instanceof MRn&&e.status===413}var _6s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(_6s||(_6s={}));var h6s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new p6s,this._isInitialized=!1,kmS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=t0S(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:l6s},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(T6.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(T6.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(T6.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=d6s();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...o||{}}});this.enqueue("capture",c,n)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let c=a0S(this.apiKey,YmS,XmS)?`${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:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>HmS(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=m6s(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,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={},i={},n={},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,i,n,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(_6s.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"}},n=(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 n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(T6.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(T6.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(T6.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(T6.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(T6.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=cIo(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:c6s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${xVp()}&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(wRn.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,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:c6s(),uuid:i?.uuid?i.uuid:d6s()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await KVp(t)})}async flush(){let t=GVp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),GVp([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(T6.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(p=>p.message),o=()=>{let _=(this.getPersistedProperty(T6.Queue)||[]).slice(n.length);this.setPersistedProperty(T6.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:c6s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${xVp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,u=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(wRn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>JVp(p)?!1:l6s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(JVp(p)&&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 p instanceof wOa||o(),this._events.emit("error",p),p}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let u=new AbortController;return setTimeout(()=>u.abort(),s),u.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,ZmS)}catch{c=new TextEncoder().encode(o).length}return await r0S(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new wOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new MRn(f,c);return f},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(T6.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!l6s(n))throw n;await KVp(n)}};return Promise.race([new Promise((n,a)=>{cIo(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},y6s=i0S();if(!y6s){let e=wVp();y6s=async(t,r)=>{let i=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:i.status,text:async()=>i.data,json:async()=>i.data}}}var l5p=y6s,lIo=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()}},f5p=new lIo(async()=>{try{return await import("crypto")}catch{return}});async function u0S(){return await f5p.getValue()}var s0S=new lIo(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await f5p.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function c0S(){return await s0S.getValue()}async function l0S(e){let t=await u0S();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await c0S();if(r){let i=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(i)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var f0S=60*1e3,d0S=1152921504606847e3,p0S=["is_not"],ERn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},O1=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},b6s=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,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=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||l5p,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,i={},n={},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,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof O1?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 i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let s=await this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let u=await this.computeFeatureFlagPayloadLocally(f.key,s);u&&(o[f.key]=u)}catch(s){s instanceof O1||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new O1("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 O1("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return await this.matchFeatureFlagProperties(t,i[f],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],o=!1,c,f=[...a].sort((s,u)=>{let l=!!s.variant,p=!!u.variant;return l&&p?0:l?-1:p?1:0});for(let s of f)try{if(await this.isConditionMatch(t,r,s,i)){let u=s.variant,l=n.multivariate?.variants||[];u&&l.some(p=>p.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof O1)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new O1("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((i.properties||[]).length>0){for(let c of i.properties){let f=c.type,s=!1;if(f==="cohort"?s=p5p(c,n,this.cohorts,this.debugMode):s=d5p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await $Vp(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await $Vp(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(f0S,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 ERn(`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 ERn(`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 ERn(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof ERn&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=cIo(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=cIo(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function $Vp(e,t,r=""){let i=await l0S(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/d0S}function d5p(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new O1("Operator is_not_set is not supported")}else throw new O1(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!p0S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function f(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return YVp(String(n))&&String(o).match(String(n))!==null;case"not_regex":return YVp(String(n))&&String(o).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&o!=null?typeof o=="string"?f(o,String(n),a):f(o,s,a):f(String(o),String(n),a)}case"is_date_after":case"is_date_before":{let s=_0S(String(n));if(s==null&&(s=XVp(n)),s==null)throw new O1(`Invalid date: ${n}`);let u=XVp(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new O1(`Unknown operator: ${a}`)}}function p5p(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new O1("can't match cohort without a given cohort property value");let a=r[n];return _5p(a,t,r,i)}function _5p(e,t,r,i=!1){if(!e)return!0;let n=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=_5p(c,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof O1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new O1("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=p5p(c,t,r,i):f=d5p(c,t);let s=c.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof O1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new O1("can't match cohort without a given cohort property value");return n==="AND"}}function YVp(e){try{return new RegExp(e),!0}catch{return!1}}function XVp(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 O1(`${e} is in an invalid date format`)}else throw new O1(`The date provided ${e} must be a string, number, or date object`)}function _0S(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var v6s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},h0S=100,ZVp=30*1e3,y0S=50*1e3,g6s=class extends h6s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new v6s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,h0S):ZVp,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 b6s({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new SRn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||y0S}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):l5p(t,r)}getLibraryVersion(){return GmS}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>{super.captureStateless(r,i,_,{timestamp:c,disableGeoip:f,uuid:s})},l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags,p=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})});this.addPendingPromise(p)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>super.captureStatelessImmediate(r,i,_,{timestamp:c,disableGeoip:f,uuid:s}),l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=ZVp){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:s}=i||{},u=this.addLocalPersonAndGroupProperties(r,n,f,s);f=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),p=l!==void 0,_,h;if(!p&&!o){let b=await super.getFeatureFlagDetailStateless(t,r,n,f,s,a);if(b===void 0)return;h=b.response,l=m6s(h),_=b?.requestId}let y=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(y))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(y):this.distinctIdHasSentFlagCalls[r]=[y],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:h?.metadata?.id,$feature_flag_version:h?.metadata?.version,$feature_flag_reason:h?.reason?.description??h?.reason?.code,locally_evaluated:p,[`$feature/${t}`]:l,$feature_flag_request_id:_},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:o}=n||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:s,groupProperties:u}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=l.allGroupProperties;let p;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(p=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(p!==void 0)&&!c&&(p=await super.getFeatureFlagPayloadStateless(t,r,a,s,u,o)),p}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,o,c),u={},l={},p=!0;if(s&&(u=s.response,l=s.payloads,p=s.fallbackToDecide),p&&!a){let _=await super.getFeatureFlagsAndPayloadsStateless(t,i,o,c,n);u={...u,..._.flags||{}},l={...l,..._.payloads||{}}}return{featureFlags:u,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i){let n=new Error("PostHog syntheticException");SRn.captureException(this,t,{syntheticException:n},r,i)}},kVp=/\(error: (.*)\)/,h5p=50,y5p="?";function b0S(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,o,c,f,s;if(n[1]){c=n[1];let p=c.lastIndexOf(".");if(c[p-1]==="."&&p--,p>0){a=c.slice(0,p),o=c.slice(p+1);let _=a.indexOf(".Module");_>0&&(c=c.slice(_+1),a=a.slice(0,_))}f=void 0}o&&(f=a,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||y5p,c=f?`${f}.${s}`:s);let u=n[2]?.startsWith("file://")?n[2].slice(7):n[2],l=n[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&n[5]&&!l&&(u=n[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:e5p(n[3]),colno:e5p(n[4]),in_app:v0S(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function v0S(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 e5p(e){return parseInt(e||"",10)||void 0}function g0S(e){return[90,b0S(e)]}function O0S(e){let r=[g0S(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],o=i.split(`
|
|
1158
|
-
`);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=kVp.test(f)?f.replace(kVp,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=h5p)break}}return A0S(a)}}function A0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,h5p).map(r=>({...r,filename:r.filename||m0S(t).filename,function:r.function||y5p}))}function m0S(e){return e[e.length-1]||{}}SRn.stackParser=O0S(CmS());SRn.frameModifiers=[RmS];var DRn=class extends g6s{getLibraryId(){return"posthog-node"}};var fIo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new DRn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"2.5.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var EOa=class{async sendEvent(){}async identify(){}async flush(){}};var IRn=require("fs/promises"),O5p=require("os"),A5p=require("path");var b5p=ae(require("crypto")),pIo=new Uint8Array(256),dIo=pIo.length;function P6s(){return dIo>pIo.length-16&&(b5p.default.randomFillSync(pIo),dIo=0),pIo.slice(dIo,dIo+=16)}var UQ=[];for(let e=0;e<256;++e)UQ.push((e+256).toString(16).slice(1));function v5p(e,t=0){return UQ[e[t+0]]+UQ[e[t+1]]+UQ[e[t+2]]+UQ[e[t+3]]+"-"+UQ[e[t+4]]+UQ[e[t+5]]+"-"+UQ[e[t+6]]+UQ[e[t+7]]+"-"+UQ[e[t+8]]+UQ[e[t+9]]+"-"+UQ[e[t+10]]+UQ[e[t+11]]+UQ[e[t+12]]+UQ[e[t+13]]+UQ[e[t+14]]+UQ[e[t+15]]}var g5p=ae(require("crypto")),j6s={randomUUID:g5p.default.randomUUID};function P0S(e,t,r){if(j6s.randomUUID&&!t&&!e)return j6s.randomUUID();e=e||{};let i=e.random||(e.rng||P6s)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return v5p(i)}var ahe=P0S;var j0S="id",w0S=".fern",SOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new DRn(r),this.userId=t==null?void 0:GVs(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:"2.5.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Qt(Vr.of((0,O5p.homedir)()),ke.of(w0S),ke.of(j0S));await Ri(t)||(await(0,IRn.mkdir)((0,A5p.dirname)(t),{recursive:!0}),await(0,IRn.writeFile)(t,ahe())),this.persistedDistinctId=(await(0,IRn.readFile)(t)).toString()}return this.persistedDistinctId}};var w6s;async function CRn(){return w6s==null&&(w6s=await E0S()),w6s}async function E0S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new EOa;let r=await Bjo();return r!=null?new SOa({token:r,posthogApiKey:e}):await R1n()!=null?new fIo({posthogApiKey:e}):new SOa({token:void 0,posthogApiKey:e})}catch{return new EOa}}function MOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:S0S}=Object.prototype,{getPrototypeOf:S6s}=Object,{iterator:hIo,toStringTag:P5p}=Symbol,yIo=(e=>t=>{let r=S0S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),WNt=e=>(e=e.toLowerCase(),t=>yIo(t)===e),bIo=e=>t=>typeof t===e,{isArray:TRn}=Array,qRn=bIo("undefined");function DOa(e){return e!==null&&!qRn(e)&&e.constructor!==null&&!qRn(e.constructor)&&R6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var j5p=WNt("ArrayBuffer");function M0S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&j5p(e.buffer),t}var D0S=bIo("string"),R6=bIo("function"),w5p=bIo("number"),BOa=e=>e!==null&&typeof e=="object",B0S=e=>e===!0||e===!1,_Io=e=>{if(yIo(e)!=="object")return!1;let t=S6s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(P5p in e)&&!(hIo in e)},I0S=e=>{if(!BOa(e)||DOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},C0S=WNt("Date"),q0S=WNt("File"),T0S=WNt("Blob"),R0S=WNt("FileList"),z0S=e=>BOa(e)&&R6(e.pipe),N0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||R6(e.append)&&((t=yIo(e))==="formdata"||t==="object"&&R6(e.toString)&&e.toString()==="[object FormData]"))},F0S=WNt("URLSearchParams"),[Q0S,U0S,L0S,V0S]=["ReadableStream","Request","Response","Headers"].map(WNt),W0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function IOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),TRn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(DOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function E5p(e,t){if(DOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var l6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,S5p=e=>!qRn(e)&&e!==l6i;function E6s(){let{caseless:e,skipUndefined:t}=S5p(this)&&this||{},r={},i=(n,a)=>{let o=e&&E5p(r,a)||a;_Io(r[o])&&_Io(n)?r[o]=E6s(r[o],n):_Io(n)?r[o]=E6s({},n):TRn(n)?r[o]=n.slice():(!t||!qRn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&IOa(arguments[n],i);return r}var x0S=(e,t,r,{allOwnKeys:i}={})=>(IOa(t,(n,a)=>{r&&R6(n)?e[a]=MOa(n,r):e[a]=n},{allOwnKeys:i}),e),G0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),H0S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},K0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&S6s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},J0S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},$0S=e=>{if(!e)return null;if(TRn(e))return e;let t=e.length;if(!w5p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Y0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&S6s(Uint8Array)),X0S=(e,t)=>{let i=(e&&e[hIo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},Z0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},k0S=WNt("HTMLFormElement"),ePS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),m5p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),tPS=WNt("RegExp"),M5p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};IOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},rPS=e=>{M5p(e,(t,r)=>{if(R6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(R6(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},iPS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return TRn(e)?i(e):i(String(e).split(t)),r},nPS=()=>{},aPS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function oPS(e){return!!(e&&R6(e.append)&&e[P5p]==="FormData"&&e[hIo])}var uPS=e=>{let t=new Array(10),r=(i,n)=>{if(BOa(i)){if(t.indexOf(i)>=0)return;if(DOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=TRn(i)?[]:{};return IOa(i,(o,c)=>{let f=r(o,n+1);!qRn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},sPS=WNt("AsyncFunction"),cPS=e=>e&&(BOa(e)||R6(e))&&R6(e.then)&&R6(e.catch),D5p=((e,t)=>e?setImmediate:t?((r,i)=>(l6i.addEventListener("message",({source:n,data:a})=>{n===l6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),l6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",R6(l6i.postMessage)),lPS=typeof queueMicrotask<"u"?queueMicrotask.bind(l6i):typeof process<"u"&&process.nextTick||D5p,fPS=e=>e!=null&&R6(e[hIo]),kt={isArray:TRn,isArrayBuffer:j5p,isBuffer:DOa,isFormData:N0S,isArrayBufferView:M0S,isString:D0S,isNumber:w5p,isBoolean:B0S,isObject:BOa,isPlainObject:_Io,isEmptyObject:I0S,isReadableStream:Q0S,isRequest:U0S,isResponse:L0S,isHeaders:V0S,isUndefined:qRn,isDate:C0S,isFile:q0S,isBlob:T0S,isRegExp:tPS,isFunction:R6,isStream:z0S,isURLSearchParams:F0S,isTypedArray:Y0S,isFileList:R0S,forEach:IOa,merge:E6s,extend:x0S,trim:W0S,stripBOM:G0S,inherits:H0S,toFlatObject:K0S,kindOf:yIo,kindOfTest:WNt,endsWith:J0S,toArray:$0S,forEachEntry:X0S,matchAll:Z0S,isHTMLForm:k0S,hasOwnProperty:m5p,hasOwnProp:m5p,reduceDescriptors:M5p,freezeMethods:rPS,toObjectSet:iPS,toCamelCase:ePS,noop:nPS,toFiniteNumber:aPS,findKey:E5p,global:l6i,isContextDefined:S5p,isSpecCompliantForm:oPS,toJSONObject:uPS,isAsyncFn:sPS,isThenable:cPS,setImmediate:D5p,asap:lPS,isIterable:fPS};function RRn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}kt.inherits(RRn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var B5p=RRn.prototype,I5p={};["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=>{I5p[e]={value:e}});Object.defineProperties(RRn,I5p);Object.defineProperty(B5p,"isAxiosError",{value:!0});RRn.from=(e,t,r,i,n,a)=>{let o=Object.create(B5p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return RRn.call(o,c,f,r,i,n),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 ya=RRn;var C5p=ae(J7i(),1),vIo=C5p.default;function M6s(e){return kt.isPlainObject(e)||kt.isArray(e)}function T5p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function q5p(e,t,r){return e?e.concat(t).map(function(n,a){return n=T5p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function dPS(e){return kt.isArray(e)&&!e.some(M6s)}var pPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function _PS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(vIo||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&dPS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=T5p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?q5p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return M6s(h)?!0:(t.append(q5p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(pPS,{defaultVisitor:u,convertValue:s,isVisitable:M6s});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var sIi=_PS;function R5p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function z5p(e,t){this._pairs=[],e&&sIi(e,this,t)}var N5p=z5p.prototype;N5p.append=function(t,r){this._pairs.push([t,r])};N5p.toString=function(t){let r=t?function(i){return t.call(this,i,R5p)}:R5p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var F5p=z5p;function hPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function f6i(e,t,r){if(!t)return e;let i=r&&r.encode||hPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new F5p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var D6s=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},B6s=D6s;var zRn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var V5p=ae(require("crypto"),1);var Q5p=ae(require("url"),1),U5p=Q5p.default.URLSearchParams;var I6s="abcdefghijklmnopqrstuvwxyz",L5p="0123456789",W5p={DIGIT:L5p,ALPHA:I6s,ALPHA_DIGIT:I6s+I6s.toUpperCase()+L5p},yPS=(e=16,t=W5p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);V5p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},x5p={isNode:!0,classes:{URLSearchParams:U5p,FormData:vIo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:W5p,generateString:yPS,protocols:["http","https","file","data"]};var T6s={};Kt(T6s,{hasBrowserEnv:()=>q6s,hasStandardBrowserEnv:()=>bPS,hasStandardBrowserWebWorkerEnv:()=>vPS,navigator:()=>C6s,origin:()=>gPS});var q6s=typeof window<"u"&&typeof document<"u",C6s=typeof navigator=="object"&&navigator||void 0,bPS=q6s&&(!C6s||["ReactNative","NativeScript","NS"].indexOf(C6s.product)<0),vPS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",gPS=q6s&&window.location.href||"http://localhost";var PA={...T6s,...x5p};function R6s(e,t){return sIi(e,new PA.classes.URLSearchParams,{visitor:function(r,i,n,a){return PA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function OPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function APS(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function mPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=APS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(OPS(i),n,r,0)}),r}return null}var gIo=mPS;function PPS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var z6s={transitional:zRn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(gIo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return R6s(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return sIi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),PPS(t)):t}],transformResponse:[function(t){let r=this.transitional||z6s.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.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:PA.classes.FormData,Blob:PA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{z6s.headers[e]={}});var NRn=z6s;var jPS=kt.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"]),G5p=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1158
|
+
`);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=kVp.test(f)?f.replace(kVp,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=h5p)break}}return A0S(a)}}function A0S(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,h5p).map(r=>({...r,filename:r.filename||m0S(t).filename,function:r.function||y5p}))}function m0S(e){return e[e.length-1]||{}}SRn.stackParser=O0S(CmS());SRn.frameModifiers=[RmS];var DRn=class extends g6s{getLibraryId(){return"posthog-node"}};var fIo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new DRn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"2.5.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var EOa=class{async sendEvent(){}async identify(){}async flush(){}};var IRn=require("fs/promises"),O5p=require("os"),A5p=require("path");var b5p=ae(require("crypto")),pIo=new Uint8Array(256),dIo=pIo.length;function P6s(){return dIo>pIo.length-16&&(b5p.default.randomFillSync(pIo),dIo=0),pIo.slice(dIo,dIo+=16)}var UQ=[];for(let e=0;e<256;++e)UQ.push((e+256).toString(16).slice(1));function v5p(e,t=0){return UQ[e[t+0]]+UQ[e[t+1]]+UQ[e[t+2]]+UQ[e[t+3]]+"-"+UQ[e[t+4]]+UQ[e[t+5]]+"-"+UQ[e[t+6]]+UQ[e[t+7]]+"-"+UQ[e[t+8]]+UQ[e[t+9]]+"-"+UQ[e[t+10]]+UQ[e[t+11]]+UQ[e[t+12]]+UQ[e[t+13]]+UQ[e[t+14]]+UQ[e[t+15]]}var g5p=ae(require("crypto")),j6s={randomUUID:g5p.default.randomUUID};function P0S(e,t,r){if(j6s.randomUUID&&!t&&!e)return j6s.randomUUID();e=e||{};let i=e.random||(e.rng||P6s)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return v5p(i)}var ahe=P0S;var j0S="id",w0S=".fern",SOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new DRn(r),this.userId=t==null?void 0:GVs(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:"2.5.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Qt(Vr.of((0,O5p.homedir)()),ke.of(w0S),ke.of(j0S));await Ri(t)||(await(0,IRn.mkdir)((0,A5p.dirname)(t),{recursive:!0}),await(0,IRn.writeFile)(t,ahe())),this.persistedDistinctId=(await(0,IRn.readFile)(t)).toString()}return this.persistedDistinctId}};var w6s;async function CRn(){return w6s==null&&(w6s=await E0S()),w6s}async function E0S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new EOa;let r=await Bjo();return r!=null?new SOa({token:r,posthogApiKey:e}):await R1n()!=null?new fIo({posthogApiKey:e}):new SOa({token:void 0,posthogApiKey:e})}catch{return new EOa}}function MOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:S0S}=Object.prototype,{getPrototypeOf:S6s}=Object,{iterator:hIo,toStringTag:P5p}=Symbol,yIo=(e=>t=>{let r=S0S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),WNt=e=>(e=e.toLowerCase(),t=>yIo(t)===e),bIo=e=>t=>typeof t===e,{isArray:TRn}=Array,qRn=bIo("undefined");function DOa(e){return e!==null&&!qRn(e)&&e.constructor!==null&&!qRn(e.constructor)&&R6(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var j5p=WNt("ArrayBuffer");function M0S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&j5p(e.buffer),t}var D0S=bIo("string"),R6=bIo("function"),w5p=bIo("number"),BOa=e=>e!==null&&typeof e=="object",B0S=e=>e===!0||e===!1,_Io=e=>{if(yIo(e)!=="object")return!1;let t=S6s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(P5p in e)&&!(hIo in e)},I0S=e=>{if(!BOa(e)||DOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},C0S=WNt("Date"),q0S=WNt("File"),T0S=WNt("Blob"),R0S=WNt("FileList"),z0S=e=>BOa(e)&&R6(e.pipe),N0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||R6(e.append)&&((t=yIo(e))==="formdata"||t==="object"&&R6(e.toString)&&e.toString()==="[object FormData]"))},F0S=WNt("URLSearchParams"),[Q0S,U0S,L0S,V0S]=["ReadableStream","Request","Response","Headers"].map(WNt),W0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function IOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),TRn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(DOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function E5p(e,t){if(DOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var l6i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,S5p=e=>!qRn(e)&&e!==l6i;function E6s(){let{caseless:e,skipUndefined:t}=S5p(this)&&this||{},r={},i=(n,a)=>{let o=e&&E5p(r,a)||a;_Io(r[o])&&_Io(n)?r[o]=E6s(r[o],n):_Io(n)?r[o]=E6s({},n):TRn(n)?r[o]=n.slice():(!t||!qRn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&IOa(arguments[n],i);return r}var x0S=(e,t,r,{allOwnKeys:i}={})=>(IOa(t,(n,a)=>{r&&R6(n)?e[a]=MOa(n,r):e[a]=n},{allOwnKeys:i}),e),G0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),H0S=(e,t,r,i)=>{e.prototype=Object.create(t.prototype,i),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},K0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&S6s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},J0S=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let i=e.indexOf(t,r);return i!==-1&&i===r},$0S=e=>{if(!e)return null;if(TRn(e))return e;let t=e.length;if(!w5p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Y0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&S6s(Uint8Array)),X0S=(e,t)=>{let i=(e&&e[hIo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},Z0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},k0S=WNt("HTMLFormElement"),ePS=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),m5p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),tPS=WNt("RegExp"),M5p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};IOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},rPS=e=>{M5p(e,(t,r)=>{if(R6(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(R6(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},iPS=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return TRn(e)?i(e):i(String(e).split(t)),r},nPS=()=>{},aPS=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function oPS(e){return!!(e&&R6(e.append)&&e[P5p]==="FormData"&&e[hIo])}var uPS=e=>{let t=new Array(10),r=(i,n)=>{if(BOa(i)){if(t.indexOf(i)>=0)return;if(DOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=TRn(i)?[]:{};return IOa(i,(o,c)=>{let f=r(o,n+1);!qRn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},sPS=WNt("AsyncFunction"),cPS=e=>e&&(BOa(e)||R6(e))&&R6(e.then)&&R6(e.catch),D5p=((e,t)=>e?setImmediate:t?((r,i)=>(l6i.addEventListener("message",({source:n,data:a})=>{n===l6i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),l6i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",R6(l6i.postMessage)),lPS=typeof queueMicrotask<"u"?queueMicrotask.bind(l6i):typeof process<"u"&&process.nextTick||D5p,fPS=e=>e!=null&&R6(e[hIo]),kt={isArray:TRn,isArrayBuffer:j5p,isBuffer:DOa,isFormData:N0S,isArrayBufferView:M0S,isString:D0S,isNumber:w5p,isBoolean:B0S,isObject:BOa,isPlainObject:_Io,isEmptyObject:I0S,isReadableStream:Q0S,isRequest:U0S,isResponse:L0S,isHeaders:V0S,isUndefined:qRn,isDate:C0S,isFile:q0S,isBlob:T0S,isRegExp:tPS,isFunction:R6,isStream:z0S,isURLSearchParams:F0S,isTypedArray:Y0S,isFileList:R0S,forEach:IOa,merge:E6s,extend:x0S,trim:W0S,stripBOM:G0S,inherits:H0S,toFlatObject:K0S,kindOf:yIo,kindOfTest:WNt,endsWith:J0S,toArray:$0S,forEachEntry:X0S,matchAll:Z0S,isHTMLForm:k0S,hasOwnProperty:m5p,hasOwnProp:m5p,reduceDescriptors:M5p,freezeMethods:rPS,toObjectSet:iPS,toCamelCase:ePS,noop:nPS,toFiniteNumber:aPS,findKey:E5p,global:l6i,isContextDefined:S5p,isSpecCompliantForm:oPS,toJSONObject:uPS,isAsyncFn:sPS,isThenable:cPS,setImmediate:D5p,asap:lPS,isIterable:fPS};function RRn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}kt.inherits(RRn,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:kt.toJSONObject(this.config),code:this.code,status:this.status}}});var B5p=RRn.prototype,I5p={};["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=>{I5p[e]={value:e}});Object.defineProperties(RRn,I5p);Object.defineProperty(B5p,"isAxiosError",{value:!0});RRn.from=(e,t,r,i,n,a)=>{let o=Object.create(B5p);kt.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return RRn.call(o,c,f,r,i,n),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 ya=RRn;var C5p=ae(J7i(),1),vIo=C5p.default;function M6s(e){return kt.isPlainObject(e)||kt.isArray(e)}function T5p(e){return kt.endsWith(e,"[]")?e.slice(0,-2):e}function q5p(e,t,r){return e?e.concat(t).map(function(n,a){return n=T5p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function dPS(e){return kt.isArray(e)&&!e.some(M6s)}var pPS=kt.toFlatObject(kt,{},null,function(t){return/^is[A-Z]/.test(t)});function _PS(e,t,r){if(!kt.isObject(e))throw new TypeError("target must be an object");t=t||new(vIo||FormData),r=kt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!kt.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&kt.isSpecCompliantForm(t);if(!kt.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(kt.isDate(h))return h.toISOString();if(kt.isBoolean(h))return h.toString();if(!f&&kt.isBlob(h))throw new ya("Blob is not supported. Use a Buffer instead.");return kt.isArrayBuffer(h)||kt.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(kt.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(kt.isArray(h)&&dPS(h)||(kt.isFileList(h)||kt.endsWith(y,"[]"))&&(v=kt.toArray(h)))return y=T5p(y),v.forEach(function(A,g){!(kt.isUndefined(A)||A===null)&&t.append(o===!0?q5p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return M6s(h)?!0:(t.append(q5p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(pPS,{defaultVisitor:u,convertValue:s,isVisitable:M6s});function _(h,y){if(!kt.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),kt.forEach(h,function(v,O){(!(kt.isUndefined(v)||v===null)&&n.call(t,v,kt.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!kt.isObject(e))throw new TypeError("data must be an object");return _(e),t}var sIi=_PS;function R5p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function z5p(e,t){this._pairs=[],e&&sIi(e,this,t)}var N5p=z5p.prototype;N5p.append=function(t,r){this._pairs.push([t,r])};N5p.toString=function(t){let r=t?function(i){return t.call(this,i,R5p)}:R5p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var F5p=z5p;function hPS(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function f6i(e,t,r){if(!t)return e;let i=r&&r.encode||hPS;kt.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=kt.isURLSearchParams(t)?t.toString():new F5p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var D6s=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){kt.forEach(this.handlers,function(i){i!==null&&t(i)})}},B6s=D6s;var zRn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var V5p=ae(require("crypto"),1);var Q5p=ae(require("url"),1),U5p=Q5p.default.URLSearchParams;var I6s="abcdefghijklmnopqrstuvwxyz",L5p="0123456789",W5p={DIGIT:L5p,ALPHA:I6s,ALPHA_DIGIT:I6s+I6s.toUpperCase()+L5p},yPS=(e=16,t=W5p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);V5p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},x5p={isNode:!0,classes:{URLSearchParams:U5p,FormData:vIo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:W5p,generateString:yPS,protocols:["http","https","file","data"]};var T6s={};Kt(T6s,{hasBrowserEnv:()=>q6s,hasStandardBrowserEnv:()=>bPS,hasStandardBrowserWebWorkerEnv:()=>vPS,navigator:()=>C6s,origin:()=>gPS});var q6s=typeof window<"u"&&typeof document<"u",C6s=typeof navigator=="object"&&navigator||void 0,bPS=q6s&&(!C6s||["ReactNative","NativeScript","NS"].indexOf(C6s.product)<0),vPS=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",gPS=q6s&&window.location.href||"http://localhost";var PA={...T6s,...x5p};function R6s(e,t){return sIi(e,new PA.classes.URLSearchParams,{visitor:function(r,i,n,a){return PA.isNode&&kt.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function OPS(e){return kt.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function APS(e){let t={},r=Object.keys(e),i,n=r.length,a;for(i=0;i<n;i++)a=r[i],t[a]=e[a];return t}function mPS(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&kt.isArray(n)?n.length:o,f?(kt.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!kt.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&kt.isArray(n[o])&&(n[o]=APS(n[o])),!c)}if(kt.isFormData(e)&&kt.isFunction(e.entries)){let r={};return kt.forEachEntry(e,(i,n)=>{t(OPS(i),n,r,0)}),r}return null}var gIo=mPS;function PPS(e,t,r){if(kt.isString(e))try{return(t||JSON.parse)(e),kt.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var z6s={transitional:zRn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=kt.isObject(t);if(a&&kt.isHTMLForm(t)&&(t=new FormData(t)),kt.isFormData(t))return n?JSON.stringify(gIo(t)):t;if(kt.isArrayBuffer(t)||kt.isBuffer(t)||kt.isStream(t)||kt.isFile(t)||kt.isBlob(t)||kt.isReadableStream(t))return t;if(kt.isArrayBufferView(t))return t.buffer;if(kt.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return R6s(t,this.formSerializer).toString();if((c=kt.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return sIi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),PPS(t)):t}],transformResponse:[function(t){let r=this.transitional||z6s.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(kt.isResponse(t)||kt.isReadableStream(t))return t;if(t&&kt.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ya.from(c,ya.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:PA.classes.FormData,Blob:PA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};kt.forEach(["delete","get","head","post","put","patch"],e=>{z6s.headers[e]={}});var NRn=z6s;var jPS=kt.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"]),G5p=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1159
1159
|
`).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&jPS[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var H5p=Symbol("internals");function COa(e){return e&&String(e).trim().toLowerCase()}function OIo(e){return e===!1||e==null?e:kt.isArray(e)?e.map(OIo):String(e)}function wPS(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=r.exec(e);)t[i[1]]=i[2];return t}var EPS=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function N6s(e,t,r,i,n){if(kt.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!kt.isString(t)){if(kt.isString(i))return t.indexOf(i)!==-1;if(kt.isRegExp(i))return i.test(t)}}function SPS(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function MPS(e,t){let r=kt.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,o){return this[i].call(this,t,n,a,o)},configurable:!0})})}var FRn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=COa(f);if(!u)throw new Error("header name must be a non-empty string");let l=kt.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||f]=OIo(c))}let o=(c,f)=>kt.forEach(c,(s,u)=>a(s,u,f));if(kt.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(kt.isString(t)&&(t=t.trim())&&!EPS(t))o(G5p(t),r);else if(kt.isObject(t)&&kt.isIterable(t)){let c={},f,s;for(let u of t){if(!kt.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(f=c[s])?kt.isArray(f)?[...f,u[1]]:[f,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=COa(t),t){let i=kt.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return wPS(n);if(kt.isFunction(r))return r.call(this,n,i);if(kt.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=COa(t),t){let i=kt.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||N6s(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=COa(o),o){let c=kt.findKey(i,o);c&&(!r||N6s(i,i[c],c,r))&&(delete i[c],n=!0)}}return kt.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||N6s(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return kt.forEach(this,(n,a)=>{let o=kt.findKey(i,a);if(o){r[o]=OIo(n),delete r[a];return}let c=t?SPS(a):String(a).trim();c!==a&&delete r[a],r[c]=OIo(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return kt.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&kt.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
1160
1160
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[H5p]=this[H5p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=COa(o);i[c]||(MPS(n,o),i[c]=!0)}return kt.isArray(t)?t.forEach(a):a(t),this}};FRn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);kt.reduceDescriptors(FRn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});kt.freezeMethods(FRn);var LS=FRn;function qOa(e,t){let r=this||NRn,i=t||r,n=LS.from(i.headers),a=i.data;return kt.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function TOa(e){return!!(e&&e.__CANCEL__)}function K5p(e,t,r){ya.call(this,e??"canceled",ya.ERR_CANCELED,t,r),this.name="CanceledError"}kt.inherits(K5p,ya,{__CANCEL__:!0});var ohe=K5p;function g9t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new ya("Request failed with status code "+r.status,[ya.ERR_BAD_REQUEST,ya.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function F6s(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Q6s(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function d6i(e,t,r){let i=!F6s(t);return e&&(i||r==!1)?Q6s(e,t):t}var cWp=ae(LBo(),1),lWp=ae(require("http"),1),fWp=ae(require("https"),1),dWp=ae(require("util"),1),pWp=ae(UHs(),1),Jbi=ae(require("zlib"),1);var p6i="1.12.2";function ROa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var DPS=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function U6s(e,t,r){let i=r&&r.Blob||PA.classes.Blob,n=ROa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=DPS.exec(e);if(!a)throw new ya("Invalid URL",ya.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!i)throw new ya("Blob is not supported",ya.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new ya("Unsupported protocol "+n,ya.ERR_NOT_SUPPORT)}var h6i=ae(require("stream"),1);var J5p=ae(require("stream"),1);var L6s=Symbol("internals"),V6s=class extends J5p.default.Transform{constructor(t){t=kt.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!kt.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[L6s]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[L6s];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[L6s],a=n.maxRate,o=this.readableHighWaterMark,c=n.timeWindow,f=1e3/c,s=a/f,u=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(_,h)=>{let y=Buffer.byteLength(_);n.bytesSeen+=y,n.bytes+=y,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(_)?process.nextTick(h):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(h)}},p=(_,h)=>{let y=Buffer.byteLength(_),b=null,v=o,O,A=0;if(a){let g=Date.now();(!n.ts||(A=g-n.ts)>=c)&&(n.ts=g,O=s-n.bytes,n.bytes=O<0?-O:0,A=0),O=s-n.bytes}if(a){if(O<=0)return setTimeout(()=>{h(null,_)},c-A);O<v&&(v=O)}v&&y>v&&y-v>u&&(b=_.subarray(v),_=_.subarray(0,v)),l(_,b?()=>{process.nextTick(h,null,b)}:h)};p(t,function _(h,y){if(h)return i(h);y?p(y,_):i(null)})}},W6s=V6s;var _Wp=require("events");var Y5p=ae(require("util"),1),X5p=require("stream");var{asyncIterator:$5p}=Symbol,BPS=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[$5p]?yield*e[$5p]():yield e},AIo=BPS;var IPS=PA.ALPHABET.ALPHA_DIGIT+"-_",zOa=typeof TextEncoder=="function"?new TextEncoder:new Y5p.default.TextEncoder,_6i=`\r
|
|
1161
1161
|
`,CPS=zOa.encode(_6i),qPS=2,x6s=class{constructor(t,r){let{escapeName:i}=this.constructor,n=kt.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${_6i}`;n?r=zOa.encode(String(r).replace(/\r?\n|\r\n?/g,_6i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${_6i}`,this.headers=zOa.encode(a+_6i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+qPS,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;kt.isTypedArray(t)?yield t:yield*AIo(t),yield CPS}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},TPS=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+PA.generateString(n,IPS)}=r||{};if(!kt.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=zOa.encode("--"+a+_6i),c=zOa.encode("--"+a+"--"+_6i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new x6s(l,p);return f+=_.size,_});f+=o.byteLength*s.length,f=kt.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(u["Content-Length"]=f),t&&t(u),X5p.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},Z5p=TPS;var k5p=ae(require("stream"),1),G6s=class extends k5p.default.Transform{__transform(t,r,i){this.push(t),i()}_transform(t,r,i){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,r)}this.__transform(t,r,i)}},eWp=G6s;var RPS=(e,t)=>kt.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,tWp=RPS;function zPS(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),u=i[a];o||(o=s),r[n]=f,i[n]=s;let l=a,p=0;for(;l!==n;)p+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-o<t)return;let _=u&&s-u;return _?Math.round(p*1e3/_):void 0}}var rWp=zPS;function NPS(e,t){let r=0,i=1e3/t,n,a,o=(s,u=Date.now())=>{r=u,n=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=i?o(s,u):(n=s,a||(a=setTimeout(()=>{a=null,o(n)},i-l)))},()=>n&&o(n)]}var iWp=NPS;var Kbi=(e,t,r=3)=>{let i=0,n=rWp(50,250);return iWp(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-i,s=n(f),u=o<=c;i=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},QRn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},URn=e=>(...t)=>kt.asap(()=>e(...t));function H6s(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),i=e.slice(t+1);if(/;base64/i.test(r)){let a=i.length,o=i.length;for(let p=0;p<o;p++)if(i.charCodeAt(p)===37&&p+2<o){let _=i.charCodeAt(p+1),h=i.charCodeAt(p+2);(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)&&(h>=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102)&&(a-=2,p+=2)}let c=0,f=o-1,s=p=>p>=2&&i.charCodeAt(p-2)===37&&i.charCodeAt(p-1)===51&&(i.charCodeAt(p)===68||i.charCodeAt(p)===100);f>=0&&(i.charCodeAt(f)===61?(c++,f--):s(f)&&(c++,f-=3)),c===1&&f>=0&&(i.charCodeAt(f)===61||s(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(i,"utf8")}var nWp={flush:Jbi.default.constants.Z_SYNC_FLUSH,finishFlush:Jbi.default.constants.Z_SYNC_FLUSH},FPS={flush:Jbi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Jbi.default.constants.BROTLI_OPERATION_FLUSH},aWp=kt.isFunction(Jbi.default.createBrotliDecompress),{http:QPS,https:UPS}=pWp.default,LPS=/https:?/,oWp=PA.protocols.map(e=>e+":"),uWp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function VPS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function hWp(e,t,r){let i=t;if(!i&&i!==!1){let n=cWp.default.getProxyForUrl(r);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let n=i.hostname||i.host;e.hostname=n,e.host=n,e.port=i.port,e.path=r,i.protocol&&(e.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}e.beforeRedirects.proxy=function(a){hWp(a,t,a.href)}}var WPS=typeof process<"u"&&kt.kindOf(process)==="process",xPS=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>i=f).catch(c)}),GPS=({address:e,family:t})=>{if(!kt.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},sWp=(e,t)=>GPS(kt.isObject(e)?e:{address:e,family:t}),yWp=WPS&&function(t){return xPS(async function(i,n,a){let{data:o,lookup:c,family:f}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),p,_=!1,h;if(c){let H=tWp(c,ue=>kt.isArray(ue)?ue:[ue]);c=(ue,se,x)=>{H(ue,se,(G,Pe,ne)=>{if(G)return x(G);let Ee=kt.isArray(Pe)?Pe.map(Qe=>sWp(Qe)):[sWp(Pe,ne)];se.all?x(G,Ee):x(G,Ee[0].address,Ee[0].family)})}}let y=new _Wp.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((H,ue)=>{p=!0,ue&&(_=!0,b())});function v(H){y.emit("abort",!H||H.type?new ohe(null,t,h):H)}y.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(v),t.signal&&(t.signal.aborted?v():t.signal.addEventListener("abort",v)));let O=d6i(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,PA.hasBrowserEnv?PA.origin:void 0),g=A.protocol||oWp[0];if(g==="data:"){if(t.maxContentLength>-1){let ue=String(t.url||O||"");if(H6s(ue)>t.maxContentLength)return n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t))}let H;if(l!=="GET")return g9t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{H=U6s(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(ue){throw ya.from(ue,ya.ERR_BAD_REQUEST,t)}return s==="text"?(H=H.toString(u),(!u||u==="utf8")&&(H=kt.stripBOM(H))):s==="stream"&&(H=h6i.default.Readable.from(H)),g9t(i,n,{data:H,status:200,statusText:"OK",headers:new LS,config:t})}if(oWp.indexOf(g)===-1)return n(new ya("Unsupported protocol "+g,ya.ERR_BAD_REQUEST,t));let m=LS.from(t.headers).normalize();m.set("User-Agent","axios/"+p6i,!1);let{onUploadProgress:j,onDownloadProgress:D}=t,E=t.maxRate,M,B;if(kt.isSpecCompliantForm(o)){let H=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=Z5p(o,ue=>{m.set(ue)},{tag:`axios-${p6i}-boundary`,boundary:H&&H[1]||void 0})}else if(kt.isFormData(o)&&kt.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let H=await dWp.default.promisify(o.getLength).call(o);Number.isFinite(H)&&H>=0&&m.setContentLength(H)}catch{}}else if(kt.isBlob(o)||kt.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=h6i.default.Readable.from(AIo(o));else if(o&&!kt.isStream(o)){if(!Buffer.isBuffer(o))if(kt.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(kt.isString(o))o=Buffer.from(o,"utf-8");else return n(new ya("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ya.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new ya("Request body larger than maxBodyLength limit",ya.ERR_BAD_REQUEST,t))}let F=kt.toFiniteNumber(m.getContentLength());kt.isArray(E)?(M=E[0],B=E[1]):M=B=E,o&&(j||M)&&(kt.isStream(o)||(o=h6i.default.Readable.from(o,{objectMode:!1})),o=h6i.default.pipeline([o,new W6s({maxRate:kt.toFiniteNumber(M)})],kt.noop),j&&o.on("progress",uWp(o,QRn(F,Kbi(URn(j),!1,3)))));let R;if(t.auth){let H=t.auth.username||"",ue=t.auth.password||"";R=H+":"+ue}if(!R&&A.username){let H=A.username,ue=A.password;R=H+":"+ue}R&&m.delete("authorization");let N;try{N=f6i(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(H){let ue=new Error(H.message);return ue.config=t,ue.url=t.url,ue.exists=!0,n(ue)}m.set("Accept-Encoding","gzip, compress, deflate"+(aWp?", br":""),!1);let T={path:N,method:l,headers:m.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:R,protocol:g,family:f,beforeRedirect:VPS,beforeRedirects:{}};!kt.isUndefined(c)&&(T.lookup=c),t.socketPath?T.socketPath=t.socketPath:(T.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,T.port=A.port,hWp(T,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+T.path));let W,Q=LPS.test(T.protocol);if(T.agent=Q?t.httpsAgent:t.httpAgent,t.transport?W=t.transport:t.maxRedirects===0?W=Q?fWp.default:lWp.default:(t.maxRedirects&&(T.maxRedirects=t.maxRedirects),t.beforeRedirect&&(T.beforeRedirects.config=t.beforeRedirect),W=Q?UPS:QPS),t.maxBodyLength>-1?T.maxBodyLength=t.maxBodyLength:T.maxBodyLength=1/0,t.insecureHTTPParser&&(T.insecureHTTPParser=t.insecureHTTPParser),h=W.request(T,function(ue){if(h.destroyed)return;let se=[ue],x=+ue.headers["content-length"];if(D||B){let Qe=new W6s({maxRate:kt.toFiniteNumber(B)});D&&Qe.on("progress",uWp(Qe,QRn(x,Kbi(URn(D),!0,3)))),se.push(Qe)}let G=ue,Pe=ue.req||h;if(t.decompress!==!1&&ue.headers["content-encoding"])switch((l==="HEAD"||ue.statusCode===204)&&delete ue.headers["content-encoding"],(ue.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":se.push(Jbi.default.createUnzip(nWp)),delete ue.headers["content-encoding"];break;case"deflate":se.push(new eWp),se.push(Jbi.default.createUnzip(nWp)),delete ue.headers["content-encoding"];break;case"br":aWp&&(se.push(Jbi.default.createBrotliDecompress(FPS)),delete ue.headers["content-encoding"])}G=se.length>1?h6i.default.pipeline(se,kt.noop):se[0];let ne=h6i.default.finished(G,()=>{ne(),b()}),Ee={status:ue.statusCode,statusText:ue.statusMessage,headers:new LS(ue.headers),config:t,request:Pe};if(s==="stream")Ee.data=G,g9t(i,n,Ee);else{let Qe=[],re=0;G.on("data",function(Ve){Qe.push(Ve),re+=Ve.length,t.maxContentLength>-1&&re>t.maxContentLength&&(_=!0,G.destroy(),n(new ya("maxContentLength size of "+t.maxContentLength+" exceeded",ya.ERR_BAD_RESPONSE,t,Pe)))}),G.on("aborted",function(){if(_)return;let Ve=new ya("stream has been aborted",ya.ERR_BAD_RESPONSE,t,Pe);G.destroy(Ve),n(Ve)}),G.on("error",function(Ve){h.destroyed||n(ya.from(Ve,null,t,Pe))}),G.on("end",function(){try{let Ve=Qe.length===1?Qe[0]:Buffer.concat(Qe);s!=="arraybuffer"&&(Ve=Ve.toString(u),(!u||u==="utf8")&&(Ve=kt.stripBOM(Ve))),Ee.data=Ve}catch(Ve){return n(ya.from(Ve,null,t,Ee.request,Ee))}g9t(i,n,Ee)})}y.once("abort",Qe=>{G.destroyed||(G.emit("error",Qe),G.destroy())})}),y.once("abort",H=>{n(H),h.destroy(H)}),h.on("error",function(ue){n(ya.from(ue,null,t,h))}),h.on("socket",function(ue){ue.setKeepAlive(!0,1e3*60)}),t.timeout){let H=parseInt(t.timeout,10);if(Number.isNaN(H)){n(new ya("error trying to parse `config.timeout` to int",ya.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(H,function(){if(p)return;let se=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",x=t.transitional||zRn;t.timeoutErrorMessage&&(se=t.timeoutErrorMessage),n(new ya(se,x.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,t,h)),v()})}if(kt.isStream(o)){let H=!1,ue=!1;o.on("end",()=>{H=!0}),o.once("error",se=>{ue=!0,h.destroy(se)}),o.on("close",()=>{!H&&!ue&&v(new ohe("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var bWp=PA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,PA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(PA.origin),PA.navigator&&/(msie|trident)/i.test(PA.navigator.userAgent)):()=>!0;var vWp=PA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];kt.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),kt.isString(i)&&o.push("path="+i),kt.isString(n)&&o.push("domain="+n),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 gWp=e=>e instanceof LS?{...e}:e;function xNt(e,t){t=t||{};let r={};function i(s,u,l,p){return kt.isPlainObject(s)&&kt.isPlainObject(u)?kt.merge.call({caseless:p},s,u):kt.isPlainObject(u)?kt.merge({},u):kt.isArray(u)?u.slice():u}function n(s,u,l,p){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!kt.isUndefined(u))return i(void 0,u)}function o(s,u){if(kt.isUndefined(u)){if(!kt.isUndefined(s))return i(void 0,s)}else return i(void 0,u)}function c(s,u,l){if(l in t)return i(s,u);if(l in e)return i(void 0,s)}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:(s,u,l)=>n(gWp(s),gWp(u),l,!0)};return kt.forEach(Object.keys({...e,...t}),function(u){let l=f[u]||n,p=l(e[u],t[u],u);kt.isUndefined(p)&&l!==c||(r[u]=p)}),r}var mIo=e=>{let t=xNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=LS.from(o),t.url=f6i(d6i(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),kt.isFormData(r)){if(PA.hasStandardBrowserEnv||PA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(kt.isFunction(r.getHeaders)){let f=r.getHeaders(),s=["content-type","content-length"];Object.entries(f).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(PA.hasStandardBrowserEnv&&(i&&kt.isFunction(i)&&(i=i(t)),i||i!==!1&&bWp(t.url))){let f=n&&a&&vWp.read(a);f&&o.set(n,f)}return t};var HPS=typeof XMLHttpRequest<"u",OWp=HPS&&function(e){return new Promise(function(r,i){let n=mIo(e),a=n.data,o=LS.from(n.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:s}=n,u,l,p,_,h;function y(){_&&_(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function v(){if(!b)return;let A=LS.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:A,config:e,request:b};g9t(function(D){r(D),y()},function(D){i(D),y()},m),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(i(new ya("Request aborted",ya.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new ya(m,ya.ERR_NETWORK,e,b);j.event=g||null,i(j),b=null},b.ontimeout=function(){let g=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",m=n.transitional||zRn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new ya(g,m.clarifyTimeoutError?ya.ETIMEDOUT:ya.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&kt.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),kt.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=Kbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Kbi(f),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new ohe(null,e,b):A),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=ROa(n.url);if(O&&PA.protocols.indexOf(O)===-1){i(new ya("Unsupported protocol "+O+":",ya.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var KPS=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,c();let u=s instanceof Error?s:this.reason;i.abort(u instanceof ya?u:new ohe(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new ya(`timeout ${t} of ms exceeded`,ya.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=i;return f.unsubscribe=()=>kt.asap(c),f}},AWp=KPS;var JPS=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let i=0,n;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},$PS=async function*(e,t){for await(let r of YPS(e))yield*JPS(r,t)},YPS=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:i}=await t.read();if(r)break;yield i}}finally{await t.cancel()}},K6s=(e,t,r,i)=>{let n=$PS(e,t),a=0,o,c=f=>{o||(o=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:u}=await n.next();if(s){c(),f.close();return}let l=u.byteLength;if(r){let p=a+=l;r(p)}f.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(f){return c(f),n.return()}},{highWaterMark:2})};var mWp=64*1024,{isFunction:PIo}=kt,XPS=(({Request:e,Response:t})=>({Request:e,Response:t}))(kt.global),{ReadableStream:PWp,TextEncoder:jWp}=kt.global,wWp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ZPS=e=>{e=kt.merge.call({skipUndefined:!0},XPS,e);let{fetch:t,Request:r,Response:i}=e,n=t?PIo(t):typeof fetch=="function",a=PIo(r),o=PIo(i);if(!n)return!1;let c=n&&PIo(PWp),f=n&&(typeof jWp=="function"?(h=>y=>h.encode(y))(new jWp):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&wWp(()=>{let h=!1,y=new r(PA.origin,{body:new PWp,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&wWp(()=>kt.isReadableStream(new i("").body)),l={stream:u&&(h=>h.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!l[h]&&(l[h]=(y,b)=>{let v=y&&y[h];if(v)return v.call(y);throw new ya(`Response type '${h}' is not supported`,ya.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(kt.isBlob(h))return h.size;if(kt.isSpecCompliantForm(h))return(await new r(PA.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(kt.isArrayBufferView(h)||kt.isArrayBuffer(h))return h.byteLength;if(kt.isURLSearchParams(h)&&(h=h+""),kt.isString(h))return(await f(h)).byteLength},_=async(h,y)=>{let b=kt.toFiniteNumber(h.getContentLength());return b??p(y)};return async h=>{let{url:y,method:b,data:v,signal:O,cancelToken:A,timeout:g,onDownloadProgress:m,onUploadProgress:j,responseType:D,headers:E,withCredentials:M="same-origin",fetchOptions:B}=mIo(h),F=t||fetch;D=D?(D+"").toLowerCase():"text";let R=AWp([O,A&&A.toAbortSignal()],g),N=null,T=R&&R.unsubscribe&&(()=>{R.unsubscribe()}),W;try{if(j&&s&&b!=="get"&&b!=="head"&&(W=await _(E,v))!==0){let G=new r(y,{method:"POST",body:v,duplex:"half"}),Pe;if(kt.isFormData(v)&&(Pe=G.headers.get("content-type"))&&E.setContentType(Pe),G.body){let[ne,Ee]=QRn(W,Kbi(URn(j)));v=K6s(G.body,mWp,ne,Ee)}}kt.isString(M)||(M=M?"include":"omit");let Q=a&&"credentials"in r.prototype,H={...B,signal:R,method:b.toUpperCase(),headers:E.normalize().toJSON(),body:v,duplex:"half",credentials:Q?M:void 0};N=a&&new r(y,H);let ue=await(a?F(N,B):F(y,H)),se=u&&(D==="stream"||D==="response");if(u&&(m||se&&T)){let G={};["status","statusText","headers"].forEach(Qe=>{G[Qe]=ue[Qe]});let Pe=kt.toFiniteNumber(ue.headers.get("content-length")),[ne,Ee]=m&&QRn(Pe,Kbi(URn(m),!0))||[];ue=new i(K6s(ue.body,mWp,ne,()=>{Ee&&Ee(),T&&T()}),G)}D=D||"text";let x=await l[kt.findKey(l,D)||"text"](ue,h);return!se&&T&&T(),await new Promise((G,Pe)=>{g9t(G,Pe,{data:x,headers:LS.from(ue.headers),status:ue.status,statusText:ue.statusText,config:h,request:N})})}catch(Q){throw T&&T(),Q&&Q.name==="TypeError"&&/Load failed|fetch/i.test(Q.message)?Object.assign(new ya("Network Error",ya.ERR_NETWORK,h,N),{cause:Q.cause||Q}):ya.from(Q,Q&&Q.code,h,N)}}},kPS=new Map,J6s=e=>{let t=e?e.env:{},{fetch:r,Request:i,Response:n}=t,a=[i,n,r],o=a.length,c=o,f,s,u=kPS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:ZPS(t)),u=s;return s},oX5=J6s();var $6s={http:yWp,xhr:OWp,fetch:{get:J6s}};kt.forEach($6s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var EWp=e=>`- ${e}`,tjS=e=>kt.isFunction(e)||e===null||e===!1,jIo={getAdapter:(e,t)=>{e=kt.isArray(e)?e:[e];let{length:r}=e,i,n,a={};for(let o=0;o<r;o++){i=e[o];let c;if(n=i,!tjS(i)&&(n=$6s[(c=String(i)).toLowerCase()],n===void 0))throw new ya(`Unknown adapter '${c}'`);if(n&&(kt.isFunction(n)||(n=n.get(t))))break;a[c||"#"+o]=n}if(!n){let o=Object.entries(a).map(([f,s])=>`adapter ${f} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
|
|
@@ -1396,7 +1396,7 @@ ${g}${O}${m}${hQn}`});function $Qo({message:e,error:t,logger:r,logLevel:i=$s.Err
|
|
|
1396
1396
|
Run ${Lt.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1397
1397
|
Run ${Lt.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),fIi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Zoc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!rd_(e))return;let n=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)n+=`
|
|
1398
1398
|
${await OZS(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Lt.dim(c.currentVersion)+Lt.reset(" \u2192 ")+Lt.green(c.latestVersion);return n+=`
|
|
1399
|
-
`,i?fIi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function OZS(e){let r=await new td_.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 AZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await nd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await nd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function nd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await ehe({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function ad_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=k6(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function kQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await AZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...ad_(s,f,t.logger));else o.push(...ad_(c.versions,void 0,t.logger))}return o}var qPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${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=i}};var gQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var koc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),od_=typeof globalThis.AbortController=="function",ud_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",sd_=typeof globalThis.ReadableStream=="function",cd_=typeof globalThis.FormData=="function",eUo=["get","post","put","patch","head","delete"],mZS=()=>{};mZS();var ld_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},tUo=2147483647,fd_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,rUo=Symbol("stop"),dd_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},pd_={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 PZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=fd_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},_d_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},hd_=(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(_d_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},yd_=(e,t,r)=>{if(!e.body)return e;let i=PZS(r??e.body);return new Request(e,{duplex:"half",body:_d_(e.body,i,t)})};var OQn=e=>e!==null&&typeof e=="object";var TPa=(...e)=>{for(let t of e)if((!OQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return ruc({},...e)},euc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:ruc(e[r]??[],t[r]??[])}var tuc=(e={},t={})=>({beforeRequest:iUo(e,t,"beforeRequest"),beforeRetry:iUo(e,t,"beforeRetry"),afterResponse:iUo(e,t,"afterResponse"),beforeError:iUo(e,t,"beforeError")}),ruc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(OQn(n)){for(let[a,o]of Object.entries(n))OQn(o)&&a in t&&(o=ruc(t[a],o)),t={...t,[a]:o};OQn(n.hooks)&&(i=tuc(i,n.hooks),t.hooks=i),OQn(n.headers)&&(r=euc(r,n.headers),t.headers=r)}return t};var vd_=e=>eUo.includes(e)?e.toUpperCase():e,jZS=["get","put","head","delete","options","trace"],wZS=[408,413,429,500,502,503,504],EZS=[413,429,503],bd_={limit:2,methods:jZS,statusCodes:wZS,afterStatusCodes:EZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},gd_=(e={})=>{if(typeof e=="number")return{...bd_,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{...bd_,...e}};async function iuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new gQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function nuc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Od_=(e,t)=>{let r={};for(let i in t)!(i in pd_)&&!(i in dd_)&&!(i in e)&&(r[i]=t[i]);return r},Ad_=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 RPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>tUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${tUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new qPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!sd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return hd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(ld_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[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:euc(this._input.headers,r.headers),hooks:tuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:vd_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:gd_(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(od_&&ud_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(koc&&(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),Ad_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(cd_&&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(!koc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=yd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof gQn)throw t;if(t instanceof qPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),tUo);if(this._retryCount<1)throw r;await nuc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===rUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Od_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):iuc(this._originalRequest,t,this.abortController,this._options)}};var auc=e=>{let t=(r,i)=>RPa.create(r,TPa(e,i));for(let r of eUo)t[r]=(i,n)=>RPa.create(i,TPa(e,n,{method:r}));return t.create=r=>auc(TPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),auc(TPa(e,r))),t.stop=rUo,t},SZS=auc(),md_=SZS;var Gd_=ae(xd_(),1);function luc(e){let t=(0,Gd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Qp_=ae(Fp_(),1),Up_=ae(O_e(),1),Puc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},juc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function wuc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??luc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Qp_.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 s;try{s=await md_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Puc(e):l}if(t.allVersions)return s;let u=new juc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Up_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function LPa(e,t){let{version:r}=await wuc(e.toLowerCase(),t);return r}async function CCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:LPa(e.packageName,{version:t?"prerelease":"latest"})}var Lp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],hUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new ZQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"2.5.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Lt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qE}failWithoutThrowing(t,r){this.didSucceed=!1,$Qo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await CRn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await id_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1399
|
+
`,i?fIi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function OZS(e){let r=await new td_.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 AZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await nd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await nd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function nd_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await ehe({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function ad_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=k6(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function kQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await AZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...ad_(s,f,t.logger));else o.push(...ad_(c.versions,void 0,t.logger))}return o}var qPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${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=i}};var gQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var koc=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),od_=typeof globalThis.AbortController=="function",ud_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",sd_=typeof globalThis.ReadableStream=="function",cd_=typeof globalThis.FormData=="function",eUo=["get","post","put","patch","head","delete"],mZS=()=>{};mZS();var ld_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},tUo=2147483647,fd_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,rUo=Symbol("stop"),dd_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},pd_={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 PZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=fd_,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},_d_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},hd_=(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(_d_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},yd_=(e,t,r)=>{if(!e.body)return e;let i=PZS(r??e.body);return new Request(e,{duplex:"half",body:_d_(e.body,i,t)})};var OQn=e=>e!==null&&typeof e=="object";var TPa=(...e)=>{for(let t of e)if((!OQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return ruc({},...e)},euc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function iUo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:ruc(e[r]??[],t[r]??[])}var tuc=(e={},t={})=>({beforeRequest:iUo(e,t,"beforeRequest"),beforeRetry:iUo(e,t,"beforeRetry"),afterResponse:iUo(e,t,"afterResponse"),beforeError:iUo(e,t,"beforeError")}),ruc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(OQn(n)){for(let[a,o]of Object.entries(n))OQn(o)&&a in t&&(o=ruc(t[a],o)),t={...t,[a]:o};OQn(n.hooks)&&(i=tuc(i,n.hooks),t.hooks=i),OQn(n.headers)&&(r=euc(r,n.headers),t.headers=r)}return t};var vd_=e=>eUo.includes(e)?e.toUpperCase():e,jZS=["get","put","head","delete","options","trace"],wZS=[408,413,429,500,502,503,504],EZS=[413,429,503],bd_={limit:2,methods:jZS,statusCodes:wZS,afterStatusCodes:EZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},gd_=(e={})=>{if(typeof e=="number")return{...bd_,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{...bd_,...e}};async function iuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new gQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function nuc(e,{signal:t}){return new Promise((r,i)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(a),i(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}var Od_=(e,t)=>{let r={};for(let i in t)!(i in pd_)&&!(i in dd_)&&!(i in e)&&(r[i]=t[i]);return r},Ad_=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 RPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>tUo)throw new RangeError(`The \`timeout\` option cannot be greater than ${tUo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new qPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!sd_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return hd_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(ld_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[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:euc(this._input.headers,r.headers),hooks:tuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:vd_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:gd_(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(od_&&ud_){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(koc&&(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),Ad_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(cd_&&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(!koc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=yd_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof gQn)throw t;if(t instanceof qPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),tUo);if(this._retryCount<1)throw r;await nuc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===rUo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Od_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):iuc(this._originalRequest,t,this.abortController,this._options)}};var auc=e=>{let t=(r,i)=>RPa.create(r,TPa(e,i));for(let r of eUo)t[r]=(i,n)=>RPa.create(i,TPa(e,n,{method:r}));return t.create=r=>auc(TPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),auc(TPa(e,r))),t.stop=rUo,t},SZS=auc(),md_=SZS;var Gd_=ae(xd_(),1);function luc(e){let t=(0,Gd_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Qp_=ae(Fp_(),1),Up_=ae(O_e(),1),Puc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},juc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function wuc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??luc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Qp_.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 s;try{s=await md_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new Puc(e):l}if(t.allVersions)return s;let u=new juc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=Up_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function LPa(e,t){let{version:r}=await wuc(e.toLowerCase(),t);return r}async function CCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:LPa(e.packageName,{version:t?"prerelease":"latest"})}var Lp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],hUo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new ZQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"2.5.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Lt.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new qE}failWithoutThrowing(t,r){this.didSucceed=!1,$Qo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await CRn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await id_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1400
1400
|
`)||(r+=`
|
|
1401
1401
|
`),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=gws(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new SPa(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new qE}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await CRn()).sendEvent(t)}logger=W8t((t,...r)=>this.log(t,...r));stderr=W8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Vp_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Vp_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Lp_[this.numTasks++%Lp_.length],o=Lt.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===gj.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>uMi.indexOf(n.level)>=uMi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===$s.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 CCi({cliEnvironment:this.environment,includePreReleases:t}),i=k6(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await kQo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await Uoc({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Lt.yellow("?"),style:{answer:n=>Lt.cyan(n),message:n=>Lt.bold(n),highlight:n=>Lt.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
|
|
1402
1402
|
Cancelled by user.`),new qE):i}}async getInput(t){return await zoc({message:t.message,default:t.default})}};function Vp_(e){return`[${e}]:`}var _Ft=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};function yUo(e,t,r,i){if(typeof r!="function")throw new Error("method for before hook must be a function");return i||(i={}),Array.isArray(t)?t.reverse().reduce((n,a)=>yUo.bind(null,e,a,n,i),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((n,a)=>a.hook.bind(null,n,i),r)():r(i))}function Wp_(e,t,r,i){let n=i;e.registry[r]||(e.registry[r]=[]),t==="before"&&(i=(a,o)=>Promise.resolve().then(n.bind(null,o)).then(a.bind(null,o))),t==="after"&&(i=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,n(c,o))).then(()=>c)}),t==="error"&&(i=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>n(c,o))),e.registry[r].push({hook:i,orig:n})}function xp_(e,t,r){if(!e.registry[t])return;let i=e.registry[t].map(n=>n.orig).indexOf(r);i!==-1&&e.registry[t].splice(i,1)}var Gp_=Function.bind,Hp_=Gp_.bind(Gp_);function Kp_(e,t,r){let i=Hp_(xp_,null).apply(null,r?[t,r]:[t]);e.api={remove:i},e.remove=i,["before","error","after","wrap"].forEach(n=>{let a=r?[t,n,r]:[t,n];e[n]=e.api[n]=Hp_(Wp_,null).apply(null,a)})}function q2S(){let e=Symbol("Singular"),t={registry:{}},r=yUo.bind(null,t,e);return Kp_(r,t,e),r}function T2S(){let e={registry:{}},t=yUo.bind(null,e);return Kp_(t,e),t}var Jp_={Singular:q2S,Collection:T2S};var R2S="0.0.0-development",z2S=`octokit-endpoint.js/${R2S} ${GR()}`,N2S={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":z2S},mediaType:{format:""}};function F2S(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function Q2S(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 Xp_(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{Q2S(t[i])?i in e?r[i]=Xp_(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function $p_(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function Suc(e,t,r){if(typeof t=="string"){let[n,a]=t.split(" ");r=Object.assign(a?{method:n,url:a}:{url:n},r)}else r=Object.assign({},t);r.headers=F2S(r.headers),$p_(r),$p_(r.headers);let i=Xp_(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(i.mediaType.previews=e.mediaType.previews.filter(n=>!i.mediaType.previews.includes(n)).concat(i.mediaType.previews)),i.mediaType.previews=(i.mediaType.previews||[]).map(n=>n.replace(/-preview/,""))),i}function U2S(e,t){let r=/\?/.test(e)?"&":"?",i=Object.keys(t);return i.length===0?e:e+r+i.map(n=>n==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${n}=${encodeURIComponent(t[n])}`).join("&")}var L2S=/\{[^{}}]+\}/g;function V2S(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function W2S(e){let t=e.match(L2S);return t?t.map(V2S).reduce((r,i)=>r.concat(i),[]):[]}function Yp_(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function Zp_(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 MQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function VPa(e,t,r){return t=e==="+"||e==="#"?Zp_(t):MQn(t),r?MQn(r)+"="+t:t}function SQn(e){return e!=null}function Euc(e){return e===";"||e==="&"||e==="?"}function x2S(e,t,r,i){var n=e[r],a=[];if(SQn(n)&&n!=="")if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")n=n.toString(),i&&i!=="*"&&(n=n.substring(0,parseInt(i,10))),a.push(VPa(t,n,Euc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(SQn).forEach(function(o){a.push(VPa(t,o,Euc(t)?r:""))}):Object.keys(n).forEach(function(o){SQn(n[o])&&a.push(VPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(SQn).forEach(function(c){o.push(VPa(t,c))}):Object.keys(n).forEach(function(c){SQn(n[c])&&(o.push(MQn(c)),o.push(VPa(t,n[c].toString())))}),Euc(t)?a.push(MQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?SQn(n)&&a.push(MQn(r)):n===""&&(t==="&"||t==="?")?a.push(MQn(r)+"="):n===""&&a.push("");return a}function G2S(e){return{expand:H2S.bind(null,e)}}function H2S(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(i,n,a){if(n){let c="",f=[];if(r.indexOf(n.charAt(0))!==-1&&(c=n.charAt(0),n=n.substr(1)),n.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);f.push(x2S(t,c,u[1],u[2]||u[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return Zp_(a)}),e==="/"?e:e.replace(/\/$/,"")}function kp_(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=Yp_(e,["method","baseUrl","url","headers","request","mediaType"]),o=W2S(r);r=G2S(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),f=Yp_(a,c);if(!/application\/octet-stream/i.test(i.accept)&&(e.mediaType.format&&(i.accept=i.accept.split(/,/).map(u=>u.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let u=i.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];i.accept=u.concat(e.mediaType.previews).map(l=>{let p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?r=U2S(r,f):"data"in f?n=f.data:Object.keys(f).length&&(n=f),!i["content-type"]&&typeof n<"u"&&(i["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof n>"u"&&(n=""),Object.assign({method:t,url:r,headers:i},typeof n<"u"?{body:n}:null,e.request?{request:e.request}:null)}function K2S(e,t,r){return kp_(Suc(e,t,r))}function e__(e,t){let r=Suc(e,t),i=K2S.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:e__.bind(null,r),merge:Suc.bind(null,r),parse:kp_})}var t__=e__(null,N2S);var u__=ae(a__(),1);var hFt=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var J2S="10.0.6",$2S={headers:{"user-agent":`octokit-request.js/${J2S} ${GR()}`}};function Y2S(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 o__(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,i=e.request?.parseSuccessResponseBody!==!1,n=Y2S(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new hFt(p,500,{request:e});throw _.cause=l,_}let c=o.status,f=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:f,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new hFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await Muc(o),new hFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await Muc(o),new hFt(Z2S(u.data),c,{response:u,request:e});return u.data=i?await Muc(o):o.body,u}async function Muc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,u__.safeParse)(t);if(X2S(r)){let i="";try{return i=await e.text(),JSON.parse(i)}catch{return i}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function X2S(e){return e.type==="application/json"||e.type==="application/scim+json"}function Z2S(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 Duc(e,t){let r=e.defaults(t);return Object.assign(function(n,a){let o=r.merge(n,a);if(!o.request||!o.request.hook)return o__(r.parse(o));let c=(f,s)=>o__(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:Duc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:Duc.bind(null,r)})}var WO=Duc(t__,$2S);var k2S="0.0.0-development";function ekS(e){return`Request failed due to following response errors:
|
|
@@ -1469,7 +1469,7 @@ For more information:
|
|
|
1469
1469
|
`,h=Math.max(...u.map(y=>y.length));return _+=u.map(y=>{let b=`${e} ${process.argv.slice(2).join(" ")} --api ${y}`;return` \u203A ${Lt.bold(y.padEnd(h))} ${Lt.dim(b)}`}).join(`
|
|
1470
1470
|
`),r.failAndThrow(_)}}let l=[],p=n!=null?u.filter(_=>_===n):u;return await Promise.all(p.map(async _=>{let h=await SEa({absolutePathToWorkspace:Qt(o,ke.of(_)),context:r,cliVersion:i,workspaceName:_});h.didSucceed?l.push(h.workspace):(Kyc(h,r.logger),r.failAndThrow())})),l}let f=await SEa({absolutePathToWorkspace:t,context:r,cliVersion:i,workspaceName:void 0});return f.didSucceed?[f.workspace]:(Kyc(f,r.logger),[])}async function bO(e,t,r=!1){let i=e.addTask().start(),n=await Xyc({...t,cliName:e.environment.cliName,cliVersion:e.environment.packageVersion,context:i});return i.finish(),r&&n.docsWorkspaces!=null?e.registerWorkspaces([...n.apiWorkspaces,n.docsWorkspaces]):e.registerWorkspaces(n.apiWorkspaces),e.registerProject(n),n}var y1_=ae(Pba(),1),b1_=require("fs/promises");var c1_=require("fs/promises");var c3n={GitHub:"github",Local:"local-file-system",PackageRegistry:"publish"};async function l1_({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:i,apiKeyFallback:n="FERN_DEFAULT",project:{apiWorkspaces:a},outputLocation:o,excludedModes:c,includedModes:f}){let s={};await Promise.all(a.map(async l=>{await e.runTaskForWorkspace(l,async p=>{if(i!=null&&(l.workspaceName==null||!i.has(l.workspaceName)))return;let _=await ehe({absolutePathToWorkspace:l.absoluteFilePath,context:p});if(_==null||_.groups==null)return;let h=l.workspaceName??n;s[h]={};for(let y of _.groups)r!=null&&!r.has(y.groupName)||(s[h][y.groupName]=y.generators.filter(b=>{let v=!0;return f!=null&&(v=s1_(b,f)),c!=null&&(v=!s1_(b,c)),v}).filter(b=>t==null||t.has(b.name)).map(b=>b.name))})}));let u=Li.dump(s);if(o==null){process.stdout.write(u);return}try{await(0,c1_.writeFile)(o,u)}catch(l){e.failAndThrow(`Could not write file to the specified location: ${o}`,l)}}function s1_(e,t){let r,i=e.outputMode.type;switch(i){case"downloadFiles":r=c3n.Local;break;case"github":case"githubV2":r=c3n.GitHub;break;case"publish":case"publishV2":r=c3n.PackageRegistry;break;default:vt(i)}return t.has(r)}async function f1_({cliContext:e,generatorFilter:t,groupFilter:r,apiFilter:i,project:{apiWorkspaces:n}}){let a;return await Promise.all(n.map(async o=>{await e.runTaskForWorkspace(o,async c=>{if(i!=null&&(o.workspaceName==null||i!==o.workspaceName))return;let f=await ehe({absolutePathToWorkspace:o.absoluteFilePath,context:c});if(!(f==null||f.groups==null)){for(let s of f.groups)if(r===s.groupName)for(let u of s.generators)t===u.name&&(a=u)}})})),a}var d1_=require("fs/promises");async function p1_({project:e,outputLocation:t,context:r}){let i=e.config.organization;if(t==null){process.stdout.write(i);return}try{await(0,d1_.writeFile)(t,i)}catch(n){r.failAndThrow(`Could not write file to the specified location: ${t}`,n)}}var H9o=require("fs/promises"),MEa=ae(require("path"),1),Zyc=ae(O_e(),1),l3n=ae(VQ(),1);function _1_(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 m1M({absolutePathToWorkspace:e,context:t,generatorFilter:r,groupFilter:i,includeMajor:n,channel:a,cliVersion:o}){let c=await sBi({absolutePathToWorkspace:e});if(c==null||!await Ri(c))return t.logger.debug("Generators configuration file was not found, no generators to upgrade."),{updatedConfiguration:void 0,skippedMajorUpgrades:[],appliedUpgrades:[],alreadyUpToDate:[]};let f=await(0,H9o.readFile)(c);t.logger.debug(`Found generators: ${f.toString()}`);let s=l3n.default.parseDocument(f.toString()),u=s.get("groups");if(u==null)return t.logger.debug("No groups were found within the generators configuration, no generators to upgrade."),{updatedConfiguration:void 0,skippedMajorUpgrades:[],appliedUpgrades:[],alreadyUpToDate:[]};if(!l3n.default.isMap(u))return t.failAndThrow(`Expected 'groups' to be a map in ${MEa.default.relative(process.cwd(),c)}`),{updatedConfiguration:void 0,skippedMajorUpgrades:[],appliedUpgrades:[],alreadyUpToDate:[]};t.logger.debug(`Groups found: ${u.toString()}`);let l=[],p=[],_=[];for(let h of u.items){let y=h.key.value,b=h.value;if(!l3n.default.isMap(b)){t.failAndThrow(`Expected group ${y} to be a map in ${MEa.default.relative(process.cwd(),c)}`);continue}if(i!=null&&i!==y){t.logger.debug(`Skipping group ${y} as it does not match the filter: ${i}`);continue}let v=b.get("generators");if(!l3n.default.isSeq(v)){t.failAndThrow(`Expected group ${y} to have a 'generators' key in ${MEa.default.relative(process.cwd(),c)}`);continue}t.logger.debug(`Generators found: ${v.toString()}`);for(let O of v.items){l3n.default.isMap(O)||t.failAndThrow(`Expected generator in group ${y} to be a map in ${MEa.default.relative(process.cwd(),c)}`);let A=O.get("name");if(r!=null&&A!==r){t.logger.debug(`Skipping generator ${A} as it does not match the filter: ${r}`);continue}let g=NMi(A,t),m=O.get("version"),j=await dNt({generatorName:g,cliVersion:o,currentGeneratorVersion:m,channel:a,includeMajor:n,context:t}),D=j??m;if(j!=null&&(j!==m?(t.logger.debug(Lt.green(`Upgrading ${A} from ${m} to ${j}`)),O.set("version",j),p.push({generatorName:A,groupName:y,previousVersion:m,newVersion:j})):(t.logger.debug(Lt.gray(`${A} is already on the latest version: ${m}`)),_.push({generatorName:A,groupName:y,version:m}))),!n){let E=await dNt({generatorName:g,cliVersion:o,currentGeneratorVersion:D,channel:a,includeMajor:!0,context:t});if(E!=null){let M=Zyc.default.parse(D),B=Zyc.default.parse(E);M!=null&&B!=null&&B.major>M.major&&l.push({generatorName:A,currentVersion:D,latestMajorVersion:E})}}}}return{updatedConfiguration:s.toString(),skippedMajorUpgrades:l,appliedUpgrades:p,alreadyUpToDate:_}}async function h1_({cliContext:e,generator:t,group:r,project:{apiWorkspaces:i},includeMajor:n,channel:a}){let o=[],c=[],f=[];if(await Promise.all(i.map(async s=>{await e.runTaskForWorkspace(s,async u=>{let l=await P1n({absolutePathToWorkspace:s.absoluteFilePath,context:u})??{};if(l==null||l.groups==null){u.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}s.workspaceName==null?u.logger.info("Upgrading generators."):u.logger.info(`Upgrading generators in workspace: ${s.workspaceName}.`);let p=await m1M({absolutePathToWorkspace:s.absoluteFilePath,context:u,generatorFilter:t,groupFilter:r,includeMajor:n,channel:a,cliVersion:e.environment.packageVersion}),_=await sBi({absolutePathToWorkspace:s.absoluteFilePath});_!=null&&p.updatedConfiguration!=null&&await(0,H9o.writeFile)(_,p.updatedConfiguration),o.push(...p.skippedMajorUpgrades),p.appliedUpgrades.length>0&&c.push({workspace:s.workspaceName,upgrades:p.appliedUpgrades}),p.alreadyUpToDate.length>0&&f.push({workspace:s.workspaceName,upToDate:p.alreadyUpToDate})})})),c.length>0){e.logger.info(""),e.logger.info(Lt.green("Successfully upgraded generators:"));for(let{workspace:s,upgrades:u}of c){let l=new Map;for(let p of u){let _=l.get(p.groupName)??[];_.push(p),l.set(p.groupName,_)}for(let[p,_]of l){let h=s!=null?`[${s}] `:"";e.logger.info(Lt.green(`${h}Group ${p}:`));for(let y of _){e.logger.info(Lt.green(` - ${y.generatorName}: ${Lt.dim(y.previousVersion)} \u2192 ${y.newVersion}`));let b=_1_(y.generatorName);b!=null&&e.logger.info(Lt.dim(` Changelog: ${b}`))}}}}if(f.length>0){e.logger.info(""),e.logger.info(Lt.dim("Generators already on latest version:"));for(let{workspace:s,upToDate:u}of f){let l=new Map;for(let p of u){let _=l.get(p.groupName)??[];_.push(p),l.set(p.groupName,_)}for(let[p,_]of l){let h=s!=null?`[${s}] `:"";e.logger.info(Lt.dim(`${h}Group ${p}:`));for(let y of _)e.logger.info(Lt.dim(` - ${y.generatorName}: ${y.version} (latest)`))}}}if(c.length===0&&f.length===0){let s=r!=null?` for group ${r}`:t!=null?` for generator ${t}`:"";e.logger.info(""),e.logger.info(Lt.gray(`No generators found${s}.`))}if(o.length>0){e.logger.info(""),e.logger.info(Lt.yellow("Major version upgrades available:"));for(let s of o){e.logger.info(Lt.yellow(` - ${s.generatorName}: ${s.currentVersion} \u2192 ${s.latestMajorVersion}`));let u=t!=null?`fern generator upgrade --generator ${s.generatorName} --include-major`:"fern generator upgrade --include-major";e.logger.info(Lt.yellow(` Run: ${u}`));let l=_1_(s.generatorName);l!=null&&e.logger.info(Lt.yellow(` Changelog: ${l}`))}}}function v1_(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 p1_({project:await bO(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),context:t,outputLocation:r.output})})}function g1_(e,t){e.command("generator","Operate on the generators within your Fern configuration",r=>{r.command("list",!1,i=>i.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generators",{string:!0,type:"array",description:"The type of generator to include in the list, ex: `fern-typescript-node-sdk`. If omitted, all generators will be listed."}).option("groups",{type:"array",string:!0,description:"The groups to include generators from, if group is not specified, the all generators of the specified type will be listed."}).option("apis",{type:"array",string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("api-fallback",{string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("include-mode",{choices:Object.values(c3n),type:"array",description:"The generator output modes to include within the outputted list."}).option("exclude-mode",{choices:Object.values(c3n),type:"array",description:"The generator output modes to exclude within the outputted list."}),async i=>{await t.instrumentPostHogEvent({command:"fern generator list",properties:{outputLocation:i.output}}),await l1_({project:await bO(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),generatorFilter:i.generators?new Set(i.generators):void 0,groupFilter:i.groups?new Set(i.groups):void 0,apiFilter:i.apis?new Set(i.apis):void 0,apiKeyFallback:i.apiFallback,cliContext:t,outputLocation:i.output,includedModes:i["include-mode"]?new Set(i["include-mode"]):void 0,excludedModes:i["exclude-mode"]?new Set(i["exclude-mode"]):void 0})}).command("upgrade",`Upgrades the specified generator in ${IS} to the latest stable version.`,i=>i.option("generator",{string:!0,description:"The type of generator to upgrade, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,description:"The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."}).option("api",{string:!0,description:"The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."}).option("include-major",{boolean:!0,default:!1,description:"Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."}).option("channel",{demandOption:!1,choices:Object.values(y1_.FernRegistry.generators.ReleaseType)}).option("list",{demandOption:!1,boolean:!0,default:!1,description:"When specified, a list of available upgrades will be displayed, but no upgrade will be taken."}),async i=>{await t.instrumentPostHogEvent({command:"fern generator upgrade",properties:{generator:i.generator,version:i.version,api:i.api,group:i.group,includeMajor:i.includeMajor,rc:i.rc}});let n=await bO(t,{commandLineApiWorkspace:i.api,defaultToAllApiWorkspaces:!0});if(i.list){t.suppressUpgradeMessage();let a=await kQo({cliContext:t,project:n,generatorFilter:i.generator,groupFilter:i.group,includeMajor:i.includeMajor,channel:i.channel}),o=await Zoc({generatorUpgradeInfo:a,header:`Generator Upgrades
|
|
1471
1471
|
`,includeBoxen:!0});o!=null&&t.logger.info(o)}else await h1_({cliContext:t,generator:i.generator,group:i.group,project:await bO(t,{commandLineApiWorkspace:i.api,defaultToAllApiWorkspaces:!0}),includeMajor:i.includeMajor,channel:i.channel})}).command("get",!1,i=>i.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("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 i=>{await t.instrumentPostHogEvent({command:"fern generator get",properties:{generator:i.generator,version:i.version,api:i.api,group:i.group,includeMajor:i.includeMajor}});let n=await f1_({cliContext:t,generatorFilter:i.generator,groupFilter:i.group,apiFilter:i.api,project:await bO(t,{commandLineApiWorkspace:i.api,defaultToAllApiWorkspaces:!0})});if(n==null){let o=i.api?` for API ${i.api}`:"";t.failAndThrow(`Generator ${i.generator}, in group ${i.group}${o} was not found.`)}let a={};if(i.version&&(a.version=n.version,i.output==null)){process.stdout.write(n.version);return}if(i.language)if(n.language!=null){if(a.language=n.language,i.output==null){process.stdout.write(n.language);return}}else t.logger.warn(`Language information is not available for generator ${n.name} in group ${i.group}`);if(i.repository){let o=n.outputMode.type==="github"?n.outputMode.repo:n.outputMode.type==="githubV2"?n.outputMode.githubV2.repo:void 0;if(o!=null){if(a.repository=o,i.output==null){process.stdout.write(a.repository);return}}else t.logger.warn(`Repository information is not available for generator ${n.name} in group ${i.group}`)}if(i.output)try{await(0,b1_.writeFile)(i.output,JSON.stringify(a,null,2))}catch(o){t.failAndThrow(`Could not write file to the specified location: ${i.output}`,o)}})})}var O1_=require("fs/promises");async function A1_({project:{apiWorkspaces:e},generatorName:t,groupName:r,cliContext:i}){await Promise.all(e.map(async n=>{await i.runTaskForWorkspace(n,async a=>{let o=await P1n({absolutePathToWorkspace:n.absoluteFilePath,context:a})??{},c=await AQs({generatorName:t,generatorsConfiguration:o,groupName:r,context:a,cliVersion:i.environment.packageVersion}),f=n.generatorsConfiguration?.absolutePathToConfiguration??await sBi({absolutePathToWorkspace:n.absoluteFilePath});f!=null&&(await(0,O1_.writeFile)(f,`# yaml-language-server: $schema=https://schema.buildwithfern.dev/generators-yml.json
|
|
1472
|
-
`+Li.dump(c)),a.logger.info(Lt.green(`Added ${t} generator`)))})}))}var P1_=require("fs/promises"),j1_=ae(O_e(),1);async function w1_({context:e,from:t,to:r,fromVersion:i,generatorVersions:n}){let a=new oPa,o=P1M(await a.check({from:await m1_({context:e,filepath:t,flagName:"from"}),to:await m1_({context:e,filepath:r,flagName:"to"})})),c=E1M(e,n),{bump:f,errors:s}=j1M(o,c);if(i==null)return{bump:f??"patch",errors:s};if(f==="no_change")return{bump:"no_change",nextVersion:i,errors:s};let u=f??"patch",l=j1_.default.inc(i,u);if(!l)throw e.failWithoutThrowing(`Invalid current version: ${i}`),new qE;return{bump:u,nextVersion:l,errors:s}}async function m1_({context:e,filepath:t,flagName:r}){let i=Vr.of(_s(F0(),t));if(!await Ri(i,"file"))throw e.failWithoutThrowing(`File not found: ${i}`),new qE;let n=await(0,P1_.readFile)(i,"utf-8"),a=zn.IntermediateRepresentation.parse(JSON.parse(n));if(!a.ok)throw e.failWithoutThrowing(`Invalid --${r}; expected a filepath containing a valid IR`),new qE;return a.value}function P1M(e){return{bump:e.bump,errors:e.errors.map(t=>t.message)}}function j1M(e,t){return{bump:w1M(e.bump,t.bump),errors:[...e.errors,...t.errors]}}function w1M(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 E1M(e,t){if(t===void 0)return{bump:void 0,errors:[]};let{from:r,to:i}=t;try{let n=S1M(Xws(r,i)),a=[];return n==="major"&&a.push("Generator version changed by major version."),{bump:n,errors:a}}catch(n){throw e.failWithoutThrowing(`Error diffing generator versions ${r} and ${i}: ${n}`),new qE}}function S1M(e){if(e!==null)switch(e){case"major":case"minor":case"patch":return e;default:return}}var E1_=require("fs"),K9o=class{parse({absoluteFilePath:t}){let r=(0,E1_.readFileSync)(t,"utf-8"),i=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),n=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:i?.[1],packageName:n?.[1],serviceName:a?.[1]}}};var Zw=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let i=this.resolveSource({source:t});return i==null&&(pWt(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}`)),i}resolveSource({source:t}){return pWt(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let n=new K9o().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ke.of(t.proto),csharpNamespace:n.csharpNamespace,packageName:n.packageName,serviceName:n.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let i={type:"openapi",absoluteFilePath:r,relativeFilePath:ke.of(t.openapi)};return this.sourceCache.set(r,i),i}};var DEa=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,i,n){t&&r&&(i!=null?t[r][i]=n:t[r]=n)}remove(t,r,i){t&&r&&(i!=null?t[r].splice(i,1):delete t[r])}};var J9o=class extends DEa{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:i=>this.replacement=i},this.enter=t,this.leave=r}visit(t,r,i,n){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,i,n),this.replacement&&(t=this.replacement,this.replace(r,i,n,t)),this.should_remove&&this.remove(r,i,n);let s=this.should_skip,u=this.should_remove;if(this.should_skip=o,this.should_remove=c,this.replacement=f,s)return t;if(u)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 s=c[f];S1_(s)&&(this.visit(s,t,a,f)||f--)}}else S1_(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,i,n),this.replacement&&(t=this.replacement,this.replace(r,i,n,t)),this.should_remove&&this.remove(r,i,n);let f=this.should_remove;if(this.replacement=o,this.should_remove=c,f)return null}}return t}};function S1_(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function QC(e,{enter:t,leave:r}){return new J9o(t,r).visit(e,null)}function Igi(e){if(e==null)return;let t=[],r=!1;if(QC(e,{enter(i){(i.type==="FunctionDeclaration"||i.type==="ArrowFunctionExpression"||i.type==="JSXOpeningElement"||i.type==="JSXOpeningFragment"||i.type==="Identifier")&&(r=!0,this.skip()),i.type==="Literal"&&t.push(i.value)}}),!r)return t.length===1?t[0]:void 0}function e1i(e){if(typeof e=="string")return e;if(e?.type==="mdxJsxAttributeValueExpression")return Igi(e.data?.estree)}function kyc(e){let t=b9i(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 $9o(e){return e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement"}function Y9o(e){return e.type==="mdxFlowExpression"||e.type==="mdxTextExpression"}function Cgi(e){return e.type==="mdxJsxAttribute"}function X9o(e){return e.type==="mdxJsxExpressionAttribute"}var UEa=ae(F_e(),1),vR_=require("path");var bR_=ae(F_e(),1);var M1_={tokenize:M1M};function M1M(e){let t=e.attempt(this.parser.constructs.contentInitial,i,n),r;return t;function i(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Su(e,t,"linePrefix")}function n(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 nn(c)?(e.consume(c),e.exit("chunkText"),a):(e.consume(c),o)}}var B1_={tokenize:D1M},D1_={tokenize:B1M};function D1M(e){let t=this,r=[],i=0,n,a,o;return c;function c(A){if(i<r.length){let g=r[i];return t.containerState=g[1],e.attempt(g[0].continuation,f,s)(A)}return s(A)}function f(A){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,n&&O();let g=t.events.length,m=g,j;for(;m--;)if(t.events[m][0]==="exit"&&t.events[m][1].type==="chunkFlow"){j=t.events[m][1].end;break}v(i);let D=g;for(;D<t.events.length;)t.events[D][1].end={...j},D++;return gB(t.events,m+1,0,t.events.slice(g)),t.events.length=D,s(A)}return c(A)}function s(A){if(i===r.length){if(!n)return p(A);if(n.currentConstruct&&n.currentConstruct.concrete)return h(A);t.interrupt=!!(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(D1_,u,l)(A)}function u(A){return n&&O(),v(i),p(A)}function l(A){return t.parser.lazy[t.now().line]=i!==r.length,o=t.now().offset,h(A)}function p(A){return t.containerState={},e.attempt(D1_,_,h)(A)}function _(A){return i++,r.push([t.currentConstruct,t.containerState]),p(A)}function h(A){if(A===null){n&&O(),v(0),e.consume(A);return}return n=n||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:n,contentType:"flow",previous:a}),y(A)}function y(A){if(A===null){b(e.exit("chunkFlow"),!0),v(0),e.consume(A);return}return nn(A)?(e.consume(A),b(e.exit("chunkFlow")),i=0,t.interrupt=void 0,c):(e.consume(A),y)}function b(A,g){let m=t.sliceStream(A);if(g&&m.push(null),A.previous=a,a&&(a.next=A),a=A,n.defineSkip(A.start),n.write(m),t.parser.lazy[A.start.line]){let j=n.events.length;for(;j--;)if(n.events[j][1].start.offset<o&&(!n.events[j][1].end||n.events[j][1].end.offset>o))return;let D=t.events.length,E=D,M,B;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){if(M){B=t.events[E][1].end;break}M=!0}for(v(i),j=D;j<t.events.length;)t.events[j][1].end={...B},j++;gB(t.events,E+1,0,t.events.slice(D)),t.events.length=j}}function v(A){let g=r.length;for(;g-- >A;){let m=r[g];t.containerState=m[1],m[0].exit.call(t,e)}r.length=A}function O(){n.write([null]),a=void 0,n=void 0,t.containerState._closeFlow=void 0}}function B1M(e,t,r){return Su(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var I1_={tokenize:I1M};function I1M(e){let t=this,r=e.attempt(o0e,i,e.attempt(this.parser.constructs.flowInitial,n,Su(e,e.attempt(this.parser.constructs.flow,n,e.attempt(Y$s,n)),"linePrefix")));return r;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function n(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,r}}var C1_={resolveAll:z1_()},q1_=R1_("string"),T1_=R1_("text");function R1_(e){return{resolveAll:z1_(e==="text"?C1M:void 0),tokenize:t};function t(r){let i=this,n=this.parser.constructs[e],a=r.attempt(n,o,c);return o;function o(u){return s(u)?a(u):c(u)}function c(u){if(u===null){r.consume(u);return}return r.enter("data"),r.consume(u),f}function f(u){return s(u)?(r.exit("data"),a(u)):(r.consume(u),f)}function s(u){if(u===null)return!0;let l=n[u],p=-1;if(l)for(;++p<l.length;){let _=l[p];if(!_.previous||_.previous.call(i,i.previous))return!0}return!1}}}function z1_(e){return t;function t(r,i){let n=-1,a;for(;++n<=r.length;)a===void 0?r[n]&&r[n][1].type==="data"&&(a=n,n++):(!r[n]||r[n][1].type!=="data")&&(n!==a+2&&(r[a][1].end=r[n-1][1].end,r.splice(a+2,n-a-2),n=a+2),a=void 0);return e?e(r,i):r}}function C1M(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 i=e[r-1][1],n=t.sliceStream(i),a=n.length,o=-1,c=0,f;for(;a--;){let s=n[a];if(typeof s=="string"){for(o=s.length;s.charCodeAt(o-1)===32;)c++,o--;if(o)break;o=-1}else if(s===-2)f=!0,c++;else if(s!==-1){a++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let s={type:r===e.length||f||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:i.start._bufferIndex+o,_index:i.start._index+a,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...s.start},i.start.offset===i.end.offset?Object.assign(i,s):(e.splice(r,0,["enter",s,t],["exit",s,t]),r+=2)}r++}return e}var ebc={};Kt(ebc,{attentionMarkers:()=>U1M,contentInitial:()=>T1M,disable:()=>L1M,document:()=>q1M,flow:()=>z1M,flowInitial:()=>R1M,insideSpan:()=>Q1M,string:()=>N1M,text:()=>F1M});var q1M={42:AL,43:AL,45:AL,48:AL,49:AL,50:AL,51:AL,52:AL,53:AL,54:AL,55:AL,56:AL,57:AL,62:LCo},T1M={91:X$s},R1M={[-2]:wAa,[-1]:wAa,32:wAa},z1M={35:k$s,42:q6i,45:[YCo,q6i],60:tYs,61:YCo,95:q6i,96:xCo,126:xCo},N1M={38:WCo,92:VCo},F1M={[-5]:SAa,[-4]:SAa,[-3]:SAa,33:iYs,38:WCo,42:jAa,60:[J$s,rYs],91:nYs,92:[Z$s,VCo],93:C6i,95:jAa,96:$$s},Q1M={null:[jAa,C1_]},U1M={null:[42,95]},L1M={null:[]};function N1_(e,t,r){let i={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},a=[],o=[],c=[],f=!0,s={attempt:M(D),check:M(E),consume:g,enter:m,exit:j,interrupt:M(E,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:b,parser:e,previous:null,sliceSerialize:h,sliceStream:y,write:_},l=t.tokenize.call(u,s),p;return t.resolveAll&&a.push(t),u;function _(N){return o=tx(o,N),O(),o[o.length-1]!==null?[]:(B(t,0),u.events=jIi(a,u.events,u),u.events)}function h(N,T){return W1M(y(N),T)}function y(N){return V1M(o,N)}function b(){let{_bufferIndex:N,_index:T,line:W,column:Q,offset:H}=i;return{_bufferIndex:N,_index:T,line:W,column:Q,offset:H}}function v(N){n[N.line]=N.column,R()}function O(){let N;for(;i._index<o.length;){let T=o[i._index];if(typeof T=="string")for(N=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===N&&i._bufferIndex<T.length;)A(T.charCodeAt(i._bufferIndex));else A(T)}}function A(N){f=void 0,p=N,l=l(N)}function g(N){nn(N)?(i.line++,i.column=1,i.offset+=N===-3?2:1,R()):N!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===o[i._index].length&&(i._bufferIndex=-1,i._index++)),u.previous=N,f=!0}function m(N,T){let W=T||{};return W.type=N,W.start=b(),u.events.push(["enter",W,u]),c.push(W),W}function j(N){let T=c.pop();return T.end=b(),u.events.push(["exit",T,u]),T}function D(N,T){B(N,T.from)}function E(N,T){T.restore()}function M(N,T){return W;function W(Q,H,ue){let se,x,G,Pe;return Array.isArray(Q)?Ee(Q):"tokenize"in Q?Ee([Q]):ne(Q);function ne(Ve){return $e;function $e(wr){let Bt=wr!==null&&Ve[wr],Mt=wr!==null&&Ve.null,Et=[...Array.isArray(Bt)?Bt:Bt?[Bt]:[],...Array.isArray(Mt)?Mt:Mt?[Mt]:[]];return Ee(Et)(wr)}}function Ee(Ve){return se=Ve,x=0,Ve.length===0?ue:Qe(Ve[x])}function Qe(Ve){return $e;function $e(wr){return Pe=F(),G=Ve,Ve.partial||(u.currentConstruct=Ve),Ve.name&&u.parser.constructs.disable.null.includes(Ve.name)?ee(wr):Ve.tokenize.call(T?Object.assign(Object.create(u),T):u,s,re,ee)(wr)}}function re(Ve){return f=!0,N(G,Pe),H}function ee(Ve){return f=!0,Pe.restore(),++x<se.length?Qe(se[x]):ue}}}function B(N,T){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&gB(u.events,T,u.events.length-T,N.resolve(u.events.slice(T),u)),N.resolveTo&&(u.events=N.resolveTo(u.events,u))}function F(){let N=b(),T=u.previous,W=u.currentConstruct,Q=u.events.length,H=Array.from(c);return{from:Q,restore:ue};function ue(){i=N,u.previous=T,u.currentConstruct=W,u.events.length=Q,c=H,R()}}function R(){i.line in n&&i.column<2&&(i.column=n[i.line],i.offset+=n[i.line]-1)}}function V1M(e,t){let r=t.start._index,i=t.start._bufferIndex,n=t.end._index,a=t.end._bufferIndex,o;if(r===n)o=[e[r].slice(i,a)];else{if(o=e.slice(r,n),i>-1){let c=o[0];typeof c=="string"?o[0]=c.slice(i):o.shift()}a>0&&o.push(e[n].slice(0,a))}return o}function W1M(e,t){let r=-1,i=[],n;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=`
|
|
1472
|
+
`+Li.dump(c)),a.logger.info(Lt.green(`Added ${t} generator`)))})}))}var P1_=require("fs/promises"),j1_=ae(O_e(),1);async function w1_({context:e,from:t,to:r,fromVersion:i,generatorVersions:n}){let a=new oPa,o=P1M(await a.check({from:await m1_({context:e,filepath:t,flagName:"from"}),to:await m1_({context:e,filepath:r,flagName:"to"})})),c=E1M(e,n),{bump:f,errors:s}=j1M(o,c);if(i==null)return{bump:f??"patch",errors:s};if(f==="no_change")return{bump:"no_change",nextVersion:i,errors:s};let u=f??"patch",l=j1_.default.inc(i,u);if(!l)throw e.failWithoutThrowing(`Invalid current version: ${i}`),new qE;return{bump:u,nextVersion:l,errors:s}}async function m1_({context:e,filepath:t,flagName:r}){let i=Vr.of(_s(F0(),t));if(!await Ri(i,"file"))throw e.failWithoutThrowing(`File not found: ${i}`),new qE;let n=await(0,P1_.readFile)(i,"utf-8"),a=zn.IntermediateRepresentation.parse(JSON.parse(n));if(!a.ok)throw e.failWithoutThrowing(`Invalid --${r}; expected a filepath containing a valid IR`),new qE;return a.value}function P1M(e){return{bump:e.bump,errors:e.errors.map(t=>t.message)}}function j1M(e,t){return{bump:w1M(e.bump,t.bump),errors:[...e.errors,...t.errors]}}function w1M(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 E1M(e,t){if(t===void 0)return{bump:void 0,errors:[]};let{from:r,to:i}=t;try{let n=S1M(Xws(r,i)),a=[];return n==="major"&&a.push("Generator version changed by major version."),{bump:n,errors:a}}catch(n){throw e.failWithoutThrowing(`Error diffing generator versions ${r} and ${i}: ${n}`),new qE}}function S1M(e){if(e!==null)switch(e){case"major":case"minor":case"patch":return e;default:return}}var E1_=require("fs"),K9o=class{parse({absoluteFilePath:t}){let r=(0,E1_.readFileSync)(t,"utf-8"),i=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),n=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:i?.[1],packageName:n?.[1],serviceName:a?.[1]}}};var Zw=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let i=this.resolveSource({source:t});return i==null&&pWt(t)&&this.context.logger.warn(`Cannot resolve source ${t.proto} from file ${r}`),i}resolveSource({source:t}){return pWt(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let n=new K9o().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ke.of(t.proto),csharpNamespace:n.csharpNamespace,packageName:n.packageName,serviceName:n.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let i={type:"openapi",absoluteFilePath:r,relativeFilePath:ke.of(t.openapi)};return this.sourceCache.set(r,i),i}};var DEa=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,i,n){t&&r&&(i!=null?t[r][i]=n:t[r]=n)}remove(t,r,i){t&&r&&(i!=null?t[r].splice(i,1):delete t[r])}};var J9o=class extends DEa{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:i=>this.replacement=i},this.enter=t,this.leave=r}visit(t,r,i,n){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,i,n),this.replacement&&(t=this.replacement,this.replace(r,i,n,t)),this.should_remove&&this.remove(r,i,n);let s=this.should_skip,u=this.should_remove;if(this.should_skip=o,this.should_remove=c,this.replacement=f,s)return t;if(u)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 s=c[f];S1_(s)&&(this.visit(s,t,a,f)||f--)}}else S1_(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,i,n),this.replacement&&(t=this.replacement,this.replace(r,i,n,t)),this.should_remove&&this.remove(r,i,n);let f=this.should_remove;if(this.replacement=o,this.should_remove=c,f)return null}}return t}};function S1_(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}function QC(e,{enter:t,leave:r}){return new J9o(t,r).visit(e,null)}function Igi(e){if(e==null)return;let t=[],r=!1;if(QC(e,{enter(i){(i.type==="FunctionDeclaration"||i.type==="ArrowFunctionExpression"||i.type==="JSXOpeningElement"||i.type==="JSXOpeningFragment"||i.type==="Identifier")&&(r=!0,this.skip()),i.type==="Literal"&&t.push(i.value)}}),!r)return t.length===1?t[0]:void 0}function e1i(e){if(typeof e=="string")return e;if(e?.type==="mdxJsxAttributeValueExpression")return Igi(e.data?.estree)}function kyc(e){let t=b9i(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 $9o(e){return e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement"}function Y9o(e){return e.type==="mdxFlowExpression"||e.type==="mdxTextExpression"}function Cgi(e){return e.type==="mdxJsxAttribute"}function X9o(e){return e.type==="mdxJsxExpressionAttribute"}var UEa=ae(F_e(),1),vR_=require("path");var bR_=ae(F_e(),1);var M1_={tokenize:M1M};function M1M(e){let t=e.attempt(this.parser.constructs.contentInitial,i,n),r;return t;function i(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Su(e,t,"linePrefix")}function n(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 nn(c)?(e.consume(c),e.exit("chunkText"),a):(e.consume(c),o)}}var B1_={tokenize:D1M},D1_={tokenize:B1M};function D1M(e){let t=this,r=[],i=0,n,a,o;return c;function c(A){if(i<r.length){let g=r[i];return t.containerState=g[1],e.attempt(g[0].continuation,f,s)(A)}return s(A)}function f(A){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,n&&O();let g=t.events.length,m=g,j;for(;m--;)if(t.events[m][0]==="exit"&&t.events[m][1].type==="chunkFlow"){j=t.events[m][1].end;break}v(i);let D=g;for(;D<t.events.length;)t.events[D][1].end={...j},D++;return gB(t.events,m+1,0,t.events.slice(g)),t.events.length=D,s(A)}return c(A)}function s(A){if(i===r.length){if(!n)return p(A);if(n.currentConstruct&&n.currentConstruct.concrete)return h(A);t.interrupt=!!(n.currentConstruct&&!n._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(D1_,u,l)(A)}function u(A){return n&&O(),v(i),p(A)}function l(A){return t.parser.lazy[t.now().line]=i!==r.length,o=t.now().offset,h(A)}function p(A){return t.containerState={},e.attempt(D1_,_,h)(A)}function _(A){return i++,r.push([t.currentConstruct,t.containerState]),p(A)}function h(A){if(A===null){n&&O(),v(0),e.consume(A);return}return n=n||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:n,contentType:"flow",previous:a}),y(A)}function y(A){if(A===null){b(e.exit("chunkFlow"),!0),v(0),e.consume(A);return}return nn(A)?(e.consume(A),b(e.exit("chunkFlow")),i=0,t.interrupt=void 0,c):(e.consume(A),y)}function b(A,g){let m=t.sliceStream(A);if(g&&m.push(null),A.previous=a,a&&(a.next=A),a=A,n.defineSkip(A.start),n.write(m),t.parser.lazy[A.start.line]){let j=n.events.length;for(;j--;)if(n.events[j][1].start.offset<o&&(!n.events[j][1].end||n.events[j][1].end.offset>o))return;let D=t.events.length,E=D,M,B;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){if(M){B=t.events[E][1].end;break}M=!0}for(v(i),j=D;j<t.events.length;)t.events[j][1].end={...B},j++;gB(t.events,E+1,0,t.events.slice(D)),t.events.length=j}}function v(A){let g=r.length;for(;g-- >A;){let m=r[g];t.containerState=m[1],m[0].exit.call(t,e)}r.length=A}function O(){n.write([null]),a=void 0,n=void 0,t.containerState._closeFlow=void 0}}function B1M(e,t,r){return Su(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}var I1_={tokenize:I1M};function I1M(e){let t=this,r=e.attempt(o0e,i,e.attempt(this.parser.constructs.flowInitial,n,Su(e,e.attempt(this.parser.constructs.flow,n,e.attempt(Y$s,n)),"linePrefix")));return r;function i(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function n(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,r}}var C1_={resolveAll:z1_()},q1_=R1_("string"),T1_=R1_("text");function R1_(e){return{resolveAll:z1_(e==="text"?C1M:void 0),tokenize:t};function t(r){let i=this,n=this.parser.constructs[e],a=r.attempt(n,o,c);return o;function o(u){return s(u)?a(u):c(u)}function c(u){if(u===null){r.consume(u);return}return r.enter("data"),r.consume(u),f}function f(u){return s(u)?(r.exit("data"),a(u)):(r.consume(u),f)}function s(u){if(u===null)return!0;let l=n[u],p=-1;if(l)for(;++p<l.length;){let _=l[p];if(!_.previous||_.previous.call(i,i.previous))return!0}return!1}}}function z1_(e){return t;function t(r,i){let n=-1,a;for(;++n<=r.length;)a===void 0?r[n]&&r[n][1].type==="data"&&(a=n,n++):(!r[n]||r[n][1].type!=="data")&&(n!==a+2&&(r[a][1].end=r[n-1][1].end,r.splice(a+2,n-a-2),n=a+2),a=void 0);return e?e(r,i):r}}function C1M(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 i=e[r-1][1],n=t.sliceStream(i),a=n.length,o=-1,c=0,f;for(;a--;){let s=n[a];if(typeof s=="string"){for(o=s.length;s.charCodeAt(o-1)===32;)c++,o--;if(o)break;o=-1}else if(s===-2)f=!0,c++;else if(s!==-1){a++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(c=0),c){let s={type:r===e.length||f||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:i.start._bufferIndex+o,_index:i.start._index+a,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...s.start},i.start.offset===i.end.offset?Object.assign(i,s):(e.splice(r,0,["enter",s,t],["exit",s,t]),r+=2)}r++}return e}var ebc={};Kt(ebc,{attentionMarkers:()=>U1M,contentInitial:()=>T1M,disable:()=>L1M,document:()=>q1M,flow:()=>z1M,flowInitial:()=>R1M,insideSpan:()=>Q1M,string:()=>N1M,text:()=>F1M});var q1M={42:AL,43:AL,45:AL,48:AL,49:AL,50:AL,51:AL,52:AL,53:AL,54:AL,55:AL,56:AL,57:AL,62:LCo},T1M={91:X$s},R1M={[-2]:wAa,[-1]:wAa,32:wAa},z1M={35:k$s,42:q6i,45:[YCo,q6i],60:tYs,61:YCo,95:q6i,96:xCo,126:xCo},N1M={38:WCo,92:VCo},F1M={[-5]:SAa,[-4]:SAa,[-3]:SAa,33:iYs,38:WCo,42:jAa,60:[J$s,rYs],91:nYs,92:[Z$s,VCo],93:C6i,95:jAa,96:$$s},Q1M={null:[jAa,C1_]},U1M={null:[42,95]},L1M={null:[]};function N1_(e,t,r){let i={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0},n={},a=[],o=[],c=[],f=!0,s={attempt:M(D),check:M(E),consume:g,enter:m,exit:j,interrupt:M(E,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:b,parser:e,previous:null,sliceSerialize:h,sliceStream:y,write:_},l=t.tokenize.call(u,s),p;return t.resolveAll&&a.push(t),u;function _(N){return o=tx(o,N),O(),o[o.length-1]!==null?[]:(B(t,0),u.events=jIi(a,u.events,u),u.events)}function h(N,T){return W1M(y(N),T)}function y(N){return V1M(o,N)}function b(){let{_bufferIndex:N,_index:T,line:W,column:Q,offset:H}=i;return{_bufferIndex:N,_index:T,line:W,column:Q,offset:H}}function v(N){n[N.line]=N.column,R()}function O(){let N;for(;i._index<o.length;){let T=o[i._index];if(typeof T=="string")for(N=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===N&&i._bufferIndex<T.length;)A(T.charCodeAt(i._bufferIndex));else A(T)}}function A(N){f=void 0,p=N,l=l(N)}function g(N){nn(N)?(i.line++,i.column=1,i.offset+=N===-3?2:1,R()):N!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===o[i._index].length&&(i._bufferIndex=-1,i._index++)),u.previous=N,f=!0}function m(N,T){let W=T||{};return W.type=N,W.start=b(),u.events.push(["enter",W,u]),c.push(W),W}function j(N){let T=c.pop();return T.end=b(),u.events.push(["exit",T,u]),T}function D(N,T){B(N,T.from)}function E(N,T){T.restore()}function M(N,T){return W;function W(Q,H,ue){let se,x,G,Pe;return Array.isArray(Q)?Ee(Q):"tokenize"in Q?Ee([Q]):ne(Q);function ne(Ve){return $e;function $e(wr){let Bt=wr!==null&&Ve[wr],Mt=wr!==null&&Ve.null,Et=[...Array.isArray(Bt)?Bt:Bt?[Bt]:[],...Array.isArray(Mt)?Mt:Mt?[Mt]:[]];return Ee(Et)(wr)}}function Ee(Ve){return se=Ve,x=0,Ve.length===0?ue:Qe(Ve[x])}function Qe(Ve){return $e;function $e(wr){return Pe=F(),G=Ve,Ve.partial||(u.currentConstruct=Ve),Ve.name&&u.parser.constructs.disable.null.includes(Ve.name)?ee(wr):Ve.tokenize.call(T?Object.assign(Object.create(u),T):u,s,re,ee)(wr)}}function re(Ve){return f=!0,N(G,Pe),H}function ee(Ve){return f=!0,Pe.restore(),++x<se.length?Qe(se[x]):ue}}}function B(N,T){N.resolveAll&&!a.includes(N)&&a.push(N),N.resolve&&gB(u.events,T,u.events.length-T,N.resolve(u.events.slice(T),u)),N.resolveTo&&(u.events=N.resolveTo(u.events,u))}function F(){let N=b(),T=u.previous,W=u.currentConstruct,Q=u.events.length,H=Array.from(c);return{from:Q,restore:ue};function ue(){i=N,u.previous=T,u.currentConstruct=W,u.events.length=Q,c=H,R()}}function R(){i.line in n&&i.column<2&&(i.column=n[i.line],i.offset+=n[i.line]-1)}}function V1M(e,t){let r=t.start._index,i=t.start._bufferIndex,n=t.end._index,a=t.end._bufferIndex,o;if(r===n)o=[e[r].slice(i,a)];else{if(o=e.slice(r,n),i>-1){let c=o[0];typeof c=="string"?o[0]=c.slice(i):o.shift()}a>0&&o.push(e[n].slice(0,a))}return o}function W1M(e,t){let r=-1,i=[],n;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=`
|
|
1473
1473
|
`;break}case-3:{o=`\r
|
|
1474
1474
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&n)continue;o=" ";break}default:o=String.fromCharCode(a)}n=a===-2,i.push(o)}return i.join("")}function tbc(e){let i={constructs:szn([ebc,...(e||{}).extensions||[]]),content:n(M1_),defined:[],document:n(B1_),flow:n(I1_),lazy:{},string:n(q1_),text:n(T1_)};return i;function n(a){return o;function o(c){return N1_(i,a,c)}}}function rbc(e){for(;!HCo(e););return e}var F1_=/[\0\t\n\r]/g;function ibc(){let e=1,t="",r=!0,i;return n;function n(a,o,c){let f=[],s,u,l,p,_;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(F1_.lastIndex=l,s=F1_.exec(a),p=s&&s.index!==void 0?s.index:a.length,_=a.charCodeAt(p),!s){t=a.slice(l);break}if(_===10&&l===p&&i)f.push(-3),i=void 0;else switch(i&&(f.push(-5),i=void 0),l<p&&(f.push(a.slice(l,p)),e+=p-l),_){case 0:{f.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,f.push(-2);e++<u;)f.push(-1);break}case 10:{f.push(-4),e=1;break}default:i=!0,e=1}l=p+1}return c&&(i&&f.push(-5),t&&f.push(t),f.push(null)),f}}var U1_={}.hasOwnProperty;function I$i(e,t,r){return typeof t!="string"&&(r=t,t=void 0),x1M(r)(rbc(tbc(r).document().write(ibc()(e,t,!0))))}function x1M(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(ge),autolinkProtocol:M,autolinkEmail:M,atxHeading:a(k),blockQuote:a(wr),characterEscape:M,characterReference:M,codeFenced:a(Bt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(Bt,o),codeText:a(Mt,o),codeTextData:M,data:M,codeFlowValue:M,definition:a(Et),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(Ft),hardBreakEscape:a(ye),hardBreakTrailing:a(ye),htmlFlow:a(ut,o),htmlFlowData:M,htmlText:a(ut,o),htmlTextData:M,image:a(at),label:o,link:a(ge),listItem:a(Jt),listItemValue:p,listOrdered:a(Ht,l),listUnordered:a(Ht),paragraph:a(Yt),reference:ne,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(k),strong:a(ki),thematicBreak:a(sn)},exit:{atxHeading:f(),atxHeadingSequence:m,autolink:f(),autolinkEmail:$e,autolinkProtocol:Ve,blockQuote:f(),characterEscapeValue:B,characterReferenceMarkerHexadecimal:Qe,characterReferenceMarkerNumeric:Qe,characterReferenceValue:re,characterReference:ee,codeFenced:f(b),codeFencedFence:y,codeFencedFenceInfo:_,codeFencedFenceMeta:h,codeFlowValue:B,codeIndented:f(v),codeText:f(W),codeTextData:B,data:B,definition:f(),definitionDestinationString:g,definitionLabelString:O,definitionTitleString:A,emphasis:f(),hardBreakEscape:f(R),hardBreakTrailing:f(R),htmlFlow:f(N),htmlFlowData:B,htmlText:f(T),htmlTextData:B,image:f(H),label:se,labelText:ue,lineEnding:F,link:f(Q),listItem:f(),listOrdered:f(),listUnordered:f(),paragraph:f(),referenceString:Ee,resourceDestinationString:x,resourceTitleString:G,resource:Pe,setextHeading:f(E),setextHeadingLineSequence:D,setextHeadingText:j,strong:f(),thematicBreak:f()}};L1_(t,(e||{}).mdastExtensions||[]);let r={};return i;function i(er){let Wr={type:"root",children:[]},Ne={stack:[Wr],tokenStack:[],config:t,enter:c,exit:s,buffer:o,resume:u,data:r},Re=[],ie=-1;for(;++ie<er.length;)if(er[ie][1].type==="listOrdered"||er[ie][1].type==="listUnordered")if(er[ie][0]==="enter")Re.push(ie);else{let rt=Re.pop();ie=n(er,rt,ie)}for(ie=-1;++ie<er.length;){let rt=t[er[ie][0]];U1_.call(rt,er[ie][1].type)&&rt[er[ie][1].type].call(Object.assign({sliceSerialize:er[ie][2].sliceSerialize},Ne),er[ie][1])}if(Ne.tokenStack.length>0){let rt=Ne.tokenStack[Ne.tokenStack.length-1];(rt[1]||Q1_).call(Ne,void 0,rt[0])}for(Wr.position={start:t1i(er.length>0?er[0][1].start:{line:1,column:1,offset:0}),end:t1i(er.length>0?er[er.length-2][1].end:{line:1,column:1,offset:0})},ie=-1;++ie<t.transforms.length;)Wr=t.transforms[ie](Wr)||Wr;return Wr}function n(er,Wr,Ne){let Re=Wr-1,ie=-1,rt=!1,Nt,Xt,Mr,wi;for(;++Re<=Ne;){let tn=er[Re];switch(tn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{tn[0]==="enter"?ie++:ie--,wi=void 0;break}case"lineEndingBlank":{tn[0]==="enter"&&(Nt&&!wi&&!ie&&!Mr&&(Mr=Re),wi=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:wi=void 0}if(!ie&&tn[0]==="enter"&&tn[1].type==="listItemPrefix"||ie===-1&&tn[0]==="exit"&&(tn[1].type==="listUnordered"||tn[1].type==="listOrdered")){if(Nt){let Vt=Re;for(Xt=void 0;Vt--;){let C=er[Vt];if(C[1].type==="lineEnding"||C[1].type==="lineEndingBlank"){if(C[0]==="exit")continue;Xt&&(er[Xt][1].type="lineEndingBlank",rt=!0),C[1].type="lineEnding",Xt=Vt}else if(!(C[1].type==="linePrefix"||C[1].type==="blockQuotePrefix"||C[1].type==="blockQuotePrefixWhitespace"||C[1].type==="blockQuoteMarker"||C[1].type==="listItemIndent"))break}Mr&&(!Xt||Mr<Xt)&&(Nt._spread=!0),Nt.end=Object.assign({},Xt?er[Xt][1].start:tn[1].end),er.splice(Xt||Re,0,["exit",Nt,tn[2]]),Re++,Ne++}if(tn[1].type==="listItemPrefix"){let Vt={type:"listItem",_spread:!1,start:Object.assign({},tn[1].start),end:void 0};Nt=Vt,er.splice(Re,0,["enter",Vt,tn[2]]),Re++,Ne++,Mr=void 0,wi=!0}}}return er[Wr][1]._spread=rt,Ne}function a(er,Wr){return Ne;function Ne(Re){c.call(this,er(Re),Re),Wr&&Wr.call(this,Re)}}function o(){this.stack.push({type:"fragment",children:[]})}function c(er,Wr,Ne){this.stack[this.stack.length-1].children.push(er),this.stack.push(er),this.tokenStack.push([Wr,Ne||void 0]),er.position={start:t1i(Wr.start),end:void 0}}function f(er){return Wr;function Wr(Ne){er&&er.call(this,Ne),s.call(this,Ne)}}function s(er,Wr){let Ne=this.stack.pop(),Re=this.tokenStack.pop();if(Re)Re[0].type!==er.type&&(Wr?Wr.call(this,er,Re[0]):(Re[1]||Q1_).call(this,er,Re[0]));else throw new Error("Cannot close `"+er.type+"` ("+iz({start:er.start,end:er.end})+"): it\u2019s not open");Ne.position.end=t1i(er.end)}function u(){return Xbi(this.stack.pop())}function l(){this.data.expectingFirstListItemValue=!0}function p(er){if(this.data.expectingFirstListItemValue){let Wr=this.stack[this.stack.length-2];Wr.start=Number.parseInt(this.sliceSerialize(er),10),this.data.expectingFirstListItemValue=void 0}}function _(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.lang=er}function h(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.meta=er}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.value=er.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.value=er.replace(/(\r?\n|\r)$/g,"")}function O(er){let Wr=this.resume(),Ne=this.stack[this.stack.length-1];Ne.label=Wr,Ne.identifier=OL(this.sliceSerialize(er)).toLowerCase()}function A(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.title=er}function g(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.url=er}function m(er){let Wr=this.stack[this.stack.length-1];if(!Wr.depth){let Ne=this.sliceSerialize(er).length;Wr.depth=Ne}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function D(er){let Wr=this.stack[this.stack.length-1];Wr.depth=this.sliceSerialize(er).codePointAt(0)===61?1:2}function E(){this.data.setextHeadingSlurpLineEnding=void 0}function M(er){let Ne=this.stack[this.stack.length-1].children,Re=Ne[Ne.length-1];(!Re||Re.type!=="text")&&(Re=Gr(),Re.position={start:t1i(er.start),end:void 0},Ne.push(Re)),this.stack.push(Re)}function B(er){let Wr=this.stack.pop();Wr.value+=this.sliceSerialize(er),Wr.position.end=t1i(er.end)}function F(er){let Wr=this.stack[this.stack.length-1];if(this.data.atHardBreak){let Ne=Wr.children[Wr.children.length-1];Ne.position.end=t1i(er.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Wr.type)&&(M.call(this,er),B.call(this,er))}function R(){this.data.atHardBreak=!0}function N(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.value=er}function T(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.value=er}function W(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.value=er}function Q(){let er=this.stack[this.stack.length-1];if(this.data.inReference){let Wr=this.data.referenceType||"shortcut";er.type+="Reference",er.referenceType=Wr,delete er.url,delete er.title}else delete er.identifier,delete er.label;this.data.referenceType=void 0}function H(){let er=this.stack[this.stack.length-1];if(this.data.inReference){let Wr=this.data.referenceType||"shortcut";er.type+="Reference",er.referenceType=Wr,delete er.url,delete er.title}else delete er.identifier,delete er.label;this.data.referenceType=void 0}function ue(er){let Wr=this.sliceSerialize(er),Ne=this.stack[this.stack.length-2];Ne.label=UCo(Wr),Ne.identifier=OL(Wr).toLowerCase()}function se(){let er=this.stack[this.stack.length-1],Wr=this.resume(),Ne=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ne.type==="link"){let Re=er.children;Ne.children=Re}else Ne.alt=Wr}function x(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.url=er}function G(){let er=this.resume(),Wr=this.stack[this.stack.length-1];Wr.title=er}function Pe(){this.data.inReference=void 0}function ne(){this.data.referenceType="collapsed"}function Ee(er){let Wr=this.resume(),Ne=this.stack[this.stack.length-1];Ne.label=Wr,Ne.identifier=OL(this.sliceSerialize(er)).toLowerCase(),this.data.referenceType="full"}function Qe(er){this.data.characterReferenceType=er.type}function re(er){let Wr=this.sliceSerialize(er),Ne=this.data.characterReferenceType,Re;Ne?(Re=QCo(Wr,Ne==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Re=Zbi(Wr);let ie=this.stack[this.stack.length-1];ie.value+=Re}function ee(er){let Wr=this.stack.pop();Wr.position.end=t1i(er.end)}function Ve(er){B.call(this,er);let Wr=this.stack[this.stack.length-1];Wr.url=this.sliceSerialize(er)}function $e(er){B.call(this,er);let Wr=this.stack[this.stack.length-1];Wr.url="mailto:"+this.sliceSerialize(er)}function wr(){return{type:"blockquote",children:[]}}function Bt(){return{type:"code",lang:null,meta:null,value:""}}function Mt(){return{type:"inlineCode",value:""}}function Et(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ft(){return{type:"emphasis",children:[]}}function k(){return{type:"heading",depth:0,children:[]}}function ye(){return{type:"break"}}function ut(){return{type:"html",value:""}}function at(){return{type:"image",title:null,url:"",alt:null}}function ge(){return{type:"link",title:null,url:"",children:[]}}function Ht(er){return{type:"list",ordered:er.type==="listOrdered",start:null,spread:er._spread,children:[]}}function Jt(er){return{type:"listItem",spread:er._spread,checked:null,children:[]}}function Yt(){return{type:"paragraph",children:[]}}function ki(){return{type:"strong",children:[]}}function Gr(){return{type:"text",value:""}}function sn(){return{type:"thematicBreak"}}}function t1i(e){return{line:e.line,column:e.column,offset:e.offset}}function L1_(e,t){let r=-1;for(;++r<t.length;){let i=t[r];Array.isArray(i)?L1_(e,i):G1M(e,i)}}function G1M(e,t){let r;for(r in t)if(U1_.call(t,r))switch(r){case"canContainEols":{let i=t[r];i&&e[r].push(...i);break}case"transforms":{let i=t[r];i&&e[r].push(...i);break}case"enter":case"exit":{let i=t[r];i&&Object.assign(e[r],i);break}}}function Q1_(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+iz({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+iz({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+iz({start:t.start,end:t.end})+") is still open")}function C$i(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:n,mathFlowFence:i,mathFlowFenceMeta:r,mathFlowValue:c,mathText:o,mathTextData:c}};function e(f){let s={type:"element",tagName:"code",properties:{className:["language-math","math-display"]},children:[]};this.enter({type:"math",meta:null,value:"",data:{hName:"pre",hChildren:[s]}},f)}function t(){this.buffer()}function r(){let f=this.resume(),s=this.stack[this.stack.length-1];s.type,s.meta=f}function i(){this.data.mathFlowInside||(this.buffer(),this.data.mathFlowInside=!0)}function n(f){let s=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),u=this.stack[this.stack.length-1];u.type,this.exit(f),u.value=s;let l=u.data.hChildren[0];l.type,l.tagName,l.children.push({type:"text",value:s}),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 s=this.resume(),u=this.stack[this.stack.length-1];u.type,this.exit(f),u.value=s,u.data.hChildren.push({type:"text",value:s})}function c(f){this.config.enter.data.call(this,f),this.config.exit.data.call(this,f)}}function nbc(e){let t=(e||{}).singleDollarTextMath;return t==null&&(t=!0),i.peek=n,{unsafe:[{character:"\r",inConstruct:"mathFlowMeta"},{character:`
|
|
1475
1475
|
`,inConstruct:"mathFlowMeta"},{character:"$",after:t?void 0:"\\$",inConstruct:"phrasing"},{character:"$",inConstruct:"mathFlowMeta"},{atBreak:!0,character:"$",after:"\\$"}],handlers:{math:r,inlineMath:i}};function r(a,o,c,f){let s=a.value||"",u=c.createTracker(f),l="$".repeat(Math.max(zCo(s,"$")+1,2)),p=c.enter("mathFlow"),_=u.move(l);if(a.meta){let h=c.enter("mathFlowMeta");_+=u.move(c.safe(a.meta,{after:`
|
|
@@ -1848,7 +1848,7 @@ ${i?`
|
|
|
1848
1848
|
`+i+`
|
|
1849
1849
|
`:""}
|
|
1850
1850
|
More information: https://mdxjs.com/docs/troubleshooting-mdx`);return n.stack="",n}var LKo=(function(e){if(e==null)return G6M;if(typeof e=="string")return x6M(e);if(typeof e=="object")return Array.isArray(e)?V6M(e):W6M(e);if(typeof e=="function")return VKo(e);throw new Error("Expected function, string, or object as test")});function V6M(e){let t=[],r=-1;for(;++r<e.length;)t[r]=LKo(e[r]);return VKo(i);function i(...n){let a=-1;for(;++a<t.length;)if(t[a].call(this,...n))return!0;return!1}}function W6M(e){return VKo(t);function t(r){let i;for(i in e)if(r[i]!==e[i])return!1;return!0}}function x6M(e){return VKo(t);function t(r){return r&&r.type===e}}function VKo(e){return t;function t(r,...i){return!!(r&&typeof r=="object"&&"type"in r&&e.call(this,r,...i))}}function G6M(){return!0}var H6M=[],_0c=(function(e,t,r){let i=LKo(r||t),n=!t||t.cascade===void 0||t.cascade===null?!0:t.cascade;return a(e);function a(o,c,f){let s=o.children||H6M,u=-1,l=0;if(i(o,c,f))return null;if(s.length>0){for(;++u<s.length;)a(s[u],u,o)&&(s[l++]=s[u]);if(n&&!l)return null;s.length=l}return o}});function Q6_(){return e=>_0c(e,"mdxjsEsm")}function K6M(e={},t=!1){let r=e.useDynamicImport??!1,i=[...e.remarkPlugins||[],...r?[]:[Q6_]];return{...e,remarkPlugins:i,outputFormat:"function-body",providerImportSource:t?void 0:"@mdx-js/react",development:process.env.NODE_ENV!=="production"}}async function h0c(e,{scope:t={},mdxOptions:r={},parseFrontmatter:i=!1}={},n=!1){let a=new d0e(e);i&&p0c(a,{strip:!0});let o;try{o=await d0c(a,K6M(r,n))}catch(f){throw F6_(f,String(a))}return{compiledSource:String(o),frontmatter:a.data.matter??{},scope:t}}function y0c(e,t){let i=(t||{}).force||!1;Ni(e,n);function n(a){i?delete a.position:a.position=void 0}}function b0c(e,t){let r=ima(e,t);return y0c(r,{force:!0}),delete r.data,r}var J6M={},$6M=[];function WKo(e){let t=e||J6M;return function(r,i){j6i(r,"element",function(n,a){let o=Array.isArray(n.properties.className)?n.properties.className:$6M,c=o.includes("language-math"),f=o.includes("math-display"),s=o.includes("math-inline"),u=f;if(!c&&!f&&!s)return;let l=a[a.length-1],p=n;if(n.tagName==="code"&&c&&l&&l.type==="element"&&l.tagName==="pre"&&(p=l,l=a[a.length-2],u=!0),!l)return;let _=lhe(p,{whitespace:"pre"}),h;try{h=Jbc.renderToString(_,{...t,displayMode:u,throwOnError:!0})}catch(b){let v=b,O=v.name.toLowerCase();i.message("Could not render math with KaTeX",{ancestors:[...a,n],cause:v,place:n.position,ruleId:O,source:"rehype-katex"});try{h=Jbc.renderToString(_,{...t,displayMode:u,strict:"ignore",throwOnError:!1})}catch{h=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(b)},children:[{type:"text",value:_}]}]}}typeof h=="string"&&(h=b0c(h,{fragment:!0}).children);let y=l.children.indexOf(p);return l.children.splice(y,1,...h),uhe})}}var Y6M={};function xKo(e){let t=this,r=e||Y6M,i=t.data(),n=i.micromarkExtensions||(i.micromarkExtensions=[]),a=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),o=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);n.push(q$i(r)),a.push(C$i()),o.push(nbc(r))}var U6_={name:"valid-markdown",create:({logger:e,workspace:t})=>({markdownPage:async({content:r,absoluteFilepath:i})=>{let n;try{n=kyc(i)}catch(o){return[{severity:"error",message:`Markdown file does not have a valid extension: ${String(o)}`}]}let a=await eKM({markdown:r,absoluteFilepath:i,absolutePathToFernFolder:hn(t.absoluteFilepathToDocsConfig),logger:e});return a.type==="failure"?[{severity:"fatal",message:a.message!=null?`Markdown failed to parse: ${a.message}`:"Markdown failed to parse"}]:[]}})},X6M=[fzn,xKo],Z6M=[WKo],k6M=qt.object({title:qt.optional(qt.string(),{description:"Renders as the page title."}),"og:title":qt.optional(qt.string(),{description:"Renders as the og:title tag."}),"og:description":qt.optional(qt.string(),{description:"Renders as the og:description tag."}),subtitle:qt.optional(qt.string(),{description:"Renders as a subtitle on the page, and is also used in the meta description tag if description is not set."}),description:qt.optional(qt.string(),{description:"Renders as the meta description tag."}),image:qt.optional(qt.string(),{description:"Renders as the og:image tag."}),slug:qt.optional(qt.string(),{description:"The full slug path for the page, starting from root `/` (or basepath)."}),redirects:qt.optional(qt.array(qt.string()),{description:"A list of URLs to redirect to this page."}),editThisPageUrl:qt.optional(qt.string()),excerpt:qt.optional(qt.string(),{description:"Deprecated. Use `subtitle` instead."})});async function eKM({markdown:e,absoluteFilepath:t,absolutePathToFernFolder:r,logger:i}){try{i.trace(`Starting markdown parse for file: ${t}`),F$i(e,{absolutePathToMarkdownFile:t,absolutePathToFernFolder:r}),i.trace("Serializing markdown with MDX");let n=await h0c(e,{scope:{},mdxOptions:{remarkPlugins:X6M,rehypePlugins:Z6M,format:"detect"},parseFrontmatter:!0});i.trace("Validating frontmatter");let a=k6M.safeParse(n.frontmatter);return a.success?(i.trace("Markdown parse completed successfully"),{type:"success"}):(i.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(`
|
|
1851
|
-
`)}`})}catch(n){return i.trace(`Markdown parse failed with error: ${n instanceof Error?n.message:String(n)}`),{type:"failure",message:n instanceof Error?n.message:void 0}}}var L6_=require("fs/promises"),V6_=ae(F_e(),1);var W6_={name:"valid-markdown-file-references",create:e=>({filepath:async({absoluteFilepath:t})=>{if(!t.endsWith(".md")&&!t.endsWith(".mdx"))return[];try{let r=await(0,L6_.readFile)(t,"utf-8"),{content:i}=(0,V6_.default)(r,{}),n=u1i(i),a=[];return Ni(n,o=>{if(o.type==="link"){let c=b3n({href:aU(o.url),metadata:{absolutePathToFernFolder:t,absolutePathToMarkdownFile:t},markdownFilesToPathName:{}});if(c?.type==="missing-reference")try{let f=uzt(Vr.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 nK_=require("crypto"),w0c=ae(require("path"),1);var x6_=require("fs"),GKo=class{parse({absoluteFilePath:t}){let r=(0,x6_.readFileSync)(t,"utf-8"),i=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),n=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:i?.[1],packageName:n?.[1],serviceName:a?.[1]}}};var HKo=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let i=this.resolveSource({source:t});return i==null&&(pWt(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}`)),i}resolveSource({source:t}){return pWt(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let n=new GKo().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ke.of(t.proto),csharpNamespace:n.csharpNamespace,packageName:n.packageName,serviceName:n.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let i={type:"openapi",absoluteFilePath:r,relativeFilePath:ke.of(t.openapi)};return this.sourceCache.set(r,i),i}};function tKM(e){for(var t=[],r=0;r<e.length;){var i=e[r];if(i==="*"||i==="+"||i==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(i==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(i==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(i==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(i===":"){for(var n="",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){n+=e[a++];continue}break}if(!n)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:n}),r=a;continue}if(i==="("){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 G6_(e,t){t===void 0&&(t={});for(var r=tKM(e),i=t.prefixes,n=i===void 0?"./":i,a=t.delimiter,o=a===void 0?"/#?":a,c=[],f=0,s=0,u="",l=function(M){if(s<r.length&&r[s].type===M)return r[s++].value},p=function(M){var B=l(M);if(B!==void 0)return B;var F=r[s],R=F.type,N=F.index;throw new TypeError("Unexpected ".concat(R," at ").concat(N,", expected ").concat(M))},_=function(){for(var M="",B;B=l("CHAR")||l("ESCAPED_CHAR");)M+=B;return M},h=function(M){for(var B=0,F=o;B<F.length;B++){var R=F[B];if(M.indexOf(R)>-1)return!0}return!1},y=function(M){var B=c[c.length-1],F=M||(B&&typeof B=="string"?B:"");if(B&&!F)throw new TypeError('Must have text between two parameters, missing text after "'.concat(B.name,'"'));return!F||h(F)?"[^".concat(Q1i(o),"]+?"):"(?:(?!".concat(Q1i(F),")[^").concat(Q1i(o),"])+?")};s<r.length;){var b=l("CHAR"),v=l("NAME"),O=l("PATTERN");if(v||O){var A=b||"";n.indexOf(A)===-1&&(u+=A,A=""),u&&(c.push(u),u=""),c.push({name:v||f++,prefix:A,suffix:"",pattern:O||y(A),modifier:l("MODIFIER")||""});continue}var g=b||l("ESCAPED_CHAR");if(g){u+=g;continue}u&&(c.push(u),u="");var m=l("OPEN");if(m){var A=_(),j=l("NAME")||"",D=l("PATTERN")||"",E=_();p("CLOSE"),c.push({name:j||(D?f++:""),pattern:j&&!D?y(A):D,prefix:A,suffix:E,modifier:l("MODIFIER")||""});continue}p("END")}return c}function H6_(e,t){return rKM(G6_(e,t),t)}function rKM(e,t){t===void 0&&(t={});var r=v0c(t),i=t.encode,n=i===void 0?function(f){return f}:i,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 s="",u=0;u<e.length;u++){var l=e[u];if(typeof l=="string"){s+=l;continue}var p=f?f[l.name]:void 0,_=l.modifier==="?"||l.modifier==="*",h=l.modifier==="*"||l.modifier==="+";if(Array.isArray(p)){if(!h)throw new TypeError('Expected "'.concat(l.name,'" to not repeat, but got an array'));if(p.length===0){if(_)continue;throw new TypeError('Expected "'.concat(l.name,'" to not be empty'))}for(var y=0;y<p.length;y++){var b=n(p[y],l);if(o&&!c[u].test(b))throw new TypeError('Expected all "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(b,'"'));s+=l.prefix+b+l.suffix}continue}if(typeof p=="string"||typeof p=="number"){var b=n(String(p),l);if(o&&!c[u].test(b))throw new TypeError('Expected "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(b,'"'));s+=l.prefix+b+l.suffix;continue}if(!_){var v=h?"an array":"a string";throw new TypeError('Expected "'.concat(l.name,'" to be ').concat(v))}}return s}}function K6_(e,t){var r=[],i=J6_(e,r,t);return iKM(i,r,t)}function iKM(e,t,r){r===void 0&&(r={});var i=r.decode,n=i===void 0?function(a){return a}:i;return function(a){var o=e.exec(a);if(!o)return!1;for(var c=o[0],f=o.index,s=Object.create(null),u=function(p){if(o[p]===void 0)return"continue";var _=t[p-1];_.modifier==="*"||_.modifier==="+"?s[_.name]=o[p].split(_.prefix+_.suffix).map(function(h){return n(h,_)}):s[_.name]=n(o[p],_)},l=1;l<o.length;l++)u(l);return{path:c,index:f,params:s}}}function Q1i(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function v0c(e){return e&&e.sensitive?"":"i"}function nKM(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,i=0,n=r.exec(e.source);n;)t.push({name:n[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),n=r.exec(e.source);return e}function aKM(e,t,r){var i=e.map(function(n){return J6_(n,t,r).source});return new RegExp("(?:".concat(i.join("|"),")"),v0c(r))}function oKM(e,t,r){return uKM(G6_(e,r),t,r)}function uKM(e,t,r){r===void 0&&(r={});for(var i=r.strict,n=i===void 0?!1:i,a=r.start,o=a===void 0?!0:a,c=r.end,f=c===void 0?!0:c,s=r.encode,u=s===void 0?function(B){return B}:s,l=r.delimiter,p=l===void 0?"/#?":l,_=r.endsWith,h=_===void 0?"":_,y="[".concat(Q1i(h),"]|$"),b="[".concat(Q1i(p),"]"),v=o?"^":"",O=0,A=e;O<A.length;O++){var g=A[O];if(typeof g=="string")v+=Q1i(u(g));else{var m=Q1i(u(g.prefix)),j=Q1i(u(g.suffix));if(g.pattern)if(t&&t.push(g),m||j)if(g.modifier==="+"||g.modifier==="*"){var D=g.modifier==="*"?"?":"";v+="(?:".concat(m,"((?:").concat(g.pattern,")(?:").concat(j).concat(m,"(?:").concat(g.pattern,"))*)").concat(j,")").concat(D)}else v+="(?:".concat(m,"(").concat(g.pattern,")").concat(j,")").concat(g.modifier);else{if(g.modifier==="+"||g.modifier==="*")throw new TypeError('Can not repeat "'.concat(g.name,'" without a prefix and suffix'));v+="(".concat(g.pattern,")").concat(g.modifier)}else v+="(?:".concat(m).concat(j,")").concat(g.modifier)}}if(f)n||(v+="".concat(b,"?")),v+=r.endsWith?"(?=".concat(y,")"):"$";else{var E=e[e.length-1],M=typeof E=="string"?b.indexOf(E[E.length-1])>-1:E===void 0;n||(v+="(?:".concat(b,"(?=").concat(y,"))?")),M||(v+="(?=".concat(b,"|").concat(y,")"))}return new RegExp(v,v0c(r))}function J6_(e,t,r){return e instanceof RegExp?nKM(e,t):Array.isArray(e)?aKM(e,t,r):oKM(e,t,r)}var Z6_=ae(Sv(),1);function $6_(e){return e.split(/[?#]/)[0]??""}function pYi(e){return e.startsWith("/")?e.slice(1):e}function g0c(e){return e.startsWith("/")?e:`/${e}`}function KKo(e){return e.endsWith("/")?e.slice(0,-1):e}function Y6_(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 X6_(e){let t=new URL(F1(e));return{domain:t.host,basePath:t.pathname==="/"||t.pathname===""?void 0:t.pathname}}function sKM(e,t){if(e===t)return{params:{},path:t,index:0};try{return K6_(e)(t)}catch(r){return console.error(r,{pattern:e,path:t}),!1}}function cKM(e,t){try{return H6_(e)(t.params)}catch(r){return console.error(r,{match:t,destination:e}),e}}function k6_(e,t,r=[]){for(let i of r){let n=KKo(lKM(i.source,t.basePath)),a=sKM(n,e);if(a){let o=cKM(i.destination,a);if(!o.startsWith("/"))try{new URL(o)}catch{console.error("Invalid redirect destination:",o);return}return{redirect:{destination:encodeURI(o),permanent:i.permanent??!1}}}}}function lKM(e,t){return t==null||e.startsWith(t)?e:(0,Z6_.default)(t,e)}async function m0c({pathname:e,markdown:t,absoluteFilepath:r,workspaceAbsoluteFilePath:i,pageSlugs:n,absoluteFilePathsToSlugs:a,redirects:o=[],baseUrl:c}){e=KKo(e);let f=r!=null?a.get(r)??[]:[];if(e.trim()==="")return!0;if(e=A0c(e),e.startsWith("/")){let u=A0c(O0c(e,c,o));for(let p=0;p<5;++p){let _=A0c(O0c(u,c,o));if(u===_)break;u=_}if(t&&n.has(pYi(u)))return!0;let l=Qt(i,ke.of(pYi(e)));return await Ri(l,"file")?!0:f.map(p=>g0c(p))}if(r!=null){if(e==="."){let l=hn(r);if(await Ri(l,"directory"))return!0}let u=Qt(hn(r),ke.of(e));if(await Ri(u,"file"))return!0}if(!t)return f.map(u=>g0c(u));let s=[];for(let u of f){let l=new URL(`/${u}`,F1(c.domain)),p=O0c(new URL(e,l).pathname,c,o);n.has(pYi(p))||s.push(u)}return s.length>0?s:!0}function O0c(e,t,r){let i=k6_(e,t,r);return i==null?e:i.redirect.destination}function A0c(e){let t=e.indexOf("#");return t===-1?e:e.substring(0,t)}var eK_=require("fs");var fKM=["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"];function dKM({readFile:e=r=>(0,eK_.readFileSync)(r,"utf-8"),...t}){let r=new Set,i=[t],n=[],a=[],o=1e3,c=0;do{if(c++,c>o)throw new Error("Infinite loop detected while collecting links and sources");let f=i.shift();if(f==null)break;let{content:s,absoluteFilepath:u}=f;if(u!=null){if(r.has(u))throw new Error(`Circular import detected: ${u}`);r.add(u)}let l=u1i(s),p=jLn(l,{allowDangerousHtml:!0,passThrough:[...fKM]});Ni(p,_=>{if(_.type==="mdxjsEsm"&&u!=null)return _.data?.estree&&QC(_.data.estree,{enter:y=>{if(y.type==="ImportDeclaration"&&y.source.type==="Literal"&&typeof y.source.value=="string"){let b=ke.of(y.source.value),v=_s(hn(u),b);(v.endsWith(".mdx")||v.endsWith(".md"))&&i.push({content:e(v),absoluteFilepath:v})}}}),"skip";if(_.type==="element"){let y=_.properties.href;typeof y=="string"&&n.push({href:y,sourceFilepath:u,position:_.position});let b=_.properties.src;typeof b=="string"&&a.push({src:b,sourceFilepath:u,position:_.position})}function h(y,b){y3n(y,{src:v=>{let O=Igi(v.value);typeof O=="string"&&a.push({src:O,sourceFilepath:u,position:b})},href:v=>{let O=Igi(v.value);typeof O=="string"&&n.push({href:O,sourceFilepath:u,position:b})}})}if(_.type==="mdxJsxFlowElement"||_.type==="mdxJsxTextElement"){let y=e1i(_.attributes.filter(Cgi).find(v=>v.name==="href")?.value),b=e1i(_.attributes.filter(Cgi).find(v=>v.name==="src")?.value);if(_.name==="Markdown"){if(u&&typeof b=="string"){let v=_s(hn(u),b);i.push({content:e(v),absoluteFilepath:v})}return"skip"}typeof y=="string"&&n.push({href:y,sourceFilepath:u,position:_.position}),typeof b=="string"&&a.push({src:b,sourceFilepath:u,position:_.position}),_.attributes.forEach(v=>{v.type==="mdxJsxAttribute"&&typeof v.value!="string"&&v.value!=null&&v.value.data?.estree?h(v.value.data.estree,v.position):v.type==="mdxJsxExpressionAttribute"&&v.data?.estree&&h(v.data.estree,v.position)})}(_.type==="mdxFlowExpression"||_.type==="mdxTextExpression")&&_.data?.estree&&h(_.data.estree,_.position)})}while(i.length>0);return{links:n,sources:a}}function tK_({content:e,absoluteFilepath:t}){try{return dKM({content:e,absoluteFilepath:t})}catch{return{links:[],sources:[]}}}var rK_=/^(?:[a-z+]+:)/gi;function pKM(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);return r?(r[0].match(/\n/g)||[]).length+1:0}function P0c(e,t){return e&&{...e,start:{...e.start,line:e.start.line+t},end:{...e.end,line:e.end.line+t}}}function j0c(e,{absoluteFilepath:t,instanceUrls:r}){let i=[],n=[],a=pKM(e),{links:o,sources:c}=tK_({content:e,absoluteFilepath:t});return o.forEach(f=>{if(f.href.trimStart().match(rK_)){if(!f.href.trimStart().startsWith("http"))return;try{let u=new URL(f.href);if(!r.some(l=>f.href.includes(l)))return;n.push({pathname:u.pathname,sourceFilepath:f.sourceFilepath,position:P0c(f.position,a),markdown:!0})}catch{i.push({severity:"warning",message:`Invalid URL: ${f.href}`})}return}let s=$6_(f.href);s.trim()!==""&&n.push({pathname:s,sourceFilepath:f.sourceFilepath,position:P0c(f.position,a),markdown:!0})}),c.forEach(f=>{if(f.src.match(rK_))try{new URL(f.src)}catch{i.push({severity:"warning",message:`Invalid URL: ${f.src}`});return}else n.push({pathname:f.src,sourceFilepath:f.sourceFilepath,position:P0c(f.position,a),markdown:!1})}),{pathnamesToCheck:n,violations:i}}var gMa=rBs({logger:W8t(St)}),U1i={name:"valid-markdown-links",create:async({workspace:e,apiWorkspaces:t,ossWorkspaces:r})=>{let i=Y6_(e),n=i[0]??"http://localhost",a=X6_(i[0]??"http://localhost"),c=await new UFt({domain:n,docsWorkspace:e,ossWorkspaces:r,apiWorkspaces:t,taskContext:gMa,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=Tt.migrate.FernNavigationV1ToLatest.create().root(c.config.root),s=Tt.NodeCollector.collect(f),u=new Set,l=new Map,p=[];s.slugMap.forEach((h,y)=>{if(u.add(y),h==null||!Tt.isPage(h))return;Tt.isApiLeaf(h)&&p.push(h);let b=Tt.getPageId(h);if(b==null)return;let v=Qt(e.absoluteFilePath,ke.of(b)),O=l.get(v)??[];O.push(y),l.set(v,O)});let _=["/llms-full.txt","/llms.txt"];for(let h of _){let y=a.basePath?`${pYi(a.basePath)}${h}`:pYi(h);u.add(y)}return{markdownPage:async({content:h,absoluteFilepath:y})=>{let b=l.get(y);if(!b||b.length===0)return[];let{pathnamesToCheck:v,violations:O}=j0c(h,{absoluteFilepath:y,instanceUrls:i}),A=await Promise.all(v.map(async g=>{let m=await m0c({pathname:g.pathname,markdown:g.markdown,absoluteFilepath:y,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:u,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return m===!0?[]:m.map(j=>{let[D,E]=iK_({pathnameToCheck:g,targetPathname:j,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:U1i.name,severity:"error",message:D,relativeFilepath:E}})}));return[...O,...A.flat()]},apiSection:async({workspace:h,config:y})=>{let b=await h.toFernWorkspace({context:gMa},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1}),v=kw({workspace:b,audiences:y.audiences?{type:"select",audiences:Array.isArray(y.audiences)?y.audiences:[y.audiences]}:{type:"all"},generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1},readme:void 0,version:void 0,packageName:void 0,context:gMa,sourceResolver:new HKo(gMa,b)}),O=_KM(rSa({ir:v,apiDefinitionId:(0,nK_.randomUUID)(),context:gMa})),A=[];for(let g of p){let m=await hKM(_In.prune(O,g));for(let j of m){let{pathnamesToCheck:D,violations:E}=j0c(j,{instanceUrls:i});A.push(...E);let M=await Promise.all(D.map(async B=>{let F=await m0c({pathname:B.pathname,markdown:B.markdown,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:u,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return F===!0?[]:F.map(R=>{let[N,T]=iK_({pathnameToCheck:B,targetPathname:R,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:U1i.name,severity:"error",message:N,relFilepath:T}})}));A.push(...M.flat())}}return A}}}};function iK_({pathnameToCheck:e,targetPathname:t,absoluteFilepathToWorkspace:r}){let i=`${t} links to non-existent page ${Lt.bold(e.pathname)}`,{position:n,sourceFilepath:a}=e;if(a==null||n==null)return[i,ke.of("")];i=`broken link to ${Lt.bold(e.pathname)}`,e.pathname.length>0&&!w0c.default.isAbsolute(e.pathname)&&(i+=` (resolved path: ${w0c.default.join(t,e.pathname)})`);let o=Ev(r,a);return i+=`
|
|
1851
|
+
`)}`})}catch(n){return i.trace(`Markdown parse failed with error: ${n instanceof Error?n.message:String(n)}`),{type:"failure",message:n instanceof Error?n.message:void 0}}}var L6_=require("fs/promises"),V6_=ae(F_e(),1);var W6_={name:"valid-markdown-file-references",create:e=>({filepath:async({absoluteFilepath:t})=>{if(!t.endsWith(".md")&&!t.endsWith(".mdx"))return[];try{let r=await(0,L6_.readFile)(t,"utf-8"),{content:i}=(0,V6_.default)(r,{}),n=u1i(i),a=[];return Ni(n,o=>{if(o.type==="link"){let c=b3n({href:aU(o.url),metadata:{absolutePathToFernFolder:t,absolutePathToMarkdownFile:t},markdownFilesToPathName:{}});if(c?.type==="missing-reference")try{let f=uzt(Vr.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 nK_=require("crypto"),w0c=ae(require("path"),1);var x6_=require("fs"),GKo=class{parse({absoluteFilePath:t}){let r=(0,x6_.readFileSync)(t,"utf-8"),i=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),n=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:i?.[1],packageName:n?.[1],serviceName:a?.[1]}}};var HKo=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let i=this.resolveSource({source:t});return i==null&&pWt(t)&&this.context.logger.warn(`Cannot resolve source ${t.proto} from file ${r}`),i}resolveSource({source:t}){return pWt(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let n=new GKo().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:ke.of(t.proto),csharpNamespace:n.csharpNamespace,packageName:n.packageName,serviceName:n.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=Qt(this.workspace.absoluteFilePath,ke.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!uzt(r))return;let i={type:"openapi",absoluteFilePath:r,relativeFilePath:ke.of(t.openapi)};return this.sourceCache.set(r,i),i}};function tKM(e){for(var t=[],r=0;r<e.length;){var i=e[r];if(i==="*"||i==="+"||i==="?"){t.push({type:"MODIFIER",index:r,value:e[r++]});continue}if(i==="\\"){t.push({type:"ESCAPED_CHAR",index:r++,value:e[r++]});continue}if(i==="{"){t.push({type:"OPEN",index:r,value:e[r++]});continue}if(i==="}"){t.push({type:"CLOSE",index:r,value:e[r++]});continue}if(i===":"){for(var n="",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){n+=e[a++];continue}break}if(!n)throw new TypeError("Missing parameter name at ".concat(r));t.push({type:"NAME",index:r,value:n}),r=a;continue}if(i==="("){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 G6_(e,t){t===void 0&&(t={});for(var r=tKM(e),i=t.prefixes,n=i===void 0?"./":i,a=t.delimiter,o=a===void 0?"/#?":a,c=[],f=0,s=0,u="",l=function(M){if(s<r.length&&r[s].type===M)return r[s++].value},p=function(M){var B=l(M);if(B!==void 0)return B;var F=r[s],R=F.type,N=F.index;throw new TypeError("Unexpected ".concat(R," at ").concat(N,", expected ").concat(M))},_=function(){for(var M="",B;B=l("CHAR")||l("ESCAPED_CHAR");)M+=B;return M},h=function(M){for(var B=0,F=o;B<F.length;B++){var R=F[B];if(M.indexOf(R)>-1)return!0}return!1},y=function(M){var B=c[c.length-1],F=M||(B&&typeof B=="string"?B:"");if(B&&!F)throw new TypeError('Must have text between two parameters, missing text after "'.concat(B.name,'"'));return!F||h(F)?"[^".concat(Q1i(o),"]+?"):"(?:(?!".concat(Q1i(F),")[^").concat(Q1i(o),"])+?")};s<r.length;){var b=l("CHAR"),v=l("NAME"),O=l("PATTERN");if(v||O){var A=b||"";n.indexOf(A)===-1&&(u+=A,A=""),u&&(c.push(u),u=""),c.push({name:v||f++,prefix:A,suffix:"",pattern:O||y(A),modifier:l("MODIFIER")||""});continue}var g=b||l("ESCAPED_CHAR");if(g){u+=g;continue}u&&(c.push(u),u="");var m=l("OPEN");if(m){var A=_(),j=l("NAME")||"",D=l("PATTERN")||"",E=_();p("CLOSE"),c.push({name:j||(D?f++:""),pattern:j&&!D?y(A):D,prefix:A,suffix:E,modifier:l("MODIFIER")||""});continue}p("END")}return c}function H6_(e,t){return rKM(G6_(e,t),t)}function rKM(e,t){t===void 0&&(t={});var r=v0c(t),i=t.encode,n=i===void 0?function(f){return f}:i,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 s="",u=0;u<e.length;u++){var l=e[u];if(typeof l=="string"){s+=l;continue}var p=f?f[l.name]:void 0,_=l.modifier==="?"||l.modifier==="*",h=l.modifier==="*"||l.modifier==="+";if(Array.isArray(p)){if(!h)throw new TypeError('Expected "'.concat(l.name,'" to not repeat, but got an array'));if(p.length===0){if(_)continue;throw new TypeError('Expected "'.concat(l.name,'" to not be empty'))}for(var y=0;y<p.length;y++){var b=n(p[y],l);if(o&&!c[u].test(b))throw new TypeError('Expected all "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(b,'"'));s+=l.prefix+b+l.suffix}continue}if(typeof p=="string"||typeof p=="number"){var b=n(String(p),l);if(o&&!c[u].test(b))throw new TypeError('Expected "'.concat(l.name,'" to match "').concat(l.pattern,'", but got "').concat(b,'"'));s+=l.prefix+b+l.suffix;continue}if(!_){var v=h?"an array":"a string";throw new TypeError('Expected "'.concat(l.name,'" to be ').concat(v))}}return s}}function K6_(e,t){var r=[],i=J6_(e,r,t);return iKM(i,r,t)}function iKM(e,t,r){r===void 0&&(r={});var i=r.decode,n=i===void 0?function(a){return a}:i;return function(a){var o=e.exec(a);if(!o)return!1;for(var c=o[0],f=o.index,s=Object.create(null),u=function(p){if(o[p]===void 0)return"continue";var _=t[p-1];_.modifier==="*"||_.modifier==="+"?s[_.name]=o[p].split(_.prefix+_.suffix).map(function(h){return n(h,_)}):s[_.name]=n(o[p],_)},l=1;l<o.length;l++)u(l);return{path:c,index:f,params:s}}}function Q1i(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function v0c(e){return e&&e.sensitive?"":"i"}function nKM(e,t){if(!t)return e;for(var r=/\((?:\?<(.*?)>)?(?!\?)/g,i=0,n=r.exec(e.source);n;)t.push({name:n[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),n=r.exec(e.source);return e}function aKM(e,t,r){var i=e.map(function(n){return J6_(n,t,r).source});return new RegExp("(?:".concat(i.join("|"),")"),v0c(r))}function oKM(e,t,r){return uKM(G6_(e,r),t,r)}function uKM(e,t,r){r===void 0&&(r={});for(var i=r.strict,n=i===void 0?!1:i,a=r.start,o=a===void 0?!0:a,c=r.end,f=c===void 0?!0:c,s=r.encode,u=s===void 0?function(B){return B}:s,l=r.delimiter,p=l===void 0?"/#?":l,_=r.endsWith,h=_===void 0?"":_,y="[".concat(Q1i(h),"]|$"),b="[".concat(Q1i(p),"]"),v=o?"^":"",O=0,A=e;O<A.length;O++){var g=A[O];if(typeof g=="string")v+=Q1i(u(g));else{var m=Q1i(u(g.prefix)),j=Q1i(u(g.suffix));if(g.pattern)if(t&&t.push(g),m||j)if(g.modifier==="+"||g.modifier==="*"){var D=g.modifier==="*"?"?":"";v+="(?:".concat(m,"((?:").concat(g.pattern,")(?:").concat(j).concat(m,"(?:").concat(g.pattern,"))*)").concat(j,")").concat(D)}else v+="(?:".concat(m,"(").concat(g.pattern,")").concat(j,")").concat(g.modifier);else{if(g.modifier==="+"||g.modifier==="*")throw new TypeError('Can not repeat "'.concat(g.name,'" without a prefix and suffix'));v+="(".concat(g.pattern,")").concat(g.modifier)}else v+="(?:".concat(m).concat(j,")").concat(g.modifier)}}if(f)n||(v+="".concat(b,"?")),v+=r.endsWith?"(?=".concat(y,")"):"$";else{var E=e[e.length-1],M=typeof E=="string"?b.indexOf(E[E.length-1])>-1:E===void 0;n||(v+="(?:".concat(b,"(?=").concat(y,"))?")),M||(v+="(?=".concat(b,"|").concat(y,")"))}return new RegExp(v,v0c(r))}function J6_(e,t,r){return e instanceof RegExp?nKM(e,t):Array.isArray(e)?aKM(e,t,r):oKM(e,t,r)}var Z6_=ae(Sv(),1);function $6_(e){return e.split(/[?#]/)[0]??""}function pYi(e){return e.startsWith("/")?e.slice(1):e}function g0c(e){return e.startsWith("/")?e:`/${e}`}function KKo(e){return e.endsWith("/")?e.slice(0,-1):e}function Y6_(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 X6_(e){let t=new URL(F1(e));return{domain:t.host,basePath:t.pathname==="/"||t.pathname===""?void 0:t.pathname}}function sKM(e,t){if(e===t)return{params:{},path:t,index:0};try{return K6_(e)(t)}catch(r){return console.error(r,{pattern:e,path:t}),!1}}function cKM(e,t){try{return H6_(e)(t.params)}catch(r){return console.error(r,{match:t,destination:e}),e}}function k6_(e,t,r=[]){for(let i of r){let n=KKo(lKM(i.source,t.basePath)),a=sKM(n,e);if(a){let o=cKM(i.destination,a);if(!o.startsWith("/"))try{new URL(o)}catch{console.error("Invalid redirect destination:",o);return}return{redirect:{destination:encodeURI(o),permanent:i.permanent??!1}}}}}function lKM(e,t){return t==null||e.startsWith(t)?e:(0,Z6_.default)(t,e)}async function m0c({pathname:e,markdown:t,absoluteFilepath:r,workspaceAbsoluteFilePath:i,pageSlugs:n,absoluteFilePathsToSlugs:a,redirects:o=[],baseUrl:c}){e=KKo(e);let f=r!=null?a.get(r)??[]:[];if(e.trim()==="")return!0;if(e=A0c(e),e.startsWith("/")){let u=A0c(O0c(e,c,o));for(let p=0;p<5;++p){let _=A0c(O0c(u,c,o));if(u===_)break;u=_}if(t&&n.has(pYi(u)))return!0;let l=Qt(i,ke.of(pYi(e)));return await Ri(l,"file")?!0:f.map(p=>g0c(p))}if(r!=null){if(e==="."){let l=hn(r);if(await Ri(l,"directory"))return!0}let u=Qt(hn(r),ke.of(e));if(await Ri(u,"file"))return!0}if(!t)return f.map(u=>g0c(u));let s=[];for(let u of f){let l=new URL(`/${u}`,F1(c.domain)),p=O0c(new URL(e,l).pathname,c,o);n.has(pYi(p))||s.push(u)}return s.length>0?s:!0}function O0c(e,t,r){let i=k6_(e,t,r);return i==null?e:i.redirect.destination}function A0c(e){let t=e.indexOf("#");return t===-1?e:e.substring(0,t)}var eK_=require("fs");var fKM=["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"];function dKM({readFile:e=r=>(0,eK_.readFileSync)(r,"utf-8"),...t}){let r=new Set,i=[t],n=[],a=[],o=1e3,c=0;do{if(c++,c>o)throw new Error("Infinite loop detected while collecting links and sources");let f=i.shift();if(f==null)break;let{content:s,absoluteFilepath:u}=f;if(u!=null){if(r.has(u))throw new Error(`Circular import detected: ${u}`);r.add(u)}let l=u1i(s),p=jLn(l,{allowDangerousHtml:!0,passThrough:[...fKM]});Ni(p,_=>{if(_.type==="mdxjsEsm"&&u!=null)return _.data?.estree&&QC(_.data.estree,{enter:y=>{if(y.type==="ImportDeclaration"&&y.source.type==="Literal"&&typeof y.source.value=="string"){let b=ke.of(y.source.value),v=_s(hn(u),b);(v.endsWith(".mdx")||v.endsWith(".md"))&&i.push({content:e(v),absoluteFilepath:v})}}}),"skip";if(_.type==="element"){let y=_.properties.href;typeof y=="string"&&n.push({href:y,sourceFilepath:u,position:_.position});let b=_.properties.src;typeof b=="string"&&a.push({src:b,sourceFilepath:u,position:_.position})}function h(y,b){y3n(y,{src:v=>{let O=Igi(v.value);typeof O=="string"&&a.push({src:O,sourceFilepath:u,position:b})},href:v=>{let O=Igi(v.value);typeof O=="string"&&n.push({href:O,sourceFilepath:u,position:b})}})}if(_.type==="mdxJsxFlowElement"||_.type==="mdxJsxTextElement"){let y=e1i(_.attributes.filter(Cgi).find(v=>v.name==="href")?.value),b=e1i(_.attributes.filter(Cgi).find(v=>v.name==="src")?.value);if(_.name==="Markdown"){if(u&&typeof b=="string"){let v=_s(hn(u),b);i.push({content:e(v),absoluteFilepath:v})}return"skip"}typeof y=="string"&&n.push({href:y,sourceFilepath:u,position:_.position}),typeof b=="string"&&a.push({src:b,sourceFilepath:u,position:_.position}),_.attributes.forEach(v=>{v.type==="mdxJsxAttribute"&&typeof v.value!="string"&&v.value!=null&&v.value.data?.estree?h(v.value.data.estree,v.position):v.type==="mdxJsxExpressionAttribute"&&v.data?.estree&&h(v.data.estree,v.position)})}(_.type==="mdxFlowExpression"||_.type==="mdxTextExpression")&&_.data?.estree&&h(_.data.estree,_.position)})}while(i.length>0);return{links:n,sources:a}}function tK_({content:e,absoluteFilepath:t}){try{return dKM({content:e,absoluteFilepath:t})}catch{return{links:[],sources:[]}}}var rK_=/^(?:[a-z+]+:)/gi;function pKM(e){let t=/^---\n([\s\S]*?)\n---/,r=e.match(t);return r?(r[0].match(/\n/g)||[]).length+1:0}function P0c(e,t){return e&&{...e,start:{...e.start,line:e.start.line+t},end:{...e.end,line:e.end.line+t}}}function j0c(e,{absoluteFilepath:t,instanceUrls:r}){let i=[],n=[],a=pKM(e),{links:o,sources:c}=tK_({content:e,absoluteFilepath:t});return o.forEach(f=>{if(f.href.trimStart().match(rK_)){if(!f.href.trimStart().startsWith("http"))return;try{let u=new URL(f.href);if(!r.some(l=>f.href.includes(l)))return;n.push({pathname:u.pathname,sourceFilepath:f.sourceFilepath,position:P0c(f.position,a),markdown:!0})}catch{i.push({severity:"warning",message:`Invalid URL: ${f.href}`})}return}let s=$6_(f.href);s.trim()!==""&&n.push({pathname:s,sourceFilepath:f.sourceFilepath,position:P0c(f.position,a),markdown:!0})}),c.forEach(f=>{if(f.src.match(rK_))try{new URL(f.src)}catch{i.push({severity:"warning",message:`Invalid URL: ${f.src}`});return}else n.push({pathname:f.src,sourceFilepath:f.sourceFilepath,position:P0c(f.position,a),markdown:!1})}),{pathnamesToCheck:n,violations:i}}var gMa=rBs({logger:W8t(St)}),U1i={name:"valid-markdown-links",create:async({workspace:e,apiWorkspaces:t,ossWorkspaces:r})=>{let i=Y6_(e),n=i[0]??"http://localhost",a=X6_(i[0]??"http://localhost"),c=await new UFt({domain:n,docsWorkspace:e,ossWorkspaces:r,apiWorkspaces:t,taskContext:gMa,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=Tt.migrate.FernNavigationV1ToLatest.create().root(c.config.root),s=Tt.NodeCollector.collect(f),u=new Set,l=new Map,p=[];s.slugMap.forEach((h,y)=>{if(u.add(y),h==null||!Tt.isPage(h))return;Tt.isApiLeaf(h)&&p.push(h);let b=Tt.getPageId(h);if(b==null)return;let v=Qt(e.absoluteFilePath,ke.of(b)),O=l.get(v)??[];O.push(y),l.set(v,O)});let _=["/llms-full.txt","/llms.txt"];for(let h of _){let y=a.basePath?`${pYi(a.basePath)}${h}`:pYi(h);u.add(y)}return{markdownPage:async({content:h,absoluteFilepath:y})=>{let b=l.get(y);if(!b||b.length===0)return[];let{pathnamesToCheck:v,violations:O}=j0c(h,{absoluteFilepath:y,instanceUrls:i}),A=await Promise.all(v.map(async g=>{let m=await m0c({pathname:g.pathname,markdown:g.markdown,absoluteFilepath:y,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:u,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return m===!0?[]:m.map(j=>{let[D,E]=iK_({pathnameToCheck:g,targetPathname:j,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:U1i.name,severity:"error",message:D,relativeFilepath:E}})}));return[...O,...A.flat()]},apiSection:async({workspace:h,config:y})=>{let b=await h.toFernWorkspace({context:gMa},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1}),v=kw({workspace:b,audiences:y.audiences?{type:"select",audiences:Array.isArray(y.audiences)?y.audiences:[y.audiences]}:{type:"all"},generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1},readme:void 0,version:void 0,packageName:void 0,context:gMa,sourceResolver:new HKo(gMa,b)}),O=_KM(rSa({ir:v,apiDefinitionId:(0,nK_.randomUUID)(),context:gMa})),A=[];for(let g of p){let m=await hKM(_In.prune(O,g));for(let j of m){let{pathnamesToCheck:D,violations:E}=j0c(j,{instanceUrls:i});A.push(...E);let M=await Promise.all(D.map(async B=>{let F=await m0c({pathname:B.pathname,markdown:B.markdown,workspaceAbsoluteFilePath:e.absoluteFilePath,pageSlugs:u,absoluteFilePathsToSlugs:l,redirects:e.config.redirects,baseUrl:a});return F===!0?[]:F.map(R=>{let[N,T]=iK_({pathnameToCheck:B,targetPathname:R,absoluteFilepathToWorkspace:e.absoluteFilePath});return{name:U1i.name,severity:"error",message:N,relFilepath:T}})}));A.push(...M.flat())}}return A}}}};function iK_({pathnameToCheck:e,targetPathname:t,absoluteFilepathToWorkspace:r}){let i=`${t} links to non-existent page ${Lt.bold(e.pathname)}`,{position:n,sourceFilepath:a}=e;if(a==null||n==null)return[i,ke.of("")];i=`broken link to ${Lt.bold(e.pathname)}`,e.pathname.length>0&&!w0c.default.isAbsolute(e.pathname)&&(i+=` (resolved path: ${w0c.default.join(t,e.pathname)})`);let o=Ev(r,a);return i+=`
|
|
1852
1852
|
fix here: ${o}:${n.start.line}:${n.start.column}`,[i,o]}function _KM(e){return _In.ApiDefinitionV1ToLatest.from(e).migrate()}async function hKM(e){let t=[];return _In.Transformer.descriptions(r=>(typeof r=="string"&&t.push(r),r)).apiDefinition(e),t}var JKo={name:"validate-product-file",create:()=>({productFile:async({path:e,content:t})=>{let r=await hKo({value:t});return r.type==="success"?[]:[{severity:"fatal",message:`${r.message}`}]}})};var $Ko={name:"validate-version-file",create:()=>({versionFile:async({path:e,content:t})=>{let r=await _Ko({value:t});return r.type==="success"?[]:[{severity:"fatal",message:`${r.message}`}]}})};function aK_({relativeFilepath:e,allRuleVisitors:t,addViolations:r}){function i(n){let a=async(o,c)=>{for(let f of t){let s=f[n];if(s!=null){let u=await s(o);r(u.map(l=>({name:l.name,severity:l.severity,relativeFilepath:l.relativeFilepath??ke.of(""),nodePath:c,message:l.message})))}}};return{[n]:a}}return{...i("file"),...i("filepath"),...i("markdownPage"),...i("versionFile"),...i("apiSection"),...i("permissions"),...i("productFile")}}var oK_=require("fs/promises"),E0c={name:"no-non-component-refs",create:({ossWorkspaces:e,logger:t,workspace:r})=>({file:async()=>{let i=[],n=new Set;for(let a of e)for(let o of a.specs)if(o.type==="openapi"&&!n.has(o.absoluteFilepath)){n.add(o.absoluteFilepath);try{let c=(await(0,oK_.readFile)(o.absoluteFilepath)).toString(),f=Ev(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 u=c.matchAll(/["']?\$ref["']?\s*:\s*["']([^"']+)["']/g);for(let l of u){let p=l[1];p&&p.startsWith("#/")&&!p.startsWith("#/components/")&&i.push({severity:"error",name:"Invalid OpenAPI reference",message:`Reference "${p}" 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 i}})};var uK_=require("fs/promises"),S0c={name:"no-openapi-v2-in-docs",create:({ossWorkspaces:e,logger:t,workspace:r})=>({file:async()=>{let i=[],n=new Set;for(let a of e)for(let o of a.specs)if(o.type==="openapi"&&!n.has(o.absoluteFilepath)){n.add(o.absoluteFilepath);try{let c=(await(0,uK_.readFile)(o.absoluteFilepath)).toString(),f=Ev(r.absoluteFilePath,o.absoluteFilepath);c.includes("swagger:")&&(c.includes('swagger: "2.0"')||c.includes("swagger: '2.0'")||c.includes("swagger: 2.0"))&&i.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 i}})};var sK_=["docs.buildwithfern.com","docs.dev.buildwithfern.com"];function yKM(e){return e.includes(".")?{valid:!1,error:`Subdomain "${e}" contains a '.' character, which is not allowed`,suggestion:e.replace(/\./g,"-")}:e.length>62?{valid:!1,error:`Subdomain "${e}" is ${e.length} characters long, which exceeds the maximum of 62 characters`}:/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(e)?{valid:!0}:{valid:!1,error:`Subdomain "${e}" contains invalid characters. Subdomains must contain only alphanumeric characters and hyphens, and cannot start or end with a hyphen`}}function bKM(e){let t;try{let o=e.startsWith("http://")||e.startsWith("https://")?e:`https://${e}`;t=new URL(o).hostname.toLowerCase()}catch{return{severity:"fatal",message:`Invalid URL format: "${e}". Expected format: <subdomain>.docs.buildwithfern.com`}}let r=sK_.find(o=>t.endsWith(o));if(!r)return{severity:"fatal",message:`Invalid domain in URL "${e}". The URL must end with one of: ${sK_.join(", ")}`};let i="."+r;if(!t.endsWith(i))return{severity:"fatal",message:`Invalid URL "${e}". A subdomain is required before ${r}`};let n=t.slice(0,t.length-i.length);if(!n||n.length===0)return{severity:"fatal",message:`Invalid URL "${e}". A subdomain is required before ${r}`};let a=yKM(n);if(!a.valid){let o=`Invalid instance URL "${e}": ${a.error}`;return a.suggestion&&(o+=`. Suggestion: ${a.suggestion}.${r}`),{severity:"fatal",message:o}}return null}var M0c={name:"valid-instance-url",create:()=>({file:async({config:e})=>{let t=[];if(!e.instances||e.instances.length===0)return t;for(let r=0;r<e.instances.length;r++){let i=e.instances[r];if(i?.url){let n=bKM(i.url);n&&t.push({...n,message:`instances[${r}].url: ${n.message}`})}}return t}})};var cK_=require("fs/promises");function vKM(e,t){let r=e.replace(/^#\//,"").split("/").map(n=>n.replace(/~1/g,"/").replace(/~0/g,"~")),i=t;for(let n of r)if(i==null||typeof i!="object"||(i=i[n],i===void 0))return!1;return i!=null}function gKM(e){let t=new Map;for(let i of e){let n=i.replace(/^#\//,"").split("/"),a="Other";n.length>=2&&(n[0]==="components"?a=`components/${n[1]??"unknown"}`:a=n[0]??"unknown"),t.has(a)||t.set(a,[]);let o=t.get(a);o&&o.push(i)}let r=`Found ${e.length} invalid OpenAPI reference${e.length===1?"":"s"}:
|
|
1853
1853
|
|
|
1854
1854
|
`;for(let[i,n]of t){r+=`${i}:
|