fern-api 0.107.5 → 0.107.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +3 -3
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -2427,7 +2427,7 @@ ${fgy.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&mgf(th
|
|
|
2427
2427
|
`+dua.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?dua.default.cyan(mgy(t,this.opt.mask)):dua.default.italic(dua.default.dim("[hidden]")):this.opt.mask?mgy(t,this.opt.mask):dua.default.italic(dua.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 iSu=$i(hse(),1);var m0y=$i(t0f(),1),rSu=require("child_process"),tZa=require("fs"),tSu=$i(require("path"),1),O0y=$i(require("os"),1),A0y=require("crypto"),z0f=$i(b0y(),1);var ZEu=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var CKo=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var kEu=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var eSu=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function nSu(e="",t,r){let n=new Q0f(e,r);n.runAsync((i,a)=>{if(i)setImmediate(t,i,void 0);else try{n.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function g0y(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function XOC(e){let t=[],r="";for(let n=0;n<e.length;n++){let i=e.charAt(n);n>0&&i===" "&&e[n-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${i}`}return r.length>0&&t.push(r),t}var Q0f=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=XOC(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??O0y.default.tmpdir(),r=(0,A0y.randomUUID)(),n=g0y(this.fileOptions.prefix),i=g0y(this.fileOptions.postfix),a=`${n}${r}${i}`,o=tSu.default.resolve(t,a),c=tSu.default.resolve(t)+tSu.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,tZa.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new ZEu(t)}}readTemporaryFile(){try{let t=(0,tZa.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,m0y.detect)(t)??"utf8";z0f.default.encodingExists(r)||(r="utf8"),this.text=z0f.default.decode(t,r)}}catch(t){throw new kEu(t)}}removeTemporaryFile(){try{(0,tZa.unlinkSync)(this.tempFile)}catch(t){throw new eSu(t)}}launchEditor(){try{let t=(0,rSu.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new CKo(t)}}launchEditorAsync(t){try{(0,rSu.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new CKo(r)}}};var P0y=$i(Ert(),1);var IKo=class extends yse{_run(t){this.done=t,this.editorResult=new P0y.Subject;let r=Vve(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?iSu.default.dim("Received"):iSu.default.dim("Press <enter> to launch your preferred editor."),t&&(r=iSu.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),nSu(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 D0y=require("stream");var E0y=$i(require("readline"),1),S0y=$i(j0y(),1),yua=class{constructor(t){this.rl||=E0y.default.createInterface(kOC(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 kOC(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new S0y.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var MKo=class extends yua{constructor(t={}){super(t),this.log=new D0y.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return _Ko(this.rl,this.bottomBar.split(`
|
|
2428
2428
|
`).length),this}updateBottomBar(t){return _Ko(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+`
|
|
2429
2429
|
`}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&&EEu(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var L4=$i(Ert(),1),M0y=$i(RJo(),1);var aSu=$i(Ert(),1),C0y=$i(RJo(),1),oSu=function(e,t,r){return typeof e[t]!="function"?(0,aSu.of)(e):(0,aSu.from)((0,C0y.default)(e[t])(r).then(n=>(e[t]=n,e)))};var I0y={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,a,o)=>{i==="__proto__"||i==="constructor"||(a===o.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},rZa=class extends yua{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let n;return Array.isArray(t)?n=(0,L4.from)(t):(0,L4.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,L4.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,L4.from)([t]),this.process=n.pipe((0,L4.concatMap)(this.processQuestion.bind(this)),(0,L4.publish)()),this.process.connect(),this.process.pipe((0,L4.reduce)((i,a)=>(I0y.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,L4.defer)(()=>(0,L4.of)(t).pipe((0,L4.concatMap)(this.setDefaultType.bind(this)),(0,L4.concatMap)(this.filterIfRunnable.bind(this)),(0,L4.concatMap)(()=>oSu(t,"message",this.answers)),(0,L4.concatMap)(()=>oSu(t,"default",this.answers)),(0,L4.concatMap)(()=>oSu(t,"choices",this.answers)),(0,L4.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,L4.defer)(()=>(0,L4.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,L4.defer)(()=>(0,L4.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&I0y.get(this.answers,t.name)!==void 0)return L4.EMPTY;if(t.when===!1)return L4.EMPTY;if(typeof t.when!="function")return(0,L4.of)(t);let{answers:r}=this;return(0,L4.defer)(()=>(0,L4.from)((0,M0y.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,L4.filter)(n=>n!=null)))}};function B0y(e){let t=function(r,n){let i;try{i=new rZa(t.prompts,e)}catch(o){return Promise.reject(o)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",yKo),this.registerPrompt("input",fua),this.registerPrompt("number",vKo),this.registerPrompt("confirm",bKo),this.registerPrompt("rawlist",gKo),this.registerPrompt("expand",mKo),this.registerPrompt("checkbox",OKo),this.registerPrompt("password",AKo),this.registerPrompt("editor",IKo)},t.restoreDefaultPrompts(),t}var U0f=B0y();function tAC(e,t){U0f.registerPrompt(e,t)}function rAC(){U0f.restoreDefaultPrompts()}var nAC={prompt:U0f,ui:{BottomBar:MKo,Prompt:rZa},createPromptModule:B0y,registerPrompt:tAC,restoreDefaultPrompts:rAC,Separator:YFe},sSu=nAC;var hZa=require("path"),fOy=require("fs"),dOy=require("readline"),Nmy="posthog-node";function IwC(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"]}={}){return a=>{if(!(i==="*"||i.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[SSu.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=u;let s=a.exception?.values||[],l=s.map(A=>({...A,stacktrace:A.stacktrace?{...A.stacktrace,type:"raw",frames:(A.stacktrace.frames||[]).map(P=>({...P,platform:"node:javascript"}))}:void 0})),m={$exception_message:s[0]?.value||a.message,$exception_type:s[0]?.type,$exception_personURL:u,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:s[0]?.value||a.message,$sentry_exception_type:s[0]?.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:m}),a}}var SSu=class{constructor(t,r,n,i){this.name=Nmy,this.name=Nmy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(IwC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};SSu.POSTHOG_ID_TAG="posthog_distinct_id";var ASu="0123456789abcdef",DSu=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=ASu.charAt(this.bytes[r]>>>4),t+=ASu.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+=ASu.charAt(this.bytes[r]>>>4),t+=ASu.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},Emf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??MwC()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return DSu.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,DSu.ofInner(t)}},MwC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Fmy,Smf=()=>BwC().toString(),BwC=()=>(Fmy||(Fmy=new Emf)).generate();function TwC(e,t){let r=!1;return Object.assign(n=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function qwC(e,t){global.process.on("uncaughtException",TwC(e,t))}function RwC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var PSu,xmy,wSu;function NwC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return wSu&&r.length===xmy||(xmy=r.length,wSu=r.reduce((n,i)=>{PSu||(PSu={});let a=PSu[i];if(a)n[a[0]]=a[1];else{let o=e(i);for(let c=o.length-1;c>=0;c--){let u=o[c]?.filename,s=t[i];if(u&&s){n[u]=s,PSu[i]=[u,s];break}}}return n},{})),wSu}function FwC(e){return typeof Event<"u"&&pOy(e,Event)}function xwC(e){return _Oy(e,"Object")}function Rmf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return pOy(e,Error)}}function pOy(e,t){try{return e instanceof t}catch{return!1}}function zwC(e){return _Oy(e,"ErrorEvent")}function _Oy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function QwC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=hOy(a,r,n);return{$exception_list:await Promise.all(o.map(async u=>{let s=await JwC(e,t,u);return s.value=s.value||"",s.type=s.type||"Error",s.mechanism=a,s}))}}function hOy(e,t,r){let n=LwC(e,t,r);return n.cause?[n,...hOy(e,n.cause,r)]:[n]}function LwC(e,t,r){if(Rmf(t))return t;if(e.synthetic=!0,xwC(t)){let i=UwC(t);if(i)return i;let a=VwC(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let n=r?.syntheticException||new Error(t);return n.message=`${t}`,n}function UwC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(Rmf(r))return r}}function VwC(e){if("name"in e&&typeof e.name=="string"){let n=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(n+=` with message '${e.message}'`),n}else if("message"in e&&typeof e.message=="string")return e.message;let t=HwC(e);if(zwC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=WwC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function WwC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function HwC(e,t=40){let r=Object.keys(GwC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return zmy(n,t);for(let i=r.length;i>0;i--){let a=r.slice(0,i).join(", ");if(!(a.length>t))return i===r.length?a:zmy(a,t)}return""}function zmy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function GwC(e){return Rmf(e)?{message:e.message,name:e.name,stack:e.stack,...Qmy(e)}:FwC(e)?{type:e.type,target:Lmy(e.target),currentTarget:Lmy(e.currentTarget),...Qmy(e)}:e}function Qmy(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 Lmy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function JwC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=KwC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function KwC(e,t){return $wC(e(t.stack||"",1),e)}function $wC(e,t){let r=NwC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var YwC=2e3,dZa=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await QwC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||Smf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(qwC(this.onException.bind(this),this.onFatalError.bind(this)),RwC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(YwC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function XwC(e=process.argv[1]?(0,hZa.dirname)(process.argv[1]):process.cwd(),t=hZa.sep==="\\"){let r=t?Umy(e):e;return n=>{if(!n)return;let i=t?Umy(n):n,{dir:a,base:o,ext:c}=hZa.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let u=a.lastIndexOf("/node_modules");if(u>-1)return`${a.slice(u+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let s=a.slice(r.length+1).replace(/\//g,".");return s?`${s}:${f}`:f}return f}}function Umy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var CSu=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)}}},ESu=new CSu(25),yOy=new CSu(20),Nmf=7,ZwC=1e3,kwC=1e4;async function ejC(e){let t={};for(let i=e.length-1;i>=0;i--){let a=e[i],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||ijC(o)||ajC(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(yOy.get(i))continue;let a=t[i];if(!a)continue;a.sort((f,u)=>f-u);let o=sjC(a);if(o.every(f=>ojC(i,f)))continue;let c=ujC(ESu,i,{});n.push(tjC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&rjC(e,ESu),ESu.reduce(),e}function tjC(e,t,r){return new Promise(n=>{let i=(0,fOy.createReadStream)(e),a=(0,dOy.createInterface)({input:i});function o(){i.destroy(),n()}let c=0,f=0,u=t[f];if(u===void 0){o();return}let s=u[0],l=u[1];function m(){yOy.set(e,1),a.close(),a.removeAllListeners(),o()}i.on("error",m),a.on("error",m),a.on("close",o),a.on("line",A=>{if(c++,!(c<s)&&(r[c]=cjC(A,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let P=t[f];if(P===void 0){a.close(),a.removeAllListeners();return}s=P[0],l=P[1]}})})}function rjC(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;njC(r.lineno,r,n)}}function njC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=vOy(e);i<e;i++){let a=r[i];if(a===void 0){Vmy(t);return}t.pre_context.push(a)}if(r[e]===void 0){Vmy(t);return}t.context_line=r[e];let n=bOy(e);t.post_context=[];for(let i=e+1;i<=n;i++){let a=r[i];if(a===void 0)break;t.post_context.push(a)}}function Vmy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function ijC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function ajC(e){return e.lineno!==void 0&&e.lineno>kwC||e.colno!==void 0&&e.colno>ZwC}function ojC(e,t){let r=ESu.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function sjC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=Wmy(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let a=e[t+1];if(typeof a!="number")break;a<=n[1]?n[1]=a+Nmf:(i.push(n),n=Wmy(a)),t++}return i}function Wmy(e){return[vOy(e),bOy(e)]}function vOy(e){return Math.max(1,e-Nmf)}function bOy(e){return e+Nmf}function ujC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function cjC(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,n);return a>n-5&&(a=n),a===n&&(i=Math.max(a-140,0)),r=r.slice(i,a),i>0&&(r=`...${r}`),a<n&&(r+="..."),r}var ljC="4.18.0",txe;(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"})(txe||(txe={}));var Hmy;(function(e){e.Left="left",e.Right="right",e.Center="center"})(Hmy||(Hmy={}));var Gmy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(Gmy||(Gmy={}));var Jmy;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(Jmy||(Jmy={}));var Kmy;(function(e){e.Html="html",e.Text="text"})(Kmy||(Kmy={}));var $my;(function(e){e.Number="number",e.Emoji="emoji"})($my||($my={}));var Ymy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(Ymy||(Ymy={}));var Xmy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(Xmy||(Xmy={}));var Zmy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(Zmy||(Zmy={}));var kmy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(kmy||(kmy={}));var fjC=e=>{if("flags"in e){let t=pjC(e.flags),r=_jC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,gOy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,djC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function djC(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 pjC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,Fmf(r)]).filter(([,t])=>t!==void 0)),_jC=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let n=t[r];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(r=>{let n=t[r].metadata?.payload;return[r,n?gOy(n):void 0]}))},Fmf=e=>e===void 0?void 0:e.variant??e.enabled,gOy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},hjC=1,yjC=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"]),vjC="utf8";function bjC(e,t){if(!e||typeof e!="string"||gjC(e))throw new Error(t)}function gjC(e){return e.trim().length===0}function mjC(e){return e?.replace(/\/+$/,"")}async function OjC(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function eOy(){return new Date().getTime()}function wmf(){return new Date().toISOString()}function ISu(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function AjC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function PjC(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 wjC(e,t=0,r){let n=PjC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function tOy(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var LKo=String.fromCharCode,rOy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",jSu={};function jjC(e,t){if(!jSu[e]){jSu[e]={};for(let r=0;r<e.length;r++)jSu[e][e.charAt(r)]=r}return jSu[e][t]}var lZa={compressToBase64:function(e){if(e==null)return"";let t=lZa._compress(e,6,function(r){return rOy.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:lZa._decompress(e.length,32,function(t){return jjC(rOy,e.charAt(t))})},compress:function(e){return lZa._compress(e,16,function(t){return LKo(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],o,c,f="",u="",s="",l=2,m=3,A=2,P=0,C=0,M;for(M=0;M<e.length;M+=1)if(f=e.charAt(M),Object.prototype.hasOwnProperty.call(n,f)||(n[f]=m++,i[f]=!0),u=s+f,Object.prototype.hasOwnProperty.call(n,u))s=u;else{if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<A;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<A;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[s]}else for(c=n[s],o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++),n[u]=m++,s=String(f)}if(s!==""){if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<A;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<A;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,A),A++),delete i[s]}else for(c=n[s],o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,A),A++)}for(c=2,o=0;o<A;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;for(;;)if(P=P<<1,C==t-1){a.push(r(P));break}else C++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:lZa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,u="",s,l,m,A,P,C,M;for(s=0;s<3;s+=1)n[s]=s;for(m=0,P=Math.pow(2,2),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;M=LKo(m);break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;M=LKo(m);break;case 2:return""}for(n[3]=M,l=M,i.push(M);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,f),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(M=m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=LKo(m),M=c-1,o--;break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=LKo(m),M=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,f),f++),n[M])u=n[M];else if(M===c)u=l+l.charAt(0);else return null;i.push(u),n[c++]=l+u.charAt(0),o--,l=u,o==0&&(o=Math.pow(2,f),f++)}}},Dmf=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}},pZa=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()}},UKo=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function nOy(e){if(e instanceof pZa){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 jmf(e){return typeof e=="object"&&(e instanceof pZa||e instanceof UKo)}function iOy(e){return typeof e=="object"&&e instanceof pZa&&e.status===413}var Cmf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(Cmf||(Cmf={}));var Imf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new Dmf,this._isInitialized=!1,bjC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=mjC(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:jmf},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(txe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(txe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(txe.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Smf();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}async identifyStatelessImmediate(t,r,n){let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",i,n)}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}async captureStatelessImmediate(t,r,n,i){let a=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",a,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}async aliasStatelessImmediate(t,r,n,i){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,i)}groupIdentifyStateless(t,r,n,i,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...o||{}}});this.enqueue("capture",c,i)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(i=>i.json()).catch(i=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",i)),this._events.emit("error",i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let c=wjC(this.apiKey,hjC,yjC)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(u=>u.json()).then(u=>fjC(u)).catch(u=>{this._events.emit("error",u)})}async getFeatureFlagStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,n,i,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=Fmf(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,n,i,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,n,i,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,n,i,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,n,i,c);if(f!==void 0)return f.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),f.quotaLimited?.includes(Cmf.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},i=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return i&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(i))),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(txe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(txe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(txe.Props,this.props)})}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i=this.prepareMessage(t,r,n),a=this.getPersistedProperty(txe.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:i}),this.setPersistedProperty(txe.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=ISu(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={api_key:this.apiKey,batch:[this.prepareMessage(t,r,n)],sent_at:wmf()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${eOy()}&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(lZa.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:wmf(),uuid:n?.uuid?n.uuid:Smf()};return(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId),i}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await nOy(t)})}async flush(){let t=tOy([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),tOy([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(txe.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),a=i.map(m=>m.message),o=()=>{let A=(this.getPersistedProperty(txe.Queue)||[]).slice(i.length);this.setPersistedProperty(txe.Queue,A),t=A},c={api_key:this.apiKey,batch:a,sent_at:wmf()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${eOy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,s=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(lZa.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:m=>iOy(m)?!1:jmf(m)};try{await this.fetchWithRetry(u,s,l)}catch(m){if(iOy(m)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw m instanceof UKo||o(),this._events.emit("error",m),m}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(u){let s=new AbortController;return setTimeout(()=>s.abort(),u),s.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,vjC)}catch{c=new TextEncoder().encode(o).length}return await OjC(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(s){throw new UKo(s)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new pZa(f,c);return f},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(txe.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!jmf(i))throw i;await nOy(i)}};return Promise.race([new Promise((i,a)=>{ISu(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},Mmf=AjC();if(!Mmf){let e=Rmy();Mmf=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var mOy=Mmf,MSu=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()}},OOy=new MSu(async()=>{try{return await import("crypto")}catch{return}});async function EjC(){return await OOy.getValue()}var SjC=new MSu(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await OOy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function DjC(){return await SjC.getValue()}async function CjC(e){let t=await EjC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await DjC();if(r){let n=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var IjC=60*1e3,MjC=1152921504606847e3,BjC=["is_not"],fZa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},vse=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},Bmf=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=c.fetch||mOy,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof vse?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let u=await this.computeFlagLocally(f,t,r,n,i);a[f.key]=u;let s=await this.computeFeatureFlagPayloadLocally(f.key,u);s&&(o[f.key]=s)}catch(u){u instanceof vse||u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${u}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new vse("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 vse("Flag has unknown group type index");if(!(f in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[f];return await this.matchFeatureFlagProperties(t,n[f],u)}else return await this.matchFeatureFlagProperties(t,r,i)}async matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],o=!1,c,f=[...a].sort((u,s)=>{let l=!!u.variant,m=!!s.variant;return l&&m?0:l?-1:m?1:0});for(let u of f)try{if(await this.isConditionMatch(t,r,u,n)){let s=u.variant,l=i.multivariate?.variants||[];s&&l.some(m=>m.key===s)?c=s:c=await this.getMatchingVariant(t,r)||!0;break}}catch(s){if(s instanceof vse)o=!0;else throw s}if(c!==void 0)return c;if(o)throw new vse("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i){let a=n.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let f=c.type,u=!1;if(f==="cohort"?u=POy(c,i,this.cohorts,this.debugMode):u=AOy(c,i,o),!u)return!1}if(a==null)return!0}return!(a!=null&&await aOy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await aOy(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{i=n+c.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:c.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(IjC,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 fZa(`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 fZa(`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 fZa(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof fZa&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=ISu(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,n=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;i=ISu(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function aOy(e,t,r=""){let n=await CjC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/MjC}function AOy(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new vse("Operator is_not_set is not supported")}else throw new vse(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!BjC.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(u,s){return Array.isArray(u)?u.map(l=>String(l).toLowerCase()).includes(String(s).toLowerCase()):String(u).toLowerCase()===String(s).toLowerCase()}function f(u,s,l){if(l==="gt")return u>s;if(l==="gte")return u>=s;if(l==="lt")return u<s;if(l==="lte")return u<=s;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(i,o);case"is_not":return!c(i,o);case"is_set":return n in t;case"icontains":return String(o).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(i).toLowerCase());case"regex":return oOy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return oOy(String(i))&&String(o).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let u=typeof i=="number"?i:null;if(typeof i=="string")try{u=parseFloat(i)}catch{}return u!=null&&o!=null?typeof o=="string"?f(o,String(i),a):f(o,u,a):f(String(o),String(i),a)}case"is_date_after":case"is_date_before":{let u=TjC(String(i));if(u==null&&(u=sOy(i)),u==null)throw new vse(`Invalid date: ${i}`);let s=sOy(o);return["is_date_before"].includes(a)?s<u:s>u}default:throw new vse(`Unknown operator: ${a}`)}}function POy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new vse("can't match cohort without a given cohort property value");let a=r[i];return wOy(a,t,r,n)}function wOy(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=wOy(c,t,r,n);if(i==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof vse)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new vse("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=POy(c,t,r,n):f=AOy(c,t);let u=c.negation||!1;if(i==="AND"){if(!f&&!u||f&&u)return!1}else if(f&&!u||!f&&u)return!0}catch(f){if(f instanceof vse)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new vse("can't match cohort without a given cohort property value");return i==="AND"}}function oOy(e){try{return new RegExp(e),!0}catch{return!1}}function sOy(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 vse(`${e} is in an invalid date format`)}else throw new vse(`The date provided ${e} must be a string, number, or date object`)}function TjC(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var Tmf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},qjC=100,uOy=30*1e3,RjC=50*1e3,qmf=class extends Imf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new Tmf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,qjC):uOy,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 Bmf({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new dZa(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||RjC}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):mOy(t,r)}getLibraryVersion(){return ljC}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=A=>{super.captureStateless(r,n,A,{timestamp:c,disableGeoip:f,uuid:u})},l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags,m=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[M,T]of Object.entries(A))P[`$feature/${M}`]=T;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{s({...A,...i,$groups:a})});this.addPendingPromise(m)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=A=>super.captureStatelessImmediate(r,n,A,{timestamp:c,disableGeoip:f,uuid:u}),l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[M,T]of Object.entries(A))P[`$feature/${M}`]=T;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{s({...A,...i,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:i},{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=uOy){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(n),i(),r(a>0)})})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:u}=n||{},s=this.addLocalPersonAndGroupProperties(r,i,f,u);f=s.allPersonProperties,u=s.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,f,u),m=l!==void 0,A,P;if(!m&&!o){let M=await super.getFeatureFlagDetailStateless(t,r,i,f,u,a);if(M===void 0)return;P=M.response,l=Fmf(P),A=M?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id:A},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:o}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:u,groupProperties:s}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,u,s);u=l.allPersonProperties,s=l.allGroupProperties;let m;return this.featureFlagsPoller!==void 0&&(n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(m!==void 0)&&!c&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,u,s,o)),m}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,n,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,o,c),s={},l={},m=!0;if(u&&(s=u.response,l=u.payloads,m=u.fallbackToDecide),m&&!a){let A=await super.getFeatureFlagsAndPayloadsStateless(t,n,o,c,i);s={...s,...A.flags||{}},l={...l,...A.payloads||{}}}return{featureFlags:s,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...i?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,n){let i=new Error("PostHog syntheticException");dZa.captureException(this,t,{syntheticException:i},r,n)}},cOy=/\(error: (.*)\)/,jOy=50,EOy="?";function NjC(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return n=>{let i=n.match(r);if(i){let a,o,c,f,u;if(i[1]){c=i[1];let m=c.lastIndexOf(".");if(c[m-1]==="."&&m--,m>0){a=c.slice(0,m),o=c.slice(m+1);let A=a.indexOf(".Module");A>0&&(c=c.slice(A+1),a=a.slice(0,A))}f=void 0}o&&(f=a,u=o),o==="<anonymous>"&&(u=void 0,c=void 0),c===void 0&&(u=u||EOy,c=f?`${f}.${u}`:u);let s=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return s?.match(/\/[A-Z]:/)&&(s=s.slice(1)),!s&&i[5]&&!l&&(s=i[5]),{filename:s?decodeURI(s):void 0,module:e?e(s):void 0,function:c,lineno:lOy(i[3]),colno:lOy(i[4]),in_app:FjC(s||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function FjC(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 lOy(e){return parseInt(e||"",10)||void 0}function xjC(e){return[90,NjC(e)]}function zjC(e){let r=[xjC(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],o=n.split(`
|
|
2430
|
-
`);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=cOy.test(f)?f.replace(cOy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=jOy)break}}return QjC(a)}}function QjC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,jOy).map(r=>({...r,filename:r.filename||LjC(t).filename,function:r.function||EOy}))}function LjC(e){return e[e.length-1]||{}}dZa.stackParser=zjC(XwC());dZa.frameModifiers=[ejC];var _Za=class extends qmf{getLibraryId(){return"posthog-node"}};var BSu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new _Za(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.107.5",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var VKo=class{async sendEvent(){}async identify(){}async flush(){}};var yZa=require("fs/promises"),IOy=require("os"),MOy=require("path");var SOy=$i(require("crypto")),qSu=new Uint8Array(256),TSu=qSu.length;function xmf(){return TSu>qSu.length-16&&(SOy.default.randomFillSync(qSu),TSu=0),qSu.slice(TSu,TSu+=16)}var Hve=[];for(let e=0;e<256;++e)Hve.push((e+256).toString(16).slice(1));function DOy(e,t=0){return Hve[e[t+0]]+Hve[e[t+1]]+Hve[e[t+2]]+Hve[e[t+3]]+"-"+Hve[e[t+4]]+Hve[e[t+5]]+"-"+Hve[e[t+6]]+Hve[e[t+7]]+"-"+Hve[e[t+8]]+Hve[e[t+9]]+"-"+Hve[e[t+10]]+Hve[e[t+11]]+Hve[e[t+12]]+Hve[e[t+13]]+Hve[e[t+14]]+Hve[e[t+15]]}var COy=$i(require("crypto")),zmf={randomUUID:COy.default.randomUUID};function UjC(e,t,r){if(zmf.randomUUID&&!t&&!e)return zmf.randomUUID();e=e||{};let n=e.random||(e.rng||xmf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return DOy(n)}var Drt=UjC;var VjC="id",WjC=".fern",WKo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new _Za(r),this.userId=t==null?void 0:n_f(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.107.5",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ql(L_.of((0,IOy.homedir)()),ru.of(WjC),ru.of(VjC));await Xv(t)||(await(0,yZa.mkdir)((0,MOy.dirname)(t),{recursive:!0}),await(0,yZa.writeFile)(t,Drt())),this.persistedDistinctId=(await(0,yZa.readFile)(t)).toString()}return this.persistedDistinctId}};var Qmf;async function vZa(){return Qmf==null&&(Qmf=await HjC()),Qmf}async function HjC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new VKo;let r=await GOu();return r!=null?new WKo({token:r,posthogApiKey:e}):await vYa()!=null?new BSu({posthogApiKey:e}):new WKo({token:void 0,posthogApiKey:e})}catch{return new VKo}}function HKo(e,t){return function(){return e.apply(t,arguments)}}var{toString:GjC}=Object.prototype,{getPrototypeOf:Umf}=Object,{iterator:NSu,toStringTag:TOy}=Symbol,FSu=(e=>t=>{let r=GjC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),FTr=e=>(e=e.toLowerCase(),t=>FSu(t)===e),xSu=e=>t=>typeof t===e,{isArray:gZa}=Array,bZa=xSu("undefined");function GKo(e){return e!==null&&!bZa(e)&&e.constructor!==null&&!bZa(e.constructor)&&rxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var qOy=FTr("ArrayBuffer");function JjC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&qOy(e.buffer),t}var KjC=xSu("string"),rxe=xSu("function"),ROy=xSu("number"),JKo=e=>e!==null&&typeof e=="object",$jC=e=>e===!0||e===!1,RSu=e=>{if(FSu(e)!=="object")return!1;let t=Umf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(TOy in e)&&!(NSu in e)},YjC=e=>{if(!JKo(e)||GKo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},XjC=FTr("Date"),ZjC=FTr("File"),kjC=FTr("Blob"),e1C=FTr("FileList"),t1C=e=>JKo(e)&&rxe(e.pipe),r1C=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||rxe(e.append)&&((t=FSu(e))==="formdata"||t==="object"&&rxe(e.toString)&&e.toString()==="[object FormData]"))},n1C=FTr("URLSearchParams"),[i1C,a1C,o1C,s1C]=["ReadableStream","Request","Response","Headers"].map(FTr),u1C=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function KKo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),gZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(GKo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function NOy(e,t){if(GKo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Aua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,FOy=e=>!bZa(e)&&e!==Aua;function Lmf(){let{caseless:e,skipUndefined:t}=FOy(this)&&this||{},r={},n=(i,a)=>{let o=e&&NOy(r,a)||a;RSu(r[o])&&RSu(i)?r[o]=Lmf(r[o],i):RSu(i)?r[o]=Lmf({},i):gZa(i)?r[o]=i.slice():(!t||!bZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&KKo(arguments[i],n);return r}var c1C=(e,t,r,{allOwnKeys:n}={})=>(KKo(t,(i,a)=>{r&&rxe(i)?e[a]=HKo(i,r):e[a]=i},{allOwnKeys:n}),e),l1C=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),f1C=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},d1C=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&Umf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},p1C=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},_1C=e=>{if(!e)return null;if(gZa(e))return e;let t=e.length;if(!ROy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},h1C=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Umf(Uint8Array)),y1C=(e,t)=>{let n=(e&&e[NSu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},v1C=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},b1C=FTr("HTMLFormElement"),g1C=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),BOy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),m1C=FTr("RegExp"),xOy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};KKo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},O1C=e=>{xOy(e,(t,r)=>{if(rxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(rxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},A1C=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return gZa(e)?n(e):n(String(e).split(t)),r},P1C=()=>{},w1C=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function j1C(e){return!!(e&&rxe(e.append)&&e[TOy]==="FormData"&&e[NSu])}var E1C=e=>{let t=new Array(10),r=(n,i)=>{if(JKo(n)){if(t.indexOf(n)>=0)return;if(GKo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=gZa(n)?[]:{};return KKo(n,(o,c)=>{let f=r(o,i+1);!bZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},S1C=FTr("AsyncFunction"),D1C=e=>e&&(JKo(e)||rxe(e))&&rxe(e.then)&&rxe(e.catch),zOy=((e,t)=>e?setImmediate:t?((r,n)=>(Aua.addEventListener("message",({source:i,data:a})=>{i===Aua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Aua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",rxe(Aua.postMessage)),C1C=typeof queueMicrotask<"u"?queueMicrotask.bind(Aua):typeof process<"u"&&process.nextTick||zOy,I1C=e=>e!=null&&rxe(e[NSu]),Zf={isArray:gZa,isArrayBuffer:qOy,isBuffer:GKo,isFormData:r1C,isArrayBufferView:JjC,isString:KjC,isNumber:ROy,isBoolean:$jC,isObject:JKo,isPlainObject:RSu,isEmptyObject:YjC,isReadableStream:i1C,isRequest:a1C,isResponse:o1C,isHeaders:s1C,isUndefined:bZa,isDate:XjC,isFile:ZjC,isBlob:kjC,isRegExp:m1C,isFunction:rxe,isStream:t1C,isURLSearchParams:n1C,isTypedArray:h1C,isFileList:e1C,forEach:KKo,merge:Lmf,extend:c1C,trim:u1C,stripBOM:l1C,inherits:f1C,toFlatObject:d1C,kindOf:FSu,kindOfTest:FTr,endsWith:p1C,toArray:_1C,forEachEntry:y1C,matchAll:v1C,isHTMLForm:b1C,hasOwnProperty:BOy,hasOwnProp:BOy,reduceDescriptors:xOy,freezeMethods:O1C,toObjectSet:A1C,toCamelCase:g1C,noop:P1C,toFiniteNumber:w1C,findKey:NOy,global:Aua,isContextDefined:FOy,isSpecCompliantForm:j1C,toJSONObject:E1C,isAsyncFn:S1C,isThenable:D1C,setImmediate:zOy,asap:C1C,isIterable:I1C};function mZa(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(mZa,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var QOy=mZa.prototype,LOy={};["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=>{LOy[e]={value:e}});Object.defineProperties(mZa,LOy);Object.defineProperty(QOy,"isAxiosError",{value:!0});mZa.from=(e,t,r,n,i,a)=>{let o=Object.create(QOy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return mZa.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Qm=mZa;var UOy=$i(asa(),1),zSu=UOy.default;function Vmf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function WOy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function VOy(e,t,r){return e?e.concat(t).map(function(i,a){return i=WOy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function M1C(e){return Zf.isArray(e)&&!e.some(Vmf)}var B1C=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function T1C(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(zSu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Zf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new Qm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,M){let T=P;if(P&&!M&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&M1C(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=WOy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?VOy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return Vmf(P)?!0:(t.append(VOy(M,C,a),u(P)),!1)}let l=[],m=Object.assign(B1C,{defaultVisitor:s,convertValue:u,isVisitable:Vmf});function A(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&A(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var p4i=T1C;function HOy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function GOy(e,t){this._pairs=[],e&&p4i(e,this,t)}var JOy=GOy.prototype;JOy.append=function(t,r){this._pairs.push([t,r])};JOy.toString=function(t){let r=t?function(n){return t.call(this,n,HOy)}:HOy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var KOy=GOy;function q1C(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pua(e,t,r){if(!t)return e;let n=r&&r.encode||q1C;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new KOy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Wmf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},Hmf=Wmf;var OZa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ZOy=$i(require("crypto"),1);var $Oy=$i(require("url"),1),YOy=$Oy.default.URLSearchParams;var Gmf="abcdefghijklmnopqrstuvwxyz",XOy="0123456789",kOy={DIGIT:XOy,ALPHA:Gmf,ALPHA_DIGIT:Gmf+Gmf.toUpperCase()+XOy},R1C=(e=16,t=kOy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);ZOy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},eAy={isNode:!0,classes:{URLSearchParams:YOy,FormData:zSu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:kOy,generateString:R1C,protocols:["http","https","file","data"]};var $mf={};yf($mf,{hasBrowserEnv:()=>Kmf,hasStandardBrowserEnv:()=>N1C,hasStandardBrowserWebWorkerEnv:()=>F1C,navigator:()=>Jmf,origin:()=>x1C});var Kmf=typeof window<"u"&&typeof document<"u",Jmf=typeof navigator=="object"&&navigator||void 0,N1C=Kmf&&(!Jmf||["ReactNative","NativeScript","NS"].indexOf(Jmf.product)<0),F1C=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",x1C=Kmf&&window.location.href||"http://localhost";var L7={...$mf,...eAy};function Ymf(e,t){return p4i(e,new L7.classes.URLSearchParams,{visitor:function(r,n,i,a){return L7.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function z1C(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Q1C(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function L1C(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=Q1C(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(z1C(n),i,r,0)}),r}return null}var QSu=L1C;function U1C(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var Xmf={transitional:OZa,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(QSu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Ymf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return p4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),U1C(t)):t}],transformResponse:[function(t){let r=this.transitional||Xmf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Qm.from(c,Qm.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:L7.classes.FormData,Blob:L7.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{Xmf.headers[e]={}});var AZa=Xmf;var V1C=Zf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),tAy=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2430
|
+
`);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=cOy.test(f)?f.replace(cOy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=jOy)break}}return QjC(a)}}function QjC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,jOy).map(r=>({...r,filename:r.filename||LjC(t).filename,function:r.function||EOy}))}function LjC(e){return e[e.length-1]||{}}dZa.stackParser=zjC(XwC());dZa.frameModifiers=[ejC];var _Za=class extends qmf{getLibraryId(){return"posthog-node"}};var BSu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new _Za(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.107.6",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var VKo=class{async sendEvent(){}async identify(){}async flush(){}};var yZa=require("fs/promises"),IOy=require("os"),MOy=require("path");var SOy=$i(require("crypto")),qSu=new Uint8Array(256),TSu=qSu.length;function xmf(){return TSu>qSu.length-16&&(SOy.default.randomFillSync(qSu),TSu=0),qSu.slice(TSu,TSu+=16)}var Hve=[];for(let e=0;e<256;++e)Hve.push((e+256).toString(16).slice(1));function DOy(e,t=0){return Hve[e[t+0]]+Hve[e[t+1]]+Hve[e[t+2]]+Hve[e[t+3]]+"-"+Hve[e[t+4]]+Hve[e[t+5]]+"-"+Hve[e[t+6]]+Hve[e[t+7]]+"-"+Hve[e[t+8]]+Hve[e[t+9]]+"-"+Hve[e[t+10]]+Hve[e[t+11]]+Hve[e[t+12]]+Hve[e[t+13]]+Hve[e[t+14]]+Hve[e[t+15]]}var COy=$i(require("crypto")),zmf={randomUUID:COy.default.randomUUID};function UjC(e,t,r){if(zmf.randomUUID&&!t&&!e)return zmf.randomUUID();e=e||{};let n=e.random||(e.rng||xmf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return DOy(n)}var Drt=UjC;var VjC="id",WjC=".fern",WKo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new _Za(r),this.userId=t==null?void 0:n_f(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.107.6",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ql(L_.of((0,IOy.homedir)()),ru.of(WjC),ru.of(VjC));await Xv(t)||(await(0,yZa.mkdir)((0,MOy.dirname)(t),{recursive:!0}),await(0,yZa.writeFile)(t,Drt())),this.persistedDistinctId=(await(0,yZa.readFile)(t)).toString()}return this.persistedDistinctId}};var Qmf;async function vZa(){return Qmf==null&&(Qmf=await HjC()),Qmf}async function HjC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new VKo;let r=await GOu();return r!=null?new WKo({token:r,posthogApiKey:e}):await vYa()!=null?new BSu({posthogApiKey:e}):new WKo({token:void 0,posthogApiKey:e})}catch{return new VKo}}function HKo(e,t){return function(){return e.apply(t,arguments)}}var{toString:GjC}=Object.prototype,{getPrototypeOf:Umf}=Object,{iterator:NSu,toStringTag:TOy}=Symbol,FSu=(e=>t=>{let r=GjC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),FTr=e=>(e=e.toLowerCase(),t=>FSu(t)===e),xSu=e=>t=>typeof t===e,{isArray:gZa}=Array,bZa=xSu("undefined");function GKo(e){return e!==null&&!bZa(e)&&e.constructor!==null&&!bZa(e.constructor)&&rxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var qOy=FTr("ArrayBuffer");function JjC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&qOy(e.buffer),t}var KjC=xSu("string"),rxe=xSu("function"),ROy=xSu("number"),JKo=e=>e!==null&&typeof e=="object",$jC=e=>e===!0||e===!1,RSu=e=>{if(FSu(e)!=="object")return!1;let t=Umf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(TOy in e)&&!(NSu in e)},YjC=e=>{if(!JKo(e)||GKo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},XjC=FTr("Date"),ZjC=FTr("File"),kjC=FTr("Blob"),e1C=FTr("FileList"),t1C=e=>JKo(e)&&rxe(e.pipe),r1C=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||rxe(e.append)&&((t=FSu(e))==="formdata"||t==="object"&&rxe(e.toString)&&e.toString()==="[object FormData]"))},n1C=FTr("URLSearchParams"),[i1C,a1C,o1C,s1C]=["ReadableStream","Request","Response","Headers"].map(FTr),u1C=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function KKo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),gZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(GKo(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function NOy(e,t){if(GKo(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Aua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,FOy=e=>!bZa(e)&&e!==Aua;function Lmf(){let{caseless:e,skipUndefined:t}=FOy(this)&&this||{},r={},n=(i,a)=>{let o=e&&NOy(r,a)||a;RSu(r[o])&&RSu(i)?r[o]=Lmf(r[o],i):RSu(i)?r[o]=Lmf({},i):gZa(i)?r[o]=i.slice():(!t||!bZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&KKo(arguments[i],n);return r}var c1C=(e,t,r,{allOwnKeys:n}={})=>(KKo(t,(i,a)=>{r&&rxe(i)?e[a]=HKo(i,r):e[a]=i},{allOwnKeys:n}),e),l1C=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),f1C=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},d1C=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&Umf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},p1C=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},_1C=e=>{if(!e)return null;if(gZa(e))return e;let t=e.length;if(!ROy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},h1C=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Umf(Uint8Array)),y1C=(e,t)=>{let n=(e&&e[NSu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},v1C=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},b1C=FTr("HTMLFormElement"),g1C=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),BOy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),m1C=FTr("RegExp"),xOy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};KKo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},O1C=e=>{xOy(e,(t,r)=>{if(rxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(rxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},A1C=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return gZa(e)?n(e):n(String(e).split(t)),r},P1C=()=>{},w1C=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function j1C(e){return!!(e&&rxe(e.append)&&e[TOy]==="FormData"&&e[NSu])}var E1C=e=>{let t=new Array(10),r=(n,i)=>{if(JKo(n)){if(t.indexOf(n)>=0)return;if(GKo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=gZa(n)?[]:{};return KKo(n,(o,c)=>{let f=r(o,i+1);!bZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},S1C=FTr("AsyncFunction"),D1C=e=>e&&(JKo(e)||rxe(e))&&rxe(e.then)&&rxe(e.catch),zOy=((e,t)=>e?setImmediate:t?((r,n)=>(Aua.addEventListener("message",({source:i,data:a})=>{i===Aua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Aua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",rxe(Aua.postMessage)),C1C=typeof queueMicrotask<"u"?queueMicrotask.bind(Aua):typeof process<"u"&&process.nextTick||zOy,I1C=e=>e!=null&&rxe(e[NSu]),Zf={isArray:gZa,isArrayBuffer:qOy,isBuffer:GKo,isFormData:r1C,isArrayBufferView:JjC,isString:KjC,isNumber:ROy,isBoolean:$jC,isObject:JKo,isPlainObject:RSu,isEmptyObject:YjC,isReadableStream:i1C,isRequest:a1C,isResponse:o1C,isHeaders:s1C,isUndefined:bZa,isDate:XjC,isFile:ZjC,isBlob:kjC,isRegExp:m1C,isFunction:rxe,isStream:t1C,isURLSearchParams:n1C,isTypedArray:h1C,isFileList:e1C,forEach:KKo,merge:Lmf,extend:c1C,trim:u1C,stripBOM:l1C,inherits:f1C,toFlatObject:d1C,kindOf:FSu,kindOfTest:FTr,endsWith:p1C,toArray:_1C,forEachEntry:y1C,matchAll:v1C,isHTMLForm:b1C,hasOwnProperty:BOy,hasOwnProp:BOy,reduceDescriptors:xOy,freezeMethods:O1C,toObjectSet:A1C,toCamelCase:g1C,noop:P1C,toFiniteNumber:w1C,findKey:NOy,global:Aua,isContextDefined:FOy,isSpecCompliantForm:j1C,toJSONObject:E1C,isAsyncFn:S1C,isThenable:D1C,setImmediate:zOy,asap:C1C,isIterable:I1C};function mZa(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(mZa,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var QOy=mZa.prototype,LOy={};["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=>{LOy[e]={value:e}});Object.defineProperties(mZa,LOy);Object.defineProperty(QOy,"isAxiosError",{value:!0});mZa.from=(e,t,r,n,i,a)=>{let o=Object.create(QOy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return mZa.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Qm=mZa;var UOy=$i(asa(),1),zSu=UOy.default;function Vmf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function WOy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function VOy(e,t,r){return e?e.concat(t).map(function(i,a){return i=WOy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function M1C(e){return Zf.isArray(e)&&!e.some(Vmf)}var B1C=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function T1C(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(zSu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Zf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new Qm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,M){let T=P;if(P&&!M&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&M1C(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=WOy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?VOy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return Vmf(P)?!0:(t.append(VOy(M,C,a),u(P)),!1)}let l=[],m=Object.assign(B1C,{defaultVisitor:s,convertValue:u,isVisitable:Vmf});function A(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&A(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return A(e),t}var p4i=T1C;function HOy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function GOy(e,t){this._pairs=[],e&&p4i(e,this,t)}var JOy=GOy.prototype;JOy.append=function(t,r){this._pairs.push([t,r])};JOy.toString=function(t){let r=t?function(n){return t.call(this,n,HOy)}:HOy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var KOy=GOy;function q1C(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Pua(e,t,r){if(!t)return e;let n=r&&r.encode||q1C;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new KOy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var Wmf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},Hmf=Wmf;var OZa={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ZOy=$i(require("crypto"),1);var $Oy=$i(require("url"),1),YOy=$Oy.default.URLSearchParams;var Gmf="abcdefghijklmnopqrstuvwxyz",XOy="0123456789",kOy={DIGIT:XOy,ALPHA:Gmf,ALPHA_DIGIT:Gmf+Gmf.toUpperCase()+XOy},R1C=(e=16,t=kOy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);ZOy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},eAy={isNode:!0,classes:{URLSearchParams:YOy,FormData:zSu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:kOy,generateString:R1C,protocols:["http","https","file","data"]};var $mf={};yf($mf,{hasBrowserEnv:()=>Kmf,hasStandardBrowserEnv:()=>N1C,hasStandardBrowserWebWorkerEnv:()=>F1C,navigator:()=>Jmf,origin:()=>x1C});var Kmf=typeof window<"u"&&typeof document<"u",Jmf=typeof navigator=="object"&&navigator||void 0,N1C=Kmf&&(!Jmf||["ReactNative","NativeScript","NS"].indexOf(Jmf.product)<0),F1C=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",x1C=Kmf&&window.location.href||"http://localhost";var L7={...$mf,...eAy};function Ymf(e,t){return p4i(e,new L7.classes.URLSearchParams,{visitor:function(r,n,i,a){return L7.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function z1C(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Q1C(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function L1C(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=Q1C(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(z1C(n),i,r,0)}),r}return null}var QSu=L1C;function U1C(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var Xmf={transitional:OZa,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(QSu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Ymf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return p4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),U1C(t)):t}],transformResponse:[function(t){let r=this.transitional||Xmf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Qm.from(c,Qm.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:L7.classes.FormData,Blob:L7.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{Xmf.headers[e]={}});var AZa=Xmf;var V1C=Zf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),tAy=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2431
2431
|
`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&V1C[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var rAy=Symbol("internals");function $Ko(e){return e&&String(e).trim().toLowerCase()}function LSu(e){return e===!1||e==null?e:Zf.isArray(e)?e.map(LSu):String(e)}function W1C(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var H1C=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Zmf(e,t,r,n,i){if(Zf.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Zf.isString(t)){if(Zf.isString(n))return t.indexOf(n)!==-1;if(Zf.isRegExp(n))return n.test(t)}}function G1C(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function J1C(e,t){let r=Zf.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,o){return this[n].call(this,t,i,a,o)},configurable:!0})})}var PZa=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,f,u){let s=$Ko(f);if(!s)throw new Error("header name must be a non-empty string");let l=Zf.findKey(i,s);(!l||i[l]===void 0||u===!0||u===void 0&&i[l]!==!1)&&(i[l||f]=LSu(c))}let o=(c,f)=>Zf.forEach(c,(u,s)=>a(u,s,f));if(Zf.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(Zf.isString(t)&&(t=t.trim())&&!H1C(t))o(tAy(t),r);else if(Zf.isObject(t)&&Zf.isIterable(t)){let c={},f,u;for(let s of t){if(!Zf.isArray(s))throw TypeError("Object iterator must return a key-value pair");c[u=s[0]]=(f=c[u])?Zf.isArray(f)?[...f,s[1]]:[f,s[1]]:s[1]}o(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=$Ko(t),t){let n=Zf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return W1C(i);if(Zf.isFunction(r))return r.call(this,i,n);if(Zf.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=$Ko(t),t){let n=Zf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Zmf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=$Ko(o),o){let c=Zf.findKey(n,o);c&&(!r||Zmf(n,n[c],c,r))&&(delete n[c],i=!0)}}return Zf.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||Zmf(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Zf.forEach(this,(i,a)=>{let o=Zf.findKey(n,a);if(o){r[o]=LSu(i),delete r[a];return}let c=t?G1C(a):String(a).trim();c!==a&&delete r[a],r[c]=LSu(i),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Zf.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Zf.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
2432
2432
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[rAy]=this[rAy]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=$Ko(o);n[c]||(J1C(i,o),n[c]=!0)}return Zf.isArray(t)?t.forEach(a):a(t),this}};PZa.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Zf.reduceDescriptors(PZa.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Zf.freezeMethods(PZa);var _$=PZa;function YKo(e,t){let r=this||AZa,n=t||r,i=_$.from(n.headers),a=n.data;return Zf.forEach(e,function(c){a=c.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function XKo(e){return!!(e&&e.__CANCEL__)}function nAy(e,t,r){Qm.call(this,e??"canceled",Qm.ERR_CANCELED,t,r),this.name="CanceledError"}Zf.inherits(nAy,Qm,{__CANCEL__:!0});var Crt=nAy;function yUr(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Qm("Request failed with status code "+r.status,[Qm.ERR_BAD_REQUEST,Qm.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function kmf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function eOf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function wua(e,t,r){let n=!kmf(t);return e&&(n||r==!1)?eOf(e,t):t}var gAy=$i(uSu(),1),mAy=$i(require("http"),1),OAy=$i(require("https"),1),AAy=$i(require("util"),1),PAy=$i(tmf(),1),PAi=$i(require("zlib"),1);var jua="1.12.2";function ZKo(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var K1C=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function tOf(e,t,r){let n=r&&r.Blob||L7.classes.Blob,i=ZKo(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=K1C.exec(e);if(!a)throw new Qm("Invalid URL",Qm.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],u=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!n)throw new Qm("Blob is not supported",Qm.ERR_NOT_SUPPORT);return new n([u],{type:o})}return u}throw new Qm("Unsupported protocol "+i,Qm.ERR_NOT_SUPPORT)}var Sua=$i(require("stream"),1);var iAy=$i(require("stream"),1);var rOf=Symbol("internals"),nOf=class extends iAy.default.Transform{constructor(t){t=Zf.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Zf.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[rOf]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[rOf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[rOf],a=i.maxRate,o=this.readableHighWaterMark,c=i.timeWindow,f=1e3/c,u=a/f,s=i.minChunkSize!==!1?Math.max(i.minChunkSize,u*.01):0,l=(A,P)=>{let C=Buffer.byteLength(A);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(A)?process.nextTick(P):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(P)}},m=(A,P)=>{let C=Buffer.byteLength(A),M=null,T=o,z,U=0;if(a){let q=Date.now();(!i.ts||(U=q-i.ts)>=c)&&(i.ts=q,z=u-i.bytes,i.bytes=z<0?-z:0,U=0),z=u-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,A)},c-U);z<T&&(T=z)}T&&C>T&&C-T>s&&(M=A.subarray(T),A=A.subarray(0,T)),l(A,M?()=>{process.nextTick(P,null,M)}:P)};m(t,function A(P,C){if(P)return n(P);C?m(C,A):n(null)})}},iOf=nOf;var wAy=require("events");var oAy=$i(require("util"),1),sAy=require("stream");var{asyncIterator:aAy}=Symbol,$1C=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[aAy]?yield*e[aAy]():yield e},USu=$1C;var Y1C=L7.ALPHABET.ALPHA_DIGIT+"-_",kKo=typeof TextEncoder=="function"?new TextEncoder:new oAy.default.TextEncoder,Eua=`\r
|
|
2433
2433
|
`,X1C=kKo.encode(Eua),Z1C=2,aOf=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Zf.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${Eua}`;i?r=kKo.encode(String(r).replace(/\r?\n|\r\n?/g,Eua)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Eua}`,this.headers=kKo.encode(a+Eua),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+Z1C,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Zf.isTypedArray(t)?yield t:yield*USu(t),yield X1C}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},k1C=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+L7.generateString(i,Y1C)}=r||{};if(!Zf.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=kKo.encode("--"+a+Eua),c=kKo.encode("--"+a+"--"+Eua),f=c.byteLength,u=Array.from(e.entries()).map(([l,m])=>{let A=new aOf(l,m);return f+=A.size,A});f+=o.byteLength*u.length,f=Zf.toFiniteNumber(f);let s={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(s["Content-Length"]=f),t&&t(s),sAy.Readable.from((async function*(){for(let l of u)yield o,yield*l.encode();yield c})())},uAy=k1C;var cAy=$i(require("stream"),1),oOf=class extends cAy.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},lAy=oOf;var eEC=(e,t)=>Zf.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,fAy=eEC;function tEC(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let u=Date.now(),s=n[a];o||(o=u),r[i]=f,n[i]=u;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),u-o<t)return;let A=s&&u-s;return A?Math.round(m*1e3/A):void 0}}var dAy=tEC;function rEC(e,t){let r=0,n=1e3/t,i,a,o=(u,s=Date.now())=>{r=s,i=null,a&&(clearTimeout(a),a=null),e(...u)};return[(...u)=>{let s=Date.now(),l=s-r;l>=n?o(u,s):(i=u,a||(a=setTimeout(()=>{a=null,o(i)},n-l)))},()=>i&&o(i)]}var pAy=rEC;var AAi=(e,t,r=3)=>{let n=0,i=dAy(50,250);return pAy(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-n,u=i(f),s=o<=c;n=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:u||void 0,estimated:u&&c&&s?(c-o)/u:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},wZa=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},jZa=e=>(...t)=>Zf.asap(()=>e(...t));function sOf(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let m=0;m<o;m++)if(n.charCodeAt(m)===37&&m+2<o){let A=n.charCodeAt(m+1),P=n.charCodeAt(m+2);(A>=48&&A<=57||A>=65&&A<=70||A>=97&&A<=102)&&(P>=48&&P<=57||P>=65&&P<=70||P>=97&&P<=102)&&(a-=2,m+=2)}let c=0,f=o-1,u=m=>m>=2&&n.charCodeAt(m-2)===37&&n.charCodeAt(m-1)===51&&(n.charCodeAt(m)===68||n.charCodeAt(m)===100);f>=0&&(n.charCodeAt(f)===61?(c++,f--):u(f)&&(c++,f-=3)),c===1&&f>=0&&(n.charCodeAt(f)===61||u(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var _Ay={flush:PAi.default.constants.Z_SYNC_FLUSH,finishFlush:PAi.default.constants.Z_SYNC_FLUSH},nEC={flush:PAi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:PAi.default.constants.BROTLI_OPERATION_FLUSH},hAy=Zf.isFunction(PAi.default.createBrotliDecompress),{http:iEC,https:aEC}=PAy.default,oEC=/https:?/,yAy=L7.protocols.map(e=>e+":"),vAy=(e,[t,r])=>(e.on("end",r).on("error",r),t);function sEC(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function jAy(e,t,r){let n=t;if(!n&&n!==!1){let i=gAy.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){jAy(a,t,a.href)}}var uEC=typeof process<"u"&&Zf.kindOf(process)==="process",cEC=e=>new Promise((t,r)=>{let n,i,a=(f,u)=>{i||(i=!0,n&&n(f,u))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>n=f).catch(c)}),lEC=({address:e,family:t})=>{if(!Zf.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},bAy=(e,t)=>lEC(Zf.isObject(e)?e:{address:e,family:t}),EAy=uEC&&function(t){return cEC(async function(n,i,a){let{data:o,lookup:c,family:f}=t,{responseType:u,responseEncoding:s}=t,l=t.method.toUpperCase(),m,A=!1,P;if(c){let Se=fAy(c,jt=>Zf.isArray(jt)?jt:[jt]);c=(jt,bt,ze)=>{Se(jt,bt,(Me,Zt,dt)=>{if(Me)return ze(Me);let Ar=Zf.isArray(Zt)?Zt.map(Ft=>bAy(Ft)):[bAy(Zt,dt)];bt.all?ze(Me,Ar):ze(Me,Ar[0].address,Ar[0].family)})}}let C=new wAy.EventEmitter,M=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Se,jt)=>{m=!0,jt&&(A=!0,M())});function T(Se){C.emit("abort",!Se||Se.type?new Crt(null,t,P):Se)}C.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(T),t.signal&&(t.signal.aborted?T():t.signal.addEventListener("abort",T)));let z=wua(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,L7.hasBrowserEnv?L7.origin:void 0),q=U.protocol||yAy[0];if(q==="data:"){if(t.maxContentLength>-1){let jt=String(t.url||z||"");if(sOf(jt)>t.maxContentLength)return i(new Qm("maxContentLength size of "+t.maxContentLength+" exceeded",Qm.ERR_BAD_RESPONSE,t))}let Se;if(l!=="GET")return yUr(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=tOf(t.url,u==="blob",{Blob:t.env&&t.env.Blob})}catch(jt){throw Qm.from(jt,Qm.ERR_BAD_REQUEST,t)}return u==="text"?(Se=Se.toString(s),(!s||s==="utf8")&&(Se=Zf.stripBOM(Se))):u==="stream"&&(Se=Sua.default.Readable.from(Se)),yUr(n,i,{data:Se,status:200,statusText:"OK",headers:new _$,config:t})}if(yAy.indexOf(q)===-1)return i(new Qm("Unsupported protocol "+q,Qm.ERR_BAD_REQUEST,t));let V=_$.from(t.headers).normalize();V.set("User-Agent","axios/"+jua,!1);let{onUploadProgress:$,onDownloadProgress:re}=t,Y=t.maxRate,k,ne;if(Zf.isSpecCompliantForm(o)){let Se=V.getContentType(/boundary=([-_\w\d]{10,70})/i);o=uAy(o,jt=>{V.set(jt)},{tag:`axios-${jua}-boundary`,boundary:Se&&Se[1]||void 0})}else if(Zf.isFormData(o)&&Zf.isFunction(o.getHeaders)){if(V.set(o.getHeaders()),!V.hasContentLength())try{let Se=await AAy.default.promisify(o.getLength).call(o);Number.isFinite(Se)&&Se>=0&&V.setContentLength(Se)}catch{}}else if(Zf.isBlob(o)||Zf.isFile(o))o.size&&V.setContentType(o.type||"application/octet-stream"),V.setContentLength(o.size||0),o=Sua.default.Readable.from(USu(o));else if(o&&!Zf.isStream(o)){if(!Buffer.isBuffer(o))if(Zf.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(Zf.isString(o))o=Buffer.from(o,"utf-8");else return i(new Qm("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Qm.ERR_BAD_REQUEST,t));if(V.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return i(new Qm("Request body larger than maxBodyLength limit",Qm.ERR_BAD_REQUEST,t))}let Oe=Zf.toFiniteNumber(V.getContentLength());Zf.isArray(Y)?(k=Y[0],ne=Y[1]):k=ne=Y,o&&($||k)&&(Zf.isStream(o)||(o=Sua.default.Readable.from(o,{objectMode:!1})),o=Sua.default.pipeline([o,new iOf({maxRate:Zf.toFiniteNumber(k)})],Zf.noop),$&&o.on("progress",vAy(o,wZa(Oe,AAi(jZa($),!1,3)))));let he;if(t.auth){let Se=t.auth.username||"",jt=t.auth.password||"";he=Se+":"+jt}if(!he&&U.username){let Se=U.username,jt=U.password;he=Se+":"+jt}he&&V.delete("authorization");let me;try{me=Pua(U.pathname+U.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Se){let jt=new Error(Se.message);return jt.config=t,jt.url=t.url,jt.exists=!0,i(jt)}V.set("Accept-Encoding","gzip, compress, deflate"+(hAy?", br":""),!1);let ve={path:me,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:he,protocol:q,family:f,beforeRedirect:sEC,beforeRedirects:{}};!Zf.isUndefined(c)&&(ve.lookup=c),t.socketPath?ve.socketPath=t.socketPath:(ve.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,ve.port=U.port,jAy(ve,t.proxy,q+"//"+U.hostname+(U.port?":"+U.port:"")+ve.path));let Ce,Be=oEC.test(ve.protocol);if(ve.agent=Be?t.httpsAgent:t.httpAgent,t.transport?Ce=t.transport:t.maxRedirects===0?Ce=Be?OAy.default:mAy.default:(t.maxRedirects&&(ve.maxRedirects=t.maxRedirects),t.beforeRedirect&&(ve.beforeRedirects.config=t.beforeRedirect),Ce=Be?aEC:iEC),t.maxBodyLength>-1?ve.maxBodyLength=t.maxBodyLength:ve.maxBodyLength=1/0,t.insecureHTTPParser&&(ve.insecureHTTPParser=t.insecureHTTPParser),P=Ce.request(ve,function(jt){if(P.destroyed)return;let bt=[jt],ze=+jt.headers["content-length"];if(re||ne){let Ft=new iOf({maxRate:Zf.toFiniteNumber(ne)});re&&Ft.on("progress",vAy(Ft,wZa(ze,AAi(jZa(re),!0,3)))),bt.push(Ft)}let Me=jt,Zt=jt.req||P;if(t.decompress!==!1&&jt.headers["content-encoding"])switch((l==="HEAD"||jt.statusCode===204)&&delete jt.headers["content-encoding"],(jt.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":bt.push(PAi.default.createUnzip(_Ay)),delete jt.headers["content-encoding"];break;case"deflate":bt.push(new lAy),bt.push(PAi.default.createUnzip(_Ay)),delete jt.headers["content-encoding"];break;case"br":hAy&&(bt.push(PAi.default.createBrotliDecompress(nEC)),delete jt.headers["content-encoding"])}Me=bt.length>1?Sua.default.pipeline(bt,Zf.noop):bt[0];let dt=Sua.default.finished(Me,()=>{dt(),M()}),Ar={status:jt.statusCode,statusText:jt.statusMessage,headers:new _$(jt.headers),config:t,request:Zt};if(u==="stream")Ar.data=Me,yUr(n,i,Ar);else{let Ft=[],Xe=0;Me.on("data",function(cr){Ft.push(cr),Xe+=cr.length,t.maxContentLength>-1&&Xe>t.maxContentLength&&(A=!0,Me.destroy(),i(new Qm("maxContentLength size of "+t.maxContentLength+" exceeded",Qm.ERR_BAD_RESPONSE,t,Zt)))}),Me.on("aborted",function(){if(A)return;let cr=new Qm("stream has been aborted",Qm.ERR_BAD_RESPONSE,t,Zt);Me.destroy(cr),i(cr)}),Me.on("error",function(cr){P.destroyed||i(Qm.from(cr,null,t,Zt))}),Me.on("end",function(){try{let cr=Ft.length===1?Ft[0]:Buffer.concat(Ft);u!=="arraybuffer"&&(cr=cr.toString(s),(!s||s==="utf8")&&(cr=Zf.stripBOM(cr))),Ar.data=cr}catch(cr){return i(Qm.from(cr,null,t,Ar.request,Ar))}yUr(n,i,Ar)})}C.once("abort",Ft=>{Me.destroyed||(Me.emit("error",Ft),Me.destroy())})}),C.once("abort",Se=>{i(Se),P.destroy(Se)}),P.on("error",function(jt){i(Qm.from(jt,null,t,P))}),P.on("socket",function(jt){jt.setKeepAlive(!0,1e3*60)}),t.timeout){let Se=parseInt(t.timeout,10);if(Number.isNaN(Se)){i(new Qm("error trying to parse `config.timeout` to int",Qm.ERR_BAD_OPTION_VALUE,t,P));return}P.setTimeout(Se,function(){if(m)return;let bt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",ze=t.transitional||OZa;t.timeoutErrorMessage&&(bt=t.timeoutErrorMessage),i(new Qm(bt,ze.clarifyTimeoutError?Qm.ETIMEDOUT:Qm.ECONNABORTED,t,P)),T()})}if(Zf.isStream(o)){let Se=!1,jt=!1;o.on("end",()=>{Se=!0}),o.once("error",bt=>{jt=!0,P.destroy(bt)}),o.on("close",()=>{!Se&&!jt&&T(new Crt("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var SAy=L7.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,L7.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(L7.origin),L7.navigator&&/(msie|trident)/i.test(L7.navigator.userAgent)):()=>!0;var DAy=L7.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let o=[e+"="+encodeURIComponent(t)];Zf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Zf.isString(n)&&o.push("path="+n),Zf.isString(i)&&o.push("domain="+i),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var CAy=e=>e instanceof _$?{...e}:e;function xTr(e,t){t=t||{};let r={};function n(u,s,l,m){return Zf.isPlainObject(u)&&Zf.isPlainObject(s)?Zf.merge.call({caseless:m},u,s):Zf.isPlainObject(s)?Zf.merge({},s):Zf.isArray(s)?s.slice():s}function i(u,s,l,m){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u,l,m)}else return n(u,s,l,m)}function a(u,s){if(!Zf.isUndefined(s))return n(void 0,s)}function o(u,s){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u)}else return n(void 0,s)}function c(u,s,l){if(l in t)return n(u,s);if(l in e)return n(void 0,u)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,s,l)=>i(CAy(u),CAy(s),l,!0)};return Zf.forEach(Object.keys({...e,...t}),function(s){let l=f[s]||i,m=l(e[s],t[s],s);Zf.isUndefined(m)&&l!==c||(r[s]=m)}),r}var VSu=e=>{let t=xTr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=_$.from(o),t.url=Pua(wua(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Zf.isFormData(r)){if(L7.hasStandardBrowserEnv||L7.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Zf.isFunction(r.getHeaders)){let f=r.getHeaders(),u=["content-type","content-length"];Object.entries(f).forEach(([s,l])=>{u.includes(s.toLowerCase())&&o.set(s,l)})}}if(L7.hasStandardBrowserEnv&&(n&&Zf.isFunction(n)&&(n=n(t)),n||n!==!1&&SAy(t.url))){let f=i&&a&&DAy.read(a);f&&o.set(i,f)}return t};var fEC=typeof XMLHttpRequest<"u",IAy=fEC&&function(e){return new Promise(function(r,n){let i=VSu(e),a=i.data,o=_$.from(i.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:u}=i,s,l,m,A,P;function C(){A&&A(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(s),i.signal&&i.signal.removeEventListener("abort",s)}let M=new XMLHttpRequest;M.open(i.method.toUpperCase(),i.url,!0),M.timeout=i.timeout;function T(){if(!M)return;let U=_$.from("getAllResponseHeaders"in M&&M.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?M.responseText:M.response,status:M.status,statusText:M.statusText,headers:U,config:e,request:M};yUr(function(re){r(re),C()},function(re){n(re),C()},V),M=null}"onloadend"in M?M.onloadend=T:M.onreadystatechange=function(){!M||M.readyState!==4||M.status===0&&!(M.responseURL&&M.responseURL.indexOf("file:")===0)||setTimeout(T)},M.onabort=function(){M&&(n(new Qm("Request aborted",Qm.ECONNABORTED,e,M)),M=null)},M.onerror=function(q){let V=q&&q.message?q.message:"Network Error",$=new Qm(V,Qm.ERR_NETWORK,e,M);$.event=q||null,n($),M=null},M.ontimeout=function(){let q=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||OZa;i.timeoutErrorMessage&&(q=i.timeoutErrorMessage),n(new Qm(q,V.clarifyTimeoutError?Qm.ETIMEDOUT:Qm.ECONNABORTED,e,M)),M=null},a===void 0&&o.setContentType(null),"setRequestHeader"in M&&Zf.forEach(o.toJSON(),function(q,V){M.setRequestHeader(V,q)}),Zf.isUndefined(i.withCredentials)||(M.withCredentials=!!i.withCredentials),c&&c!=="json"&&(M.responseType=i.responseType),u&&([m,P]=AAi(u,!0),M.addEventListener("progress",m)),f&&M.upload&&([l,A]=AAi(f),M.upload.addEventListener("progress",l),M.upload.addEventListener("loadend",A)),(i.cancelToken||i.signal)&&(s=U=>{M&&(n(!U||U.type?new Crt(null,e,M):U),M.abort(),M=null)},i.cancelToken&&i.cancelToken.subscribe(s),i.signal&&(i.signal.aborted?s():i.signal.addEventListener("abort",s)));let z=ZKo(i.url);if(z&&L7.protocols.indexOf(z)===-1){n(new Qm("Unsupported protocol "+z+":",Qm.ERR_BAD_REQUEST,e));return}M.send(a||null)})};var dEC=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(u){if(!i){i=!0,c();let s=u instanceof Error?u:this.reason;n.abort(s instanceof Qm?s:new Crt(s instanceof Error?s.message:s))}},o=t&&setTimeout(()=>{o=null,a(new Qm(`timeout ${t} of ms exceeded`,Qm.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(a):u.removeEventListener("abort",a)}),e=null)};e.forEach(u=>u.addEventListener("abort",a));let{signal:f}=n;return f.unsubscribe=()=>Zf.asap(c),f}},MAy=dEC;var pEC=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},_EC=async function*(e,t){for await(let r of hEC(e))yield*pEC(r,t)},hEC=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},uOf=(e,t,r,n)=>{let i=_EC(e,t),a=0,o,c=f=>{o||(o=!0,n&&n(f))};return new ReadableStream({async pull(f){try{let{done:u,value:s}=await i.next();if(u){c(),f.close();return}let l=s.byteLength;if(r){let m=a+=l;r(m)}f.enqueue(new Uint8Array(s))}catch(u){throw c(u),u}},cancel(f){return c(f),i.return()}},{highWaterMark:2})};var BAy=64*1024,{isFunction:WSu}=Zf,yEC=(({Request:e,Response:t})=>({Request:e,Response:t}))(Zf.global),{ReadableStream:TAy,TextEncoder:qAy}=Zf.global,RAy=(e,...t)=>{try{return!!e(...t)}catch{return!1}},vEC=e=>{e=Zf.merge.call({skipUndefined:!0},yEC,e);let{fetch:t,Request:r,Response:n}=e,i=t?WSu(t):typeof fetch=="function",a=WSu(r),o=WSu(n);if(!i)return!1;let c=i&&WSu(TAy),f=i&&(typeof qAy=="function"?(P=>C=>P.encode(C))(new qAy):async P=>new Uint8Array(await new r(P).arrayBuffer())),u=a&&c&&RAy(()=>{let P=!1,C=new r(L7.origin,{body:new TAy,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),s=o&&c&&RAy(()=>Zf.isReadableStream(new n("").body)),l={stream:s&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,M)=>{let T=C&&C[P];if(T)return T.call(C);throw new Qm(`Response type '${P}' is not supported`,Qm.ERR_NOT_SUPPORT,M)})});let m=async P=>{if(P==null)return 0;if(Zf.isBlob(P))return P.size;if(Zf.isSpecCompliantForm(P))return(await new r(L7.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(Zf.isArrayBufferView(P)||Zf.isArrayBuffer(P))return P.byteLength;if(Zf.isURLSearchParams(P)&&(P=P+""),Zf.isString(P))return(await f(P)).byteLength},A=async(P,C)=>{let M=Zf.toFiniteNumber(P.getContentLength());return M??m(C)};return async P=>{let{url:C,method:M,data:T,signal:z,cancelToken:U,timeout:q,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:Y,withCredentials:k="same-origin",fetchOptions:ne}=VSu(P),Oe=t||fetch;re=re?(re+"").toLowerCase():"text";let he=MAy([z,U&&U.toAbortSignal()],q),me=null,ve=he&&he.unsubscribe&&(()=>{he.unsubscribe()}),Ce;try{if($&&u&&M!=="get"&&M!=="head"&&(Ce=await A(Y,T))!==0){let Me=new r(C,{method:"POST",body:T,duplex:"half"}),Zt;if(Zf.isFormData(T)&&(Zt=Me.headers.get("content-type"))&&Y.setContentType(Zt),Me.body){let[dt,Ar]=wZa(Ce,AAi(jZa($)));T=uOf(Me.body,BAy,dt,Ar)}}Zf.isString(k)||(k=k?"include":"omit");let Be=a&&"credentials"in r.prototype,Se={...ne,signal:he,method:M.toUpperCase(),headers:Y.normalize().toJSON(),body:T,duplex:"half",credentials:Be?k:void 0};me=a&&new r(C,Se);let jt=await(a?Oe(me,ne):Oe(C,Se)),bt=s&&(re==="stream"||re==="response");if(s&&(V||bt&&ve)){let Me={};["status","statusText","headers"].forEach(Ft=>{Me[Ft]=jt[Ft]});let Zt=Zf.toFiniteNumber(jt.headers.get("content-length")),[dt,Ar]=V&&wZa(Zt,AAi(jZa(V),!0))||[];jt=new n(uOf(jt.body,BAy,dt,()=>{Ar&&Ar(),ve&&ve()}),Me)}re=re||"text";let ze=await l[Zf.findKey(l,re)||"text"](jt,P);return!bt&&ve&&ve(),await new Promise((Me,Zt)=>{yUr(Me,Zt,{data:ze,headers:_$.from(jt.headers),status:jt.status,statusText:jt.statusText,config:P,request:me})})}catch(Be){throw ve&&ve(),Be&&Be.name==="TypeError"&&/Load failed|fetch/i.test(Be.message)?Object.assign(new Qm("Network Error",Qm.ERR_NETWORK,P,me),{cause:Be.cause||Be}):Qm.from(Be,Be&&Be.code,P,me)}}},bEC=new Map,cOf=e=>{let t=e?e.env:{},{fetch:r,Request:n,Response:i}=t,a=[n,i,r],o=a.length,c=o,f,u,s=bEC;for(;c--;)f=a[c],u=s.get(f),u===void 0&&s.set(f,u=c?new Map:vEC(t)),s=u;return u},TnU=cOf();var lOf={http:EAy,xhr:IAy,fetch:{get:cOf}};Zf.forEach(lOf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var NAy=e=>`- ${e}`,mEC=e=>Zf.isFunction(e)||e===null||e===!1,HSu={getAdapter:(e,t)=>{e=Zf.isArray(e)?e:[e];let{length:r}=e,n,i,a={};for(let o=0;o<r;o++){n=e[o];let c;if(i=n,!mEC(n)&&(i=lOf[(c=String(n)).toLowerCase()],i===void 0))throw new Qm(`Unknown adapter '${c}'`);if(i&&(Zf.isFunction(i)||(i=i.get(t))))break;a[c||"#"+o]=i}if(!i){let o=Object.entries(a).map(([f,u])=>`adapter ${f} `+(u===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
|
|
@@ -2668,7 +2668,7 @@ ${q}${z}${V}${dro}`});function sFu({message:e,error:t,logger:r,logLevel:n=oE.Err
|
|
|
2668
2668
|
Run ${Mf.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
2669
2669
|
Run ${Mf.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),SZa(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function pRf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!wUy(e))return;let i=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)i+=`
|
|
2670
2670
|
${await esI(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Mf.dim(c.currentVersion)+Mf.reset(" \u2192 ")+Mf.green(c.latestVersion);return i+=`
|
|
2671
|
-
`,n?SZa(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function esI(e){let r=await new PUy.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 tsI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await EUy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=Zxi(s.name,l),A=await aTr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await EUy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=Zxi(u.name,s),m=await aTr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function EUy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await hTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function SUy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=gxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function fFu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await tsI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...SUy(u,f,t.logger));else o.push(...SUy(c.versions,void 0,t.logger))}return o}var zZo=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var yro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var _Rf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),DUy=typeof globalThis.AbortController=="function",CUy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",IUy=typeof globalThis.ReadableStream=="function",MUy=typeof globalThis.FormData=="function",dFu=["get","post","put","patch","head","delete"],rsI=()=>{};rsI();var BUy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},pFu=2147483647,TUy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,_Fu=Symbol("stop"),qUy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},RUy={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 nsI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=TUy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},NUy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},FUy=(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(NUy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},xUy=(e,t,r)=>{if(!e.body)return e;let n=nsI(r??e.body);return new Request(e,{duplex:"half",body:NUy(e.body,n,t)})};var vro=e=>e!==null&&typeof e=="object";var QZo=(...e)=>{for(let t of e)if((!vro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return vRf({},...e)},hRf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function hFu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:vRf(e[r]??[],t[r]??[])}var yRf=(e={},t={})=>({beforeRequest:hFu(e,t,"beforeRequest"),beforeRetry:hFu(e,t,"beforeRetry"),afterResponse:hFu(e,t,"afterResponse"),beforeError:hFu(e,t,"beforeError")}),vRf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(vro(i)){for(let[a,o]of Object.entries(i))vro(o)&&a in t&&(o=vRf(t[a],o)),t={...t,[a]:o};vro(i.hooks)&&(n=yRf(n,i.hooks),t.hooks=n),vro(i.headers)&&(r=hRf(r,i.headers),t.headers=r)}return t};var QUy=e=>dFu.includes(e)?e.toUpperCase():e,isI=["get","put","head","delete","options","trace"],asI=[408,413,429,500,502,503,504],osI=[413,429,503],zUy={limit:2,methods:isI,statusCodes:asI,afterStatusCodes:osI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},LUy=(e={})=>{if(typeof e=="number")return{...zUy,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{...zUy,...e}};async function bRf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new yro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function gRf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var UUy=(e,t)=>{let r={};for(let n in t)!(n in RUy)&&!(n in qUy)&&!(n in e)&&(r[n]=t[n]);return r},VUy=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 LZo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>pFu)throw new RangeError(`The \`timeout\` option cannot be greater than ${pFu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new zZo(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!IUy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return FUy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(BUy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:hRf(this._input.headers,r.headers),hooks:yRf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:QUy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:LUy(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(DUy&&CUy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(_Rf&&(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),VUy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(MUy&&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(!_Rf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=xUy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof yro)throw t;if(t instanceof zZo){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),pFu);if(this._retryCount<1)throw r;await gRf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===_Fu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=UUy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):bRf(this._originalRequest,t,this.abortController,this._options)}};var mRf=e=>{let t=(r,n)=>LZo.create(r,QZo(e,n));for(let r of dFu)t[r]=(n,i)=>LZo.create(n,QZo(e,i,{method:r}));return t.create=r=>mRf(QZo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),mRf(QZo(e,r))),t.stop=_Fu,t},ssI=mRf(),WUy=ssI;var pVy=$i(dVy(),1);function jRf(e){let t=(0,pVy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var sWy=$i(oWy(),1),uWy=$i(JMr(),1),xRf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},zRf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function QRf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??jRf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,sWy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await WUy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new xRf(e):l}if(t.allVersions)return u;let s=new zRf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[A,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[A];if(!l){let A=Object.keys(u.versions);if(r=uWy.default.maxSatisfying(A,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function JZo(e,t){let{version:r}=await QRf(e.toLowerCase(),t);return r}async function x6i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:JZo(e.packageName,{version:t?"prerelease":"latest"})}var cWy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],SFu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=oE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new lFu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.107.5"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Mf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new gne}failWithoutThrowing(t,r){this.didSucceed=!1,sFu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await vZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await jUy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2671
|
+
`,n?SZa(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function esI(e){let r=await new PUy.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 tsI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await EUy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=Zxi(s.name,l),A=await aTr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await EUy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=Zxi(u.name,s),m=await aTr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function EUy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await hTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function SUy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=gxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function fFu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await tsI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...SUy(u,f,t.logger));else o.push(...SUy(c.versions,void 0,t.logger))}return o}var zZo=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var yro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var _Rf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),DUy=typeof globalThis.AbortController=="function",CUy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",IUy=typeof globalThis.ReadableStream=="function",MUy=typeof globalThis.FormData=="function",dFu=["get","post","put","patch","head","delete"],rsI=()=>{};rsI();var BUy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},pFu=2147483647,TUy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,_Fu=Symbol("stop"),qUy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},RUy={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 nsI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=TUy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},NUy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},FUy=(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(NUy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},xUy=(e,t,r)=>{if(!e.body)return e;let n=nsI(r??e.body);return new Request(e,{duplex:"half",body:NUy(e.body,n,t)})};var vro=e=>e!==null&&typeof e=="object";var QZo=(...e)=>{for(let t of e)if((!vro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return vRf({},...e)},hRf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function hFu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:vRf(e[r]??[],t[r]??[])}var yRf=(e={},t={})=>({beforeRequest:hFu(e,t,"beforeRequest"),beforeRetry:hFu(e,t,"beforeRetry"),afterResponse:hFu(e,t,"afterResponse"),beforeError:hFu(e,t,"beforeError")}),vRf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(vro(i)){for(let[a,o]of Object.entries(i))vro(o)&&a in t&&(o=vRf(t[a],o)),t={...t,[a]:o};vro(i.hooks)&&(n=yRf(n,i.hooks),t.hooks=n),vro(i.headers)&&(r=hRf(r,i.headers),t.headers=r)}return t};var QUy=e=>dFu.includes(e)?e.toUpperCase():e,isI=["get","put","head","delete","options","trace"],asI=[408,413,429,500,502,503,504],osI=[413,429,503],zUy={limit:2,methods:isI,statusCodes:asI,afterStatusCodes:osI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},LUy=(e={})=>{if(typeof e=="number")return{...zUy,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{...zUy,...e}};async function bRf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new yro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function gRf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var UUy=(e,t)=>{let r={};for(let n in t)!(n in RUy)&&!(n in qUy)&&!(n in e)&&(r[n]=t[n]);return r},VUy=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 LZo=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>pFu)throw new RangeError(`The \`timeout\` option cannot be greater than ${pFu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new zZo(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!IUy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return FUy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(BUy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:hRf(this._input.headers,r.headers),hooks:yRf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:QUy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:LUy(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(DUy&&CUy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(_Rf&&(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),VUy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(MUy&&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(!_Rf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=xUy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof yro)throw t;if(t instanceof zZo){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),pFu);if(this._retryCount<1)throw r;await gRf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===_Fu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=UUy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):bRf(this._originalRequest,t,this.abortController,this._options)}};var mRf=e=>{let t=(r,n)=>LZo.create(r,QZo(e,n));for(let r of dFu)t[r]=(n,i)=>LZo.create(n,QZo(e,i,{method:r}));return t.create=r=>mRf(QZo(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),mRf(QZo(e,r))),t.stop=_Fu,t},ssI=mRf(),WUy=ssI;var pVy=$i(dVy(),1);function jRf(e){let t=(0,pVy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var sWy=$i(oWy(),1),uWy=$i(JMr(),1),xRf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},zRf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function QRf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??jRf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,sWy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await WUy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new xRf(e):l}if(t.allVersions)return u;let s=new zRf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[A,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[A];if(!l){let A=Object.keys(u.versions);if(r=uWy.default.maxSatisfying(A,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function JZo(e,t){let{version:r}=await QRf(e.toLowerCase(),t);return r}async function x6i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:JZo(e.packageName,{version:t?"prerelease":"latest"})}var cWy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],SFu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=oE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new lFu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.107.6"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Mf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new gne}failWithoutThrowing(t,r){this.didSucceed=!1,sFu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await vZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await jUy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2672
2672
|
`)||(r+=`
|
|
2673
2673
|
`),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=aJl(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new TZo(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new gne}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await vZa()).sendEvent(t)}logger=B2r((t,...r)=>this.log(t,...r));stderr=B2r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=lWy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?lWy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=cWy[this.numTasks++%cWy.length],o=Mf.hex(a)(i);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===dV.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let n=t.filter(i=>vxi.indexOf(i.level)>=vxi.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===oE.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 x6i({cliEnvironment:this.environment,includePreReleases:t}),n=gxe(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await fFu({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await rRf({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Mf.yellow("?"),style:{answer:i=>Mf.cyan(i),message:i=>Mf.bold(i),highlight:i=>Mf.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
|
|
2674
2674
|
Cancelled by user.`),new gne):n}}async getInput(t){return await Zqf({message:t.message,default:t.default})}};function lWy(e){return`[${e}]:`}var uqr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};var rnt=class extends uqr{definition;sources;type="fern";constructor({definition:t,sources:r,...n}){super(n),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var uht={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,wrapReferencesToNullableInOptional:!0,coerceOptionalSchemasToNullable:!0,groupEnvironmentsByHost:!1};function KZo({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??uht.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??uht.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??uht.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??uht.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??uht.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??uht.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??uht.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??uht.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??uht.respectForwardCompatibleEnums,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??uht.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??uht.coerceOptionalSchemasToNullable,groupEnvironmentsByHost:t?.groupEnvironmentsByHost??e?.groupEnvironmentsByHost??uht.groupEnvironmentsByHost}}var vPe={openapi:e=>({...e,type:"openapi",_visit:function(t){return vPe._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return vPe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var wro={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return wro._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var nde={basic:e=>({...e,type:"basic",_visit:function(t){return nde._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return nde._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return nde._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return nde._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return nde._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var TS={primitive:e=>({value:e,type:"primitive",_visit:function(t){return TS._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return TS._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return TS._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return TS._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return TS._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return TS._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return TS._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return TS._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return TS._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"null":return t.null(e);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var zO={int:e=>({value:e,type:"int",_visit:function(t){return zO._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return zO._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return zO._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return zO._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return zO._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return zO._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return zO._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return zO._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return zO._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return zO._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return zO._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var z6i={boolean:e=>({value:e,type:"boolean",_visit:function(t){return z6i._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return z6i._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var Q6i={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return Q6i._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return Q6i._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var DFu={};yf(DFu,{Availability:()=>ide,CustomCodeSample:()=>lVr,EndpointExample:()=>cht,EndpointResponseExample:()=>lht,HttpMethod:()=>ode,LiteralSchemaValue:()=>IV,MultipartRequestPropertyEncoding:()=>VRf,MultipartSchema:()=>fVr,OneOfSchema:()=>dVr,Pagination:()=>nnt,PrimitiveSchemaValue:()=>Rq,Request:()=>cqr,Response:()=>Yve,RetriesConfiguration:()=>$Zo,Schema:()=>p1,SupportedSdkLanguage:()=>ade,WebhookHttpMethod:()=>URf,WebsocketMessageOrigin:()=>LRf});var LRf={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case LRf.Client:return t.client();case LRf.Server:return t.server();default:return t._other()}}};var URf={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case URf.Get:return t.get();case URf.Post:return t.post();default:return t._other()}}};var ide={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case ide.GenerallyAvailable:return t.generallyAvailable();case ide.Beta:return t.beta();case ide.Deprecated:return t.deprecated();default:return t._other()}}};var $Zo={disabled:e=>({value:e,type:"disabled",_visit:function(t){return $Zo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var nnt={cursor:e=>({...e,type:"cursor",_visit:function(t){return nnt._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return nnt._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return nnt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var lVr={language:e=>({...e,type:"language",_visit:function(t){return lVr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return lVr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var ade={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case ade.Curl:return t.curl();case ade.Python:return t.python();case ade.Javascript:return t.javascript();case ade.Typescript:return t.typescript();case ade.Go:return t.go();case ade.Ruby:return t.ruby();case ade.Csharp:return t.csharp();case ade.Java:return t.java();case ade.Js:return t.js();case ade.Node:return t.node();case ade.Ts:return t.ts();case ade.Nodets:return t.nodets();case ade.Golang:return t.golang();case ade.Dotnet:return t.dotnet();case ade.Jvm:return t.jvm();default:return t._other()}}};var cht={unknown:e=>({value:e,type:"unknown",_visit:function(t){return cht._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return cht._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var lht={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return lht._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return lht._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var ode={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case ode.Get:return t.get();case ode.Post:return t.post();case ode.Put:return t.put();case ode.Patch:return t.patch();case ode.Delete:return t.delete();case ode.Head:return t.head();case ode.Options:return t.options();case ode.Trace:return t.trace();default:return t._other()}}};var cqr={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return cqr._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return cqr._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return cqr._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return cqr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var VRf={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case VRf.Json:return t.json();case VRf.Form:return t.form();default:return t._other()}}};var fVr={file:e=>({...e,type:"file",_visit:function(t){return fVr._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return fVr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var Yve={file:e=>({...e,type:"file",_visit:function(t){return Yve._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Yve._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Yve._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return Yve._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Yve._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Yve._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Yve._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var p1={primitive:e=>({...e,type:"primitive",_visit:function(t){return p1._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return p1._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return p1._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return p1._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return p1._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return p1._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return p1._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return p1._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return p1._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return p1._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return p1._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Rq={int:e=>({...e,type:"int",_visit:function(t){return Rq._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Rq._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Rq._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Rq._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Rq._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Rq._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Rq._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Rq._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Rq._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Rq._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Rq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var IV={boolean:e=>({value:e,type:"boolean",_visit:function(t){return IV._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return IV._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var dVr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return dVr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return dVr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var hCe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return hCe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return hCe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return hCe._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return hCe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var VL={file:e=>({...e,type:"file",_visit:function(t){return VL._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return VL._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return VL._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return VL._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return VL._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return VL._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return VL._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Bh={primitive:e=>({...e,type:"primitive",_visit:function(t){return Bh._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Bh._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Bh._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Bh._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Bh._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Bh._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Bh._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Bh._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Bh._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Bh._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Bh._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var int={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return int._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return int._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var tm={int:e=>({...e,type:"int",_visit:function(t){return tm._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return tm._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return tm._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return tm._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return tm._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return tm._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return tm._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return tm._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return tm._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return tm._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return tm._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var Gj={};yf(Gj,{AllOfPropertyConflict:()=>Yro,ArraySchema:()=>Hxu,ArraySchemaWithExample:()=>A3u,Availability:()=>xFu,Base64WithExample:()=>v3u,BasicSecurityScheme:()=>QFu,BearerSecurityScheme:()=>LFu,BooleanSchema:()=>zxu,BooleanWithExample:()=>b3u,BytesResponse:()=>Qro,CasingOverrides:()=>WFu,CommonProperty:()=>kxu,CommonPropertyWithExample:()=>M3u,CursorPagination:()=>Axu,CustomCodeSample:()=>mxu,CustomCodeSampleLanguage:()=>vxu,CustomCodeSampleSdk:()=>gxu,CustomPagination:()=>wxu,DateWithExample:()=>y3u,DatetimeWithExample:()=>h3u,DiscriminatedOneOfSchema:()=>Xxu,DiscriminatedOneOfSchemaWithExample:()=>C3u,DoubleSchema:()=>Fxu,DoubleWithExample:()=>p3u,Encoding:()=>FFu,Endpoint:()=>jxu,EndpointExample:()=>Wro,EndpointResponseExample:()=>yxu,EndpointSdkName:()=>hVr,EndpointSecurity:()=>Bro,EndpointWithExample:()=>QWy,EnumSchema:()=>Cro,EnumSchemaWithExample:()=>m3u,EnumValue:()=>V6i,ErrorExample:()=>fxu,FernExample:()=>pxu,FileResponse:()=>xro,FileSchema:()=>nxu,FloatWithExample:()=>d3u,FormUrlEncodedRequest:()=>uxu,FullEndpointExample:()=>Oxu,FullExample:()=>jQ,FullObjectExample:()=>ZFu,FullOneOfExample:()=>exu,GlobalHeader:()=>Lxu,Header:()=>H6i,HeaderExample:()=>Vro,HeaderSecurityScheme:()=>UFu,HeaderWithExample:()=>K6i,HttpEndpointServer:()=>Lro,HttpError:()=>dxu,HttpErrorWithExample:()=>s3u,HttpMethod:()=>Tro,IdempotencyHeader:()=>Uxu,Int64WithExample:()=>c3u,IntSchema:()=>Rxu,IntWithExample:()=>u3u,JsonRequest:()=>sxu,JsonRequestWithExample:()=>n3u,JsonResponse:()=>zro,JsonResponseWithExample:()=>kro,KeyValuePair:()=>kFu,LiteralExample:()=>YFu,LiteralSchema:()=>$ro,LiteralSchemaValue:()=>Vxu,LongSchema:()=>Nxu,MapSchema:()=>Gxu,MapSchemaWithExample:()=>P3u,MultipartRequest:()=>Fro,MultipartRequestProperty:()=>oxu,MultipartRequestPropertyEncoding:()=>axu,MultipartSchema:()=>ixu,NamedFullExample:()=>dht,Namespace:()=>HFu,NamespaceId:()=>$Fu,NullExample:()=>XFu,NullableSchema:()=>Kxu,NullableSchemaWithExample:()=>j3u,OauthSecurityScheme:()=>JFu,ObjectProperty:()=>Yxu,ObjectPropertyConflictInfo:()=>Xro,ObjectPropertyWithExample:()=>D3u,ObjectSchema:()=>Wxu,ObjectSchemaWithExample:()=>E3u,OctetStreamRequest:()=>Nro,OffsetPagination:()=>Pxu,OneOfSchema:()=>$xu,OneOfSchemaWithExample:()=>S3u,OpenApiIntermediateRepresentation:()=>xWy,OpenApiSource:()=>TFu,OptionalSchema:()=>Jxu,OptionalSchemaWithExample:()=>w3u,Pagination:()=>Hro,ParseFormUrlEncodedRequest:()=>i3u,ParseMultipartRequest:()=>r3u,ParseOctetStreamRequest:()=>t3u,PathParameter:()=>qro,PathParameterExample:()=>_xu,PathParameterWithExample:()=>e3u,PrimitiveExample:()=>Mro,PrimitiveSchema:()=>J6i,PrimitiveSchemaValue:()=>Qxu,PrimitiveSchemaValueWithExample:()=>g3u,PrimitiveSchemaWithExample:()=>eno,PropertyKey:()=>Iro,ProtobufEncoding:()=>NFu,ProtobufSource:()=>qFu,QueryParameter:()=>Rro,QueryParameterExample:()=>Uro,QueryParameterWithExample:()=>Zro,QuerySecurityScheme:()=>VFu,ReferencedSchema:()=>yVr,Request:()=>cxu,RequestWithExample:()=>a3u,Response:()=>lxu,ResponseWithExample:()=>o3u,RetriesConfiguration:()=>Gro,Schema:()=>QI,SchemaId:()=>yCe,SchemaWithExample:()=>V4,Schemas:()=>qxu,SdkGroup:()=>GFu,SdkGroupInfo:()=>txu,SdkGroupName:()=>W6i,SecurityScheme:()=>KFu,SecuritySchemeId:()=>Dro,Server:()=>kZo,Source:()=>RFu,StatusCode:()=>pVr,StreamingResponseExample:()=>hxu,StringSchema:()=>xxu,StringSchemaWithExample:()=>_3u,SupportedSdkLanguage:()=>bxu,Tag:()=>zFu,TagId:()=>vCe,Tags:()=>rxu,TextResponse:()=>G6i,Uint64WithExample:()=>f3u,UintWithExample:()=>l3u,UnDiscriminatedOneOfSchema:()=>Zxu,UnDiscriminatedOneOfSchemaWithExample:()=>I3u,UnknownSchemaWithExample:()=>O3u,Webhook:()=>Exu,WebhookExampleCall:()=>Kro,WebhookHttpMethod:()=>Jro,WebhookWithExample:()=>LWy,WebsocketChannel:()=>Txu,WebsocketHandshake:()=>Sxu,WebsocketHandshakeWithExample:()=>zWy,WebsocketMessageExample:()=>Mxu,WebsocketMessageOrigin:()=>Dxu,WebsocketMessageSchema:()=>Cxu,WebsocketServer:()=>Ixu,WebsocketSessionExample:()=>Bxu,WithAvailability:()=>iw,WithDescription:()=>Ov,WithEncoding:()=>Oxe,WithInline:()=>U4,WithName:()=>PD,WithNamespace:()=>qS,WithSdkGroupName:()=>FM,WithSdkMethodName:()=>_Vr,WithSource:()=>AP,WithStatusCode:()=>fht,WithTitle:()=>NM,commons:()=>KRf,example:()=>$Rf,finalIr:()=>YRf,parseIr:()=>XRf});var KRf={};yf(KRf,{BasicSecurityScheme:()=>QFu,BearerSecurityScheme:()=>LFu,Encoding:()=>FFu,HeaderSecurityScheme:()=>UFu,Namespace:()=>HFu,NamespaceId:()=>$Fu,OauthSecurityScheme:()=>JFu,OpenApiSource:()=>TFu,ProtobufEncoding:()=>NFu,ProtobufSource:()=>qFu,QuerySecurityScheme:()=>VFu,SchemaId:()=>yCe,SdkGroup:()=>GFu,SdkGroupName:()=>W6i,SecurityScheme:()=>KFu,SecuritySchemeId:()=>Dro,Server:()=>kZo,Source:()=>RFu,StatusCode:()=>pVr,Tag:()=>zFu,TagId:()=>vCe,WithAvailability:()=>iw,WithDescription:()=>Ov,WithEncoding:()=>Oxe,WithInline:()=>U4,WithName:()=>PD,WithNamespace:()=>qS,WithSdkGroupName:()=>FM,WithSdkMethodName:()=>_Vr,WithSource:()=>AP,WithStatusCode:()=>fht,WithTitle:()=>NM});var Wr={};yf(Wr,{JsonError:()=>jro,ParseError:()=>Ero,any:()=>jWy,bigint:()=>dWy,boolean:()=>EWy,booleanLiteral:()=>wWy,date:()=>pWy,discriminant:()=>RWy,enum_:()=>IFu,getObjectLikeUtils:()=>lqr,getObjectUtils:()=>Lla,getSchemaUtils:()=>wQ,isProperty:()=>U6i,lazy:()=>_Wy,lazyObject:()=>OWy,list:()=>BFu,number:()=>SWy,object:()=>MFu,objectWithoutOptionalProperties:()=>mWy,optional:()=>WRf,property:()=>yWy,record:()=>MWy,set:()=>BWy,string:()=>DWy,stringLiteral:()=>PWy,transform:()=>HRf,undiscriminatedUnion:()=>qWy,union:()=>FWy,unknown:()=>CWy,withParsedProperties:()=>JRf});var Nq={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function G7(e,t){return`Expected ${t}. Received ${puI(e)}.`}function puI(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function sde(e){return{...e,json:fWy(e.json),parse:fWy(e.parse)}}function fWy(e){return(t,r)=>{let n=e(t,r),{skipValidation:i=!1}=r??{};return!n.ok&&i?(console.warn(["Failed to validate.",...n.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
@@ -3038,7 +3038,7 @@ ${m}
|
|
|
3038
3038
|
`),m=m+`
|
|
3039
3039
|
`,o=o.replace(f,m)}catch{n.logger.warn(`Failed to read markdown file "${s}" referenced in ${r}`);break}}return o}var _Iv=require("fs/promises"),hIv=$i(zTr(),1);async function LtM(e){let{content:t}=(0,hIv.default)(await(0,_Iv.readFile)(e));return t}async function aWf({markdown:e,absolutePathToFernFolder:t,absolutePathToMarkdownFile:r,context:n,markdownLoader:i=LtM}){if(!e.includes("<Markdown"))return e;let a=/([ \t]*)<Markdown\s+src={?['"]([^'"]+.mdx?)['"](?! \+)}?\s*\/>/g,o=e,c;for(;(c=a.exec(e))!=null;){let f=c[0],u=c[1],s=c[2];if(f==null||s==null)throw new Error(`Failed to parse regex "${c}" in ${r}`);let l=f1(s.startsWith("/")?t:Wg(r),ru.of(s.replace(/^\//,"")));try{let m=await i(l);m=m.split(`
|
|
3040
3040
|
`).map(A=>u+A).join(`
|
|
3041
|
-
`),o=o.replace(f,m)}catch{n.logger.warn(`Failed to read markdown file "${s}" referenced in ${r}`);break}}return o}async function YVu({domain:e,project:t,context:r,previousDocsDefinition:n,editedAbsoluteFilepaths:i}){let a=t.docsWorkspaces,o=t.apiWorkspaces;if(a==null)throw new Error("No docs workspace found in project");if(i!=null&&n!=null){let C=i.every(M=>M.endsWith(".mdx")||M.endsWith(".md"));for(let M of i){let T=m3(a.absoluteFilePath,M),z=(await(0,yIv.readFile)(M)).toString(),U=await aWf({markdown:z,absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M,context:r}),q=n.pages[sy.PageId(T)];if(q==null)continue;let{markdown:V,filepaths:$}=rWf(U,{absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M});n.filesV2==null&&(n.filesV2={});let re=new Map(Object.entries(n.filesV2).map(([k,ne])=>{let Oe="/"+ne.url.replace("/_local/","");return[L_.of(Oe),k]}));for(let k of $)if(!re.has(k)){let ne=sy.FileId(Drt());n.filesV2[ne]={type:"url",url:fl.Url(`/_local${uau(k)}`)},re.set(k,ne)}let Y=nWf(V,re,{},{absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M},r);Y=await iWf({markdown:Y,absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M,context:r}),n.pages[sy.PageId(T)]={markdown:Y,editThisPageUrl:q.editThisPageUrl,rawMarkdown:z}}if(C)return n}let c=await cbe(t),f=new oWf(r),u=new sWf(r),s={},m=await new Tqr({domain:e,docsWorkspace:a,ossWorkspaces:c,apiWorkspaces:o,taskContext:r,editThisPage:void 0,uploadFiles:async C=>C.map(M=>{let T=Drt();return s[T]={type:"url",url:fl.Url(`/_local${uau(M.absoluteFilePath)}`)},{absoluteFilePath:M.absoluteFilePath,relativeFilePath:M.relativeFilePath,fileId:T}}),registerApi:async C=>f.addReferencedAPI(C),targetAudiences:void 0}).resolve(),A=C5h({writeShape:m,files:{}}),P=q5h({dbShape:A.config});return{apis:f.getAPIsForDefinition(),apisV2:u.getAPIsForDefinition(),config:P,files:{},filesV2:s,pages:A.pages,jsFiles:A.jsFiles,id:void 0}}var oWf=class{context;apis={};constructor(t){this.context=t}addReferencedAPI({ir:t,snippetsConfig:r,playgroundConfig:n}){try{let i=Drt(),a=Elu(MCe({ir:t,snippetsConfig:r,playgroundConfig:n,context:this.context}),sy.ApiDefinitionId(i),new Dlu({snippetsConfigWithSdkId:{},snippetsBySdkId:{},snippetTemplatesByEndpoint:{},snippetTemplatesByEndpointId:{},snippetsBySdkIdAndEndpointId:{}})),o=Clu(a);return this.apis[i]=o,i}catch(i){let a=i;throw this.context.logger.debug(`Failed to read referenced API: ${a?.message} ${a?.stack}`),this.context.logger.error("An error occurred while trying to read an API definition. Please reach out to support."),a.stack!=null&&this.context.logger.error(a?.stack),i}}getAPIsForDefinition(){return this.apis}},sWf=class{context;apis={};constructor(t){this.context=t}addReferencedAPI({api:t,snippetsConfig:r}){try{return t.snippetsConfiguration=r,this.apis[t.id]=t,t.id}catch(n){let i=n;throw this.context.logger.debug(`Failed to read referenced API: ${i?.message} ${i?.stack}`),this.context.logger.error("An error occurred while trying to read an API definition. Please reach out to support."),i.stack!=null&&this.context.logger.error(i?.stack),n}}getAPIsForDefinition(){return this.apis}};var UtM={pages:{},apis:{},apisV2:{},files:{},filesV2:{},config:{aiChatConfig:void 0,hideNavLinks:void 0,navigation:void 0,root:void 0,title:void 0,defaultLanguage:void 0,languages:void 0,announcement:void 0,navbarLinks:void 0,footerLinks:void 0,logoHeight:void 0,logoHref:void 0,favicon:void 0,metadata:void 0,redirects:void 0,colorsV3:void 0,layout:void 0,settings:void 0,typographyV2:void 0,analyticsConfig:void 0,integrations:void 0,css:void 0,js:void 0,pageActions:void 0,theme:void 0},jsFiles:void 0,id:void 0},uWf=class{context;snippetToPages=new Map;pageToSnippets=new Map;constructor(t){this.context=t}extractReferences(t,r,n){let i=new Set,a=/<Markdown\s+src={?['"]([^'"]+\.mdx?)['"](?! \+)}?\s*\/>/g,o;for(;(o=a.exec(t))!==null;){let f=o[1];if(f){let u=f1(f.startsWith("/")?n:Wg(r),ru.of(f.replace(/^\//,"")));i.add(u)}}let c=/<Code(?:\s+[^>]*?)?\s+src={?['"]([^'"]+)['"](?! \+)}?((?:\s+[^>]*)?)\/>/g;for(;(o=c.exec(t))!==null;){let f=o[1];if(f){let u=f1(f.startsWith("/")?n:Wg(r),ru.of(f.replace(/^\//,"")));i.add(u)}}return i}async buildDependencyMap(t){this.snippetToPages.clear(),this.pageToSnippets.clear();let r=t.docsWorkspaces;if(r){this.context.logger.debug("Building snippet dependency map...");try{let n=await this.findMarkdownFiles(r.absoluteFilePath);for(let i of n)try{let a=await(0,gIv.readFile)(i,"utf-8"),o=this.extractReferences(a,i,r.absoluteFilePath);this.pageToSnippets.set(i,o);for(let c of o)this.snippetToPages.has(c)||this.snippetToPages.set(c,new Set),this.snippetToPages.get(c)?.add(i)}catch(a){this.context.logger.debug(`Failed to read markdown file ${i}: ${a}`)}this.context.logger.debug(`Built dependency map: ${this.snippetToPages.size} snippets, ${this.pageToSnippets.size} pages`)}catch(n){this.context.logger.debug(`Failed to build dependency map: ${n}`)}}}async findMarkdownFiles(t){try{let r=await nve(t,"md"),n=await nve(t,"mdx");return[...r,...n]}catch(r){return this.context.logger.debug(`Failed to list files in ${t}: ${r}`),[]}}getFilesToReload(t){let r=new Set;for(let n of t)r.add(n);for(let n of t){let i=this.snippetToPages.get(n);if(i){this.context.logger.debug(`Snippet ${n} affects ${i.size} pages`);for(let a of i)r.add(a)}}return Array.from(r).map(L_.of)}hasSnippetDependencies(t){for(let r of t){let n=this.snippetToPages.get(r);if(n&&n.size>0)return!0}return!1}getDebugInfo(){let t=0;for(let r of this.snippetToPages.values())t+=r.size;return{snippetCount:this.snippetToPages.size,pageCount:this.pageToSnippets.size,totalDependencies:t}}};async function cWf({initialProject:e,reloadProject:t,validateProject:r,context:n,port:i,bundlePath:a,backendPort:o}){if(a!=null)n.logger.info(`Using bundle from path: ${a}`);else try{let Ce="https://prod-local-preview-bundle4.s3.amazonaws.com/";if(Ce==null)throw new Error("Failed to connect to the docs preview server. Please contact support@buildwithfern.com");await Rns({bucketUrl:Ce,logger:n.logger,preferCached:!0,app:!0,tryTar:!0})}catch(Ce){Ce instanceof Error&&(n.logger.debug(`Failed to download latest docs bundle: ${Ce.message}`),n.logger.error("Failed to unzip .tar.gz bundle. Please report to support@buildwithfern.com")),n.logger.debug("Falling back to .zip bundle");try{let Be="https://prod-local-preview-bundle3.s3.amazonaws.com/";if(Be==null)throw new Error("Failed to connect to the docs preview server. Please contact support@buildwithfern.com");await Rns({bucketUrl:Be,logger:n.logger,preferCached:!0,app:!0,tryTar:!1})}catch{if(await Xv(e2i({app:!0})))n.logger.warn("Falling back to cached bundle...");else{n.logger.warn("Please reach out to support@buildwithfern.com.");return}}}let c=a||e2i({app:!0}),f=OIv.default.join(c,"standalone/packages/fern-docs/bundle/server.js"),u={...process.env,PORT:i.toString(),HOSTNAME:"0.0.0.0",NEXT_PUBLIC_FDR_ORIGIN_PORT:o.toString(),NEXT_PUBLIC_FDR_ORIGIN:`http://localhost:${o}`,NEXT_PUBLIC_DOCS_DOMAIN:e.docsWorkspaces?.config.instances[0]?.url,NEXT_PUBLIC_IS_LOCAL:"1",NEXT_DISABLE_CACHE:"1",NODE_ENV:"production",NODE_PATH:c,NODE_OPTIONS:"--max-old-space-size=8096 --enable-source-maps"},s=_8i(n.logger,"node",[f],{env:u,doNotPipeOutput:!0});s.stdout?.on("data",Ce=>{n.logger.debug(`[Next.js] ${Ce.toString()}`)}),s.stderr?.on("data",Ce=>{n.logger.debug(`[Next.js] ${Ce.toString()}`)}),n.logger.debug(`Next.js standalone server started with PID: ${s.pid}`),s.on("error",Ce=>{n.logger.debug(`Server process error: ${Ce.message}`)}),s.on("exit",(Ce,Be)=>{Ce?n.logger.debug(`Server process exited with code: ${Ce}`):Be?n.logger.debug(`Server process killed with signal: ${Be}`):n.logger.debug("Server process exited")});let l=()=>{if(!s.killed){n.logger.debug(`Killing server process with PID: ${s.pid}`);try{s.kill(),setTimeout(()=>{if(!s.killed){n.logger.debug(`Force killing server process with PID: ${s.pid}`);try{s.kill("SIGKILL")}catch(Ce){n.logger.error(`Failed to force kill server process: ${Ce}`)}}},2e3)}catch(Ce){n.logger.error(`Failed to kill server process: ${Ce}`)}}n.logger.debug("Cleaning up WebSocket connections...");for(let[Ce,Be]of z)clearInterval(Be.pingInterval),Ce.readyState===Neo.default.OPEN&&Ce.close(1e3,"Server shutting down");z.clear(),M.close()},m=["SIGTERM","SIGINT"],A=["SIGHUP"];for(let Ce of m)process.on(Ce,()=>{n.logger.debug("Shutting down server..."),l()});for(let Ce of A)process.on(Ce,()=>{n.logger.debug("Server failed, shutting down process..."),l()});process.on("exit",l),process.on("uncaughtException",Ce=>{n.logger.debug(`Uncaught exception: ${Ce}`),l(),process.exit(1)}),process.on("unhandledRejection",Ce=>{n.logger.debug(`Unhandled rejection: ${Ce}`),l(),process.exit(1)}),process.on("beforeExit",l),await new Promise(Ce=>setTimeout(Ce,3e3)),n.logger.debug(`Next.js server should now be running on http://localhost:${i}`);let P=Wg(e.config._absolutePath),C=(0,bIv.default)(),M=mIv.default.createServer(C),T=new mXo.default({server:M,clientTracking:!0,perMessageDeflate:!1}),z=new Map;function U(Ce){let Be=JSON.stringify(Ce),Se=[];for(let[jt,bt]of z)if(jt.readyState===Neo.default.OPEN)try{jt.send(Be)}catch(ze){n.logger.debug(`Failed to send message to connection ${bt.id}: ${ze}`),Se.push(jt)}else Se.push(jt);Se.forEach(jt=>{let bt=z.get(jt);bt&&(clearInterval(bt.pingInterval),z.delete(jt))})}T.on("connection",function(Be,Se){let jt=`${Se.socket.remoteAddress}:${Se.socket.remotePort}-${Date.now()}`,bt={id:jt,isAlive:!0,lastPong:Date.now(),pingInterval:setInterval(()=>{if(Be.readyState===Neo.default.OPEN){let ze=Date.now();if(ze-bt.lastPong>9e4){n.logger.debug(`Connection ${jt} timed out, closing`),Be.terminate();return}bt.isAlive=!1;try{Be.send(JSON.stringify({type:"ping",timestamp:ze}))}catch(Me){n.logger.debug(`Failed to send ping to ${jt}: ${Me}`),Be.terminate()}}},3e4)};z.set(Be,bt),Be.on("message",function(Me){try{JSON.parse(Me.toString()).type==="pong"&&(bt.isAlive=!0,bt.lastPong=Date.now())}catch(Zt){n.logger.debug(`Failed to parse message from ${jt}: ${Zt}`)}}),Be.on("error",function(Me){n.logger.debug(`WebSocket error for connection ${jt}: ${Me.message}`)}),Be.on("close",function(Me,Zt){clearInterval(bt.pingInterval),z.delete(Be)});try{Be.send(JSON.stringify({type:"connected",connectionId:jt}))}catch(ze){n.logger.debug(`Failed to send connection confirmation: ${ze}`)}}),C.use((0,vIv.default)());let q=new URL(Nse(e.docsWorkspaces?.config.instances[0]?.url??`http://localhost:${i}`)),V=e,$,re=new uWf(n);await re.buildDependencyMap(V);let Y=null,k=!1,ne=1e3,Oe=async Ce=>{n.logger.info("Reloading docs...");let Be=Date.now();try{V=await t(),await re.buildDependencyMap(V),n.logger.info("\u26A1 Starting validation in background...");let Se=Date.now();r(V).then(()=>{let bt=Date.now()-Se;n.logger.info(`\u2705 Background validation completed in ${bt}ms`)}).catch(bt=>{let ze=Date.now()-Se;n.logger.error(`\u274C Background validation failed after ${ze}ms: ${bt instanceof Error?bt.message:String(bt)}`),bt instanceof Error&&bt.stack&&n.logger.debug(`Validation error stack: ${bt.stack}`)});let jt=await YVu({domain:`${q.host}${q.pathname}`,project:V,context:n,previousDocsDefinition:$,editedAbsoluteFilepaths:Ce});return n.logger.info(`Reload completed in ${Date.now()-Be}ms`),jt}catch(Se){return $==null?n.logger.error("Failed to read docs configuration. Rendering blank page."):n.logger.error("Failed to read docs configuration. Rendering last successful configuration."),Se instanceof Error&&(n.logger.error(Se.message),Se instanceof Error&&Se.stack&&n.logger.debug(`Stack Trace:
|
|
3041
|
+
`),o=o.replace(f,m)}catch{n.logger.warn(`Failed to read markdown file "${s}" referenced in ${r}`);break}}return o}async function YVu({domain:e,project:t,context:r,previousDocsDefinition:n,editedAbsoluteFilepaths:i}){let a=t.docsWorkspaces,o=t.apiWorkspaces;if(a==null)throw new Error("No docs workspace found in project");if(i!=null&&n!=null){let C=i.every(M=>M.endsWith(".mdx")||M.endsWith(".md"));for(let M of i){let T=m3(a.absoluteFilePath,M),z=(await(0,yIv.readFile)(M)).toString(),U=await aWf({markdown:z,absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M,context:r}),q=n.pages[sy.PageId(T)];if(q==null)continue;let{markdown:V,filepaths:$}=rWf(U,{absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M});n.filesV2==null&&(n.filesV2={});let re=new Map(Object.entries(n.filesV2).map(([k,ne])=>{let Oe="/"+ne.url.replace("/_local/","");return[L_.of(Oe),k]}));for(let k of $)if(!re.has(k)){let ne=sy.FileId(Drt());n.filesV2[ne]={type:"url",url:fl.Url(`/_local${uau(k)}`)},re.set(k,ne)}let Y=nWf(V,re,{},{absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M},r);Y=await iWf({markdown:Y,absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:M,context:r}),n.pages[sy.PageId(T)]={markdown:Y,editThisPageUrl:q.editThisPageUrl,rawMarkdown:z}}if(C)return n}let c=await cbe(t),f=new oWf(r),u=new sWf(r),s={},m=await new Tqr({domain:e,docsWorkspace:a,ossWorkspaces:c,apiWorkspaces:o,taskContext:r,editThisPage:void 0,uploadFiles:async C=>C.map(M=>{let T=Drt();return s[T]={type:"url",url:fl.Url(`/_local${uau(M.absoluteFilePath)}`)},{absoluteFilePath:M.absoluteFilePath,relativeFilePath:M.relativeFilePath,fileId:T}}),registerApi:async C=>f.addReferencedAPI(C),targetAudiences:void 0}).resolve(),A=C5h({writeShape:m,files:{}}),P=q5h({dbShape:A.config});return{apis:f.getAPIsForDefinition(),apisV2:u.getAPIsForDefinition(),config:P,files:{},filesV2:s,pages:A.pages,jsFiles:A.jsFiles,id:void 0}}var oWf=class{context;apis={};constructor(t){this.context=t}addReferencedAPI({ir:t,snippetsConfig:r,playgroundConfig:n}){try{let i=Drt(),a=Elu(MCe({ir:t,snippetsConfig:r,playgroundConfig:n,context:this.context}),sy.ApiDefinitionId(i),new Dlu({snippetsConfigWithSdkId:{},snippetsBySdkId:{},snippetTemplatesByEndpoint:{},snippetTemplatesByEndpointId:{},snippetsBySdkIdAndEndpointId:{}})),o=Clu(a);return this.apis[i]=o,i}catch(i){let a=i;throw this.context.logger.debug(`Failed to read referenced API: ${a?.message} ${a?.stack}`),this.context.logger.error("An error occurred while trying to read an API definition. Please reach out to support."),a.stack!=null&&this.context.logger.error(a?.stack),i}}getAPIsForDefinition(){return this.apis}},sWf=class{context;apis={};constructor(t){this.context=t}addReferencedAPI({api:t,snippetsConfig:r}){try{return t.snippetsConfiguration=r,this.apis[t.id]=t,t.id}catch(n){let i=n;throw this.context.logger.debug(`Failed to read referenced API: ${i?.message} ${i?.stack}`),this.context.logger.error("An error occurred while trying to read an API definition. Please reach out to support."),i.stack!=null&&this.context.logger.error(i?.stack),n}}getAPIsForDefinition(){return this.apis}};var UtM={pages:{},apis:{},apisV2:{},files:{},filesV2:{},config:{aiChatConfig:void 0,hideNavLinks:void 0,navigation:void 0,root:void 0,title:void 0,defaultLanguage:void 0,languages:void 0,announcement:void 0,navbarLinks:void 0,footerLinks:void 0,logoHeight:void 0,logoHref:void 0,favicon:void 0,metadata:void 0,redirects:void 0,colorsV3:void 0,layout:void 0,settings:void 0,typographyV2:void 0,analyticsConfig:void 0,integrations:void 0,css:void 0,js:void 0,pageActions:void 0,theme:void 0},jsFiles:void 0,id:void 0},uWf=class{context;snippetToPages=new Map;pageToSnippets=new Map;constructor(t){this.context=t}extractReferences(t,r,n){let i=new Set,a=/<Markdown\s+src={?['"]([^'"]+\.mdx?)['"](?! \+)}?\s*\/>/g,o;for(;(o=a.exec(t))!==null;){let f=o[1];if(f){let u=f1(f.startsWith("/")?n:Wg(r),ru.of(f.replace(/^\//,"")));i.add(u)}}let c=/<Code(?:\s+[^>]*?)?\s+src={?['"]([^'"]+)['"](?! \+)}?((?:\s+[^>]*)?)\/>/g;for(;(o=c.exec(t))!==null;){let f=o[1];if(f){let u=f1(f.startsWith("/")?n:Wg(r),ru.of(f.replace(/^\//,"")));i.add(u)}}return i}async buildDependencyMap(t){this.snippetToPages.clear(),this.pageToSnippets.clear();let r=t.docsWorkspaces;if(r){this.context.logger.debug("Building snippet dependency map...");try{let n=await this.findMarkdownFiles(r.absoluteFilePath);for(let i of n)try{let a=await(0,gIv.readFile)(i,"utf-8"),o=this.extractReferences(a,i,r.absoluteFilePath);this.pageToSnippets.set(i,o);for(let c of o)this.snippetToPages.has(c)||this.snippetToPages.set(c,new Set),this.snippetToPages.get(c)?.add(i)}catch(a){this.context.logger.debug(`Failed to read markdown file ${i}: ${a}`)}this.context.logger.debug(`Built dependency map: ${this.snippetToPages.size} snippets, ${this.pageToSnippets.size} pages`)}catch(n){this.context.logger.debug(`Failed to build dependency map: ${n}`)}}}async findMarkdownFiles(t){try{let r=await nve(t,"md"),n=await nve(t,"mdx");return[...r,...n]}catch(r){return this.context.logger.debug(`Failed to list files in ${t}: ${r}`),[]}}getFilesToReload(t){let r=new Set;for(let n of t)r.add(n);for(let n of t){let i=this.snippetToPages.get(n);if(i){this.context.logger.debug(`Snippet ${n} affects ${i.size} pages`);for(let a of i)r.add(a)}}return Array.from(r).map(L_.of)}hasSnippetDependencies(t){for(let r of t){let n=this.snippetToPages.get(r);if(n&&n.size>0)return!0}return!1}getDebugInfo(){let t=0;for(let r of this.snippetToPages.values())t+=r.size;return{snippetCount:this.snippetToPages.size,pageCount:this.pageToSnippets.size,totalDependencies:t}}};async function cWf({initialProject:e,reloadProject:t,validateProject:r,context:n,port:i,bundlePath:a,backendPort:o}){if(a!=null)n.logger.info(`Using bundle from path: ${a}`);else try{let Ce="https://prod-local-preview-bundle4.s3.amazonaws.com/";if(Ce==null)throw new Error("Failed to connect to the docs preview server. Please contact support@buildwithfern.com");await Rns({bucketUrl:Ce,logger:n.logger,preferCached:!0,app:!0,tryTar:!0})}catch(Ce){Ce instanceof Error&&(n.logger.debug(`Failed to download latest docs bundle: ${Ce.message}`),n.logger.error("Failed to unzip .tar.gz bundle. Please report to support@buildwithfern.com")),n.logger.debug("Falling back to .zip bundle");try{let Be="https://prod-local-preview-bundle3.s3.amazonaws.com/";if(Be==null)throw new Error("Failed to connect to the docs preview server. Please contact support@buildwithfern.com");await Rns({bucketUrl:Be,logger:n.logger,preferCached:!0,app:!0,tryTar:!1})}catch{if(await Xv(e2i({app:!0})))n.logger.warn("Falling back to cached bundle...");else{n.logger.warn("Please reach out to support@buildwithfern.com.");return}}}let c=a||e2i({app:!0}),f=OIv.default.join(c,"standalone/packages/fern-docs/bundle/server.js"),u={...process.env,PORT:i.toString(),HOSTNAME:"0.0.0.0",NEXT_PUBLIC_FDR_ORIGIN_PORT:o.toString(),NEXT_PUBLIC_FDR_ORIGIN:`http://localhost:${o}`,NEXT_PUBLIC_DOCS_DOMAIN:e.docsWorkspaces?.config.instances[0]?.url,NEXT_PUBLIC_IS_LOCAL:"1",NEXT_DISABLE_CACHE:"1",NODE_ENV:"production",NODE_PATH:c,NODE_OPTIONS:"--max-old-space-size=8096 --enable-source-maps"},s=_8i(n.logger,"node",[f],{env:u,doNotPipeOutput:!0});s.stdout?.on("data",Ce=>{n.logger.debug(`[Next.js] ${Ce.toString()}`)}),s.stderr?.on("data",Ce=>{n.logger.debug(`[Next.js] ${Ce.toString()}`)}),n.logger.debug(`Next.js standalone server started with PID: ${s.pid}`),s.on("error",Ce=>{n.logger.debug(`Server process error: ${Ce.message}`)}),s.on("exit",(Ce,Be)=>{Ce?n.logger.debug(`Server process exited with code: ${Ce}`):Be?n.logger.debug(`Server process killed with signal: ${Be}`):n.logger.debug("Server process exited")});let l=()=>{if(!s.killed){n.logger.debug(`Killing server process with PID: ${s.pid}`);try{s.kill(),setTimeout(()=>{if(!s.killed){n.logger.debug(`Force killing server process with PID: ${s.pid}`);try{s.kill("SIGKILL")}catch(Ce){n.logger.error(`Failed to force kill server process: ${Ce}`)}}},2e3)}catch(Ce){n.logger.error(`Failed to kill server process: ${Ce}`)}}n.logger.debug("Cleaning up WebSocket connections...");for(let[Ce,Be]of z)clearInterval(Be.pingInterval),Ce.readyState===Neo.default.OPEN&&Ce.close(1e3,"Server shutting down");z.clear(),M.close()},m=["SIGTERM","SIGINT"],A=["SIGHUP"];for(let Ce of m)process.on(Ce,()=>{n.logger.debug("Shutting down server..."),l()});for(let Ce of A)process.on(Ce,()=>{n.logger.debug("Server failed, shutting down process..."),l()});process.on("exit",l),process.on("uncaughtException",Ce=>{n.logger.debug(`Uncaught exception: ${Ce}`),l(),process.exit(1)}),process.on("unhandledRejection",Ce=>{n.logger.debug(`Unhandled rejection: ${Ce}`),l(),process.exit(1)}),process.on("beforeExit",l),await new Promise(Ce=>setTimeout(Ce,3e3)),n.logger.debug(`Next.js server should now be running on http://localhost:${i}`);let P=Wg(e.config._absolutePath),C=(0,bIv.default)(),M=mIv.default.createServer(C),T=new mXo.default({server:M,clientTracking:!0,perMessageDeflate:!1}),z=new Map;function U(Ce){let Be=JSON.stringify(Ce),Se=[];for(let[jt,bt]of z)if(jt.readyState===Neo.default.OPEN)try{jt.send(Be)}catch(ze){n.logger.debug(`Failed to send message to connection ${bt.id}: ${ze}`),Se.push(jt)}else Se.push(jt);Se.forEach(jt=>{let bt=z.get(jt);bt&&(clearInterval(bt.pingInterval),z.delete(jt))})}T.on("connection",function(Be,Se){let jt=`${Se.socket.remoteAddress}:${Se.socket.remotePort}-${Date.now()}`,bt={id:jt,isAlive:!0,lastPong:Date.now(),pingInterval:setInterval(()=>{if(Be.readyState===Neo.default.OPEN){let ze=Date.now();if(ze-bt.lastPong>9e4){n.logger.debug(`Connection ${jt} timed out, closing`),Be.terminate();return}bt.isAlive=!1;try{Be.send(JSON.stringify({type:"ping",timestamp:ze}))}catch(Me){n.logger.debug(`Failed to send ping to ${jt}: ${Me}`),Be.terminate()}}},3e4)};z.set(Be,bt),Be.on("message",function(Me){try{JSON.parse(Me.toString()).type==="pong"&&(bt.isAlive=!0,bt.lastPong=Date.now())}catch(Zt){n.logger.debug(`Failed to parse message from ${jt}: ${Zt}`)}}),Be.on("error",function(Me){n.logger.debug(`WebSocket error for connection ${jt}: ${Me.message}`)}),Be.on("close",function(Me,Zt){clearInterval(bt.pingInterval),z.delete(Be)});try{Be.send(JSON.stringify({type:"connected",connectionId:jt}))}catch(ze){n.logger.debug(`Failed to send connection confirmation: ${ze}`)}}),C.use((0,vIv.default)());let q=new URL(Nse(e.docsWorkspaces?.config.instances[0]?.url??`http://localhost:${i}`)),V=e,$,re=new uWf(n);await re.buildDependencyMap(V);let Y=null,k=!1,ne=1e3,Oe=async Ce=>{n.logger.info("Reloading docs...");let Be=Date.now();try{V=await t(),await re.buildDependencyMap(V);let Se=Date.now();r(V).catch(bt=>{let ze=Date.now()-Se;n.logger.error(`Validation failed (took ${ze}ms): ${bt instanceof Error?bt.message:String(bt)}`),bt instanceof Error&&bt.stack&&n.logger.debug(`Validation error stack: ${bt.stack}`)});let jt=await YVu({domain:`${q.host}${q.pathname}`,project:V,context:n,previousDocsDefinition:$,editedAbsoluteFilepaths:Ce});return n.logger.info(`Reload completed in ${Date.now()-Be}ms`),jt}catch(Se){return $==null?n.logger.error("Failed to read docs configuration. Rendering blank page."):n.logger.error("Failed to read docs configuration. Rendering last successful configuration."),Se instanceof Error&&(n.logger.error(Se.message),Se instanceof Error&&Se.stack&&n.logger.debug(`Stack Trace:
|
|
3042
3042
|
${Se.stack}`)),$}};$=await Oe();let he=V.apiWorkspaces.flatMap(Ce=>Ce.getAbsoluteFilePaths()),me=new VUu([P,...he],{recursive:!0,ignoreInitial:!0,debounce:100,renameDetection:!0}),ve=[];me.on("all",async(Ce,Be,Se)=>{n.logger.info(Mf.dim(`[${Ce}] ${Be}`)),!k&&(ve.push(L_.of(Be)),Y!=null&&clearTimeout(Y),Y=setTimeout(()=>{(async()=>{k=!0;let jt=re.getFilesToReload(ve);re.hasSnippetDependencies(ve)&&n.logger.info(`Snippet dependencies detected. Reloading ${jt.length} files (${ve.length} changed, ${jt.length-ve.length} dependent pages)`),U({version:1,type:"startReload"});let ze=await Oe(jt);ze!=null&&($=ze),ve.length=0,U({version:1,type:"finishReload"}),k=!1})()},ne))}),C.post("/v2/registry/docs/load-with-url",async(Ce,Be)=>{try{let Se=$??UtM,jt={baseUrl:{domain:q.host,basePath:q.pathname},definition:Se,lightModeEnabled:Se.config.colorsV3?.type!=="dark",orgId:fl.OrgId(e.config.organization)};Be.send(jt)}catch(Se){n.logger.error("Stack trace:",Se.stack??""),n.logger.error("Error loading docs",Se.message),Be.status(500).send()}}),C.get(/^\/_local\/(.*)/,(Ce,Be)=>Be.sendFile(`/${Ce.params[0]}`)),M.listen(o,()=>{n.logger.info(Mf.dim(`Backend server running on http://localhost:${o}`)),n.logger.info(`Development server ready on http://localhost:${i}`)}),await new Promise(()=>{})}var AIv=$i(u9f(),1),lWf=$i(FUu(),1),PIv=$i(require("http"),1),XVu=$i(require("path"),1);mTu();var VtM={pages:{},apis:{},apisV2:{},files:{},filesV2:{},config:{aiChatConfig:void 0,hideNavLinks:void 0,navigation:void 0,root:void 0,title:void 0,defaultLanguage:void 0,languages:void 0,announcement:void 0,navbarLinks:void 0,footerLinks:void 0,logoHeight:void 0,logoHref:void 0,favicon:void 0,metadata:void 0,redirects:void 0,colorsV3:void 0,layout:void 0,settings:void 0,typographyV2:void 0,analyticsConfig:void 0,integrations:void 0,css:void 0,js:void 0,pageActions:void 0,theme:void 0},jsFiles:void 0,id:void 0};async function fWf({initialProject:e,reloadProject:t,validateProject:r,context:n,port:i,bundlePath:a}){if(a!=null)n.logger.info(`Using bundle from path: ${a}`);else try{let re="https://prod-local-preview-bundle2.s3.amazonaws.com/";if(re==null)throw new Error("Failed to connect to the docs preview server. Please contact support@buildwithfern.com");await Rns({bucketUrl:re,logger:n.logger,preferCached:!0,tryTar:!1})}catch(re){let Y=e2i({});if(re instanceof Error&&n.logger.debug(`Failed to download latest docs bundle: ${re.message}`),await Xv(Y))n.logger.warn("Falling back to cached bundle...");else{n.logger.warn("Please reach out to support@buildwithfern.com.");return}}let o=Wg(e.config._absolutePath),c=(0,lWf.default)(),f=PIv.default.createServer(c),u=new mXo.default({server:f}),s=new Set;function l(re){for(let Y of s)Y.send(JSON.stringify(re))}u.on("connection",function(Y){s.add(Y),Y.on("close",function(){s.delete(Y)})}),c.use((0,AIv.default)());let m=new URL(Nse(e.docsWorkspaces?.config.instances[0]?.url??`http://localhost:${i}`)),A=e,P,C=null,M=!1,T=1e3,z=async re=>{n.logger.info("Reloading docs...");let Y=Date.now();try{A=await t(),n.logger.info("Validating docs..."),await r(A);let k=await YVu({domain:`${m.host}${m.pathname}`,project:A,context:n,previousDocsDefinition:P,editedAbsoluteFilepaths:re});return n.logger.info(`Reload completed in ${Date.now()-Y}ms`),k}catch(k){return P==null?n.logger.error("Failed to read docs configuration. Rendering blank page."):n.logger.error("Failed to read docs configuration. Rendering last successful configuration."),k instanceof Error&&(n.logger.error(k.message),k instanceof Error&&k.stack&&n.logger.debug(`Stack Trace:
|
|
3043
3043
|
${k.stack}`)),P}};P=await z();let U=A.apiWorkspaces.flatMap(re=>re.getAbsoluteFilePaths()),q=a?L_.of(XVu.default.resolve(a)):e2i({}),V=new VUu([o,...U],{recursive:!0,ignoreInitial:!0,debounce:100,renameDetection:!0}),$=[];V.on("all",async(re,Y,k)=>{n.logger.info(Mf.dim(`[${re}] ${Y}`)),!M&&($.push(L_.of(Y)),C!=null&&clearTimeout(C),C=setTimeout(()=>{(async()=>{M=!0,l({version:1,type:"startReload"});let ne=await z($);ne!=null&&(P=ne),$.length=0,l({version:1,type:"finishReload"}),M=!1})()},T))}),c.post("/v2/registry/docs/load-with-url",async(re,Y)=>{try{let k=P??VtM,ne={baseUrl:{domain:m.host,basePath:m.pathname},definition:k,lightModeEnabled:k.config.colorsV3?.type!=="dark",orgId:fl.OrgId(e.config.organization)};Y.send(ne)}catch(k){n.logger.error("Stack trace:",k.stack??""),n.logger.error("Error loading docs",k.message),Y.status(500).send()}}),c.get(/^\/_local\/(.*)/,(re,Y)=>{let k=`/${re.params[0]}`,ne=new Set;if(P?.filesV2){for(let Oe of Object.values(P.filesV2))if(Oe.type==="url"){let he=Oe.url.replace(/^\/_local/,"");ne.add(he)}}return ne.has(k)?Y.sendFile(k):(n.logger.warn(`Blocked unauthorized file access attempt: ${k}`),Y.status(403).send("Access denied"))}),c.get("/",(re,Y,k)=>re.headers.upgrade==="websocket"?u.handleUpgrade(re,re.socket,Buffer.alloc(0),ne=>{u.emit("connection",ne,re)}):k()),c.use("/_next",lWf.default.static(XVu.default.join(q,"/_next"))),c.use("*",async(re,Y)=>Y.sendFile(XVu.default.join(q,"/[[...slug]].html"))),c.listen(i),n.logger.info(`Running server on http://localhost:${i}`),await new Promise(()=>{})}var dWf={};yf(dWf,{additionalProperties:()=>JtM,default:()=>$tM,definitions:()=>KtM,properties:()=>HtM,required:()=>GtM,type:()=>WtM});var WtM="object",HtM={tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{$ref:"#/definitions/docs.NavigationConfig"}},GtM=["navigation"],JtM=!1,KtM={"docs.RoleId":{type:"string"},"docs.Role":{anyOf:[{$ref:"#/definitions/docs.RoleId"},{type:"array",items:{$ref:"#/definitions/docs.RoleId"}}]},"docs.FeatureFlag":{type:"object",properties:{flag:{type:"string"},"fallback-value":{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},match:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]}},required:["flag"],additionalProperties:!1},"docs.FeatureFlagConfiguration":{anyOf:[{type:"string",description:"The name of the feature flag, We assume that it is a boolean feature flag that needs to be evaluated to true."},{$ref:"#/definitions/docs.FeatureFlag",description:"A single feature flag with a configurable name, fallback value, and match value. Especially useful for non boolean feature flags."},{type:"array",items:{$ref:"#/definitions/docs.FeatureFlag"},description:"A list of feature flags. If any of the feature flags are satisfied, we will show all content."}]},"docs.ChangelogFolderRelativePath":{type:"string"},"docs.TabConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},changelog:{oneOf:[{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},{type:"null"}]}},required:["display-name"],additionalProperties:!1},"docs.Availability":{type:"string",enum:["stable","generally-available","in-development","pre-release","deprecated","beta"]},"docs.PageConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},page:{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},noindex:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["page","path"],additionalProperties:!1},"docs.SectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},path:{oneOf:[{type:"string"},{type:"null"}]},contents:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.Audience":{anyOf:[{$ref:"#/definitions/docs.AudienceId"},{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}}]},"docs.VersionedSnippetLanguageConfiguration":{type:"object",properties:{version:{type:"string"},package:{type:"string"}},required:["version","package"],additionalProperties:!1},"docs.SnippetLanguageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.VersionedSnippetLanguageConfiguration"}]},"docs.SnippetsConfiguration":{type:"object",properties:{python:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},typescript:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},go:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},java:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},ruby:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},csharp:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},php:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},swift:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},rust:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundButtonSettings":{type:"object",properties:{href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundSettings":{type:"object",properties:{environments:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},button:{oneOf:[{$ref:"#/definitions/docs.PlaygroundButtonSettings"},{type:"null"}]},oauth:{oneOf:[{type:"boolean"},{type:"null"}]},"limit-websocket-messages-per-connection":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfigurationWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfiguration":{anyOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{$ref:"#/definitions/docs.ApiReferencePackageConfigurationWithOptions"}]},"docs.ApiReferenceSectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},"referenced-packages":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["section"],additionalProperties:!1},"docs.ApiReferenceEndpointConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},endpoint:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"docs.LinkConfiguration":{type:"object",properties:{link:{type:"string"},href:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]}},required:["link","href"],additionalProperties:!1},"docs.ApiReferenceLayoutItem":{anyOf:[{type:"string",description:"This should be either an endpoint, websocket, webhook, or subpackage ID"},{type:"object",additionalProperties:{$ref:"#/definitions/docs.ApiReferencePackageConfiguration"},description:"Keyed by subpackage name, this object allows you to group endpoints and pages together."},{$ref:"#/definitions/docs.ApiReferenceSectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceEndpointConfiguration"},{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"}]},"docs.ApiReferenceConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},api:{type:"string"},"api-name":{oneOf:[{type:"string"},{type:"null"}]},openrpc:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},alphabetized:{oneOf:[{type:"boolean"},{type:"null"}]},flattened:{oneOf:[{type:"boolean"},{type:"null"}]},paginated:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["api"],additionalProperties:!1},"docs.ChangelogConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},changelog:{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["changelog"],additionalProperties:!1},"docs.FolderConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},folder:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["folder"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"},{$ref:"#/definitions/docs.FolderConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItemWithLayout":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabVariant":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},layout:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},default:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["title","layout"],additionalProperties:!1},"docs.TabbedNavigationItemWithVariants":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},variants:{type:"array",items:{$ref:"#/definitions/docs.TabVariant"}}},required:["tab","variants"],additionalProperties:!1},"docs.TabbedNavigationItem":{anyOf:[{$ref:"#/definitions/docs.TabbedNavigationItemWithLayout"},{$ref:"#/definitions/docs.TabbedNavigationItemWithVariants"}]},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]}},$tM={type:WtM,properties:HtM,required:GtM,additionalProperties:JtM,definitions:KtM};async function ZVu({value:e}){let t=ZMr(e,dWf);if(t.success)return{type:"success",contents:HNe.RawSchemas.Serializer.VersionFileConfig.parseOrThrow(e)};let r=t.error?.instancePath?` at ${t?.error.instancePath}`:"";return{type:"failure",message:`${t.error?.message??"Failed to parse because JSON schema validation failed"}${r}`}}var hWf=require("fs/promises");var pWf={};yf(pWf,{additionalProperties:()=>ktM,default:()=>trM,definitions:()=>erM,properties:()=>XtM,required:()=>ZtM,type:()=>YtM});var YtM="object",XtM={tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{$ref:"#/definitions/docs.NavigationConfig"}},ZtM=["navigation"],ktM=!1,erM={"docs.RoleId":{type:"string"},"docs.Role":{anyOf:[{$ref:"#/definitions/docs.RoleId"},{type:"array",items:{$ref:"#/definitions/docs.RoleId"}}]},"docs.FeatureFlag":{type:"object",properties:{flag:{type:"string"},"fallback-value":{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},match:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]}},required:["flag"],additionalProperties:!1},"docs.FeatureFlagConfiguration":{anyOf:[{type:"string",description:"The name of the feature flag, We assume that it is a boolean feature flag that needs to be evaluated to true."},{$ref:"#/definitions/docs.FeatureFlag",description:"A single feature flag with a configurable name, fallback value, and match value. Especially useful for non boolean feature flags."},{type:"array",items:{$ref:"#/definitions/docs.FeatureFlag"},description:"A list of feature flags. If any of the feature flags are satisfied, we will show all content."}]},"docs.ChangelogFolderRelativePath":{type:"string"},"docs.TabConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},changelog:{oneOf:[{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},{type:"null"}]}},required:["display-name"],additionalProperties:!1},"docs.Availability":{type:"string",enum:["stable","generally-available","in-development","pre-release","deprecated","beta"]},"docs.PageConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},page:{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},noindex:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["page","path"],additionalProperties:!1},"docs.SectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},path:{oneOf:[{type:"string"},{type:"null"}]},contents:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.Audience":{anyOf:[{$ref:"#/definitions/docs.AudienceId"},{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}}]},"docs.VersionedSnippetLanguageConfiguration":{type:"object",properties:{version:{type:"string"},package:{type:"string"}},required:["version","package"],additionalProperties:!1},"docs.SnippetLanguageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.VersionedSnippetLanguageConfiguration"}]},"docs.SnippetsConfiguration":{type:"object",properties:{python:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},typescript:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},go:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},java:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},ruby:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},csharp:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},php:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},swift:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},rust:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundButtonSettings":{type:"object",properties:{href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundSettings":{type:"object",properties:{environments:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},button:{oneOf:[{$ref:"#/definitions/docs.PlaygroundButtonSettings"},{type:"null"}]},oauth:{oneOf:[{type:"boolean"},{type:"null"}]},"limit-websocket-messages-per-connection":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfigurationWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfiguration":{anyOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{$ref:"#/definitions/docs.ApiReferencePackageConfigurationWithOptions"}]},"docs.ApiReferenceSectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},"referenced-packages":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["section"],additionalProperties:!1},"docs.ApiReferenceEndpointConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},endpoint:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"docs.LinkConfiguration":{type:"object",properties:{link:{type:"string"},href:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]}},required:["link","href"],additionalProperties:!1},"docs.ApiReferenceLayoutItem":{anyOf:[{type:"string",description:"This should be either an endpoint, websocket, webhook, or subpackage ID"},{type:"object",additionalProperties:{$ref:"#/definitions/docs.ApiReferencePackageConfiguration"},description:"Keyed by subpackage name, this object allows you to group endpoints and pages together."},{$ref:"#/definitions/docs.ApiReferenceSectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceEndpointConfiguration"},{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"}]},"docs.ApiReferenceConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},api:{type:"string"},"api-name":{oneOf:[{type:"string"},{type:"null"}]},openrpc:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{$ref:"#/definitions/docs.Audience"},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},alphabetized:{oneOf:[{type:"boolean"},{type:"null"}]},flattened:{oneOf:[{type:"boolean"},{type:"null"}]},paginated:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["api"],additionalProperties:!1},"docs.ChangelogConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},changelog:{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["changelog"],additionalProperties:!1},"docs.FolderConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},folder:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},availability:{oneOf:[{$ref:"#/definitions/docs.Availability"},{type:"null"}]}},required:["folder"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"},{$ref:"#/definitions/docs.FolderConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItemWithLayout":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabVariant":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{type:"string"},subtitle:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},layout:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},default:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["title","layout"],additionalProperties:!1},"docs.TabbedNavigationItemWithVariants":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},variants:{type:"array",items:{$ref:"#/definitions/docs.TabVariant"}}},required:["tab","variants"],additionalProperties:!1},"docs.TabbedNavigationItem":{anyOf:[{$ref:"#/definitions/docs.TabbedNavigationItemWithLayout"},{$ref:"#/definitions/docs.TabbedNavigationItemWithVariants"}]},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]}},trM={type:YtM,properties:XtM,required:ZtM,additionalProperties:ktM,definitions:erM};async function kVu({value:e}){let t=ZMr(e,pWf);if(t.success)return{type:"success",contents:HNe.RawSchemas.Serializer.ProductFileConfig.parseOrThrow(e)};let r=t.error?.instancePath?` at ${t?.error.instancePath}`:"";return{type:"failure",message:`${t.error?.message??"Failed to parse because JSON schema validation failed"}${r}`}}async function mde({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:t,visitor:r,nodePath:n,willBeUploaded:i=!0}){let a=f1(Wg(e),t);await r.filepath?.({absoluteFilepath:a,value:t,willBeUploaded:i},[a])}var zns=require("fs/promises");async function tWu({absolutePathToFernFolder:e,navigation:t,apiWorkspaces:r,visitor:n,absoluteFilepathToConfiguration:i,context:a,nodePath:o}){arM(t)?await Promise.all(t.map(async(c,f)=>{orM(c)?await Promise.all(c.layout.map(async(u,s)=>{await eWu({absolutePathToFernFolder:e,navigationItem:u,visitor:n,nodePath:[...o,`${f}`,"layout",`${s}`],absoluteFilepathToConfiguration:i,apiWorkspaces:r,context:a})})):srM(c)&&await Promise.all(c.variants.flatMap((u,s)=>u.layout.map(async(l,m)=>{await eWu({absolutePathToFernFolder:e,navigationItem:l,visitor:n,nodePath:[...o,`${f}`,"variants",`${s}`,"layout",`${m}`],absoluteFilepathToConfiguration:i,apiWorkspaces:r,context:a})})))})):await Promise.all(t.map(async(c,f)=>{await eWu({absolutePathToFernFolder:e,navigationItem:c,visitor:n,nodePath:[...o,`${f}`],absoluteFilepathToConfiguration:i,apiWorkspaces:r,context:a})}))}async function eWu({absolutePathToFernFolder:e,navigationItem:t,visitor:r,nodePath:n,absoluteFilepathToConfiguration:i,apiWorkspaces:a,context:o}){if(await l2r(t,{alphabetized:xc,api:xc,apiName:xc,audiences:xc,openrpc:async c=>{c!=null&&await mde({absoluteFilepathToConfiguration:i,rawUnresolvedFilepath:c,visitor:r,nodePath:[...n,"openrpc"],willBeUploaded:!1})},displayErrors:xc,snippets:xc,summary:xc,title:xc,layout:xc,collapsed:xc,icon:xc,slug:xc,hidden:xc,skipSlug:xc,paginated:xc,playground:xc,flattened:xc,featureFlag:xc,path:async c=>{c!=null&&await mde({absoluteFilepathToConfiguration:i,rawUnresolvedFilepath:c,visitor:r,nodePath:[...n,"path"],willBeUploaded:!1})},page:xc,contents:async c=>{c!=null&&await Promise.all(c.map(async(f,u)=>{await eWu({absolutePathToFernFolder:e,navigationItem:f,visitor:r,nodePath:[...n,"contents",`${u}`],absoluteFilepathToConfiguration:i,apiWorkspaces:a,context:o})}))},viewers:async c=>{c!=null&&c.length>0&&await r.permissions?.({viewers:c},[...n,"viewers"])},orphaned:xc,availability:xc}),nrM(t)){let c=f1(Wg(i),t.path);if(await Xv(c)){let f=(await(0,zns.readFile)(c)).toString();await r.markdownPage?.({title:t.page,content:f,absoluteFilepath:c},[...n,t.path]);try{let{filepaths:u}=kfa(f,{absolutePathToFernFolder:e,absolutePathToMarkdownFile:c});for(let s of u)await r.filepath?.({absoluteFilepath:s,value:m3(e,s),willBeUploaded:!0},[...n,t.path])}catch{}}}if(irM(t)){let c=a.find(f=>f.workspaceName===t.apiName);c!=null&&await r.apiSection?.({config:t,workspace:c,context:o},[...n,"api"])}if(rrM(t)){let c=f1(Wg(i),t.changelog);if(o.logger.trace(`Starting changelog processing for directory: ${c}`),await Xv(c)){let f=await(0,zns.readdir)(c);o.logger.trace(`Validating ${f.length} files in changelog directory ${c}`),await Promise.all(f.filter(u=>u.endsWith(".md")||u.endsWith(".mdx")).map(async u=>{let s=f1(c,u),l=(await(0,zns.readFile)(s)).toString();o.logger.trace(`Validating markdown file: ${s}`),await r.markdownPage?.({title:u,content:l,absoluteFilepath:s},[...n,"changelog",u])}))}else o.logger.trace(`Changelog directory does not exist: ${c}`)}}function rrM(e){return e?.changelog!=null}function nrM(e){return e?.page!=null}function irM(e){return e?.api!=null}function arM(e){return e[0]?.tab!=null}function orM(e){return"layout"in e&&Array.isArray(e.layout)}function srM(e){return"variants"in e&&Array.isArray(e.variants)}async function jIv({contents:e,visitor:t,absoluteFilepathToConfiguration:r,context:n,apiWorkspaces:i,absolutePathToFernFolder:a}){await t.file?.({config:e},[]),await l2r(e,{instances:xc,analytics:xc,aiChat:xc,aiSearch:xc,pageActions:xc,announcement:xc,backgroundImage:async o=>{o!=null&&(typeof o=="string"?await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:o,visitor:t,nodePath:["background-image"]}):(o.dark!=null&&await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:o.dark,visitor:t,nodePath:["background-image","dark"]}),o.light!=null&&await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:o.light,visitor:t,nodePath:["background-image","light"]})))},colors:xc,css:async o=>{o!=null&&(Array.isArray(o)?await Promise.all(o.map((c,f)=>mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:c,visitor:t,nodePath:["css",`${f}`],willBeUploaded:!1}))):await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:o,visitor:t,nodePath:["css"],willBeUploaded:!1}))},defaultLanguage:xc,experimental:xc,favicon:async o=>{o!=null&&await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:o,visitor:t,nodePath:["favicon"]})},footerLinks:xc,integrations:xc,js:async o=>{o!=null&&(Array.isArray(o)?await Promise.all(o.map((c,f)=>wIv({absoluteFilepathToConfiguration:r,visitor:t,script:c,nodePath:["js",`${f}`]}))):await wIv({absoluteFilepathToConfiguration:r,visitor:t,script:o,nodePath:["js"]}))},landingPage:xc,layout:xc,settings:xc,logo:async()=>{e.logo?.dark!=null&&await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.logo.dark,visitor:t,nodePath:["logo","dark"]}),e.logo?.light!=null&&await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:e.logo.light,visitor:t,nodePath:["logo","light"]})},metadata:xc,navbarLinks:xc,navigation:async o=>{o!=null&&await tWu({absolutePathToFernFolder:a,navigation:o,visitor:t,nodePath:["navigation"],absoluteFilepathToConfiguration:r,apiWorkspaces:i,context:n})},products:async o=>{o!=null&&await Promise.all(o.map(async(c,f)=>{if("path"in c){await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:c.path,visitor:t,nodePath:["products",`${f}`],willBeUploaded:!1});let u=f1(Wg(r),c.path),s=jg.load((await(0,hWf.readFile)(u)).toString());await Xv(u)&&await t.productFile?.({path:c.path,content:s},[c.path]);let l=await kVu({value:s});l.type==="success"&&await tWu({absolutePathToFernFolder:a,navigation:l.contents.navigation,visitor:t,nodePath:["navigation"],absoluteFilepathToConfiguration:u,apiWorkspaces:i,context:n})}}))},redirects:xc,tabs:xc,title:xc,typography:async o=>{o!=null&&await l2r(o,{bodyFont:async c=>{c!=null&&await _Wf({absoluteFilepathToConfiguration:r,visitor:t,font:c,nodePath:["typography","bodyFont"]})},codeFont:async c=>{c!=null&&await _Wf({absoluteFilepathToConfiguration:r,visitor:t,font:c,nodePath:["typography","codeFont"]})},headingsFont:async c=>{c!=null&&await _Wf({absoluteFilepathToConfiguration:r,visitor:t,font:c,nodePath:["typography","headingsFont"]})}})},versions:async o=>{o!=null&&await Promise.all(o.map(async(c,f)=>{await mde({absoluteFilepathToConfiguration:r,rawUnresolvedFilepath:c.path,visitor:t,nodePath:["versions",`${f}`],willBeUploaded:!1});let u=f1(Wg(r),c.path),s=jg.load((await(0,hWf.readFile)(u)).toString());await Xv(u)&&await t.versionFile?.({path:c.path,content:s},[c.path]);let l=await ZVu({value:s});l.type==="success"&&await tWu({absolutePathToFernFolder:a,navigation:l.contents.navigation,visitor:t,nodePath:["navigation"],absoluteFilepathToConfiguration:u,apiWorkspaces:i,context:n})}))},roles:xc,languages:xc,theme:xc})}async function _Wf({absoluteFilepathToConfiguration:e,visitor:t,font:r,nodePath:n}){r.path!=null&&await mde({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:r.path,visitor:t,nodePath:n,willBeUploaded:!0});for(let i of r.paths??[])typeof i=="string"?await mde({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:i,visitor:t,nodePath:n,willBeUploaded:!0}):await mde({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:i.path,visitor:t,nodePath:n,willBeUploaded:!0})}async function wIv({absoluteFilepathToConfiguration:e,visitor:t,script:r,nodePath:n}){let i=typeof r=="string"?r:"path"in r?r.path:null;i&&await mde({absoluteFilepathToConfiguration:e,rawUnresolvedFilepath:i,visitor:t,nodePath:n,willBeUploaded:!0})}var Kns={};yf(Kns,{AccentColorContrastRule:()=>yWf,AllRolesMustBeDeclaredRule:()=>vWf,FilepathsExistRule:()=>rWu,OnlyVersionedNavigation:()=>nWu,TabWithHrefRule:()=>crM,ValidDocsEndpoints:()=>iWu,ValidFileTypes:()=>lWu,ValidFrontmatter:()=>fWu,ValidMarkdownFileReferences:()=>DBv,ValidMarkdownLinks:()=>n2i,ValidMarkdownRule:()=>jBv,ValidateProductFileRule:()=>BWu,ValidateVersionFileRule:()=>TWu,enforceBackgroundTheme:()=>EIv,validateTheme:()=>Qns});var yWf={name:"accent-color-contrast",create:()=>({file:async({config:e})=>{if(e.colors==null)return[];let t=Vau(e.colors);return t==="dark"?Qns(e.colors,"dark"):t==="light"?Qns(e.colors,"light"):t==="darkAndLight"?[...Qns(e.colors,"dark"),...Qns(e.colors,"light")]:[]}})};function Qns(e,t){let r=G9o(e.accentPrimary??e.accentPrimaryDeprecated,"accent-primary",t),n=G9o(e.background,"background",t)??(t==="dark"?"#000":"#FFF"),i=[];if(!vA(n).isValid())i.push({severity:"fatal",message:`Invalid background color provided for colors.background.${t}: ${n}.`});else{let a=EIv(vA(n),t);vA(n).toHexString()!==a.toHexString()&&i.push({severity:"warning",message:`The provided background color for ${t} mode is not ${t} enough. It will be adjusted to ${a.toHexString()}.`}),n=a.toHexString()}if(r==null)i.push({severity:"warning",message:`No accent-color provided for ${t} mode. A random color will be used.`});else if(!vA(r).isValid())i.push({severity:"fatal",message:`Invalid accent-color provided for colors.accent-primary.${t}: ${r}.`});else{let a=vA.readability(r,n),o=`${a.toFixed(2)}:1`;a<3?i.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${o}. It should be at least 3:1.`}):a<4.5?i.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${o}. Fern will adjust the color to meet the minimum contrast ratio of 4.5:1 for WCAG AA and 7:1 for WCAG AAA.`}):a<7&&i.push({severity:"warning",message:`The contrast ratio between the accent color and the background color for ${t} mode is ${o}. Fern will adjust the color to meet the minimum contrast ratio of 7:1 for WCAG AAA.`})}return i}function EIv(e,t){return t==="dark"&&e.isDark()||t==="light"&&e.isLight()?e:urM(e)}function urM(e){if(e==null)return;let{h:t,s:r,v:n}=e.toHsv();return vA({h:t,s:r,v:1-n})}var vWf={name:"all-roles-must-be-declared",create:e=>{let t=e.workspace.config.roles;return{permissions:r=>{let n=[...r.viewers??[]],i=[];for(let a of n)(t==null||!t.includes(a))&&i.push({severity:"fatal",message:`Role "${a}" is used but not declared at the top level of the docs.yml file.`});return i}}}};var rWu={name:"filepaths-exist",create:()=>({filepath:async({absoluteFilepath:e,value:t})=>await Xv(e)?[]:[{severity:"fatal",message:`Path ${t} does not exist`}]})};var nWu={name:"only-versioned-navigation",create:()=>({file:async({config:e})=>e.navigation!=null&&e.versions!=null?[{severity:"fatal",message:"Cannot contain both navigation and versions. If you want versioned docs, use versions. Otherwise use navigation."}]:[]})};var crM={name:"tab-with-href",create:()=>({file:async({config:e})=>{let t=e.tabs??{};if(e.navigation==null)return[];let r=[];if(lrM(e.navigation))for(let n of e.navigation){let i=t[n.tab];if(i==null){r.push({severity:"fatal",message:`Tab "${n.tab}" is missing from the tabs configuration.`});continue}let a=frM(n),o=drM(n);if(i.href!=null&&(a||o)){r.push({severity:"fatal",message:`Tab "${n.tab}" has both a href and ${a?"layout":"variants"}. Only one should be used.`});continue}if(i.href==null&&!a&&!o){r.push({severity:"fatal",message:`Tab "${n.tab}" is missing a href, layout, or variants.`});continue}}return[]}})};function lrM(e){return Array.isArray(e)&&e.length>0&&e[0].tab!=null}function frM(e){return"layout"in e&&Array.isArray(e.layout)}function drM(e){return"variants"in e&&Array.isArray(e.variants)}var iWu={name:"valid-docs-endpoints",create:()=>({file:async({config:e})=>!e.analytics||!Object.keys(e.analytics).length?[]:[[e.analytics.intercom?.apiBase,"Intercom API Base"],[e.analytics.posthog?.endpoint,"Posthog Host Endpoint"]].filter(([n])=>n&&!prM(n)).map(([n,i])=>({severity:"warning",message:`${i} <${n}> is malformed. Make sure it includes a protocol (e.g. 'https://')!`}))})};function prM(e){try{return!!new URL(e).protocol}catch{return!1}}var WIv=$i(t0f(),1);var IrM=require("stream/web"),wWf=require("stream");var brM=require("fs/promises");var _rM="End-Of-Stream",BQ=class extends Error{constructor(){super(_rM)}};var Lns=class{constructor(){this.maxStreamReadSize=1*1024*1024,this.endOfStream=!1,this.peekQueue=[]}async peek(t,r,n){let i=await this.read(t,r,n);return this.peekQueue.push(t.subarray(r,r+i)),i}async read(t,r,n){if(n===0)return 0;let i=this.readFromPeekBuffer(t,r,n);if(i+=await this.readRemainderFromStream(t,r+i,n-i),i===0)throw new BQ;return i}readFromPeekBuffer(t,r,n){let i=n,a=0;for(;this.peekQueue.length>0&&i>0;){let o=this.peekQueue.pop();if(!o)throw new Error("peekData should be defined");let c=Math.min(o.length,i);t.set(o.subarray(0,c),r+a),a+=c,i-=c,c<o.length&&this.peekQueue.push(o.subarray(c))}return a}async readRemainderFromStream(t,r,n){let i=n,a=0;for(;i>0&&!this.endOfStream;){let o=Math.min(i,this.maxStreamReadSize),c=await this.readFromStream(t,r+a,o);if(c===0)break;a+=c,i-=c}return a}};var Uns=class extends Lns{constructor(t){super(),this.reader=t.getReader({mode:"byob"})}async readFromStream(t,r,n){if(this.endOfStream)throw new BQ;let i=await this.reader.read(new Uint8Array(n));return i.done&&(this.endOfStream=i.done),i.value?(t.set(i.value,r),i.value.byteLength):0}abort(){return this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};var Fwi=class{constructor(t){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=t?.onClose,t?.abortSignal&&t.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(t,r=this.position){let n=new Uint8Array(t.len);if(await this.readBuffer(n,{position:r})<t.len)throw new BQ;return t.get(n,0)}async peekToken(t,r=this.position){let n=new Uint8Array(t.len);if(await this.peekBuffer(n,{position:r})<t.len)throw new BQ;return t.get(n,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new BQ;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new BQ;return t.get(this.numBuffer,0)}async ignore(t){if(this.fileInfo.size!==void 0){let r=this.fileInfo.size-this.position;if(t>r)return this.position+=r,r}return this.position+=t,t}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(t,r){if(r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return r?{mayBeLess:r.mayBeLess===!0,offset:r.offset?r.offset:0,length:r.length?r.length:t.length-(r.offset?r.offset:0),position:r.position?r.position:this.position}:{mayBeLess:!1,offset:0,length:t.length,position:this.position}}abort(){return Promise.resolve()}};var yrM=256e3,aWu=class extends Fwi{constructor(t,r){super(r),this.streamReader=t,this.fileInfo=r?.fileInfo??{}}async readBuffer(t,r){let n=this.normalizeOptions(t,r),i=n.position-this.position;if(i>0)return await this.ignore(i),this.readBuffer(t,r);if(i<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let a=await this.streamReader.read(t,n.offset,n.length);if(this.position+=a,(!r||!r.mayBeLess)&&a<n.length)throw new BQ;return a}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=0;if(n.position){let a=n.position-this.position;if(a>0){let o=new Uint8Array(n.length+a);return i=await this.peekBuffer(o,{mayBeLess:n.mayBeLess}),t.set(o.subarray(a),n.offset),i-a}if(a<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{i=await this.streamReader.peek(t,n.offset,n.length)}catch(a){if(r?.mayBeLess&&a instanceof BQ)return 0;throw a}if(!n.mayBeLess&&i<n.length)throw new BQ}return i}async ignore(t){let r=Math.min(yrM,t),n=new Uint8Array(r),i=0;for(;i<t;){let a=t-i,o=await this.readBuffer(n,{length:Math.min(r,a)});if(o<0)return o;i+=o}return i}abort(){return this.streamReader.abort()}supportsRandomAccess(){return!1}};var oWu=class extends Fwi{constructor(t,r){super(r),this.uint8Array=t,this.fileInfo={...r?.fileInfo??{},size:t.length}}async readBuffer(t,r){if(r?.position){if(r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");this.position=r.position}let n=await this.peekBuffer(t,r);return this.position+=n,n}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&i<n.length)throw new BQ;return t.set(this.uint8Array.subarray(n.position,n.position+i),n.offset),i}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}};function bWf(e,t){return new aWu(new Uns(e),t)}function SIv(e,t){return new oWu(e,t)}var DIv=require("fs/promises"),Vns=class e extends Fwi{static async fromFile(t){let r=await(0,DIv.open)(t,"r"),n=await r.stat();return new e(r,{fileInfo:{path:t,size:n.size}})}constructor(t,r){super(r),this.fileHandle=t,this.fileInfo=r.fileInfo}async readBuffer(t,r){let n=this.normalizeOptions(t,r);if(this.position=n.position,n.length===0)return 0;let i=await this.fileHandle.read(t,n.offset,n.length,n.position);if(this.position+=i.bytesRead,i.bytesRead<n.length&&(!r||!r.mayBeLess))throw new BQ;return i.bytesRead}async peekBuffer(t,r){let n=this.normalizeOptions(t,r),i=await this.fileHandle.read(t,n.offset,n.length,n.position);if(!n.mayBeLess&&i.bytesRead<n.length)throw new BQ;return i.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(t){this.position=t}supportsRandomAccess(){return!0}};var grM=Vns.fromFile;var MIv=$i(CIv(),1);var mWf={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},OrM={};for(let[e,t]of Object.entries(mWf))OrM[t]=Number.parseInt(e);function IIv(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):ArM(e);case"utf-16le":return PrM(e);case"ascii":return wrM(e);case"latin1":case"iso-8859-1":return jrM(e);case"windows-1252":return ErM(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function ArM(e){let t="",r=0;for(;r<e.length;){let n=e[r++];if(n<128)t+=String.fromCharCode(n);else if(n<224){let i=e[r++]&63;t+=String.fromCharCode((n&31)<<6|i)}else if(n<240){let i=e[r++]&63,a=e[r++]&63;t+=String.fromCharCode((n&15)<<12|i<<6|a)}else{let i=e[r++]&63,a=e[r++]&63,o=e[r++]&63,c=(n&7)<<18|i<<12|a<<6|o;c-=65536,t+=String.fromCharCode(55296+(c>>10&1023),56320+(c&1023))}}return t}function PrM(e){let t="";for(let r=0;r<e.length;r+=2)t+=String.fromCharCode(e[r]|e[r+1]<<8);return t}function wrM(e){return String.fromCharCode(...e.map(t=>t&127))}function jrM(e){return String.fromCharCode(...e)}function ErM(e){let t="";for(let r of e)r>=128&&r<=159&&mWf[r]?t+=mWf[r]:t+=String.fromCharCode(r);return t}function Gxe(e){return new DataView(e.buffer,e.byteOffset)}var BIv={len:1,get(e,t){return Gxe(e).getUint8(t)},put(e,t,r){return Gxe(e).setUint8(t,r),t+1}},sWu={len:2,get(e,t){return Gxe(e).getUint16(t,!0)},put(e,t,r){return Gxe(e).setUint16(t,r,!0),t+2}},uWu={len:2,get(e,t){return Gxe(e).getUint16(t)},put(e,t,r){return Gxe(e).setUint16(t,r),t+2}};var TIv={len:4,get(e,t){return Gxe(e).getUint32(t,!0)},put(e,t,r){return Gxe(e).setUint32(t,r,!0),t+4}},qIv={len:4,get(e,t){return Gxe(e).getUint32(t)},put(e,t,r){return Gxe(e).setUint32(t,r),t+4}};var RIv={len:4,get(e,t){return Gxe(e).getInt32(t)},put(e,t,r){return Gxe(e).setInt32(t,r),t+4}};var NIv={len:8,get(e,t){return Gxe(e).getBigUint64(t,!0)},put(e,t,r){return Gxe(e).setBigUint64(t,r,!0),t+8}};var Int=class{constructor(t,r){this.len=t,this.encoding=r}get(t,r=0){let n=t.subarray(r,r+this.len);return IIv(n,this.encoding)}};var QvW={utf8:new globalThis.TextDecoder("utf8")};var LvW=new globalThis.TextEncoder;var UvW=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function OWf(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}function AWf(e,t){let r=e.length,n=t.length;if(n===0||n>r)return-1;let i=r-n;for(let a=0;a<=i;a++){let o=!0;for(let c=0;c<n;c++)if(e[a+c]!==t[c]){o=!1;break}if(o)return a}return-1}function FIv(e,t){return AWf(e,t)!==-1}function xIv(e){return[...e].map(t=>t.charCodeAt(0))}function zIv(e,t=0){let r=Number.parseInt(new Int(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=256;for(let i=t;i<t+148;i++)n+=e[i];for(let i=t+156;i<t+512;i++)n+=e[i];return r===n}var QIv={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4};var LIv=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","ai","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk"],UIv=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/x-apache-arrow","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/x-parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive"];var VIv=4100;async function PWf(e){return new cWu().fromBuffer(e)}function _Wr(e,t,r){r={offset:0,...r};for(let[n,i]of t.entries())if(r.mask){if(i!==(r.mask[n]&e[n+r.offset]))return!1}else if(i!==e[n+r.offset])return!1;return!0}var cWu=class{constructor(t){this.detectors=t?.customDetectors,this.tokenizerOptions={abortSignal:t?.signal},this.fromTokenizer=this.fromTokenizer.bind(this),this.fromBuffer=this.fromBuffer.bind(this),this.parse=this.parse.bind(this)}async fromTokenizer(t){let r=t.position;for(let n of this.detectors||[]){let i=await n(t);if(i)return i;if(r!==t.position)return}return this.parse(t)}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);let r=t instanceof Uint8Array?t:new Uint8Array(t);if(r?.length>1)return this.fromTokenizer(SIv(r,this.tokenizerOptions))}async fromBlob(t){return this.fromStream(t.stream())}async fromStream(t){let r=await bWf(t,this.tokenizerOptions);try{return await this.fromTokenizer(r)}finally{await r.close()}}async toDetectionStream(t,r){let{sampleSize:n=VIv}=r,i,a,o=t.getReader({mode:"byob"});try{let{value:u,done:s}=await o.read(new Uint8Array(n));if(a=u,!s&&u)try{i=await this.fromBuffer(u.slice(0,n))}catch(l){if(!(l instanceof BQ))throw l;i=void 0}a=u}finally{o.releaseLock()}let c=new TransformStream({async start(u){u.enqueue(a)},transform(u,s){s.enqueue(u)}}),f=t.pipeThrough(c);return f.fileType=i,f}check(t,r){return _Wr(this.buffer,t,r)}checkString(t,r){return this.check(xIv(t),r)}async parse(t){if(this.buffer=new Uint8Array(VIv),t.fileInfo.size===void 0&&(t.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=t,await t.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await t.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.parse(t);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await t.ignore(6);let r=await t.readToken(QIv);return t.position+r>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(r),this.fromTokenizer(t))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){try{for(;t.position+30<t.fileInfo.size;){await t.readBuffer(this.buffer,{length:30});let r=new DataView(this.buffer.buffer),n={compressedSize:r.getUint32(18,!0),uncompressedSize:r.getUint32(22,!0),filenameLength:r.getUint16(26,!0),extraFieldLength:r.getUint16(28,!0)};if(n.filename=await t.readToken(new Int(n.filenameLength,"utf-8")),await t.ignore(n.extraFieldLength),/classes\d*\.dex/.test(n.filename))return{ext:"apk",mime:"application/vnd.android.package-archive"};if(n.filename==="META-INF/mozilla.rsa")return{ext:"xpi",mime:"application/x-xpinstall"};if(n.filename.endsWith(".rels")||n.filename.endsWith(".xml"))switch(n.filename.split("/")[0]){case"_rels":break;case"word":return{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};case"ppt":return{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"};case"xl":return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};case"visio":return{ext:"vsdx",mime:"application/vnd.visio"};default:break}if(n.filename.startsWith("xl/"))return{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"};if(n.filename.startsWith("3D/")&&n.filename.endsWith(".model"))return{ext:"3mf",mime:"model/3mf"};if(n.filename==="mimetype"&&n.compressedSize===n.uncompressedSize){let i=await t.readToken(new Int(n.compressedSize,"utf-8"));switch(i=i.trim(),i){case"application/epub+zip":return{ext:"epub",mime:"application/epub+zip"};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};default:}}if(n.compressedSize===0){let i=-1;for(;i<0&&t.position<t.fileInfo.size;)await t.peekBuffer(this.buffer,{mayBeLess:!0}),i=AWf(this.buffer,new Uint8Array([80,75,3,4])),await t.ignore(i>=0?i:this.buffer.length)}else await t.ignore(n.compressedSize)}}catch(r){if(!(r instanceof BQ))throw r}return{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let r=new Uint8Array(8);return await t.readBuffer(r),_Wr(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:_Wr(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:_Wr(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:_Wr(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:_Wr(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:_Wr(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let r=new Int(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/x-flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF")){try{await t.ignore(1350);let r=10*1024*1024,n=new Uint8Array(Math.min(r,t.fileInfo.size));if(await t.readBuffer(n,{mayBeLess:!0}),FIv(n,new TextEncoder().encode("AIPrivateData")))return{ext:"ai",mime:"application/postscript"}}catch(r){if(!(r instanceof BQ))throw r}return{ext:"pdf",mime:"application/pdf"}}if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){let r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){let c=await t.peekNumber(BIv),f=128,u=0;for(;(c&f)===0&&f!==0;)++u,f>>=1;let s=new Uint8Array(u+1);return await t.readBuffer(s),s}async function n(){let c=await r(),f=await r();f[0]^=128>>f.length-1;let u=Math.min(6,f.length),s=new DataView(c.buffer),l=new DataView(f.buffer,f.length-u,u);return{id:OWf(s),len:OWf(l)}}async function i(c){for(;c>0;){let f=await n();if(f.id===17026)return(await t.readToken(new Int(f.len))).replaceAll(/\00.*$/g,"");await t.ignore(f.len),--c}}let a=await n();switch(await i(a.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/x-matroska"};default:return}}if(this.check([82,73,70,70])){if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1"))return{ext:"parquet",mime:"application/x-parquet"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let r=new Int(4,"latin1").get(this.buffer,2);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await t.ignore(8),await t.readToken(new Int(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
|
|
3044
3044
|
`,"\r"," "," ","\0"].some(r=>this.checkString(r,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await t.ignore(8);async function r(){return{length:await t.readToken(RIv),type:await t.readToken(new Int(4,"latin1"))}}do{let n=await r();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await t.ignore(n.length+4)}}while(t.position+8<t.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/x-apache-arrow"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function r(){let n=new Uint8Array(16);return await t.readBuffer(n),{id:n,size:Number(await t.readToken(NIv))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let n=await r(),i=n.size-24;if(_Wr(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let a=new Uint8Array(16);if(i-=await t.readBuffer(a),_Wr(a,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(_Wr(a,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await t.ignore(i)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await t.ignore(20),await t.readToken(new Int(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await t.peekBuffer(this.buffer,{length:Math.min(256,t.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let r=new DataView(this.buffer.buffer).getUint32(12,!0);if(r>12&&this.buffer.length>=r+16)try{let n=new TextDecoder().decode(this.buffer.slice(16,r+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(await t.peekBuffer(this.buffer,{length:Math.min(512,t.fileInfo.size),mayBeLess:!0}),zIv(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254]))return this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0;if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"};if(this.buffer.length>=2&&this.check([255,224],{offset:0,mask:[255,224]})){if(this.check([16],{offset:1,mask:[22]}))return this.check([8],{offset:1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}async readTiffTag(t){let r=await this.tokenizer.readToken(t?uWu:sWu);switch(this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(t){let r=await this.tokenizer.readToken(t?uWu:sWu);for(let n=0;n<r;++n){let i=await this.readTiffTag(t);if(i)return i}}async readTiffHeader(t){let r=(t?uWu:sWu).get(this.buffer,2),n=(t?qIv:TIv).get(this.buffer,4);if(r===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8&&(this.check([28,0,254,0],{offset:8})||this.check([31,0,11,0],{offset:8})))return{ext:"nef",mime:"image/x-nikon-nef"}}return await this.tokenizer.ignore(n),await this.readTiffIFD(t)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}},DrM=new Set(LIv),CrM=new Set(UIv);var HIv=require("fs/promises"),GIv=$i(require("path"),1),MrM=new Set(["image/jpeg","image/png","image/gif","image/webp","image/tiff","image/x-icon","image/avif","video/quicktime","video/mp4","video/webm","audio/mpeg","audio/ogg","audio/wav","application/pdf","application/xml","font/woff","font/woff2","font/otf","font/ttf"]),BrM=new Set(["ASCII","UTF-8","UTF-16","ISO-8859-1","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","WINDOWS-1250","WINDOWS-1251","WINDOWS-1252","WINDOWS-1253","WINDOWS-1254","WINDOWS-1255","WINDOWS-1256","WINDOWS-1257","WINDOWS-1258","SHIFT_JIS","SHIFT-JIS","EUC-JP","ISO-2022-JP","BIG5","GB2312","GB18030","KOI8-R"]),lWu={name:"valid-file-types",create:()=>({filepath:async({absoluteFilepath:e,willBeUploaded:t})=>t?await Xv(e)?TrM(e):[]:[]})},TrM=async e=>{let t=new Uint8Array(await(0,HIv.readFile)(e)),r=await PWf(t);if(r!=null)return MrM.has(r.mime)?[]:[{severity:"fatal",message:`The file type of ${r.mime} is not allowed: ${e}`}];let n=GIv.default.extname(e).toLowerCase();n.startsWith(".")&&(n=n.substring(1));let i=WIv.default.detect(t);return i==null?[{severity:"fatal",message:`The encoding of the file could not be detected: ${e}`}]:BrM.has(i.toUpperCase())?[]:[{severity:"fatal",message:`The encoding of ${i} is not allowed: ${e}`}]};var JIv=require("fs/promises"),KIv=$i(zTr(),1),fWu={name:"valid-frontmatter",create:()=>({filepath:async({absoluteFilepath:e})=>{if(!e.endsWith(".md")&&!e.endsWith(".mdx"))return[];try{let t=await(0,JIv.readFile)(e,"utf-8");return(0,KIv.default)(t),[]}catch(t){return[{severity:"fatal",message:`Failed to parse frontmatter${t instanceof Error?`: ${t.message}`:""}`}]}}})};var qrM=["md","markdown","mdown","mkdn","mkd","mdwn","mkdown","ron"],$Iv=qrM;var YIv=$Iv.map(function(e){return"."+e});function XIv(e,t){let r=RrM(e)?e:new I_t(e),{format:n,...i}=t||{};return{file:r,options:{format:n==="md"||n==="mdx"?n:r.extname&&(i.mdExtensions||YIv).includes(r.extname)?"md":"mdx",...i}}}function RrM(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}var jWf=/@(jsx|jsxFrag|jsxImportSource|jsxRuntime)\s+(\S+)/g;function EWf(e,t){let r=t||{},n=r.runtime==="automatic",i={},a={};iie(e,{enter(o){if(o.type==="Program"){let c=o.comments||[],f=-1;for(;++f<c.length;){jWf.lastIndex=0;let u=jWf.exec(c[f].value);for(;u;)i[u[1]]=u[2],u=jWf.exec(c[f].value)}if(i.jsxRuntime)if(i.jsxRuntime==="automatic"){if(n=!0,i.jsx)throw new Error("Unexpected `@jsx` pragma w/ automatic runtime");if(i.jsxFrag)throw new Error("Unexpected `@jsxFrag` pragma w/ automatic runtime")}else if(i.jsxRuntime==="classic"){if(n=!1,i.jsxImportSource)throw new Error("Unexpected `@jsxImportSource` w/ classic runtime")}else throw new Error("Unexpected `jsxRuntime` `"+i.jsxRuntime+"`, expected `automatic` or `classic`")}},leave(o){if(o.type==="Program"){let C=[];if(a.fragment&&C.push({type:"ImportSpecifier",imported:{type:"Identifier",name:"Fragment"},local:{type:"Identifier",name:"_Fragment"}}),a.jsx&&C.push({type:"ImportSpecifier",imported:{type:"Identifier",name:"jsx"},local:{type:"Identifier",name:"_jsx"}}),a.jsxs&&C.push({type:"ImportSpecifier",imported:{type:"Identifier",name:"jsxs"},local:{type:"Identifier",name:"_jsxs"}}),a.jsxDEV&&C.push({type:"ImportSpecifier",imported:{type:"Identifier",name:"jsxDEV"},local:{type:"Identifier",name:"_jsxDEV"}}),C.length>0){let M=0;for(;M<o.body.length;){let T=o.body[M];if("directive"in T&&T.directive)M++;else break}o.body.splice(M,0,{type:"ImportDeclaration",specifiers:C,source:{type:"Literal",value:(i.jsxImportSource||r.importSource||"react")+(r.development?"/jsx-dev-runtime":"/jsx-runtime")}})}}if(o.type!=="JSXElement"&&o.type!=="JSXFragment")return;let c=[],f=-1;for(;++f<o.children.length;){let C=o.children[f];if(C.type==="JSXExpressionContainer")C.expression.type!=="JSXEmptyExpression"&&c.push(C.expression);else if(C.type==="JSXText"){let M=C.value.replace(/\t/g," ").replace(/ *(\r?\n|\r) */g,`
|