fern-api 0.107.0 → 0.107.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.cjs +3 -3
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -2163,7 +2163,7 @@ ${SEy.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&lmf(th
2163
2163
  `+yla.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?yla.default.cyan(NEy(t,this.opt.mask)):yla.default.italic(yla.default.dim("[hidden]")):this.opt.mask?NEy(t,this.opt.mask):yla.default.italic(yla.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 qCu=Wi(due(),1);var NSy=Wi(Hmf(),1),BCu=require("child_process"),Geo=require("fs"),MCu=Wi(require("path"),1),FSy=Wi(require("os"),1),xSy=require("crypto"),COf=Wi(qSy(),1);var DCu=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var V$o=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var CCu=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var ICu=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function TCu(e="",t,r){let n=new IOf(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 RSy(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function YpC(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 IOf=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=YpC(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??FSy.default.tmpdir(),r=(0,xSy.randomUUID)(),n=RSy(this.fileOptions.prefix),i=RSy(this.fileOptions.postfix),a=`${n}${r}${i}`,o=MCu.default.resolve(t,a),c=MCu.default.resolve(t)+MCu.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,Geo.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new DCu(t)}}readTemporaryFile(){try{let t=(0,Geo.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,NSy.detect)(t)??"utf8";COf.default.encodingExists(r)||(r="utf8"),this.text=COf.default.decode(t,r)}}catch(t){throw new CCu(t)}}removeTemporaryFile(){try{(0,Geo.unlinkSync)(this.tempFile)}catch(t){throw new ICu(t)}}launchEditor(){try{let t=(0,BCu.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new V$o(t)}}launchEditorAsync(t){try{(0,BCu.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new V$o(r)}}};var zSy=Wi(vit(),1);var W$o=class extends pue{_run(t){this.done=t,this.editorResult=new zSy.Subject;let r=Qbe(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"?qCu.default.dim("Received"):qCu.default.dim("Press <enter> to launch your preferred editor."),t&&(r=qCu.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),TCu(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 WSy=require("stream");var USy=Wi(require("readline"),1),VSy=Wi(LSy(),1),mla=class{constructor(t){this.rl||=USy.default.createInterface(ZpC(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 ZpC(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 VSy.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var H$o=class extends mla{constructor(t={}){super(t),this.log=new WSy.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return D$o(this.rl,this.bottomBar.split(`
2164
2164
  `).length),this}updateBottomBar(t){return D$o(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+`
2165
2165
  `}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&&rCu(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var a6=Wi(vit(),1),JSy=Wi($Ko(),1);var RCu=Wi(vit(),1),HSy=Wi($Ko(),1),NCu=function(e,t,r){return typeof e[t]!="function"?(0,RCu.of)(e):(0,RCu.from)((0,HSy.default)(e[t])(r).then(n=>(e[t]=n,e)))};var GSy={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}},Jeo=class extends mla{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,a6.from)(t):(0,a6.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,a6.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,a6.from)([t]),this.process=n.pipe((0,a6.concatMap)(this.processQuestion.bind(this)),(0,a6.publish)()),this.process.connect(),this.process.pipe((0,a6.reduce)((i,a)=>(GSy.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,a6.defer)(()=>(0,a6.of)(t).pipe((0,a6.concatMap)(this.setDefaultType.bind(this)),(0,a6.concatMap)(this.filterIfRunnable.bind(this)),(0,a6.concatMap)(()=>NCu(t,"message",this.answers)),(0,a6.concatMap)(()=>NCu(t,"default",this.answers)),(0,a6.concatMap)(()=>NCu(t,"choices",this.answers)),(0,a6.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,a6.defer)(()=>(0,a6.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,a6.defer)(()=>(0,a6.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&GSy.get(this.answers,t.name)!==void 0)return a6.EMPTY;if(t.when===!1)return a6.EMPTY;if(typeof t.when!="function")return(0,a6.of)(t);let{answers:r}=this;return(0,a6.defer)(()=>(0,a6.from)((0,JSy.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,a6.filter)(n=>n!=null)))}};function KSy(e){let t=function(r,n){let i;try{i=new Jeo(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",I$o),this.registerPrompt("input",hla),this.registerPrompt("number",M$o),this.registerPrompt("confirm",B$o),this.registerPrompt("rawlist",T$o),this.registerPrompt("expand",q$o),this.registerPrompt("checkbox",R$o),this.registerPrompt("password",N$o),this.registerPrompt("editor",W$o)},t.restoreDefaultPrompts(),t}var BOf=KSy();function e_C(e,t){BOf.registerPrompt(e,t)}function t_C(){BOf.restoreDefaultPrompts()}var r_C={prompt:BOf,ui:{BottomBar:H$o,Prompt:Jeo},createPromptModule:KSy,registerPrompt:e_C,restoreDefaultPrompts:t_C,Separator:A3e},FCu=r_C;var oto=require("path"),SCy=require("fs"),DCy=require("readline"),ZDy="posthog-node";function CyC(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[nIu.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 nIu=class{constructor(t,r,n,i){this.name=ZDy,this.name=ZDy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(CyC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};nIu.POSTHOG_ID_TAG="posthog_distinct_id";var ZCu="0123456789abcdef",iIu=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+=ZCu.charAt(this.bytes[r]>>>4),t+=ZCu.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+=ZCu.charAt(this.bytes[r]>>>4),t+=ZCu.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}},yAf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??IyC()}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 iIu.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,iIu.ofInner(t)}},IyC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),kDy,vAf=()=>MyC().toString(),MyC=()=>(kDy||(kDy=new yAf)).generate();function ByC(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 TyC(e,t){global.process.on("uncaughtException",ByC(e,t))}function qyC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var kCu,eCy,eIu;function RyC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return eIu&&r.length===eCy||(eCy=r.length,eIu=r.reduce((n,i)=>{kCu||(kCu={});let a=kCu[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,kCu[i]=[u,s];break}}}return n},{})),eIu}function NyC(e){return typeof Event<"u"&&CCy(e,Event)}function FyC(e){return ICy(e,"Object")}function jAf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return CCy(e,Error)}}function CCy(e,t){try{return e instanceof t}catch{return!1}}function xyC(e){return ICy(e,"ErrorEvent")}function ICy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function zyC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=MCy(a,r,n);return{$exception_list:await Promise.all(o.map(async u=>{let s=await GyC(e,t,u);return s.value=s.value||"",s.type=s.type||"Error",s.mechanism=a,s}))}}function MCy(e,t,r){let n=QyC(e,t,r);return n.cause?[n,...MCy(e,n.cause,r)]:[n]}function QyC(e,t,r){if(jAf(t))return t;if(e.synthetic=!0,FyC(t)){let i=LyC(t);if(i)return i;let a=UyC(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 LyC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(jAf(r))return r}}function UyC(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=WyC(e);if(xyC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=VyC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function VyC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function WyC(e,t=40){let r=Object.keys(HyC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return tCy(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:tCy(a,t)}return""}function tCy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function HyC(e){return jAf(e)?{message:e.message,name:e.name,stack:e.stack,...rCy(e)}:NyC(e)?{type:e.type,target:nCy(e.target),currentTarget:nCy(e.currentTarget),...rCy(e)}:e}function rCy(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 nCy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function GyC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=JyC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function JyC(e,t){return KyC(e(t.stack||"",1),e)}function KyC(e,t){let r=RyC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var $yC=2e3,nto=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await zyC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||vAf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(TyC(this.onException.bind(this),this.onFatalError.bind(this)),qyC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown($yC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function YyC(e=process.argv[1]?(0,oto.dirname)(process.argv[1]):process.cwd(),t=oto.sep==="\\"){let r=t?iCy(e):e;return n=>{if(!n)return;let i=t?iCy(n):n,{dir:a,base:o,ext:c}=oto.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 iCy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var aIu=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)}}},rIu=new aIu(25),BCy=new aIu(20),EAf=7,XyC=1e3,ZyC=1e4;async function kyC(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"||nvC(o)||ivC(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(BCy.get(i))continue;let a=t[i];if(!a)continue;a.sort((f,u)=>f-u);let o=ovC(a);if(o.every(f=>avC(i,f)))continue;let c=svC(rIu,i,{});n.push(evC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&tvC(e,rIu),rIu.reduce(),e}function evC(e,t,r){return new Promise(n=>{let i=(0,SCy.createReadStream)(e),a=(0,DCy.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(){BCy.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]=uvC(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 tvC(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;rvC(r.lineno,r,n)}}function rvC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=TCy(e);i<e;i++){let a=r[i];if(a===void 0){aCy(t);return}t.pre_context.push(a)}if(r[e]===void 0){aCy(t);return}t.context_line=r[e];let n=qCy(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 aCy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function nvC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function ivC(e){return e.lineno!==void 0&&e.lineno>ZyC||e.colno!==void 0&&e.colno>XyC}function avC(e,t){let r=rIu.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 ovC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=oCy(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+EAf:(i.push(n),n=oCy(a)),t++}return i}function oCy(e){return[TCy(e),qCy(e)]}function TCy(e){return Math.max(1,e-EAf)}function qCy(e){return e+EAf}function svC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function uvC(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 cvC="4.18.0",S3e;(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"})(S3e||(S3e={}));var sCy;(function(e){e.Left="left",e.Right="right",e.Center="center"})(sCy||(sCy={}));var uCy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(uCy||(uCy={}));var cCy;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(cCy||(cCy={}));var lCy;(function(e){e.Html="html",e.Text="text"})(lCy||(lCy={}));var fCy;(function(e){e.Number="number",e.Emoji="emoji"})(fCy||(fCy={}));var dCy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(dCy||(dCy={}));var pCy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(pCy||(pCy={}));var _Cy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(_Cy||(_Cy={}));var hCy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(hCy||(hCy={}));var lvC=e=>{if("flags"in e){let t=dvC(e.flags),r=pvC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,RCy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,fvC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function fvC(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 dvC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,SAf(r)]).filter(([,t])=>t!==void 0)),pvC=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?RCy(n):void 0]}))},SAf=e=>e===void 0?void 0:e.variant??e.enabled,RCy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},_vC=1,hvC=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"]),yvC="utf8";function vvC(e,t){if(!e||typeof e!="string"||bvC(e))throw new Error(t)}function bvC(e){return e.trim().length===0}function gvC(e){return e?.replace(/\/+$/,"")}async function mvC(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 yCy(){return new Date().getTime()}function _Af(){return new Date().toISOString()}function oIu(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function OvC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function AvC(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 PvC(e,t=0,r){let n=AvC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function vCy(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var tYo=String.fromCharCode,bCy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",tIu={};function wvC(e,t){if(!tIu[e]){tIu[e]={};for(let r=0;r<e.length;r++)tIu[e][e.charAt(r)]=r}return tIu[e][t]}var tto={compressToBase64:function(e){if(e==null)return"";let t=tto._compress(e,6,function(r){return bCy.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:tto._decompress(e.length,32,function(t){return wvC(bCy,e.charAt(t))})},compress:function(e){return tto._compress(e,16,function(t){return tYo(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,I;for(I=0;I<e.length;I+=1)if(f=e.charAt(I),Object.prototype.hasOwnProperty.call(n,f)||(n[f]=m++,i[f]=!0),u=s+f,Object.prototype.hasOwnProperty.call(n,u))s=u;else{if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<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:tto._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,I;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;I=tYo(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;I=tYo(m);break;case 2:return""}for(n[3]=I,l=I,i.push(I);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,f),C=1;C!=P;)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(I=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++]=tYo(m),I=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++]=tYo(m),I=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,f),f++),n[I])u=n[I];else if(I===c)u=l+l.charAt(0);else return null;i.push(u),n[c++]=l+u.charAt(0),o--,l=u,o==0&&(o=Math.pow(2,f),f++)}}},bAf=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)}},ito=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()}},rYo=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function gCy(e){if(e instanceof ito){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 hAf(e){return typeof e=="object"&&(e instanceof ito||e instanceof rYo)}function mCy(e){return typeof e=="object"&&e instanceof ito&&e.status===413}var gAf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(gAf||(gAf={}));var mAf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new bAf,this._isInitialized=!1,vvC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=gvC(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:hAf},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(S3e.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(S3e.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(S3e.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=vAf();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=PvC(this.apiKey,_vC,hvC)?`${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=>lvC(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=SAf(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(gAf.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(S3e.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(S3e.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(S3e.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(S3e.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(S3e.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=oIu(()=>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:_Af()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${yCy()}&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(tto.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:_Af(),uuid:n?.uuid?n.uuid:vAf()};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 gCy(t)})}async flush(){let t=vCy([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),vCy([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(S3e.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(S3e.Queue)||[]).slice(i.length);this.setPersistedProperty(S3e.Queue,A),t=A},c={api_key:this.apiKey,batch:a,sent_at:_Af()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${yCy()}&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(tto.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:m=>mCy(m)?!1:hAf(m)};try{await this.fetchWithRetry(u,s,l)}catch(m){if(mCy(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 rYo||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,yvC)}catch{c=new TextEncoder().encode(o).length}return await mvC(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(s){throw new rYo(s)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new ito(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(S3e.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!hAf(i))throw i;await gCy(i)}};return Promise.race([new Promise((i,a)=>{oIu(()=>{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}},OAf=OvC();if(!OAf){let e=XDy();OAf=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 NCy=OAf,sIu=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()}},FCy=new sIu(async()=>{try{return await import("crypto")}catch{return}});async function jvC(){return await FCy.getValue()}var EvC=new sIu(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await FCy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function SvC(){return await EvC.getValue()}async function DvC(e){let t=await jvC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await SvC();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 CvC=60*1e3,IvC=1152921504606847e3,MvC=["is_not"],rto=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},_ue=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},AAf=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||NCy,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 _ue?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 _ue||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 _ue("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 _ue("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 _ue)o=!0;else throw s}if(c!==void 0)return c;if(o)throw new _ue("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=zCy(c,i,this.cohorts,this.debugMode):u=xCy(c,i,o),!u)return!1}if(a==null)return!0}return!(a!=null&&await OCy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await OCy(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(CvC,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 rto(`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 rto(`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 rto(`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 rto&&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=oIu(()=>{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=oIu(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function OCy(e,t,r=""){let n=await DvC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/IvC}function xCy(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 _ue("Operator is_not_set is not supported")}else throw new _ue(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!MvC.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 ACy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return ACy(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=BvC(String(i));if(u==null&&(u=PCy(i)),u==null)throw new _ue(`Invalid date: ${i}`);let s=PCy(o);return["is_date_before"].includes(a)?s<u:s>u}default:throw new _ue(`Unknown operator: ${a}`)}}function zCy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new _ue("can't match cohort without a given cohort property value");let a=r[i];return QCy(a,t,r,n)}function QCy(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=QCy(c,t,r,n);if(i==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof _ue)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new _ue("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=zCy(c,t,r,n):f=xCy(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 _ue)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new _ue("can't match cohort without a given cohort property value");return i==="AND"}}function ACy(e){try{return new RegExp(e),!0}catch{return!1}}function PCy(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 _ue(`${e} is in an invalid date format`)}else throw new _ue(`The date provided ${e} must be a string, number, or date object`)}function BvC(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 PAf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},TvC=100,wCy=30*1e3,qvC=50*1e3,wAf=class extends mAf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new PAf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,TvC):wCy,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 AAf({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 nto(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||qvC}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):NCy(t,r)}getLibraryVersion(){return cvC}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[I,T]of Object.entries(A))P[`$feature/${I}`]=T;let C=Object.keys(A||{}).filter(I=>A?.[I]!==!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[I,T]of Object.entries(A))P[`$feature/${I}`]=T;let C=Object.keys(A||{}).filter(I=>A?.[I]!==!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=wCy){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 I=await super.getFeatureFlagDetailStateless(t,r,i,f,u,a);if(I===void 0)return;P=I.response,l=SAf(P),A=I?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id: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");nto.captureException(this,t,{syntheticException:i},r,n)}},jCy=/\(error: (.*)\)/,LCy=50,UCy="?";function RvC(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||UCy,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:ECy(i[3]),colno:ECy(i[4]),in_app:NvC(s||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function NvC(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 ECy(e){return parseInt(e||"",10)||void 0}function FvC(e){return[90,RvC(e)]}function xvC(e){let r=[FvC(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],o=n.split(`
2166
- `);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=jCy.test(f)?f.replace(jCy,"$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>=LCy)break}}return zvC(a)}}function zvC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,LCy).map(r=>({...r,filename:r.filename||QvC(t).filename,function:r.function||UCy}))}function QvC(e){return e[e.length-1]||{}}nto.stackParser=xvC(YyC());nto.frameModifiers=[kyC];var ato=class extends wAf{getLibraryId(){return"posthog-node"}};var uIu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new ato(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.107.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var nYo=class{async sendEvent(){}async identify(){}async flush(){}};var sto=require("fs/promises"),GCy=require("os"),JCy=require("path");var VCy=Wi(require("crypto")),lIu=new Uint8Array(256),cIu=lIu.length;function DAf(){return cIu>lIu.length-16&&(VCy.default.randomFillSync(lIu),cIu=0),lIu.slice(cIu,cIu+=16)}var Ube=[];for(let e=0;e<256;++e)Ube.push((e+256).toString(16).slice(1));function WCy(e,t=0){return Ube[e[t+0]]+Ube[e[t+1]]+Ube[e[t+2]]+Ube[e[t+3]]+"-"+Ube[e[t+4]]+Ube[e[t+5]]+"-"+Ube[e[t+6]]+Ube[e[t+7]]+"-"+Ube[e[t+8]]+Ube[e[t+9]]+"-"+Ube[e[t+10]]+Ube[e[t+11]]+Ube[e[t+12]]+Ube[e[t+13]]+Ube[e[t+14]]+Ube[e[t+15]]}var HCy=Wi(require("crypto")),CAf={randomUUID:HCy.default.randomUUID};function LvC(e,t,r){if(CAf.randomUUID&&!t&&!e)return CAf.randomUUID();e=e||{};let n=e.random||(e.rng||DAf)();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 WCy(n)}var git=LvC;var UvC="id",VvC=".fern",iYo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new ato(r),this.userId=t==null?void 0:Jhf(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.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wl(L_.of((0,GCy.homedir)()),nu.of(VvC),nu.of(UvC));await Kv(t)||(await(0,sto.mkdir)((0,JCy.dirname)(t),{recursive:!0}),await(0,sto.writeFile)(t,git())),this.persistedDistinctId=(await(0,sto.readFile)(t)).toString()}return this.persistedDistinctId}};var IAf;async function uto(){return IAf==null&&(IAf=await WvC()),IAf}async function WvC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new nYo;let r=await Awu();return r!=null?new iYo({token:r,posthogApiKey:e}):await uka()!=null?new uIu({posthogApiKey:e}):new iYo({token:void 0,posthogApiKey:e})}catch{return new nYo}}function aYo(e,t){return function(){return e.apply(t,arguments)}}var{toString:HvC}=Object.prototype,{getPrototypeOf:BAf}=Object,{iterator:dIu,toStringTag:$Cy}=Symbol,pIu=(e=>t=>{let r=HvC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),pRr=e=>(e=e.toLowerCase(),t=>pIu(t)===e),_Iu=e=>t=>typeof t===e,{isArray:lto}=Array,cto=_Iu("undefined");function oYo(e){return e!==null&&!cto(e)&&e.constructor!==null&&!cto(e.constructor)&&D3e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var YCy=pRr("ArrayBuffer");function GvC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&YCy(e.buffer),t}var JvC=_Iu("string"),D3e=_Iu("function"),XCy=_Iu("number"),sYo=e=>e!==null&&typeof e=="object",KvC=e=>e===!0||e===!1,fIu=e=>{if(pIu(e)!=="object")return!1;let t=BAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!($Cy in e)&&!(dIu in e)},$vC=e=>{if(!sYo(e)||oYo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},YvC=pRr("Date"),XvC=pRr("File"),ZvC=pRr("Blob"),kvC=pRr("FileList"),ebC=e=>sYo(e)&&D3e(e.pipe),tbC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||D3e(e.append)&&((t=pIu(e))==="formdata"||t==="object"&&D3e(e.toString)&&e.toString()==="[object FormData]"))},rbC=pRr("URLSearchParams"),[nbC,ibC,abC,obC]=["ReadableStream","Request","Response","Headers"].map(pRr),sbC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function uYo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),lto(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(oYo(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 ZCy(e,t){if(oYo(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 Ela=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,kCy=e=>!cto(e)&&e!==Ela;function MAf(){let{caseless:e,skipUndefined:t}=kCy(this)&&this||{},r={},n=(i,a)=>{let o=e&&ZCy(r,a)||a;fIu(r[o])&&fIu(i)?r[o]=MAf(r[o],i):fIu(i)?r[o]=MAf({},i):lto(i)?r[o]=i.slice():(!t||!cto(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&uYo(arguments[i],n);return r}var ubC=(e,t,r,{allOwnKeys:n}={})=>(uYo(t,(i,a)=>{r&&D3e(i)?e[a]=aYo(i,r):e[a]=i},{allOwnKeys:n}),e),cbC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),lbC=(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)},fbC=(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&&BAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},dbC=(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},pbC=e=>{if(!e)return null;if(lto(e))return e;let t=e.length;if(!XCy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},_bC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&BAf(Uint8Array)),hbC=(e,t)=>{let n=(e&&e[dIu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ybC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},vbC=pRr("HTMLFormElement"),bbC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),KCy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gbC=pRr("RegExp"),eIy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};uYo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},mbC=e=>{eIy(e,(t,r)=>{if(D3e(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(D3e(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+"'")})}})},ObC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return lto(e)?n(e):n(String(e).split(t)),r},AbC=()=>{},PbC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function wbC(e){return!!(e&&D3e(e.append)&&e[$Cy]==="FormData"&&e[dIu])}var jbC=e=>{let t=new Array(10),r=(n,i)=>{if(sYo(n)){if(t.indexOf(n)>=0)return;if(oYo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=lto(n)?[]:{};return uYo(n,(o,c)=>{let f=r(o,i+1);!cto(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},EbC=pRr("AsyncFunction"),SbC=e=>e&&(sYo(e)||D3e(e))&&D3e(e.then)&&D3e(e.catch),tIy=((e,t)=>e?setImmediate:t?((r,n)=>(Ela.addEventListener("message",({source:i,data:a})=>{i===Ela&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Ela.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",D3e(Ela.postMessage)),DbC=typeof queueMicrotask<"u"?queueMicrotask.bind(Ela):typeof process<"u"&&process.nextTick||tIy,CbC=e=>e!=null&&D3e(e[dIu]),Zf={isArray:lto,isArrayBuffer:YCy,isBuffer:oYo,isFormData:tbC,isArrayBufferView:GvC,isString:JvC,isNumber:XCy,isBoolean:KvC,isObject:sYo,isPlainObject:fIu,isEmptyObject:$vC,isReadableStream:nbC,isRequest:ibC,isResponse:abC,isHeaders:obC,isUndefined:cto,isDate:YvC,isFile:XvC,isBlob:ZvC,isRegExp:gbC,isFunction:D3e,isStream:ebC,isURLSearchParams:rbC,isTypedArray:_bC,isFileList:kvC,forEach:uYo,merge:MAf,extend:ubC,trim:sbC,stripBOM:cbC,inherits:lbC,toFlatObject:fbC,kindOf:pIu,kindOfTest:pRr,endsWith:dbC,toArray:pbC,forEachEntry:hbC,matchAll:ybC,isHTMLForm:vbC,hasOwnProperty:KCy,hasOwnProp:KCy,reduceDescriptors:eIy,freezeMethods:mbC,toObjectSet:ObC,toCamelCase:bbC,noop:AbC,toFiniteNumber:PbC,findKey:ZCy,global:Ela,isContextDefined:kCy,isSpecCompliantForm:wbC,toJSONObject:jbC,isAsyncFn:EbC,isThenable:SbC,setImmediate:tIy,asap:DbC,isIterable:CbC};function fto(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(fto,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 rIy=fto.prototype,nIy={};["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=>{nIy[e]={value:e}});Object.defineProperties(fto,nIy);Object.defineProperty(rIy,"isAxiosError",{value:!0});fto.from=(e,t,r,n,i,a)=>{let o=Object.create(rIy);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 fto.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 xm=fto;var iIy=Wi(cca(),1),hIu=iIy.default;function TAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function oIy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function aIy(e,t,r){return e?e.concat(t).map(function(i,a){return i=oIy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function IbC(e){return Zf.isArray(e)&&!e.some(TAf)}var MbC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function BbC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(hIu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new xm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&IbC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=oIy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?aIy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return TAf(P)?!0:(t.append(aIy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(MbC,{defaultVisitor:s,convertValue:u,isVisitable:TAf});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 t8i=BbC;function sIy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function uIy(e,t){this._pairs=[],e&&t8i(e,this,t)}var cIy=uIy.prototype;cIy.append=function(t,r){this._pairs.push([t,r])};cIy.toString=function(t){let r=t?function(n){return t.call(this,n,sIy)}:sIy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var lIy=uIy;function TbC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sla(e,t,r){if(!t)return e;let n=r&&r.encode||TbC;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 lIy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var qAf=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)})}},RAf=qAf;var dto={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var _Iy=Wi(require("crypto"),1);var fIy=Wi(require("url"),1),dIy=fIy.default.URLSearchParams;var NAf="abcdefghijklmnopqrstuvwxyz",pIy="0123456789",hIy={DIGIT:pIy,ALPHA:NAf,ALPHA_DIGIT:NAf+NAf.toUpperCase()+pIy},qbC=(e=16,t=hIy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);_Iy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},yIy={isNode:!0,classes:{URLSearchParams:dIy,FormData:hIu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:hIy,generateString:qbC,protocols:["http","https","file","data"]};var zAf={};yf(zAf,{hasBrowserEnv:()=>xAf,hasStandardBrowserEnv:()=>RbC,hasStandardBrowserWebWorkerEnv:()=>NbC,navigator:()=>FAf,origin:()=>FbC});var xAf=typeof window<"u"&&typeof document<"u",FAf=typeof navigator=="object"&&navigator||void 0,RbC=xAf&&(!FAf||["ReactNative","NativeScript","NS"].indexOf(FAf.product)<0),NbC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",FbC=xAf&&window.location.href||"http://localhost";var i8={...zAf,...yIy};function QAf(e,t){return t8i(e,new i8.classes.URLSearchParams,{visitor:function(r,n,i,a){return i8.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function xbC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function zbC(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 QbC(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]=zbC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(xbC(n),i,r,0)}),r}return null}var yIu=QbC;function LbC(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 LAf={transitional:dto,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(yIu(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 QAf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return t8i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),LbC(t)):t}],transformResponse:[function(t){let r=this.transitional||LAf.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"?xm.from(c,xm.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:i8.classes.FormData,Blob:i8.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=>{LAf.headers[e]={}});var pto=LAf;var UbC=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"]),vIy=e=>{let t={},r,n,i;return e&&e.split(`
2166
+ `);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=jCy.test(f)?f.replace(jCy,"$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>=LCy)break}}return zvC(a)}}function zvC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,LCy).map(r=>({...r,filename:r.filename||QvC(t).filename,function:r.function||UCy}))}function QvC(e){return e[e.length-1]||{}}nto.stackParser=xvC(YyC());nto.frameModifiers=[kyC];var ato=class extends wAf{getLibraryId(){return"posthog-node"}};var uIu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new ato(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.107.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var nYo=class{async sendEvent(){}async identify(){}async flush(){}};var sto=require("fs/promises"),GCy=require("os"),JCy=require("path");var VCy=Wi(require("crypto")),lIu=new Uint8Array(256),cIu=lIu.length;function DAf(){return cIu>lIu.length-16&&(VCy.default.randomFillSync(lIu),cIu=0),lIu.slice(cIu,cIu+=16)}var Ube=[];for(let e=0;e<256;++e)Ube.push((e+256).toString(16).slice(1));function WCy(e,t=0){return Ube[e[t+0]]+Ube[e[t+1]]+Ube[e[t+2]]+Ube[e[t+3]]+"-"+Ube[e[t+4]]+Ube[e[t+5]]+"-"+Ube[e[t+6]]+Ube[e[t+7]]+"-"+Ube[e[t+8]]+Ube[e[t+9]]+"-"+Ube[e[t+10]]+Ube[e[t+11]]+Ube[e[t+12]]+Ube[e[t+13]]+Ube[e[t+14]]+Ube[e[t+15]]}var HCy=Wi(require("crypto")),CAf={randomUUID:HCy.default.randomUUID};function LvC(e,t,r){if(CAf.randomUUID&&!t&&!e)return CAf.randomUUID();e=e||{};let n=e.random||(e.rng||DAf)();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 WCy(n)}var git=LvC;var UvC="id",VvC=".fern",iYo=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new ato(r),this.userId=t==null?void 0:Jhf(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.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wl(L_.of((0,GCy.homedir)()),nu.of(VvC),nu.of(UvC));await Kv(t)||(await(0,sto.mkdir)((0,JCy.dirname)(t),{recursive:!0}),await(0,sto.writeFile)(t,git())),this.persistedDistinctId=(await(0,sto.readFile)(t)).toString()}return this.persistedDistinctId}};var IAf;async function uto(){return IAf==null&&(IAf=await WvC()),IAf}async function WvC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new nYo;let r=await Awu();return r!=null?new iYo({token:r,posthogApiKey:e}):await uka()!=null?new uIu({posthogApiKey:e}):new iYo({token:void 0,posthogApiKey:e})}catch{return new nYo}}function aYo(e,t){return function(){return e.apply(t,arguments)}}var{toString:HvC}=Object.prototype,{getPrototypeOf:BAf}=Object,{iterator:dIu,toStringTag:$Cy}=Symbol,pIu=(e=>t=>{let r=HvC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),pRr=e=>(e=e.toLowerCase(),t=>pIu(t)===e),_Iu=e=>t=>typeof t===e,{isArray:lto}=Array,cto=_Iu("undefined");function oYo(e){return e!==null&&!cto(e)&&e.constructor!==null&&!cto(e.constructor)&&D3e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var YCy=pRr("ArrayBuffer");function GvC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&YCy(e.buffer),t}var JvC=_Iu("string"),D3e=_Iu("function"),XCy=_Iu("number"),sYo=e=>e!==null&&typeof e=="object",KvC=e=>e===!0||e===!1,fIu=e=>{if(pIu(e)!=="object")return!1;let t=BAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!($Cy in e)&&!(dIu in e)},$vC=e=>{if(!sYo(e)||oYo(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},YvC=pRr("Date"),XvC=pRr("File"),ZvC=pRr("Blob"),kvC=pRr("FileList"),ebC=e=>sYo(e)&&D3e(e.pipe),tbC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||D3e(e.append)&&((t=pIu(e))==="formdata"||t==="object"&&D3e(e.toString)&&e.toString()==="[object FormData]"))},rbC=pRr("URLSearchParams"),[nbC,ibC,abC,obC]=["ReadableStream","Request","Response","Headers"].map(pRr),sbC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function uYo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),lto(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(oYo(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 ZCy(e,t){if(oYo(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 Ela=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,kCy=e=>!cto(e)&&e!==Ela;function MAf(){let{caseless:e,skipUndefined:t}=kCy(this)&&this||{},r={},n=(i,a)=>{let o=e&&ZCy(r,a)||a;fIu(r[o])&&fIu(i)?r[o]=MAf(r[o],i):fIu(i)?r[o]=MAf({},i):lto(i)?r[o]=i.slice():(!t||!cto(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&uYo(arguments[i],n);return r}var ubC=(e,t,r,{allOwnKeys:n}={})=>(uYo(t,(i,a)=>{r&&D3e(i)?e[a]=aYo(i,r):e[a]=i},{allOwnKeys:n}),e),cbC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),lbC=(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)},fbC=(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&&BAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},dbC=(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},pbC=e=>{if(!e)return null;if(lto(e))return e;let t=e.length;if(!XCy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},_bC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&BAf(Uint8Array)),hbC=(e,t)=>{let n=(e&&e[dIu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ybC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},vbC=pRr("HTMLFormElement"),bbC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),KCy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),gbC=pRr("RegExp"),eIy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};uYo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},mbC=e=>{eIy(e,(t,r)=>{if(D3e(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(D3e(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+"'")})}})},ObC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return lto(e)?n(e):n(String(e).split(t)),r},AbC=()=>{},PbC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function wbC(e){return!!(e&&D3e(e.append)&&e[$Cy]==="FormData"&&e[dIu])}var jbC=e=>{let t=new Array(10),r=(n,i)=>{if(sYo(n)){if(t.indexOf(n)>=0)return;if(oYo(n))return n;if(!("toJSON"in n)){t[i]=n;let a=lto(n)?[]:{};return uYo(n,(o,c)=>{let f=r(o,i+1);!cto(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},EbC=pRr("AsyncFunction"),SbC=e=>e&&(sYo(e)||D3e(e))&&D3e(e.then)&&D3e(e.catch),tIy=((e,t)=>e?setImmediate:t?((r,n)=>(Ela.addEventListener("message",({source:i,data:a})=>{i===Ela&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Ela.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",D3e(Ela.postMessage)),DbC=typeof queueMicrotask<"u"?queueMicrotask.bind(Ela):typeof process<"u"&&process.nextTick||tIy,CbC=e=>e!=null&&D3e(e[dIu]),Zf={isArray:lto,isArrayBuffer:YCy,isBuffer:oYo,isFormData:tbC,isArrayBufferView:GvC,isString:JvC,isNumber:XCy,isBoolean:KvC,isObject:sYo,isPlainObject:fIu,isEmptyObject:$vC,isReadableStream:nbC,isRequest:ibC,isResponse:abC,isHeaders:obC,isUndefined:cto,isDate:YvC,isFile:XvC,isBlob:ZvC,isRegExp:gbC,isFunction:D3e,isStream:ebC,isURLSearchParams:rbC,isTypedArray:_bC,isFileList:kvC,forEach:uYo,merge:MAf,extend:ubC,trim:sbC,stripBOM:cbC,inherits:lbC,toFlatObject:fbC,kindOf:pIu,kindOfTest:pRr,endsWith:dbC,toArray:pbC,forEachEntry:hbC,matchAll:ybC,isHTMLForm:vbC,hasOwnProperty:KCy,hasOwnProp:KCy,reduceDescriptors:eIy,freezeMethods:mbC,toObjectSet:ObC,toCamelCase:bbC,noop:AbC,toFiniteNumber:PbC,findKey:ZCy,global:Ela,isContextDefined:kCy,isSpecCompliantForm:wbC,toJSONObject:jbC,isAsyncFn:EbC,isThenable:SbC,setImmediate:tIy,asap:DbC,isIterable:CbC};function fto(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(fto,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 rIy=fto.prototype,nIy={};["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=>{nIy[e]={value:e}});Object.defineProperties(fto,nIy);Object.defineProperty(rIy,"isAxiosError",{value:!0});fto.from=(e,t,r,n,i,a)=>{let o=Object.create(rIy);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 fto.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 xm=fto;var iIy=Wi(cca(),1),hIu=iIy.default;function TAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function oIy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function aIy(e,t,r){return e?e.concat(t).map(function(i,a){return i=oIy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function IbC(e){return Zf.isArray(e)&&!e.some(TAf)}var MbC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function BbC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(hIu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new xm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&IbC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=oIy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?aIy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return TAf(P)?!0:(t.append(aIy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(MbC,{defaultVisitor:s,convertValue:u,isVisitable:TAf});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 t8i=BbC;function sIy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function uIy(e,t){this._pairs=[],e&&t8i(e,this,t)}var cIy=uIy.prototype;cIy.append=function(t,r){this._pairs.push([t,r])};cIy.toString=function(t){let r=t?function(n){return t.call(this,n,sIy)}:sIy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var lIy=uIy;function TbC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Sla(e,t,r){if(!t)return e;let n=r&&r.encode||TbC;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 lIy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var qAf=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)})}},RAf=qAf;var dto={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var _Iy=Wi(require("crypto"),1);var fIy=Wi(require("url"),1),dIy=fIy.default.URLSearchParams;var NAf="abcdefghijklmnopqrstuvwxyz",pIy="0123456789",hIy={DIGIT:pIy,ALPHA:NAf,ALPHA_DIGIT:NAf+NAf.toUpperCase()+pIy},qbC=(e=16,t=hIy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);_Iy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},yIy={isNode:!0,classes:{URLSearchParams:dIy,FormData:hIu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:hIy,generateString:qbC,protocols:["http","https","file","data"]};var zAf={};yf(zAf,{hasBrowserEnv:()=>xAf,hasStandardBrowserEnv:()=>RbC,hasStandardBrowserWebWorkerEnv:()=>NbC,navigator:()=>FAf,origin:()=>FbC});var xAf=typeof window<"u"&&typeof document<"u",FAf=typeof navigator=="object"&&navigator||void 0,RbC=xAf&&(!FAf||["ReactNative","NativeScript","NS"].indexOf(FAf.product)<0),NbC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",FbC=xAf&&window.location.href||"http://localhost";var i8={...zAf,...yIy};function QAf(e,t){return t8i(e,new i8.classes.URLSearchParams,{visitor:function(r,n,i,a){return i8.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function xbC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function zbC(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 QbC(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]=zbC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(xbC(n),i,r,0)}),r}return null}var yIu=QbC;function LbC(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 LAf={transitional:dto,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(yIu(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 QAf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return t8i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),LbC(t)):t}],transformResponse:[function(t){let r=this.transitional||LAf.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"?xm.from(c,xm.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:i8.classes.FormData,Blob:i8.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=>{LAf.headers[e]={}});var pto=LAf;var UbC=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"]),vIy=e=>{let t={},r,n,i;return e&&e.split(`
2167
2167
  `).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&UbC[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var bIy=Symbol("internals");function cYo(e){return e&&String(e).trim().toLowerCase()}function vIu(e){return e===!1||e==null?e:Zf.isArray(e)?e.map(vIu):String(e)}function VbC(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 WbC=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function UAf(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 HbC(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function GbC(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 _to=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,f,u){let s=cYo(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]=vIu(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())&&!WbC(t))o(vIy(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=cYo(t),t){let n=Zf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return VbC(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=cYo(t),t){let n=Zf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||UAf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=cYo(o),o){let c=Zf.findKey(n,o);c&&(!r||UAf(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||UAf(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]=vIu(i),delete r[a];return}let c=t?HbC(a):String(a).trim();c!==a&&delete r[a],r[c]=vIu(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(`
2168
2168
  `)}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[bIy]=this[bIy]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=cYo(o);n[c]||(GbC(i,o),n[c]=!0)}return Zf.isArray(t)?t.forEach(a):a(t),this}};_to.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Zf.reduceDescriptors(_to.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Zf.freezeMethods(_to);var J$=_to;function lYo(e,t){let r=this||pto,n=t||r,i=J$.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 fYo(e){return!!(e&&e.__CANCEL__)}function gIy(e,t,r){xm.call(this,e??"canceled",xm.ERR_CANCELED,t,r),this.name="CanceledError"}Zf.inherits(gIy,xm,{__CANCEL__:!0});var mit=gIy;function QVr(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new xm("Request failed with status code "+r.status,[xm.ERR_BAD_REQUEST,xm.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function VAf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function WAf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Dla(e,t,r){let n=!VAf(t);return e&&(n||r==!1)?WAf(e,t):t}var RIy=Wi(xCu(),1),NIy=Wi(require("http"),1),FIy=Wi(require("https"),1),xIy=Wi(require("util"),1),zIy=Wi(HOf(),1),xPi=Wi(require("zlib"),1);var Cla="1.12.2";function dYo(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var JbC=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function HAf(e,t,r){let n=r&&r.Blob||i8.classes.Blob,i=dYo(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=JbC.exec(e);if(!a)throw new xm("Invalid URL",xm.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 xm("Blob is not supported",xm.ERR_NOT_SUPPORT);return new n([u],{type:o})}return u}throw new xm("Unsupported protocol "+i,xm.ERR_NOT_SUPPORT)}var Mla=Wi(require("stream"),1);var mIy=Wi(require("stream"),1);var GAf=Symbol("internals"),JAf=class extends mIy.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[GAf]={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[GAf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[GAf],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),I=null,T=o,z,U=0;if(a){let q=Date.now();(!i.ts||(U=q-i.ts)>=c)&&(i.ts=q,z=u-i.bytes,i.bytes=z<0?-z:0,U=0),z=u-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,A)},c-U);z<T&&(T=z)}T&&C>T&&C-T>s&&(I=A.subarray(T),A=A.subarray(0,T)),l(A,I?()=>{process.nextTick(P,null,I)}:P)};m(t,function A(P,C){if(P)return n(P);C?m(C,A):n(null)})}},KAf=JAf;var QIy=require("events");var AIy=Wi(require("util"),1),PIy=require("stream");var{asyncIterator:OIy}=Symbol,KbC=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[OIy]?yield*e[OIy]():yield e},bIu=KbC;var $bC=i8.ALPHABET.ALPHA_DIGIT+"-_",pYo=typeof TextEncoder=="function"?new TextEncoder:new AIy.default.TextEncoder,Ila=`\r
2169
2169
  `,YbC=pYo.encode(Ila),XbC=2,$Af=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)}"`:""}${Ila}`;i?r=pYo.encode(String(r).replace(/\r?\n|\r\n?/g,Ila)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Ila}`,this.headers=pYo.encode(a+Ila),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+XbC,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Zf.isTypedArray(t)?yield t:yield*bIu(t),yield YbC}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},ZbC=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+i8.generateString(i,$bC)}=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=pYo.encode("--"+a+Ila),c=pYo.encode("--"+a+"--"+Ila),f=c.byteLength,u=Array.from(e.entries()).map(([l,m])=>{let A=new $Af(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),PIy.Readable.from((async function*(){for(let l of u)yield o,yield*l.encode();yield c})())},wIy=ZbC;var jIy=Wi(require("stream"),1),YAf=class extends jIy.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)}},EIy=YAf;var kbC=(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,SIy=kbC;function egC(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 DIy=egC;function tgC(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 CIy=tgC;var FPi=(e,t,r=3)=>{let n=0,i=DIy(50,250);return CIy(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)},hto=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},yto=e=>(...t)=>Zf.asap(()=>e(...t));function XAf(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let m=0;m<o;m++)if(n.charCodeAt(m)===37&&m+2<o){let 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 IIy={flush:xPi.default.constants.Z_SYNC_FLUSH,finishFlush:xPi.default.constants.Z_SYNC_FLUSH},rgC={flush:xPi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:xPi.default.constants.BROTLI_OPERATION_FLUSH},MIy=Zf.isFunction(xPi.default.createBrotliDecompress),{http:ngC,https:igC}=zIy.default,agC=/https:?/,BIy=i8.protocols.map(e=>e+":"),TIy=(e,[t,r])=>(e.on("end",r).on("error",r),t);function ogC(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function LIy(e,t,r){let n=t;if(!n&&n!==!1){let i=RIy.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){LIy(a,t,a.href)}}var sgC=typeof process<"u"&&Zf.kindOf(process)==="process",ugC=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)}),cgC=({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)}},qIy=(e,t)=>cgC(Zf.isObject(e)?e:{address:e,family:t}),UIy=sgC&&function(t){return ugC(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=SIy(c,jt=>Zf.isArray(jt)?jt:[jt]);c=(jt,bt,ze)=>{Se(jt,bt,(Me,$t,rt)=>{if(Me)return ze(Me);let nr=Zf.isArray($t)?$t.map(Ft=>qIy(Ft)):[qIy($t,rt)];bt.all?ze(Me,nr):ze(Me,nr[0].address,nr[0].family)})}}let C=new QIy.EventEmitter,I=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Se,jt)=>{m=!0,jt&&(A=!0,I())});function T(Se){C.emit("abort",!Se||Se.type?new mit(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=Dla(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,i8.hasBrowserEnv?i8.origin:void 0),q=U.protocol||BIy[0];if(q==="data:"){if(t.maxContentLength>-1){let jt=String(t.url||z||"");if(XAf(jt)>t.maxContentLength)return i(new xm("maxContentLength size of "+t.maxContentLength+" exceeded",xm.ERR_BAD_RESPONSE,t))}let Se;if(l!=="GET")return QVr(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=HAf(t.url,u==="blob",{Blob:t.env&&t.env.Blob})}catch(jt){throw xm.from(jt,xm.ERR_BAD_REQUEST,t)}return u==="text"?(Se=Se.toString(s),(!s||s==="utf8")&&(Se=Zf.stripBOM(Se))):u==="stream"&&(Se=Mla.default.Readable.from(Se)),QVr(n,i,{data:Se,status:200,statusText:"OK",headers:new J$,config:t})}if(BIy.indexOf(q)===-1)return i(new xm("Unsupported protocol "+q,xm.ERR_BAD_REQUEST,t));let V=J$.from(t.headers).normalize();V.set("User-Agent","axios/"+Cla,!1);let{onUploadProgress:$,onDownloadProgress:re}=t,X=t.maxRate,k,ne;if(Zf.isSpecCompliantForm(o)){let Se=V.getContentType(/boundary=([-_\w\d]{10,70})/i);o=wIy(o,jt=>{V.set(jt)},{tag:`axios-${Cla}-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 xIy.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=Mla.default.Readable.from(bIu(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 xm("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",xm.ERR_BAD_REQUEST,t));if(V.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return i(new xm("Request body larger than maxBodyLength limit",xm.ERR_BAD_REQUEST,t))}let me=Zf.toFiniteNumber(V.getContentLength());Zf.isArray(X)?(k=X[0],ne=X[1]):k=ne=X,o&&($||k)&&(Zf.isStream(o)||(o=Mla.default.Readable.from(o,{objectMode:!1})),o=Mla.default.pipeline([o,new KAf({maxRate:Zf.toFiniteNumber(k)})],Zf.noop),$&&o.on("progress",TIy(o,hto(me,FPi(yto($),!1,3)))));let ve;if(t.auth){let Se=t.auth.username||"",jt=t.auth.password||"";ve=Se+":"+jt}if(!ve&&U.username){let Se=U.username,jt=U.password;ve=Se+":"+jt}ve&&V.delete("authorization");let Oe;try{Oe=Sla(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"+(MIy?", br":""),!1);let be={path:Oe,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:ve,protocol:q,family:f,beforeRedirect:ogC,beforeRedirects:{}};!Zf.isUndefined(c)&&(be.lookup=c),t.socketPath?be.socketPath=t.socketPath:(be.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,be.port=U.port,LIy(be,t.proxy,q+"//"+U.hostname+(U.port?":"+U.port:"")+be.path));let Ie,Be=agC.test(be.protocol);if(be.agent=Be?t.httpsAgent:t.httpAgent,t.transport?Ie=t.transport:t.maxRedirects===0?Ie=Be?FIy.default:NIy.default:(t.maxRedirects&&(be.maxRedirects=t.maxRedirects),t.beforeRedirect&&(be.beforeRedirects.config=t.beforeRedirect),Ie=Be?igC:ngC),t.maxBodyLength>-1?be.maxBodyLength=t.maxBodyLength:be.maxBodyLength=1/0,t.insecureHTTPParser&&(be.insecureHTTPParser=t.insecureHTTPParser),P=Ie.request(be,function(jt){if(P.destroyed)return;let bt=[jt],ze=+jt.headers["content-length"];if(re||ne){let Ft=new KAf({maxRate:Zf.toFiniteNumber(ne)});re&&Ft.on("progress",TIy(Ft,hto(ze,FPi(yto(re),!0,3)))),bt.push(Ft)}let Me=jt,$t=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(xPi.default.createUnzip(IIy)),delete jt.headers["content-encoding"];break;case"deflate":bt.push(new EIy),bt.push(xPi.default.createUnzip(IIy)),delete jt.headers["content-encoding"];break;case"br":MIy&&(bt.push(xPi.default.createBrotliDecompress(rgC)),delete jt.headers["content-encoding"])}Me=bt.length>1?Mla.default.pipeline(bt,Zf.noop):bt[0];let rt=Mla.default.finished(Me,()=>{rt(),I()}),nr={status:jt.statusCode,statusText:jt.statusMessage,headers:new J$(jt.headers),config:t,request:$t};if(u==="stream")nr.data=Me,QVr(n,i,nr);else{let Ft=[],Xe=0;Me.on("data",function(sr){Ft.push(sr),Xe+=sr.length,t.maxContentLength>-1&&Xe>t.maxContentLength&&(A=!0,Me.destroy(),i(new xm("maxContentLength size of "+t.maxContentLength+" exceeded",xm.ERR_BAD_RESPONSE,t,$t)))}),Me.on("aborted",function(){if(A)return;let sr=new xm("stream has been aborted",xm.ERR_BAD_RESPONSE,t,$t);Me.destroy(sr),i(sr)}),Me.on("error",function(sr){P.destroyed||i(xm.from(sr,null,t,$t))}),Me.on("end",function(){try{let sr=Ft.length===1?Ft[0]:Buffer.concat(Ft);u!=="arraybuffer"&&(sr=sr.toString(s),(!s||s==="utf8")&&(sr=Zf.stripBOM(sr))),nr.data=sr}catch(sr){return i(xm.from(sr,null,t,nr.request,nr))}QVr(n,i,nr)})}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(xm.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 xm("error trying to parse `config.timeout` to int",xm.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||dto;t.timeoutErrorMessage&&(bt=t.timeoutErrorMessage),i(new xm(bt,ze.clarifyTimeoutError?xm.ETIMEDOUT:xm.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 mit("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var VIy=i8.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,i8.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(i8.origin),i8.navigator&&/(msie|trident)/i.test(i8.navigator.userAgent)):()=>!0;var WIy=i8.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 HIy=e=>e instanceof J$?{...e}:e;function _Rr(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(HIy(u),HIy(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 gIu=e=>{let t=_Rr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=J$.from(o),t.url=Sla(Dla(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(i8.hasStandardBrowserEnv||i8.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(i8.hasStandardBrowserEnv&&(n&&Zf.isFunction(n)&&(n=n(t)),n||n!==!1&&VIy(t.url))){let f=i&&a&&WIy.read(a);f&&o.set(i,f)}return t};var lgC=typeof XMLHttpRequest<"u",GIy=lgC&&function(e){return new Promise(function(r,n){let i=gIu(e),a=i.data,o=J$.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 I=new XMLHttpRequest;I.open(i.method.toUpperCase(),i.url,!0),I.timeout=i.timeout;function T(){if(!I)return;let U=J$.from("getAllResponseHeaders"in I&&I.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?I.responseText:I.response,status:I.status,statusText:I.statusText,headers:U,config:e,request:I};QVr(function(re){r(re),C()},function(re){n(re),C()},V),I=null}"onloadend"in I?I.onloadend=T:I.onreadystatechange=function(){!I||I.readyState!==4||I.status===0&&!(I.responseURL&&I.responseURL.indexOf("file:")===0)||setTimeout(T)},I.onabort=function(){I&&(n(new xm("Request aborted",xm.ECONNABORTED,e,I)),I=null)},I.onerror=function(q){let V=q&&q.message?q.message:"Network Error",$=new xm(V,xm.ERR_NETWORK,e,I);$.event=q||null,n($),I=null},I.ontimeout=function(){let q=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||dto;i.timeoutErrorMessage&&(q=i.timeoutErrorMessage),n(new xm(q,V.clarifyTimeoutError?xm.ETIMEDOUT:xm.ECONNABORTED,e,I)),I=null},a===void 0&&o.setContentType(null),"setRequestHeader"in I&&Zf.forEach(o.toJSON(),function(q,V){I.setRequestHeader(V,q)}),Zf.isUndefined(i.withCredentials)||(I.withCredentials=!!i.withCredentials),c&&c!=="json"&&(I.responseType=i.responseType),u&&([m,P]=FPi(u,!0),I.addEventListener("progress",m)),f&&I.upload&&([l,A]=FPi(f),I.upload.addEventListener("progress",l),I.upload.addEventListener("loadend",A)),(i.cancelToken||i.signal)&&(s=U=>{I&&(n(!U||U.type?new mit(null,e,I):U),I.abort(),I=null)},i.cancelToken&&i.cancelToken.subscribe(s),i.signal&&(i.signal.aborted?s():i.signal.addEventListener("abort",s)));let z=dYo(i.url);if(z&&i8.protocols.indexOf(z)===-1){n(new xm("Unsupported protocol "+z+":",xm.ERR_BAD_REQUEST,e));return}I.send(a||null)})};var fgC=(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 xm?s:new mit(s instanceof Error?s.message:s))}},o=t&&setTimeout(()=>{o=null,a(new xm(`timeout ${t} of ms exceeded`,xm.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}},JIy=fgC;var dgC=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},pgC=async function*(e,t){for await(let r of _gC(e))yield*dgC(r,t)},_gC=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},ZAf=(e,t,r,n)=>{let i=pgC(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 KIy=64*1024,{isFunction:mIu}=Zf,hgC=(({Request:e,Response:t})=>({Request:e,Response:t}))(Zf.global),{ReadableStream:$Iy,TextEncoder:YIy}=Zf.global,XIy=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ygC=e=>{e=Zf.merge.call({skipUndefined:!0},hgC,e);let{fetch:t,Request:r,Response:n}=e,i=t?mIu(t):typeof fetch=="function",a=mIu(r),o=mIu(n);if(!i)return!1;let c=i&&mIu($Iy),f=i&&(typeof YIy=="function"?(P=>C=>P.encode(C))(new YIy):async P=>new Uint8Array(await new r(P).arrayBuffer())),u=a&&c&&XIy(()=>{let P=!1,C=new r(i8.origin,{body:new $Iy,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),s=o&&c&&XIy(()=>Zf.isReadableStream(new n("").body)),l={stream:s&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,I)=>{let T=C&&C[P];if(T)return T.call(C);throw new xm(`Response type '${P}' is not supported`,xm.ERR_NOT_SUPPORT,I)})});let m=async P=>{if(P==null)return 0;if(Zf.isBlob(P))return P.size;if(Zf.isSpecCompliantForm(P))return(await new r(i8.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 I=Zf.toFiniteNumber(P.getContentLength());return I??m(C)};return async P=>{let{url:C,method:I,data:T,signal:z,cancelToken:U,timeout:q,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:X,withCredentials:k="same-origin",fetchOptions:ne}=gIu(P),me=t||fetch;re=re?(re+"").toLowerCase():"text";let ve=JIy([z,U&&U.toAbortSignal()],q),Oe=null,be=ve&&ve.unsubscribe&&(()=>{ve.unsubscribe()}),Ie;try{if($&&u&&I!=="get"&&I!=="head"&&(Ie=await A(X,T))!==0){let Me=new r(C,{method:"POST",body:T,duplex:"half"}),$t;if(Zf.isFormData(T)&&($t=Me.headers.get("content-type"))&&X.setContentType($t),Me.body){let[rt,nr]=hto(Ie,FPi(yto($)));T=ZAf(Me.body,KIy,rt,nr)}}Zf.isString(k)||(k=k?"include":"omit");let Be=a&&"credentials"in r.prototype,Se={...ne,signal:ve,method:I.toUpperCase(),headers:X.normalize().toJSON(),body:T,duplex:"half",credentials:Be?k:void 0};Oe=a&&new r(C,Se);let jt=await(a?me(Oe,ne):me(C,Se)),bt=s&&(re==="stream"||re==="response");if(s&&(V||bt&&be)){let Me={};["status","statusText","headers"].forEach(Ft=>{Me[Ft]=jt[Ft]});let $t=Zf.toFiniteNumber(jt.headers.get("content-length")),[rt,nr]=V&&hto($t,FPi(yto(V),!0))||[];jt=new n(ZAf(jt.body,KIy,rt,()=>{nr&&nr(),be&&be()}),Me)}re=re||"text";let ze=await l[Zf.findKey(l,re)||"text"](jt,P);return!bt&&be&&be(),await new Promise((Me,$t)=>{QVr(Me,$t,{data:ze,headers:J$.from(jt.headers),status:jt.status,statusText:jt.statusText,config:P,request:Oe})})}catch(Be){throw be&&be(),Be&&Be.name==="TypeError"&&/Load failed|fetch/i.test(Be.message)?Object.assign(new xm("Network Error",xm.ERR_NETWORK,P,Oe),{cause:Be.cause||Be}):xm.from(Be,Be&&Be.code,P,Oe)}}},vgC=new Map,kAf=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=vgC;for(;c--;)f=a[c],u=s.get(f),u===void 0&&s.set(f,u=c?new Map:ygC(t)),s=u;return u},tYU=kAf();var ePf={http:UIy,xhr:GIy,fetch:{get:kAf}};Zf.forEach(ePf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var ZIy=e=>`- ${e}`,ggC=e=>Zf.isFunction(e)||e===null||e===!1,OIu={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,!ggC(n)&&(i=ePf[(c=String(n)).toLowerCase()],i===void 0))throw new xm(`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 :
@@ -2404,7 +2404,7 @@ ${q}${z}${V}${iao}`});function z3u({message:e,error:t,logger:r,logLevel:n=oE.Err
2404
2404
  Run ${Mf.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
2405
2405
  Run ${Mf.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),bto(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function sFf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!GXy(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+=`
2406
2406
  ${await oZC(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Mf.dim(c.currentVersion)+Mf.reset(" \u2192 ")+Mf.green(c.latestVersion);return i+=`
2407
- `,n?bto(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function oZC(e){let r=await new HXy.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 sZC({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await KXy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=Q4i(s.name,l),A=await Rqr({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 KXy({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=Q4i(u.name,s),m=await Rqr({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 KXy({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 Hqr({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 $Xy(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=H3e(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 V3u({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await sZC({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(...$Xy(u,f,t.logger));else o.push(...$Xy(c.versions,void 0,t.logger))}return o}var ees=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 uao=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var uFf=(()=>{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})(),YXy=typeof globalThis.AbortController=="function",XXy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ZXy=typeof globalThis.ReadableStream=="function",kXy=typeof globalThis.FormData=="function",W3u=["get","post","put","patch","head","delete"],uZC=()=>{};uZC();var eZy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},H3u=2147483647,tZy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,G3u=Symbol("stop"),rZy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},nZy={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 cZC=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=tZy,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},iZy=(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))}}))},aZy=(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(iZy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},oZy=(e,t,r)=>{if(!e.body)return e;let n=cZC(r??e.body);return new Request(e,{duplex:"half",body:iZy(e.body,n,t)})};var cao=e=>e!==null&&typeof e=="object";var tes=(...e)=>{for(let t of e)if((!cao(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return fFf({},...e)},cFf=(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 J3u(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:fFf(e[r]??[],t[r]??[])}var lFf=(e={},t={})=>({beforeRequest:J3u(e,t,"beforeRequest"),beforeRetry:J3u(e,t,"beforeRetry"),afterResponse:J3u(e,t,"afterResponse"),beforeError:J3u(e,t,"beforeError")}),fFf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(cao(i)){for(let[a,o]of Object.entries(i))cao(o)&&a in t&&(o=fFf(t[a],o)),t={...t,[a]:o};cao(i.hooks)&&(n=lFf(n,i.hooks),t.hooks=n),cao(i.headers)&&(r=cFf(r,i.headers),t.headers=r)}return t};var uZy=e=>W3u.includes(e)?e.toUpperCase():e,lZC=["get","put","head","delete","options","trace"],fZC=[408,413,429,500,502,503,504],dZC=[413,429,503],sZy={limit:2,methods:lZC,statusCodes:fZC,afterStatusCodes:dZC,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},cZy=(e={})=>{if(typeof e=="number")return{...sZy,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{...sZy,...e}};async function dFf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new uao(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function pFf(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 lZy=(e,t)=>{let r={};for(let n in t)!(n in nZy)&&!(n in rZy)&&!(n in e)&&(r[n]=t[n]);return r},fZy=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 res=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>H3u)throw new RangeError(`The \`timeout\` option cannot be greater than ${H3u}`);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 ees(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(!ZXy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return aZy(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(eZy))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:cFf(this._input.headers,r.headers),hooks:lFf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:uZy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:cZy(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(YXy&&XXy){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(uFf&&(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),fZy(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);(kXy&&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(!uFf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=oZy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof uao)throw t;if(t instanceof ees){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),H3u);if(this._retryCount<1)throw r;await pFf(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})===G3u)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=lZy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):dFf(this._originalRequest,t,this.abortController,this._options)}};var _Ff=e=>{let t=(r,n)=>res.create(r,tes(e,n));for(let r of W3u)t[r]=(n,i)=>res.create(n,tes(e,i,{method:r}));return t.create=r=>_Ff(tes(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),_Ff(tes(e,r))),t.stop=G3u,t},pZC=_Ff(),dZy=pZC;var RZy=Wi(qZy(),1);function gFf(e){let t=(0,RZy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Cky=Wi(Dky(),1),Iky=Wi(eqr(),1),BFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},TFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function qFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??gFf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Cky.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 dZy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new BFf(e):l}if(t.allVersions)return u;let s=new TFf(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=Iky.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 ues(e,t){let{version:r}=await qFf(e.toLowerCase(),t);return r}async function E2i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:ues(e.packageName,{version:t?"prerelease":"latest"})}var Mky=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],azu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=oE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new U3u(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.0"}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 cie}failWithoutThrowing(t,r){this.didSucceed=!1,z3u({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await uto()).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 JXy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2407
+ `,n?bto(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function oZC(e){let r=await new HXy.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 sZC({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await KXy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=Q4i(s.name,l),A=await Rqr({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 KXy({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=Q4i(u.name,s),m=await Rqr({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 KXy({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 Hqr({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 $Xy(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=H3e(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 V3u({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await sZC({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(...$Xy(u,f,t.logger));else o.push(...$Xy(c.versions,void 0,t.logger))}return o}var ees=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 uao=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var uFf=(()=>{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})(),YXy=typeof globalThis.AbortController=="function",XXy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ZXy=typeof globalThis.ReadableStream=="function",kXy=typeof globalThis.FormData=="function",W3u=["get","post","put","patch","head","delete"],uZC=()=>{};uZC();var eZy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},H3u=2147483647,tZy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,G3u=Symbol("stop"),rZy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},nZy={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 cZC=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=tZy,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},iZy=(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))}}))},aZy=(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(iZy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},oZy=(e,t,r)=>{if(!e.body)return e;let n=cZC(r??e.body);return new Request(e,{duplex:"half",body:iZy(e.body,n,t)})};var cao=e=>e!==null&&typeof e=="object";var tes=(...e)=>{for(let t of e)if((!cao(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return fFf({},...e)},cFf=(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 J3u(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:fFf(e[r]??[],t[r]??[])}var lFf=(e={},t={})=>({beforeRequest:J3u(e,t,"beforeRequest"),beforeRetry:J3u(e,t,"beforeRetry"),afterResponse:J3u(e,t,"afterResponse"),beforeError:J3u(e,t,"beforeError")}),fFf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(cao(i)){for(let[a,o]of Object.entries(i))cao(o)&&a in t&&(o=fFf(t[a],o)),t={...t,[a]:o};cao(i.hooks)&&(n=lFf(n,i.hooks),t.hooks=n),cao(i.headers)&&(r=cFf(r,i.headers),t.headers=r)}return t};var uZy=e=>W3u.includes(e)?e.toUpperCase():e,lZC=["get","put","head","delete","options","trace"],fZC=[408,413,429,500,502,503,504],dZC=[413,429,503],sZy={limit:2,methods:lZC,statusCodes:fZC,afterStatusCodes:dZC,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},cZy=(e={})=>{if(typeof e=="number")return{...sZy,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{...sZy,...e}};async function dFf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new uao(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function pFf(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 lZy=(e,t)=>{let r={};for(let n in t)!(n in nZy)&&!(n in rZy)&&!(n in e)&&(r[n]=t[n]);return r},fZy=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 res=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>H3u)throw new RangeError(`The \`timeout\` option cannot be greater than ${H3u}`);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 ees(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(!ZXy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return aZy(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(eZy))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:cFf(this._input.headers,r.headers),hooks:lFf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:uZy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:cZy(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(YXy&&XXy){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(uFf&&(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),fZy(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);(kXy&&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(!uFf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=oZy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof uao)throw t;if(t instanceof ees){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),H3u);if(this._retryCount<1)throw r;await pFf(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})===G3u)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=lZy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):dFf(this._originalRequest,t,this.abortController,this._options)}};var _Ff=e=>{let t=(r,n)=>res.create(r,tes(e,n));for(let r of W3u)t[r]=(n,i)=>res.create(n,tes(e,i,{method:r}));return t.create=r=>_Ff(tes(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),_Ff(tes(e,r))),t.stop=G3u,t},pZC=_Ff(),dZy=pZC;var RZy=Wi(qZy(),1);function gFf(e){let t=(0,RZy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var Cky=Wi(Dky(),1),Iky=Wi(eqr(),1),BFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},TFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function qFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??gFf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,Cky.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 dZy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new BFf(e):l}if(t.allVersions)return u;let s=new TFf(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=Iky.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 ues(e,t){let{version:r}=await qFf(e.toLowerCase(),t);return r}async function E2i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:ues(e.packageName,{version:t?"prerelease":"latest"})}var Mky=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],azu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=oE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new U3u(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.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Mf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new cie}failWithoutThrowing(t,r){this.didSucceed=!1,z3u({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await uto()).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 JXy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
2408
2408
  `)||(r+=`
2409
2409
  `),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=fef(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 Kko(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 cie}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await uto()).sendEvent(t)}logger=K5r((t,...r)=>this.log(t,...r));stderr=K5r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Bky(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?Bky(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=Mky[this.numTasks++%Mky.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===VV.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=>kzi.indexOf(i.level)>=kzi.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 E2i({cliEnvironment:this.environment,includePreReleases:t}),n=H3e(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await V3u({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await YNf({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(`
2410
2410
  Cancelled by user.`),new cie):n}}async getInput(t){return await GNf({message:t.message,default:t.default})}};function Bky(e){return`[${e}]:`}var xRr=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 Jit=class extends xRr{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 dvt={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 ces({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??dvt.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??dvt.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??dvt.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??dvt.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??dvt.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??dvt.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??dvt.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??dvt.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??dvt.respectForwardCompatibleEnums,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??dvt.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??dvt.coerceOptionalSchemasToNullable,groupEnvironmentsByHost:t?.groupEnvironmentsByHost??e?.groupEnvironmentsByHost??dvt.groupEnvironmentsByHost}}var Awe={openapi:e=>({...e,type:"openapi",_visit:function(t){return Awe._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Awe._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 yao={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return yao._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Hde={basic:e=>({...e,type:"basic",_visit:function(t){return Hde._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Hde._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Hde._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Hde._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Hde._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 RS={primitive:e=>({value:e,type:"primitive",_visit:function(t){return RS._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return RS._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return RS._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return RS._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return RS._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return RS._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return RS._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return RS._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return RS._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 FO={int:e=>({value:e,type:"int",_visit:function(t){return FO._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return FO._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return FO._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return FO._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return FO._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return FO._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return FO._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return FO._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return FO._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return FO._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return FO._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 S2i={boolean:e=>({value:e,type:"boolean",_visit:function(t){return S2i._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return S2i._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 D2i={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return D2i._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return D2i._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 ozu={};yf(ozu,{Availability:()=>Gde,CustomCodeSample:()=>qWr,EndpointExample:()=>pvt,EndpointResponseExample:()=>_vt,HttpMethod:()=>Kde,LiteralSchemaValue:()=>uW,MultipartRequestPropertyEncoding:()=>FFf,MultipartSchema:()=>RWr,OneOfSchema:()=>NWr,Pagination:()=>Kit,PrimitiveSchemaValue:()=>Jq,Request:()=>zRr,Response:()=>Jbe,RetriesConfiguration:()=>les,Schema:()=>Wj,SupportedSdkLanguage:()=>Jde,WebhookHttpMethod:()=>NFf,WebsocketMessageOrigin:()=>RFf});var RFf={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case RFf.Client:return t.client();case RFf.Server:return t.server();default:return t._other()}}};var NFf={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case NFf.Get:return t.get();case NFf.Post:return t.post();default:return t._other()}}};var Gde={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case Gde.GenerallyAvailable:return t.generallyAvailable();case Gde.Beta:return t.beta();case Gde.Deprecated:return t.deprecated();default:return t._other()}}};var les={disabled:e=>({value:e,type:"disabled",_visit:function(t){return les._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var Kit={cursor:e=>({...e,type:"cursor",_visit:function(t){return Kit._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Kit._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Kit._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 qWr={language:e=>({...e,type:"language",_visit:function(t){return qWr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return qWr._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 Jde={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 Jde.Curl:return t.curl();case Jde.Python:return t.python();case Jde.Javascript:return t.javascript();case Jde.Typescript:return t.typescript();case Jde.Go:return t.go();case Jde.Ruby:return t.ruby();case Jde.Csharp:return t.csharp();case Jde.Java:return t.java();case Jde.Js:return t.js();case Jde.Node:return t.node();case Jde.Ts:return t.ts();case Jde.Nodets:return t.nodets();case Jde.Golang:return t.golang();case Jde.Dotnet:return t.dotnet();case Jde.Jvm:return t.jvm();default:return t._other()}}};var pvt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return pvt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return pvt._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 _vt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return _vt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return _vt._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 Kde={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case Kde.Get:return t.get();case Kde.Post:return t.post();case Kde.Put:return t.put();case Kde.Patch:return t.patch();case Kde.Delete:return t.delete();case Kde.Head:return t.head();case Kde.Options:return t.options();case Kde.Trace:return t.trace();default:return t._other()}}};var zRr={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return zRr._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return zRr._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return zRr._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return zRr._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 FFf={Json:"json",Form:"form",_visit:(e,t)=>{switch(e){case FFf.Json:return t.json();case FFf.Form:return t.form();default:return t._other()}}};var RWr={file:e=>({...e,type:"file",_visit:function(t){return RWr._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return RWr._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 Jbe={file:e=>({...e,type:"file",_visit:function(t){return Jbe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Jbe._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Jbe._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return Jbe._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Jbe._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Jbe._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Jbe._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 Wj={primitive:e=>({...e,type:"primitive",_visit:function(t){return Wj._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Wj._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Wj._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Wj._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Wj._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Wj._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Wj._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Wj._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Wj._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Wj._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Wj._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 Jq={int:e=>({...e,type:"int",_visit:function(t){return Jq._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Jq._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Jq._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Jq._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Jq._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Jq._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Jq._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Jq._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Jq._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Jq._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Jq._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 uW={boolean:e=>({value:e,type:"boolean",_visit:function(t){return uW._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return uW._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 NWr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return NWr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return NWr._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 SIe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return SIe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return SIe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return SIe._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return SIe._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 v9={file:e=>({...e,type:"file",_visit:function(t){return v9._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return v9._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return v9._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return v9._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return v9._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return v9._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return v9._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 Mh={primitive:e=>({...e,type:"primitive",_visit:function(t){return Mh._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Mh._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Mh._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Mh._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Mh._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Mh._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Mh._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Mh._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Mh._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Mh._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Mh._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 $it={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return $it._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return $it._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 Z0={int:e=>({...e,type:"int",_visit:function(t){return Z0._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Z0._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Z0._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Z0._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Z0._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Z0._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Z0._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Z0._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Z0._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Z0._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Z0._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 Hj={};yf(Hj,{AllOfPropertyConflict:()=>Uao,ArraySchema:()=>P4u,ArraySchemaWithExample:()=>e6u,Availability:()=>yzu,Base64WithExample:()=>$4u,BasicSecurityScheme:()=>bzu,BearerSecurityScheme:()=>gzu,BooleanSchema:()=>v4u,BooleanWithExample:()=>Y4u,BytesResponse:()=>Bao,CasingOverrides:()=>Azu,CommonProperty:()=>M4u,CommonPropertyWithExample:()=>c6u,CursorPagination:()=>e4u,CustomCodeSample:()=>Zzu,CustomCodeSampleLanguage:()=>$zu,CustomCodeSampleSdk:()=>Xzu,CustomPagination:()=>r4u,DateWithExample:()=>K4u,DatetimeWithExample:()=>J4u,DiscriminatedOneOfSchema:()=>C4u,DiscriminatedOneOfSchemaWithExample:()=>s6u,DoubleSchema:()=>h4u,DoubleWithExample:()=>H4u,Encoding:()=>hzu,Endpoint:()=>n4u,EndpointExample:()=>Nao,EndpointResponseExample:()=>Kzu,EndpointSdkName:()=>zWr,EndpointSecurity:()=>wao,EndpointWithExample:()=>uev,EnumSchema:()=>Oao,EnumSchemaWithExample:()=>Z4u,EnumValue:()=>M2i,ErrorExample:()=>Vzu,FernExample:()=>Hzu,FileResponse:()=>Iao,FileSchema:()=>Rzu,FloatWithExample:()=>W4u,FormUrlEncodedRequest:()=>Qzu,FullEndpointExample:()=>kzu,FullExample:()=>GQ,FullObjectExample:()=>Izu,FullOneOfExample:()=>Bzu,GlobalHeader:()=>g4u,Header:()=>T2i,HeaderExample:()=>Rao,HeaderSecurityScheme:()=>mzu,HeaderWithExample:()=>N2i,HttpEndpointServer:()=>Tao,HttpError:()=>Wzu,HttpErrorWithExample:()=>z4u,HttpMethod:()=>jao,IdempotencyHeader:()=>m4u,Int64WithExample:()=>L4u,IntSchema:()=>p4u,IntWithExample:()=>Q4u,JsonRequest:()=>zzu,JsonRequestWithExample:()=>R4u,JsonResponse:()=>Mao,JsonResponseWithExample:()=>Hao,KeyValuePair:()=>Mzu,LiteralExample:()=>Dzu,LiteralSchema:()=>Lao,LiteralSchemaValue:()=>O4u,LongSchema:()=>_4u,MapSchema:()=>w4u,MapSchemaWithExample:()=>t6u,MultipartRequest:()=>Cao,MultipartRequestProperty:()=>xzu,MultipartRequestPropertyEncoding:()=>Fzu,MultipartSchema:()=>Nzu,NamedFullExample:()=>yvt,Namespace:()=>Pzu,NamespaceId:()=>Szu,NullExample:()=>Czu,NullableSchema:()=>E4u,NullableSchemaWithExample:()=>n6u,OauthSecurityScheme:()=>jzu,ObjectProperty:()=>D4u,ObjectPropertyConflictInfo:()=>Vao,ObjectPropertyWithExample:()=>o6u,ObjectSchema:()=>A4u,ObjectSchemaWithExample:()=>i6u,OctetStreamRequest:()=>Dao,OffsetPagination:()=>t4u,OneOfSchema:()=>S4u,OneOfSchemaWithExample:()=>a6u,OpenApiIntermediateRepresentation:()=>oev,OpenApiSource:()=>fzu,OptionalSchema:()=>j4u,OptionalSchemaWithExample:()=>r6u,Pagination:()=>Fao,ParseFormUrlEncodedRequest:()=>N4u,ParseMultipartRequest:()=>q4u,ParseOctetStreamRequest:()=>T4u,PathParameter:()=>Eao,PathParameterExample:()=>Gzu,PathParameterWithExample:()=>B4u,PrimitiveExample:()=>Pao,PrimitiveSchema:()=>R2i,PrimitiveSchemaValue:()=>b4u,PrimitiveSchemaValueWithExample:()=>X4u,PrimitiveSchemaWithExample:()=>Gao,PropertyKey:()=>Aao,ProtobufEncoding:()=>_zu,ProtobufSource:()=>dzu,QueryParameter:()=>Sao,QueryParameterExample:()=>qao,QueryParameterWithExample:()=>Wao,QuerySecurityScheme:()=>Ozu,ReferencedSchema:()=>QWr,Request:()=>Lzu,RequestWithExample:()=>F4u,Response:()=>Uzu,ResponseWithExample:()=>x4u,RetriesConfiguration:()=>xao,Schema:()=>$I,SchemaId:()=>DIe,SchemaWithExample:()=>s6,Schemas:()=>d4u,SdkGroup:()=>wzu,SdkGroupInfo:()=>Tzu,SdkGroupName:()=>B2i,SecurityScheme:()=>Ezu,SecuritySchemeId:()=>mao,Server:()=>_es,Source:()=>pzu,StatusCode:()=>FWr,StreamingResponseExample:()=>Jzu,StringSchema:()=>y4u,StringSchemaWithExample:()=>G4u,SupportedSdkLanguage:()=>Yzu,Tag:()=>vzu,TagId:()=>CIe,Tags:()=>qzu,TextResponse:()=>q2i,Uint64WithExample:()=>V4u,UintWithExample:()=>U4u,UnDiscriminatedOneOfSchema:()=>I4u,UnDiscriminatedOneOfSchemaWithExample:()=>u6u,UnknownSchemaWithExample:()=>k4u,Webhook:()=>i4u,WebhookExampleCall:()=>Qao,WebhookHttpMethod:()=>zao,WebhookWithExample:()=>cev,WebsocketChannel:()=>f4u,WebsocketHandshake:()=>a4u,WebsocketHandshakeWithExample:()=>sev,WebsocketMessageExample:()=>c4u,WebsocketMessageOrigin:()=>o4u,WebsocketMessageSchema:()=>s4u,WebsocketServer:()=>u4u,WebsocketSessionExample:()=>l4u,WithAvailability:()=>nw,WithDescription:()=>bv,WithEncoding:()=>J3e,WithInline:()=>o6,WithName:()=>ED,WithNamespace:()=>NS,WithSdkGroupName:()=>$M,WithSdkMethodName:()=>xWr,WithSource:()=>AP,WithStatusCode:()=>hvt,WithTitle:()=>KM,commons:()=>UFf,example:()=>VFf,finalIr:()=>WFf,parseIr:()=>HFf});var UFf={};yf(UFf,{BasicSecurityScheme:()=>bzu,BearerSecurityScheme:()=>gzu,Encoding:()=>hzu,HeaderSecurityScheme:()=>mzu,Namespace:()=>Pzu,NamespaceId:()=>Szu,OauthSecurityScheme:()=>jzu,OpenApiSource:()=>fzu,ProtobufEncoding:()=>_zu,ProtobufSource:()=>dzu,QuerySecurityScheme:()=>Ozu,SchemaId:()=>DIe,SdkGroup:()=>wzu,SdkGroupName:()=>B2i,SecurityScheme:()=>Ezu,SecuritySchemeId:()=>mao,Server:()=>_es,Source:()=>pzu,StatusCode:()=>FWr,Tag:()=>vzu,TagId:()=>CIe,WithAvailability:()=>nw,WithDescription:()=>bv,WithEncoding:()=>J3e,WithInline:()=>o6,WithName:()=>ED,WithNamespace:()=>NS,WithSdkGroupName:()=>$M,WithSdkMethodName:()=>xWr,WithSource:()=>AP,WithStatusCode:()=>hvt,WithTitle:()=>KM});var Wr={};yf(Wr,{JsonError:()=>vao,ParseError:()=>bao,any:()=>Jky,bigint:()=>qky,boolean:()=>Kky,booleanLiteral:()=>Gky,date:()=>Rky,discriminant:()=>nev,enum_:()=>uzu,getObjectLikeUtils:()=>QRr,getObjectUtils:()=>Hda,getSchemaUtils:()=>HQ,isProperty:()=>I2i,lazy:()=>Nky,lazyObject:()=>Vky,list:()=>lzu,number:()=>$ky,object:()=>czu,objectWithoutOptionalProperties:()=>Uky,optional:()=>xFf,property:()=>xky,record:()=>kky,set:()=>eev,string:()=>Yky,stringLiteral:()=>Hky,transform:()=>zFf,undiscriminatedUnion:()=>rev,union:()=>aev,unknown:()=>Xky,withParsedProperties:()=>LFf});var Kq={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 c8(e,t){return`Expected ${t}. Received ${gkC(e)}.`}function gkC(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 $de(e){return{...e,json:Tky(e.json),parse:Tky(e.parse)}}function Tky(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(`
@@ -3086,7 +3086,7 @@ If you believe this is an error, please contact support@buildwithfern.com`),orgN
3086
3086
  `)}var fA=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};var fj=class e extends Qd{constructor(t,r){super({message:"UnprocessableEntityError",statusCode:422,body:t,rawResponse:r}),Object.setPrototypeOf(this,e.prototype)}};var u0L={arrayFormat:"indices",encode:!0};function jeS(e,t){if(e===void 0||e===null)return"";let r=String(e);return t?encodeURIComponent(r):r}function DG_(e,t="",r){let n=[];for(let[i,a]of Object.entries(e)){let o=t?`${t}[${i}]`:i;if(a!==void 0)if(Array.isArray(a)){if(a.length===0)continue;for(let c=0;c<a.length;c++){let f=a[c];if(f!==void 0)if(typeof f=="object"&&!Array.isArray(f)&&f!==null){let u=r.arrayFormat==="indices"?`${o}[${c}]`:o;n.push(...DG_(f,u,r))}else{let u=r.arrayFormat==="indices"?`${o}[${c}]`:o,s=r.encode?encodeURIComponent(u):u;n.push(`${s}=${jeS(f,r.encode)}`)}}}else if(typeof a=="object"&&a!==null){if(Object.keys(a).length===0)continue;n.push(...DG_(a,o,r))}else{let c=r.encode?encodeURIComponent(o):o;n.push(`${c}=${jeS(a,r.encode)}`)}}return n}function ywl(e,t){return e==null||typeof e!="object"?"":DG_(e,"",Object.assign(Object.assign({},u0L),t)).join("&")}function EeS(e,t){let r=ywl(t,{arrayFormat:"repeat"});return r?`${e}?${r}`:e}function SeS(e){let t={get bodyUsed(){return e.bodyUsed},stream:()=>e.body,arrayBuffer:e.arrayBuffer.bind(e),blob:e.blob.bind(e)};return"bytes"in e&&typeof e.bytes=="function"&&(t.bytes=e.bytes.bind(e)),t}function DeS(e){return e.body!=null}var c0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})};function vwl(e,t){return c0L(this,void 0,void 0,function*(){if(!DeS(e))return;switch(t){case"binary-response":return SeS(e);case"blob":return yield e.blob();case"arrayBuffer":return yield e.arrayBuffer();case"sse":return e.body;case"streaming":return e.body;case"text":return yield e.text()}let r=yield e.text();if(r.length>0)try{return r4s(r)}catch{return{ok:!1,error:{reason:"non-json",statusCode:e.status,rawBody:r}}}})}var l0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})};function CeS(e){return l0L(this,void 0,void 0,function*(){var t,r,n;let i=(t=e.headers.get("Content-Type"))===null||t===void 0?void 0:t.toLowerCase();if(i==null||i.length===0)return vwl(e);switch(i.indexOf(";")!==-1&&(i=(n=(r=i.split(";")[0])===null||r===void 0?void 0:r.trim())!==null&&n!==void 0?n:""),i){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":let a=yield e.text();return a.length>0?r4s(a):void 0;default:if(i.startsWith("application/vnd.")&&i.endsWith("+json")){let o=yield e.text();return o.length>0?r4s(o):void 0}return yield e.text()}})}var f0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})};function IeS(){return f0L(this,void 0,void 0,function*(){return fetch})}var d0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})};function MeS(e){return d0L(this,arguments,void 0,function*({body:t,type:r}){return r.includes("json")?EFo(t):t})}var p0L="timeout";function BeS(e){let t=new AbortController,r=setTimeout(()=>t.abort(p0L),e);return{signal:t.signal,abortId:r}}function TeS(...e){let t=e.length===1&&Array.isArray(e[0])?e[0]:e,r=new AbortController;for(let n of t){if(n.aborted){r.abort(n?.reason);break}n.addEventListener("abort",()=>r.abort(n?.reason),{signal:r.signal})}return r.signal}var _0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},qeS=(e,t,r,n,i,a,o,c,f)=>_0L(void 0,void 0,void 0,function*(){let u=[],s;if(a!=null){let{signal:A,abortId:P}=BeS(a);s=P,u.push(A)}o!=null&&u.push(o);let l=TeS(u),m=yield e(t,{method:r,headers:n,body:i,signal:l,credentials:c?"include":void 0,duplex:f});return s!=null&&clearTimeout(s),m});var n4s;typeof globalThis.Headers<"u"?n4s=globalThis.Headers:n4s=class ReS{constructor(t){if(this.headers=new Map,t)if(t instanceof ReS)t.forEach((r,n)=>this.append(n,r));else if(Array.isArray(t))for(let[r,n]of t)if(typeof r=="string"&&typeof n=="string")this.append(r,n);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[r,n]of Object.entries(t))if(typeof n=="string")this.append(r,n);else throw new TypeError("Header values must be strings")}append(t,r){let n=t.toLowerCase(),i=this.headers.get(n)||[];this.headers.set(n,[...i,r])}delete(t){let r=t.toLowerCase();this.headers.delete(r)}get(t){let r=t.toLowerCase(),n=this.headers.get(r);return n?n.join(", "):null}has(t){let r=t.toLowerCase();return this.headers.has(r)}set(t,r){let n=t.toLowerCase();this.headers.set(n,[r])}forEach(t,r){let n=r?t.bind(r):t;this.headers.forEach((i,a)=>n(i.join(", "),a,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[t,r]of this.headers.entries())yield[t,r.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let t of this.headers.values())yield t.join(", ")}[Symbol.iterator](){return this.entries()}};var CG_={headers:new n4s,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},IG_={headers:new n4s,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function MG_(e){return{headers:e.headers,redirected:e.redirected,status:e.status,statusText:e.statusText,type:e.type,url:e.url}}var h0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})};function y0L(e){let t=1+(Math.random()*2-1)*.2;return e*t}function NeS(e){return h0L(this,arguments,void 0,function*(t,r=2){let n=yield t();for(let i=0;i<r&&([408,429].includes(n.status)||n.status>=500);++i){let a=Math.min(1e3*Math.pow(2,i),6e4),o=y0L(a);yield new Promise(c=>setTimeout(c,o)),n=yield t()}return n})}var v0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},k_={get:e=>v0L(void 0,void 0,void 0,function*(){return typeof e=="function"?e():e})};var BG_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})};function b0L(e){return BG_(this,void 0,void 0,function*(){let t={};if(e.body!==void 0&&e.contentType!=null&&(t["Content-Type"]=e.contentType),e.headers==null)return t;for(let[r,n]of Object.entries(e.headers)){let i=yield k_.get(n);if(typeof i=="string"){t[r]=i;continue}i!=null&&(t[r]=`${i}`)}return t})}function g0L(e){return BG_(this,void 0,void 0,function*(){let t=EeS(e.url,e.queryParameters),r=yield MeS({body:e.body,type:e.requestType==="json"?"json":"other"}),n=yield IeS();try{let i=yield NeS(()=>BG_(this,void 0,void 0,function*(){return qeS(n,t,e.method,yield b0L(e),r,e.timeoutMs,e.abortSignal,e.withCredentials,e.duplex)}),e.maxRetries);return i.status>=200&&i.status<400?{ok:!0,body:yield vwl(i,e.responseType),headers:i.headers,rawResponse:MG_(i)}:{ok:!1,error:{reason:"status-code",statusCode:i.status,body:yield CeS(i)},rawResponse:MG_(i)}}catch(i){return e.abortSignal!=null&&e.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:CG_}:i instanceof Error&&i.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:CG_}:i instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:i.message},rawResponse:IG_}:{ok:!1,error:{reason:"unknown",errorMessage:EFo(i)},rawResponse:IG_}}})}var zA=g0L;var m0L=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},dA=class e extends Promise{constructor(t){super(r=>{r(void 0)}),this.innerPromise=t}static fromFunction(t,...r){return new e(t(...r))}static interceptFunction(t){return(...r)=>e.fromPromise(t(...r))}static fromPromise(t){return new e(t)}static fromExecutor(t){let r=new Promise(t);return new e(r)}static fromResult(t){let r=Promise.resolve(t);return new e(r)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:t})=>t)),this.unwrappedPromise}then(t,r){return this.unwrap().then(t,r)}catch(t){return this.unwrap().catch(t)}finally(t){return this.unwrap().finally(t)}withRawResponse(){return m0L(this,void 0,void 0,function*(){return yield this.innerPromise})}};var bwl=O0L();function O0L(){var e,t,r,n,i;return typeof window<"u"&&typeof window.document<"u"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis<"u"&&((e=globalThis?.navigator)===null||e===void 0?void 0:e.userAgent)==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof self?.importScripts=="function"&&(((t=self.constructor)===null||t===void 0?void 0:t.name)==="DedicatedWorkerGlobalScope"||((r=self.constructor)===null||r===void 0?void 0:r.name)==="ServiceWorkerGlobalScope"||((n=self.constructor)===null||n===void 0?void 0:n.name)==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u"?{type:"deno",version:Deno.version.deno}:typeof Bun<"u"&&typeof Bun.version<"u"?{type:"bun",version:Bun.version}:typeof process<"u"&&"version"in process&&!!process.version&&"versions"in process&&!!(!((i=process.versions)===null||i===void 0)&&i.node)?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator<"u"&&navigator?.product==="ReactNative"?{type:"react-native"}:{type:"unknown"}}var PA={};yf(PA,{join:()=>xeS,toQueryString:()=>ywl});function xeS(e,...t){if(!e)return"";if(t.length===0)return e;if(e.includes("://")){let r;try{r=new URL(e)}catch{return FeS(e,...t)}let n=t[t.length-1],i=n&&n.endsWith("/");for(let a of t){let o=QeS(a);o&&(r.pathname=zeS(r.pathname,o))}return i&&!r.pathname.endsWith("/")&&(r.pathname+="/"),r.toString()}return FeS(e,...t)}function FeS(e,...t){if(t.length===0)return e;let r=e,n=t[t.length-1],i=n&&n.endsWith("/");for(let a of t){let o=QeS(a);o&&(r=zeS(r,o))}return i&&!r.endsWith("/")&&(r+="/"),r}function zeS(e,t){return e.endsWith("/")?e+t:e+"/"+t}function QeS(e){if(!e)return e;let t=0,r=e.length;return e.startsWith("/")&&(t=1),e.endsWith("/")&&(r=e.length-1),t===0&&r===e.length?e:e.slice(t,r)}function wA(...e){let t={};for(let[r,n]of e.filter(i=>i!=null).flatMap(i=>Object.entries(i)))n!=null?t[r]=n:r in t&&delete t[r];return t}function uP(...e){let t={};for(let[r,n]of e.filter(i=>i!=null).flatMap(i=>Object.entries(i)))n!=null&&(t[r]=n);return t}var cP={Production:"https://fai.buildwithfern.com",Development:"https://fai-dev.buildwithfern.com",Local:"http://localhost:8080"};var T5a=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},gwl=class{constructor(t={}){this._options=t}getAnalyticsHistogram(t,r={},n){return dA.fromPromise(this.__getAnalyticsHistogram(t,r,n))}__getAnalyticsHistogram(t){return T5a(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:f,end_date:u,group_by:s}=n,l={};f!=null&&(l.start_date=f),u!=null&&(l.end_date=u),s!=null&&(l.group_by=s);let m=wA((a=this._options)===null||a===void 0?void 0:a.headers,uP({Authorization:yield this._getAuthorizationHeader()}),i?.headers),A=yield zA({url:PA.join((c=(o=yield k_.get(this._options.baseUrl))!==null&&o!==void 0?o:yield k_.get(this._options.environment))!==null&&c!==void 0?c:cP.Production,`analytics/histogram/${encodeURIComponent(r)}`),method:"GET",headers:m,queryParameters:Object.assign(Object.assign({},l),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(A.ok)return{data:A.body,rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 422:throw new fj(A.error.body,A.rawResponse);default:throw new Qd({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}switch(A.error.reason){case"non-json":throw new Qd({statusCode:A.error.statusCode,body:A.error.rawBody,rawResponse:A.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /analytics/histogram/{domain}.");case"unknown":throw new Qd({message:A.error.errorMessage,rawResponse:A.rawResponse})}})}generateAllInsights(t={},r){return dA.fromPromise(this.__generateAllInsights(t,r))}__generateAllInsights(){return T5a(this,arguments,void 0,function*(t={},r){var n,i,a;let{start_date:o,end_date:c}=t,f={};o!=null&&(f.start_date=o),c!=null&&(f.end_date=c);let u=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"analytics/insights/generate_all"),method:"POST",headers:u,queryParameters:Object.assign(Object.assign({},f),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new fj(s.error.body,s.rawResponse);default:throw new Qd({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new Qd({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /analytics/insights/generate_all.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}triggerScheduledInsightsGeneration(t){return dA.fromPromise(this.__triggerScheduledInsightsGeneration(t))}__triggerScheduledInsightsGeneration(t){return T5a(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,uP({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield zA({url:PA.join((i=(n=yield k_.get(this._options.baseUrl))!==null&&n!==void 0?n:yield k_.get(this._options.environment))!==null&&i!==void 0?i:cP.Production,"analytics/insights/trigger_scheduled"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Qd({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new Qd({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /analytics/insights/trigger_scheduled.");case"unknown":throw new Qd({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}getQueryInsights(t,r){return dA.fromPromise(this.__getQueryInsights(t,r))}__getQueryInsights(t,r){return T5a(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,`analytics/insights/${encodeURIComponent(t)}`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /analytics/insights/{domain}.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}getSchedulerStatus(t){return dA.fromPromise(this.__getSchedulerStatus(t))}__getSchedulerStatus(t){return T5a(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,uP({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield zA({url:PA.join((i=(n=yield k_.get(this._options.baseUrl))!==null&&n!==void 0?n:yield k_.get(this._options.environment))!==null&&i!==void 0?i:cP.Production,"analytics/scheduler/status"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Qd({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new Qd({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /analytics/scheduler/status.");case"unknown":throw new Qd({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}getConversationResolution(t,r={},n){return dA.fromPromise(this.__getConversationResolution(t,r,n))}__getConversationResolution(t){return T5a(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:f,end_date:u}=n,s={};f!=null&&(s.start_date=f),u!=null&&(s.end_date=u);let l=wA((a=this._options)===null||a===void 0?void 0:a.headers,uP({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield zA({url:PA.join((c=(o=yield k_.get(this._options.baseUrl))!==null&&o!==void 0?o:yield k_.get(this._options.environment))!==null&&c!==void 0?c:cP.Production,`analytics/resolution/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},s),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new fj(m.error.body,m.rawResponse);default:throw new Qd({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new Qd({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /analytics/resolution/{domain}.");case"unknown":throw new Qd({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}_getAuthorizationHeader(){return T5a(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var LeS=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},mwl=class{constructor(t={}){this._options=t}postChatCompletion(t,r,n){return dA.fromPromise(this.__postChatCompletion(t,r,n))}__postChatCompletion(t,r,n){return LeS(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`chat/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /chat/{domain}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}_getAuthorizationHeader(){return LeS(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var UeS=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Owl=class{constructor(t={}){this._options=t}getConversationById(t,r,n){return dA.fromPromise(this.__getConversationById(t,r,n))}__getConversationById(t,r,n){return UeS(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`conversation/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /conversation/{domain}/{conversation_id}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}_getAuthorizationHeader(){return UeS(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var TG_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Awl=class{constructor(t={}){this._options=t}createDiscordIntegration(t,r){return dA.fromPromise(this.__createDiscordIntegration(t,r))}__createDiscordIntegration(t,r){return TG_(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"discord/install"),method:"POST",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /discord/install.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}handleDiscordInstallCallback(t){return dA.fromPromise(this.__handleDiscordInstallCallback(t))}__handleDiscordInstallCallback(t){return TG_(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,uP({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield zA({url:PA.join((i=(n=yield k_.get(this._options.baseUrl))!==null&&n!==void 0?n:yield k_.get(this._options.environment))!==null&&i!==void 0?i:cP.Production,"discord/install/callback"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Qd({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new Qd({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /discord/install/callback.");case"unknown":throw new Qd({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return TG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var lqi=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Pwl=class{constructor(t={}){this._options=t}createDocument(t,r,n){return dA.fromPromise(this.__createDocument(t,r,n))}__createDocument(t,r,n){return lqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`document/${encodeURIComponent(t)}/create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /document/{domain}/create.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}batchCreateDocument(t,r,n){return dA.fromPromise(this.__batchCreateDocument(t,r,n))}__batchCreateDocument(t,r,n){return lqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`document/${encodeURIComponent(t)}/batch-create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /document/{domain}/batch-create.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}getDocumentById(t,r,n){return dA.fromPromise(this.__getDocumentById(t,r,n))}__getDocumentById(t,r,n){return lqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`document/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /document/{domain}/{document_id}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}updateDocument(t,r,n={},i){return dA.fromPromise(this.__updateDocument(t,r,n,i))}__updateDocument(t,r){return lqi(this,arguments,void 0,function*(n,i,a={},o){var c,f,u;let s=wA((c=this._options)===null||c===void 0?void 0:c.headers,uP({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield zA({url:PA.join((u=(f=yield k_.get(this._options.baseUrl))!==null&&f!==void 0?f:yield k_.get(this._options.environment))!==null&&u!==void 0?u:cP.Production,`document/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:s,contentType:"application/json",queryParameters:o?.queryParams,requestType:"json",body:a,timeoutMs:o?.timeoutInSeconds!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o?.maxRetries,abortSignal:o?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new fj(l.error.body,l.rawResponse);default:throw new Qd({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new Qd({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling PATCH /document/{domain}/{document_id}.");case"unknown":throw new Qd({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}deleteDocumentById(t,r,n){return dA.fromPromise(this.__deleteDocumentById(t,r,n))}__deleteDocumentById(t,r,n){return lqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`document/${encodeURIComponent(t)}/delete`),method:"DELETE",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling DELETE /document/{domain}/delete.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}batchDeleteDocument(t,r,n){return dA.fromPromise(this.__batchDeleteDocument(t,r,n))}__batchDeleteDocument(t,r,n){return lqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`document/${encodeURIComponent(t)}/batch-delete`),method:"DELETE",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling DELETE /document/{domain}/batch-delete.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}getDocuments(t,r={},n){return dA.fromPromise(this.__getDocuments(t,r,n))}__getDocuments(t){return lqi(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:f,limit:u}=n,s={};f!=null&&(s.page=f.toString()),u!=null&&(s.limit=u.toString());let l=wA((a=this._options)===null||a===void 0?void 0:a.headers,uP({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield zA({url:PA.join((c=(o=yield k_.get(this._options.baseUrl))!==null&&o!==void 0?o:yield k_.get(this._options.environment))!==null&&c!==void 0?c:cP.Production,`document/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},s),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new fj(m.error.body,m.rawResponse);default:throw new Qd({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new Qd({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /document/{domain}.");case"unknown":throw new Qd({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}deleteAllDocuments(t,r){return dA.fromPromise(this.__deleteAllDocuments(t,r))}__deleteAllDocuments(t,r){return lqi(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,`document/${encodeURIComponent(t)}/delete-all`),method:"DELETE",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling DELETE /document/{domain}/delete-all.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return lqi(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var wwl=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},jwl=class{constructor(t={}){this._options=t}createEditingSession(t,r){return dA.fromPromise(this.__createEditingSession(t,r))}__createEditingSession(t,r){return wwl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"editing-sessions"),method:"POST",headers:o,contentType:"application/json",queryParameters:r?.queryParams,requestType:"json",body:t,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /editing-sessions.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}getEditingSession(t,r){return dA.fromPromise(this.__getEditingSession(t,r))}__getEditingSession(t,r){return wwl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,`editing-sessions/${encodeURIComponent(t)}`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /editing-sessions/{editing_id}.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}updateEditingSession(t,r={},n){return dA.fromPromise(this.__updateEditingSession(t,r,n))}__updateEditingSession(t){return wwl(this,arguments,void 0,function*(r,n={},i){var a,o,c;let f=wA((a=this._options)===null||a===void 0?void 0:a.headers,uP({Authorization:yield this._getAuthorizationHeader()}),i?.headers),u=yield zA({url:PA.join((c=(o=yield k_.get(this._options.baseUrl))!==null&&o!==void 0?o:yield k_.get(this._options.environment))!==null&&c!==void 0?c:cP.Production,`editing-sessions/${encodeURIComponent(r)}`),method:"PUT",headers:f,contentType:"application/json",queryParameters:i?.queryParams,requestType:"json",body:n,timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling PUT /editing-sessions/{editing_id}.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}_getAuthorizationHeader(){return wwl(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var qG_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Ewl=class{constructor(t={}){this._options=t}createFeedback(t,r,n){return dA.fromPromise(this.__createFeedback(t,r,n))}__createFeedback(t,r,n){return qG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`feedback/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /feedback/{domain}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}getFeedbackById(t,r,n){return dA.fromPromise(this.__getFeedbackById(t,r,n))}__getFeedbackById(t,r,n){return qG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`feedback/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /feedback/{domain}/{conversation_id}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}_getAuthorizationHeader(){return qG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var SFo=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Swl=class{constructor(t={}){this._options=t}createGuidance(t,r,n){return dA.fromPromise(this.__createGuidance(t,r,n))}__createGuidance(t,r,n){return SFo(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`guidance/${encodeURIComponent(t)}/create`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /guidance/{domain}/create.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}getGuidanceById(t,r,n){return dA.fromPromise(this.__getGuidanceById(t,r,n))}__getGuidanceById(t,r,n){return SFo(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`guidance/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"GET",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /guidance/{domain}/{guidance_id}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}deleteGuidanceById(t,r,n){return dA.fromPromise(this.__deleteGuidanceById(t,r,n))}__deleteGuidanceById(t,r,n){return SFo(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`guidance/${encodeURIComponent(t)}/${encodeURIComponent(r)}`),method:"DELETE",headers:c,queryParameters:n?.queryParams,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling DELETE /guidance/{domain}/{guidance_id}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}update(t,r,n={},i){return dA.fromPromise(this.__update(t,r,n,i))}__update(t,r){return SFo(this,arguments,void 0,function*(n,i,a={},o){var c,f,u;let s=wA((c=this._options)===null||c===void 0?void 0:c.headers,uP({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield zA({url:PA.join((u=(f=yield k_.get(this._options.baseUrl))!==null&&f!==void 0?f:yield k_.get(this._options.environment))!==null&&u!==void 0?u:cP.Production,`guidance/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:s,contentType:"application/json",queryParameters:o?.queryParams,requestType:"json",body:a,timeoutMs:o?.timeoutInSeconds!=null?o.timeoutInSeconds*1e3:6e4,maxRetries:o?.maxRetries,abortSignal:o?.abortSignal});if(l.ok)return{data:l.body,rawResponse:l.rawResponse};if(l.error.reason==="status-code")switch(l.error.statusCode){case 422:throw new fj(l.error.body,l.rawResponse);default:throw new Qd({statusCode:l.error.statusCode,body:l.error.body,rawResponse:l.rawResponse})}switch(l.error.reason){case"non-json":throw new Qd({statusCode:l.error.statusCode,body:l.error.rawBody,rawResponse:l.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling PATCH /guidance/{domain}/{guidance_id}.");case"unknown":throw new Qd({message:l.error.errorMessage,rawResponse:l.rawResponse})}})}getGuidances(t,r={},n){return dA.fromPromise(this.__getGuidances(t,r,n))}__getGuidances(t){return SFo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:f,limit:u}=n,s={};f!=null&&(s.page=f.toString()),u!=null&&(s.limit=u.toString());let l=wA((a=this._options)===null||a===void 0?void 0:a.headers,uP({Authorization:yield this._getAuthorizationHeader()}),i?.headers),m=yield zA({url:PA.join((c=(o=yield k_.get(this._options.baseUrl))!==null&&o!==void 0?o:yield k_.get(this._options.environment))!==null&&c!==void 0?c:cP.Production,`guidance/${encodeURIComponent(r)}`),method:"GET",headers:l,queryParameters:Object.assign(Object.assign({},s),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new fj(m.error.body,m.rawResponse);default:throw new Qd({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new Qd({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /guidance/{domain}.");case"unknown":throw new Qd({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}_getAuthorizationHeader(){return SFo(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var VeS=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Dwl=class{constructor(t={}){this._options=t}check(t){return dA.fromPromise(this.__check(t))}__check(t){return VeS(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,uP({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield zA({url:PA.join((i=(n=yield k_.get(this._options.baseUrl))!==null&&n!==void 0?n:yield k_.get(this._options.environment))!==null&&i!==void 0?i:cP.Production,"health"),method:"GET",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Qd({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new Qd({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /health.");case"unknown":throw new Qd({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}_getAuthorizationHeader(){return VeS(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var Cwl=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Iwl=class{constructor(t={}){this._options=t}reconstructQueryIndex(t,r){return dA.fromPromise(this.__reconstructQueryIndex(t,r))}__reconstructQueryIndex(t,r){return Cwl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,`index/${encodeURIComponent(t)}/reconstruct`),method:"POST",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /index/{domain}/reconstruct.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}syncIndexToQueryIndex(t,r,n){return dA.fromPromise(this.__syncIndexToQueryIndex(t,r,n))}__syncIndexToQueryIndex(t,r,n){return Cwl(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`index/${encodeURIComponent(t)}/sync`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /index/{domain}/sync.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}getJobStatus(t,r){return dA.fromPromise(this.__getJobStatus(t,r))}__getJobStatus(t,r){return Cwl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,`jobs/${encodeURIComponent(t)}/status`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /jobs/{job_id}/status.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return Cwl(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var RG_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Mwl=class{constructor(t={}){this._options=t}getMcpSemanticQuery(t,r,n){return dA.fromPromise(this.__getMcpSemanticQuery(t,r,n))}__getMcpSemanticQuery(t,r,n){return RG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`mcp/semantic/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /mcp/semantic/{domain}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}getMcpBmfQuery(t,r,n){return dA.fromPromise(this.__getMcpBmfQuery(t,r,n))}__getMcpBmfQuery(t,r,n){return RG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,uP({Authorization:yield this._getAuthorizationHeader()}),n?.headers),f=yield zA({url:PA.join((o=(a=yield k_.get(this._options.baseUrl))!==null&&a!==void 0?a:yield k_.get(this._options.environment))!==null&&o!==void 0?o:cP.Production,`mcp/bmf/${encodeURIComponent(t)}`),method:"POST",headers:c,contentType:"application/json",queryParameters:n?.queryParams,requestType:"json",body:r,timeoutMs:n?.timeoutInSeconds!=null?n.timeoutInSeconds*1e3:6e4,maxRetries:n?.maxRetries,abortSignal:n?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 422:throw new fj(f.error.body,f.rawResponse);default:throw new Qd({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new Qd({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /mcp/bmf/{domain}.");case"unknown":throw new Qd({message:f.error.errorMessage,rawResponse:f.rawResponse})}})}_getAuthorizationHeader(){return RG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var NG_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Bwl=class{constructor(t={}){this._options=t}createQuery(t,r){return dA.fromPromise(this.__createQuery(t,r))}__createQuery(t,r){return NG_(this,void 0,void 0,function*(){var n,i,a;let{domain:o,body:c}=t,f={};f.domain=o;let u=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"queries"),method:"POST",headers:u,contentType:"application/json",queryParameters:Object.assign(Object.assign({},f),r?.queryParams),requestType:"json",body:c,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new fj(s.error.body,s.rawResponse);default:throw new Qd({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new Qd({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /queries.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getRecentQueries(t,r={},n){return dA.fromPromise(this.__getRecentQueries(t,r,n))}__getRecentQueries(t){return NG_(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:f,limit:u,cutoff_time:s,include_assistant:l,start_date:m,end_date:A}=n,P={};f!=null&&(P.page=f.toString()),u!=null&&(P.limit=u.toString()),s!=null&&(P.cutoff_time=s),l!=null&&(P.include_assistant=l.toString()),m!=null&&(P.start_date=m),A!=null&&(P.end_date=A);let C=wA((a=this._options)===null||a===void 0?void 0:a.headers,uP({Authorization:yield this._getAuthorizationHeader()}),i?.headers),I=yield zA({url:PA.join((c=(o=yield k_.get(this._options.baseUrl))!==null&&o!==void 0?o:yield k_.get(this._options.environment))!==null&&c!==void 0?c:cP.Production,`queries/${encodeURIComponent(r)}`),method:"GET",headers:C,queryParameters:Object.assign(Object.assign({},P),i?.queryParams),timeoutMs:i?.timeoutInSeconds!=null?i.timeoutInSeconds*1e3:6e4,maxRetries:i?.maxRetries,abortSignal:i?.abortSignal});if(I.ok)return{data:I.body,rawResponse:I.rawResponse};if(I.error.reason==="status-code")switch(I.error.statusCode){case 422:throw new fj(I.error.body,I.rawResponse);default:throw new Qd({statusCode:I.error.statusCode,body:I.error.body,rawResponse:I.rawResponse})}switch(I.error.reason){case"non-json":throw new Qd({statusCode:I.error.statusCode,body:I.error.rawBody,rawResponse:I.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /queries/{domain}.");case"unknown":throw new Qd({message:I.error.errorMessage,rawResponse:I.rawResponse})}})}_getAuthorizationHeader(){return NG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var FG_=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Twl=class{constructor(t={}){this._options=t}slackCallback(t,r,n,i,a){return dA.fromPromise(this.__slackCallback(t,r,n,i,a))}__slackCallback(t,r,n,i,a){return FG_(this,void 0,void 0,function*(){var o,c,f;let u=wA((o=this._options)===null||o===void 0?void 0:o.headers,uP({Authorization:yield this._getAuthorizationHeader()}),a?.headers),s=yield zA({url:PA.join((f=(c=yield k_.get(this._options.baseUrl))!==null&&c!==void 0?c:yield k_.get(this._options.environment))!==null&&f!==void 0?f:cP.Production,`scribe/callback/slack/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(n)}`),method:"POST",headers:u,contentType:"application/json",queryParameters:a?.queryParams,requestType:"json",body:i,timeoutMs:a?.timeoutInSeconds!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a?.maxRetries,abortSignal:a?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new fj(s.error.body,s.rawResponse);default:throw new Qd({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new Qd({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /scribe/callback/slack/{team_id}/{channel_id}/{thread_ts}.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}editCallback(t,r,n,i,a){return dA.fromPromise(this.__editCallback(t,r,n,i,a))}__editCallback(t,r,n,i,a){return FG_(this,void 0,void 0,function*(){var o,c,f;let u=wA((o=this._options)===null||o===void 0?void 0:o.headers,uP({Authorization:yield this._getAuthorizationHeader()}),a?.headers),s=yield zA({url:PA.join((f=(c=yield k_.get(this._options.baseUrl))!==null&&c!==void 0?c:yield k_.get(this._options.environment))!==null&&f!==void 0?f:cP.Production,`scribe/callback/slack/edit/${encodeURIComponent(t)}/${encodeURIComponent(r)}/${encodeURIComponent(n)}`),method:"POST",headers:u,contentType:"application/json",queryParameters:a?.queryParams,requestType:"json",body:i,timeoutMs:a?.timeoutInSeconds!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a?.maxRetries,abortSignal:a?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new fj(s.error.body,s.rawResponse);default:throw new Qd({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new Qd({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /scribe/callback/slack/edit/{team_id}/{channel_id}/{thread_ts}.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}_getAuthorizationHeader(){return FG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var ebi=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},qwl=class{constructor(t={}){this._options=t}getSettings(t,r){return dA.fromPromise(this.__getSettings(t,r))}__getSettings(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai"),method:"GET",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /settings/ask-ai.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getDocsSettings(t,r){return dA.fromPromise(this.__getDocsSettings(t,r))}__getDocsSettings(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai/docs"),method:"GET",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /settings/ask-ai/docs.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getSlackSettings(t,r){return dA.fromPromise(this.__getSlackSettings(t,r))}__getSlackSettings(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai/slack"),method:"GET",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /settings/ask-ai/slack.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getDiscordSettings(t,r){return dA.fromPromise(this.__getDiscordSettings(t,r))}__getDiscordSettings(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai/discord"),method:"GET",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /settings/ask-ai/discord.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}enableAskAi(t,r){return dA.fromPromise(this.__enableAskAi(t,r))}__enableAskAi(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai/enable"),method:"POST",headers:o,contentType:"application/json",queryParameters:r?.queryParams,requestType:"json",body:t,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /settings/ask-ai/enable.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}toggleAskAi(t,r){return dA.fromPromise(this.__toggleAskAi(t,r))}__toggleAskAi(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let{domain:o,org_name:c,preview:f,locations:u}=t,s={};s.domain=o,s.org_name=c,f!=null&&(s.preview=f.toString()),u!=null&&(Array.isArray(u)?s.locations=u.map(A=>A):s.locations=u);let l=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),m=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai/toggle"),method:"POST",headers:l,queryParameters:Object.assign(Object.assign({},s),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")switch(m.error.statusCode){case 422:throw new fj(m.error.body,m.rawResponse);default:throw new Qd({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse})}switch(m.error.reason){case"non-json":throw new Qd({statusCode:m.error.statusCode,body:m.error.rawBody,rawResponse:m.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /settings/ask-ai/toggle.");case"unknown":throw new Qd({message:m.error.errorMessage,rawResponse:m.rawResponse})}})}reindexAskAi(t,r){return dA.fromPromise(this.__reindexAskAi(t,r))}__reindexAskAi(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let{domain:o,org_name:c}=t,f={};f.domain=o,f.org_name=c;let u=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai/reindex"),method:"POST",headers:u,queryParameters:Object.assign(Object.assign({},f),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new fj(s.error.body,s.rawResponse);default:throw new Qd({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new Qd({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /settings/ask-ai/reindex.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getToggleStatus(t,r){return dA.fromPromise(this.__getToggleStatus(t,r))}__getToggleStatus(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/ask-ai/toggle/status"),method:"GET",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /settings/ask-ai/toggle/status.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}reindexPreviewCallback(t,r){return dA.fromPromise(this.__reindexPreviewCallback(t,r))}__reindexPreviewCallback(t,r){return ebi(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"settings/reindex-preview-callback"),method:"POST",headers:o,contentType:"application/json",queryParameters:r?.queryParams,requestType:"json",body:t,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /settings/reindex-preview-callback.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return ebi(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var Dea=function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(s){try{u(n.next(s))}catch(l){o(l)}}function f(s){try{u(n.throw(s))}catch(l){o(l)}}function u(s){s.done?a(s.value):i(s.value).then(c,f)}u((n=n.apply(e,t||[])).next())})},Rwl=class{constructor(t={}){this._options=t}createSlackIntegration(t,r){return dA.fromPromise(this.__createSlackIntegration(t,r))}__createSlackIntegration(t,r){return Dea(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"slack/install"),method:"POST",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /slack/install.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}handleSlackEvents(t){return dA.fromPromise(this.__handleSlackEvents(t))}__handleSlackEvents(t){return Dea(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,uP({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield zA({url:PA.join((i=(n=yield k_.get(this._options.baseUrl))!==null&&n!==void 0?n:yield k_.get(this._options.environment))!==null&&i!==void 0?i:cP.Production,"slack/events"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Qd({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new Qd({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /slack/events.");case"unknown":throw new Qd({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackSlashCommands(t){return dA.fromPromise(this.__handleSlackSlashCommands(t))}__handleSlackSlashCommands(t){return Dea(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,uP({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield zA({url:PA.join((i=(n=yield k_.get(this._options.baseUrl))!==null&&n!==void 0?n:yield k_.get(this._options.environment))!==null&&i!==void 0?i:cP.Production,"slack/slash-commands"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Qd({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new Qd({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /slack/slash-commands.");case"unknown":throw new Qd({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackInteractions(t){return dA.fromPromise(this.__handleSlackInteractions(t))}__handleSlackInteractions(t){return Dea(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,uP({Authorization:yield this._getAuthorizationHeader()}),t?.headers),o=yield zA({url:PA.join((i=(n=yield k_.get(this._options.baseUrl))!==null&&n!==void 0?n:yield k_.get(this._options.environment))!==null&&i!==void 0?i:cP.Production,"slack/interactions"),method:"POST",headers:a,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")throw new Qd({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse});switch(o.error.reason){case"non-json":throw new Qd({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling POST /slack/interactions.");case"unknown":throw new Qd({message:o.error.errorMessage,rawResponse:o.rawResponse})}})}handleSlackOauthCallback(t,r){return dA.fromPromise(this.__handleSlackOauthCallback(t,r))}__handleSlackOauthCallback(t,r){return Dea(this,void 0,void 0,function*(){var n,i,a;let{code:o,state:c}=t,f={};f.code=o,c!=null&&(f.state=c);let u=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),s=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"slack/oauth/callback"),method:"GET",headers:u,queryParameters:Object.assign(Object.assign({},f),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(s.ok)return{data:s.body,rawResponse:s.rawResponse};if(s.error.reason==="status-code")switch(s.error.statusCode){case 422:throw new fj(s.error.body,s.rawResponse);default:throw new Qd({statusCode:s.error.statusCode,body:s.error.body,rawResponse:s.rawResponse})}switch(s.error.reason){case"non-json":throw new Qd({statusCode:s.error.statusCode,body:s.error.rawBody,rawResponse:s.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /slack/oauth/callback.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getSlackInstallLink(t,r){return dA.fromPromise(this.__getSlackInstallLink(t,r))}__getSlackInstallLink(t,r){return Dea(this,void 0,void 0,function*(){var n,i,a;let{domain:o}=t,c={};c.domain=o;let f=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),u=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,"slack/get-install"),method:"GET",headers:f,queryParameters:Object.assign(Object.assign({},c),r?.queryParams),timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(u.ok)return{data:u.body,rawResponse:u.rawResponse};if(u.error.reason==="status-code")switch(u.error.statusCode){case 422:throw new fj(u.error.body,u.rawResponse);default:throw new Qd({statusCode:u.error.statusCode,body:u.error.body,rawResponse:u.rawResponse})}switch(u.error.reason){case"non-json":throw new Qd({statusCode:u.error.statusCode,body:u.error.rawBody,rawResponse:u.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /slack/get-install.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}listSlackIntegrations(t,r){return dA.fromPromise(this.__listSlackIntegrations(t,r))}__listSlackIntegrations(t,r){return Dea(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,uP({Authorization:yield this._getAuthorizationHeader()}),r?.headers),c=yield zA({url:PA.join((a=(i=yield k_.get(this._options.baseUrl))!==null&&i!==void 0?i:yield k_.get(this._options.environment))!==null&&a!==void 0?a:cP.Production,`slack/integrations/${encodeURIComponent(t)}`),method:"GET",headers:o,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(c.ok)return{data:c.body,rawResponse:c.rawResponse};if(c.error.reason==="status-code")switch(c.error.statusCode){case 422:throw new fj(c.error.body,c.rawResponse);default:throw new Qd({statusCode:c.error.statusCode,body:c.error.body,rawResponse:c.rawResponse})}switch(c.error.reason){case"non-json":throw new Qd({statusCode:c.error.statusCode,body:c.error.rawBody,rawResponse:c.rawResponse});case"timeout":throw new fA("Timeout exceeded when calling GET /slack/integrations/{domain}.");case"unknown":throw new Qd({message:c.error.errorMessage,rawResponse:c.rawResponse})}})}_getAuthorizationHeader(){return Dea(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var i4s=class{constructor(t={}){this._options=Object.assign(Object.assign({},t),{headers:wA({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@fern-api/fai-sdk","X-Fern-SDK-Version":"0.0.6-2ee1b7e28","X-Fern-Runtime":bwl.type,"X-Fern-Runtime-Version":bwl.version},t?.headers)})}get analytics(){var t;return(t=this._analytics)!==null&&t!==void 0?t:this._analytics=new gwl(this._options)}get chat(){var t;return(t=this._chat)!==null&&t!==void 0?t:this._chat=new mwl(this._options)}get conversation(){var t;return(t=this._conversation)!==null&&t!==void 0?t:this._conversation=new Owl(this._options)}get discord(){var t;return(t=this._discord)!==null&&t!==void 0?t:this._discord=new Awl(this._options)}get document(){var t;return(t=this._document)!==null&&t!==void 0?t:this._document=new Pwl(this._options)}get editingSessions(){var t;return(t=this._editingSessions)!==null&&t!==void 0?t:this._editingSessions=new jwl(this._options)}get feedback(){var t;return(t=this._feedback)!==null&&t!==void 0?t:this._feedback=new Ewl(this._options)}get guidance(){var t;return(t=this._guidance)!==null&&t!==void 0?t:this._guidance=new Swl(this._options)}get health(){var t;return(t=this._health)!==null&&t!==void 0?t:this._health=new Dwl(this._options)}get index(){var t;return(t=this._index)!==null&&t!==void 0?t:this._index=new Iwl(this._options)}get mcp(){var t;return(t=this._mcp)!==null&&t!==void 0?t:this._mcp=new Mwl(this._options)}get query(){var t;return(t=this._query)!==null&&t!==void 0?t:this._query=new Bwl(this._options)}get scribe(){var t;return(t=this._scribe)!==null&&t!==void 0?t:this._scribe=new Twl(this._options)}get settings(){var t;return(t=this._settings)!==null&&t!==void 0?t:this._settings=new qwl(this._options)}get slack(){var t;return(t=this._slack)!==null&&t!==void 0?t:this._slack=new Rwl(this._options)}};function WeS({token:e}){return new i4s({baseUrl:"https://fai.buildwithfern.com",token:e})}var ItS=Wi(CtS(),1);var MtS=require("util"),uOL=(0,MtS.promisify)(ItS.default);async function BtS(e,t,r){let n=OWo(e,t),i=[];for(let a of n){let o=await Promise.all(a.map(async c=>{try{let f=await uOL(c);return f==null||f.height==null||f.width==null?void 0:{filePath:c,width:f.width,height:f.height,blurDataUrl:void 0}}catch(f){r.logger.error(`Failed to measure image size for ${c}. ${f?.message}`);return}}));i.push(...o.filter(pj))}return new Map(i.map(a=>[a.filePath,a]))}var cOL=10,TtS=10;async function xtS({token:e,organization:t,docsWorkspace:r,domain:n,customDomains:i,apiWorkspaces:a,ossWorkspaces:o,context:c,preview:f,editThisPage:u,isPrivate:s=!1,disableTemplates:l=!1,skipUpload:m=!1,targetAudiences:A}){let P=Bca({token:e.value}),C=s?{type:"private",authType:"sso"}:{type:"public"},I,T=i[0]??n,z=lOL(n),U=r.config.experimental?.dynamicSnippets,q=f||U,$=await new $Nr({domain:n,docsWorkspace:r,ossWorkspaces:o,apiWorkspaces:a,taskContext:c,editThisPage:u,uploadFiles:async X=>{let k=new Map(X.map(Ie=>[Ie.absoluteFilePath,Ie])),me=X.map(Ie=>({...Ie,mediaType:iJ_.lookup(Ie.absoluteFilePath)})).filter(Ie=>Ie.mediaType!==!1).filter(Ie=>Y8.parse(Ie.mediaType)?.isImage()??!1).map(Ie=>Ie.absoluteFilePath),ve=await BtS(me,cOL,c),Oe=[];[...ve.values()].forEach(Ie=>{let Be=k.get(Ie.filePath);if(Be==null)return;let Se={filePath:rbi.FernRegistry.docs.v1.write.FilePath(Wcu(Be.relativeFilePath)),width:Ie.width,height:Ie.height,blurDataUrl:Ie.blurDataUrl,alt:void 0,fileHash:void 0};Oe.push(Se)});let be=X.filter(({absoluteFilePath:Ie})=>!ve.has(Ie)).map(({relativeFilePath:Ie})=>Wcu(Ie));if(f){let Ie=await P.docs.v2.write.startDocsPreviewRegister({orgId:rbi.FernRegistry.OrgId(t),authConfig:s?{type:"private",authType:"sso"}:{type:"public"},filepaths:be.map(Be=>rbi.FernRegistry.docs.v1.write.FilePath(Be)),images:Oe,basePath:z});return Ie.ok?(T=Ie.body.previewUrl,I=Ie.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs preview"):await qtS(Ie.body.uploadUrls,r.absoluteFilePath,c,TtS),RtS(Ie.body.uploadUrls,r.absoluteFilePath)):await NtS(Ie.error,c)}else{let Ie=await P.docs.v2.write.startDocsRegister({domain:n,customDomains:i,authConfig:C,apiId:rbi.FernRegistry.ApiId(""),orgId:rbi.FernRegistry.OrgId(t),filepaths:be.map(Be=>rbi.FernRegistry.docs.v1.write.FilePath(Be)),images:Oe});return Ie.ok?(I=Ie.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs"):await qtS(Ie.body.uploadUrls,r.absoluteFilePath,c,TtS),RtS(Ie.body.uploadUrls,r.absoluteFilePath)):NtS(Ie.error,c)}},registerApi:async({ir:X,snippetsConfig:k,playgroundConfig:ne,apiName:me,workspace:ve})=>{let Oe=GIe({ir:X,snippetsConfig:k,playgroundConfig:ne,context:c}),be;U&&(be=await fOL({workspace:ve,organization:t,context:c,snippetsConfig:k}));let Ie=await P.api.v1.register.registerApiDefinition({orgId:rbi.FernRegistry.OrgId(t),apiId:rbi.FernRegistry.ApiId(X.apiName.originalName),definition:Oe,definitionV2:void 0,dynamicIRs:be});if(Ie.ok)return c.logger.debug(`Registered API Definition ${me}: ${Ie.body.apiDefinitionId}`),Ie.body.dynamicIRs&&be&&(m?c.logger.debug("Skip-upload mode: skipping dynamic IR uploads"):await dOL({dynamicIRs:be,dynamicIRUploadUrls:Ie.body.dynamicIRs,context:c,apiId:Ie.body.apiDefinitionId})),Ie.body.apiDefinitionId;switch(Ie.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return me!=null?c.failAndThrow(`Failed to publish docs because API definition (${me}) could not be uploaded. Please contact support@buildwithfern.com
3087
3087
  ${JSON.stringify(Ie.error)}`):c.failAndThrow(`Failed to publish docs because API definition could not be uploaded. Please contact support@buildwithfern.com
3088
3088
  ${JSON.stringify(Ie.error)}`)}},targetAudiences:A}).resolve();if(I==null)return c.failAndThrow("Failed to publish docs.","Docs registration ID is missing.");c.logger.debug("Publishing docs...");let re=await P.docs.v2.write.finishDocsRegister(rbi.FernRegistry.docs.v1.write.DocsRegistrationId(I),{docsDefinition:$,excludeApis:!1});if(re.ok){let X=Rue(T);await pOL({docsDefinition:$,organization:t,token:e,url:X.replace("https://",""),context:c,fdr:P,isPreview:f,domain:n,customDomains:i});let k=cqi(X,X);c.logger.info(Mf.green(`Published docs to ${k}`))}else switch(re.error.error){case"UnauthorizedError":case"UserNotInOrgError":return c.failAndThrow("Insufficient permissions. Failed to publish docs to "+n);case"DocsRegistrationIdNotFound":return c.failAndThrow("Failed to publish docs to "+n,`Docs registration ID ${I} does not exist.`);default:return c.failAndThrow("Failed to publish docs to "+n,re.error)}}async function qtS(e,t,r,n){let i=Date.now(),a=Object.keys(e).length;r.logger.debug(`Start uploading ${a} files...`);let o=OWo(Object.entries(e),n),c=0;for(let u of o){await Promise.all(u.map(async([l,{uploadUrl:m}])=>{let A=nu.of(l),P=f1(t,A);try{let C=iJ_.lookup(P);await CZ.put(m,await(0,FtS.readFile)(P),{headers:{"Content-Type":C===!1?"application/octet-stream":C,"Cache-Control":"public, max-age=31536000, immutable"}})}catch(C){r.failAndThrow(`Failed to upload ${P}`,C)}}));let s=Date.now();c+=u.length,r.logger.debug(`Uploaded ${c}/${a} files in ${s-i}ms`)}let f=Date.now();r.logger.debug(`Finished uploading ${a} files in ${f-i}ms`)}function RtS(e,t){let r=[];for(let[n,i]of Object.entries(e)){let a=nu.of(n),o=f1(t,a);r.push({relativeFilePath:a,absoluteFilePath:o,fileId:i.fileId})}return r}async function NtS(e,t){switch(await t.instrumentPostHogEvent({command:"docs-generation",properties:{error:JSON.stringify(e)}}),e.error){case"InvalidCustomDomainError":return t.failAndThrow("Your docs domain should end with docs.buildwithfern.com");case"InvalidDomainError":return t.failAndThrow("Please make sure that none of your custom domains are not overlapping (i.e. one is a substring of another)");case"UnauthorizedError":return t.failAndThrow("Please make sure that your FERN_TOKEN is set.");case"UserNotInOrgError":return t.failAndThrow("Please verify if you have access to the organization you are trying to publish the docs to. If you are not a member of the organization, please reach out to the organization owner.");case"UnavailableError":return t.failAndThrow("Failed to publish docs. Please try again later or reach out to Fern support at support@buildwithfern.com.");default:return t.failAndThrow("Failed to publish docs.",e)}}function lOL(e){try{return new URL(Rue(e)).pathname}catch{return}}async function fOL({workspace:e,organization:t,context:r,snippetsConfig:n}){let i={};if(!e)return;Object.keys(n).length===0&&(r.logger.warn(`WARNING: No snippets defined for ${e.workspaceName}.`),r.logger.warn("Did you add snippets to your docs configuration?"),r.logger.warn("For more info: https://buildwithfern.com/learn/docs/api-references/sdk-snippets"));let a={typescript:n.typescriptSdk?.package,python:n.pythonSdk?.package,java:n.javaSdk?.coordinate,go:n.goSdk?.githubRepo,csharp:n.csharpSdk?.package,ruby:n.rubySdk?.gem,php:n.phpSdk?.package,swift:n.swiftSdk?.package,rust:n.rustSdk?.package};if(e.generatorsConfiguration?.groups)for(let o of e.generatorsConfiguration.groups)for(let c of o.generators){let f=cwl({apiName:e.workspaceName??"",organization:t,generatorInvocation:c}),u="";if(f?.outputConfig.type==="publish")switch(f.outputConfig.value.type){case"npm":case"nuget":case"pypi":case"rubygems":u=f.outputConfig.value.packageName;break;case"maven":u=f.outputConfig.value.coordinate;break;case"go":u=f.outputConfig.value.repoUrl;break;case"swift":u=f.outputConfig.value.repoUrl;break;case"crates":u=f.outputConfig.value.packageName;break}if(c.language==="php"&&c.config&&typeof c.config=="object"&&"packageName"in c.config&&(u=c.config.packageName??""),!!c.language&&c.language&&a[c.language]===u){let s=_G({workspace:e,generationLanguage:c.language,keywords:void 0,smartCasing:c.smartCasing,exampleGeneration:{disabled:!0,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},audiences:{type:"all"},readme:void 0,packageName:u,version:void 0,context:r,sourceResolver:new cG(r,e),dynamicGeneratorConfig:f}),l=css({ir:s,disableExamples:!0,smartCasing:c.smartCasing,generationLanguage:c.language,generatorConfig:f});l?i[c.language]={dynamicIR:l}:r.logger.debug(`Failed to create dynamic IR for ${c.language}`)}}for(let[o,c]of Object.entries(a))o&&c&&!Object.keys(i).includes(o)&&(r.logger.warn(),r.logger.warn(`Failed to upload ${o} SDK snippets because of unknown package \`${c}\`.`),r.logger.warn(`Please make sure your ${e.workspaceName?`${e.workspaceName}/`:""}generators.yml has a generator that publishes a ${c} package.`),r.logger.warn());if(Object.keys(i).length>0)return i}async function dOL({dynamicIRs:e,dynamicIRUploadUrls:t,context:r,apiId:n}){if(Object.keys(t).length>0)for(let[i,a]of Object.entries(t)){let o=e[i]?.dynamicIR;o?(await fetch(a.uploadUrl,{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/octet-stream","Content-Length":JSON.stringify(o).length.toString()}})).ok?r.logger.debug(`Uploaded dynamic IR for ${n}:${i}`):r.logger.warn(`Failed to upload dynamic IR for ${n}:${i}`):r.logger.warn(`Could not find matching dynamic IR to upload for ${n}:${i}`)}}async function pOL({docsDefinition:e,organization:t,token:r,url:n,context:i,fdr:a,isPreview:o,domain:c,customDomains:f}){if(e.config.aiChatConfig!=null&&(i.logger.debug("Processing AI Chat configuration from docs.yml"),e.config.aiChatConfig.location!=null)){let u=WeS({token:r.value}),s=o?[Rue(n).replace("https://","")]:[Rue(c).replace("https://",""),...f.map(m=>Rue(m).replace("https://",""))];if(i.logger.debug(`Enabling Ask AI for domain${s.length>1?"s":""}: ${s.join(", ")}`),e.config.aiChatConfig.location.includes("docs"))for(let m of s){let A=new URL(Rue(m)).hostname;i.logger.debug(`Adding domain ${A} to Algolia whitelist`),(await a.docs.v2.write.addAlgoliaPreviewWhitelistEntry({domain:A})).ok||i.logger.warn(`Failed to add domain ${A} to Algolia whitelist${o?". Please try regenerating to test AI chat in preview.":"."}`)}(await u.settings.enableAskAi({domains:s,org_name:t,locations:e.config.aiChatConfig.location,preview:o})).success&&i.logger.info(Mf.green(`${o?"":`Ask Fern enabled for ${s.join(", ")}. `}
3089
- Note: it may take a few minutes after publishing for Ask Fern settings to reflect expected state.`))}}async function aJ_({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:a,instanceUrl:o,preview:c,disableTemplates:f,skipUpload:u}){let s=n.config.instances;if(n.config=Ozi(n.config,{onError:A=>i.failAndThrow(A)},{substituteAsEmpty:c}),s.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(s.length>1&&o==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${s[0]?.url})`);return}let l=s.find(A=>A.url===o)??s[0];if(l==null){i.failAndThrow(`No docs instance with url ${o}. Failed to register.`);return}let m=[];l.customDomain!=null&&(typeof l.customDomain=="string"?m.push(l.customDomain):Array.isArray(l.customDomain)&&m.push(...l.customDomain)),await i.runInteractiveTask({name:l.url},async()=>{await xtS({docsWorkspace:n,customDomains:m,domain:l.url,token:a,organization:e,context:i,apiWorkspaces:t,ossWorkspaces:r,preview:c,editThisPage:l.editThisPage,isPrivate:l.private,disableTemplates:f,skipUpload:u,targetAudiences:l.audiences?Array.isArray(l.audiences)?l.audiences:[l.audiences]:void 0})})}var QrS=Wi(e7i(),1);var Bhe={RequestReference:"requestReference",InlinedRequestProperty:"inlinedRequestProperty",Response:"response",StreamingResponse:"streamingResponse"};function QL(e,t){return r=>{r!=null&&e.docs?.(r,[...t,"docs"])}}function aCr({example:e,visitor:t,nodePath:r}){if(typeof e=="string")e.startsWith("$")&&t.exampleTypeReference?.(e,r);else if(Lq(e))for(let n of Object.values(e))aCr({example:n,visitor:t,nodePath:r});else if(Array.isArray(e))for(let n of e)aCr({example:n,visitor:t,nodePath:r})}function l6r(e){return(t,r,{_default:n,validation:i,location:a}={})=>{e.typeReference?.({typeReference:t,_default:n,validation:i,location:a,nodePath:r},r)}}function ztS({service:e,visitor:t,nodePath:r}){t.httpService?.(e,r),AN(e,{url:n=>{t.serviceBaseUrl?.(n,[...r,"url"])},"base-path":Qc,"display-name":Qc,availability:Qc,headers:n=>{QtS({headers:n,visitor:t,nodePath:[...r,"headers"]})},audiences:Qc,auth:Qc,"path-parameters":n=>{s4s({pathParameters:n,visitor:t,nodePath:[...r,"path-parameters"]})},endpoints:n=>{for(let[i,a]of Object.entries(n)){let o=[...r,"endpoints",i];_OL({endpointId:i,endpoint:a,service:e,visitor:t,nodePathForEndpoint:o})}},idempotent:Qc,transport:Qc,source:Qc})}function _OL({endpointId:e,endpoint:t,service:r,visitor:n,nodePathForEndpoint:i}){let a=l6r(n);n.httpEndpoint?.({endpointId:e,endpoint:t,service:r},i),AN(t,{docs:QL(n,i),"display-name":Qc,availability:Qc,"base-path":Qc,path:Qc,idempotent:Qc,url:o=>{n.endpointBaseUrl?.({baseUrl:o,service:r},[...i,"url"])},"path-parameters":o=>{s4s({pathParameters:o,visitor:n,nodePath:[...i,"path-parameters"]})},request:o=>{if(o==null)return;let c=[...i,"request"];if(typeof o=="string"){a(o,c,{location:"requestReference"});return}AN(o,{name:Qc,docs:QL(n,c),"path-parameters":f=>{s4s({pathParameters:f,visitor:n,nodePath:[...c,"path-parameters"]})},"query-parameters":f=>{if(f!=null)for(let[u,s]of Object.entries(f)){let l=[...c,"query-parameters",u];n.queryParameter?.({queryParameterKey:u,queryParameter:s},l),typeof s=="string"?a(s,l):AN(s,{name:Qc,docs:QL(n,l),availability:Qc,type:m=>{a(m,[...l,"type"],{_default:s.default,validation:s.validation})},"allow-multiple":Qc,audiences:Qc,encoding:Qc,default:Qc,validation:Qc})}},"content-type":Qc,headers:f=>{QtS({headers:f,visitor:n,nodePath:[...c,"headers"]})},body:f=>{if(f==null)return;let u=[...c,"body"];typeof f=="string"?a(f,u,{location:"requestReference"}):BU(f)?(n.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:f},u),AN(f,{extends:s=>{if(s==null)return;let l=typeof s=="string"?[s]:s;for(let m of l){let A=[...u,"extends",m];n.extension?.(m,A),a(m,A)}},properties:s=>{if(s!=null)for(let[l,m]of Object.entries(s)){let A=[...u,"properties",l];typeof m=="string"?a(m,A,{location:Bhe.InlinedRequestProperty}):AN(m,{name:Qc,docs:QL(n,A),availability:Qc,type:P=>{a(P,[...A,"type"],{location:Bhe.InlinedRequestProperty,_default:m.default,validation:m.validation})},style:Qc,"content-type":Qc,audiences:Qc,encoding:Qc,default:Qc,validation:Qc})}},"extra-properties":Qc})):(QL(n,u)(f.docs),a(f.type,u))}})},audiences:Qc,method:Qc,auth:Qc,"stream-condition":o=>{n.streamCondition?.({streamCondition:o,endpoint:t},[...i,"stream-condition"])},"response-stream":o=>{o!=null&&(typeof o=="string"?a(o,[...i,"response-stream"],{location:Bhe.StreamingResponse}):a(o.type,[...i,"response-stream"],{location:Bhe.StreamingResponse}))},response:o=>{if(o==null)return;let c=[...i,"response"];typeof o=="string"?a(o,c,{location:Bhe.Response}):AN(o,{docs:QL(n,c),type:f=>{f!=null&&a(f,[...c,"type"],{location:Bhe.Response})},property:Qc,"status-code":Qc})},errors:o=>{if(o!=null)for(let c of o){let f=[...i,"errors",typeof c=="string"?c:c.error];typeof c=="string"?n.errorReference?.(c,f):AN(c,{docs:QL(n,f),error:u=>{n.errorReference?.(u,[...f,"error"])}})}},examples:o=>{if(o!=null)for(let[c,f]of o.entries())hOL({nodePathForExample:[...i,{key:"examples",arrayIndex:c}],visitor:n,service:r,endpoint:t,example:f})},pagination:Qc,source:Qc,transport:Qc,retries:Qc})}function hOL({nodePathForExample:e,visitor:t,service:r,endpoint:n,example:i}){if(i.headers==null&&i["path-parameters"]==null&&i["query-parameters"]==null&&i.request==null&&i.response==null&&i["code-samples"]!=null)return;t.exampleHttpEndpointCall?.({service:r,endpoint:n,example:i},e);let a=[...e,"headers"];if(t.exampleHeaders?.({service:r,endpoint:n,examples:i.headers},a),i.headers!=null)for(let s of Object.values(i.headers))aCr({example:s,visitor:t,nodePath:a});let o=[...e,"path-parameters"];if(t.examplePathParameters?.({service:r,endpoint:n,examples:i["path-parameters"]},o),i["path-parameters"]!=null)for(let s of Object.values(i["path-parameters"]))aCr({example:s,visitor:t,nodePath:o});let c=[...e,"query-parameters"];if(t.exampleQueryParameters?.({service:r,endpoint:n,examples:i["query-parameters"]},c),i["query-parameters"]!=null)for(let s of Object.values(i["query-parameters"]))aCr({example:s,visitor:t,nodePath:c});let f=[...e,"request"];t.exampleRequest?.({service:r,endpoint:n,example:i.request},f),i.request!=null&&aCr({example:i.request,visitor:t,nodePath:f});let u=[...e,"response"];if(t.exampleResponse?.({service:r,endpoint:n,example:i.response},u),i.response!=null&&rca(n,i.response,{body:s=>{s.body!=null&&aCr({example:s.body,visitor:t,nodePath:u}),s.error!=null&&t.errorReference?.(s.error,[...u,"error"])},stream:s=>{for(let l of s.stream)aCr({example:l,visitor:t,nodePath:u})},events:s=>{for(let{data:l}of s.stream)aCr({example:l,visitor:t,nodePath:u})}}),i["code-samples"]!=null)for(let[s,l]of i["code-samples"].entries())t.exampleCodeSample?.({service:r,endpoint:n,example:i,sample:l},[...e,{key:"code-samples",arrayIndex:s}])}function s4s({pathParameters:e,visitor:t,nodePath:r}){if(e==null)return;let n=l6r(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.pathParameter?.({pathParameterKey:i,pathParameter:a},o),bZa(a)?typeof a=="string"?t.variableReference?.(a,o):AN(a,{docs:QL(t,o),variable:c=>t.variableReference?.(c,[...o,"variable"]),availability:Qc}):typeof a=="string"?n(a,o):AN(a,{docs:QL(t,o),type:c=>{n(c,[...o,"type"],{_default:a.default,validation:a.validation})},availability:Qc,encoding:Qc,default:Qc,validation:Qc,name:Qc,audiences:Qc})}}function QtS({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=l6r(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.header?.({headerKey:i,header:a},o),typeof a=="string"?n(a,o):AN(a,{name:Qc,availability:Qc,type:c=>{n(c,o,{_default:a.default,validation:a.validation})},docs:QL(t,o),audiences:Qc,encoding:Qc,env:Qc,default:Qc,validation:Qc})}}function LtS({typeDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.typeName?.(n,a),oJ_({typeName:n,declaration:i,visitor:t,nodePathForType:a})}}function oJ_({typeName:e,declaration:t,visitor:r,nodePathForType:n}){let i=l6r(r);r.typeDeclaration?.({typeName:{isInlined:!1,name:e},declaration:t,nodePath:n},n);let a=o=>{if(o!=null)for(let[c,f]of o.entries()){let u=[...n,{key:"examples",arrayIndex:c}];r.exampleType?.({typeName:e,typeDeclaration:t,example:f},u),aCr({example:f.value,nodePath:u,visitor:r})}};Uee(t,{alias:o=>{typeof o=="string"?i(o,n):AN(o,{type:c=>{i(c,[...n,"type"])},docs:QL(r,n),availability:Qc,audiences:Qc,examples:a,validation:Qc,encoding:Qc,source:Qc,inline:Qc})},object:o=>{AN(o,{docs:QL(r,n),extends:c=>{if(c==null)return;let f=typeof c=="string"?[c]:c;for(let u of f){let s=[...n,"extends",u];r.extension?.(u,s),i(u,s)}},properties:c=>{if(c!=null)for(let[f,u]of Object.entries(c)){let s=[...n,"properties",f];typeof u=="string"?i(u,s):AN(u,{name:Qc,docs:QL(r,s),availability:Qc,type:l=>{i(l,[...s,"type"],{_default:u.default,validation:u.validation})},audiences:Qc,encoding:Qc,default:Qc,validation:Qc,access:Qc})}},"extra-properties":Qc,availability:Qc,audiences:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})},discriminatedUnion:o=>{AN(o,{docs:QL(r,n),discriminant:Qc,extends:c=>{if(c==null)return;let f=typeof c=="string"?[c]:c;for(let u of f){let s=[...n,"extends",u];r.extension?.(u,s),i(u,s)}},union:c=>{for(let[f,u]of Object.entries(c)){let s=[...n,"union",f];typeof u=="string"?i(u,s):AN(u,{docs:QL(r,s),name:Qc,key:Qc,type:l=>{typeof l=="string"&&i(l,[...n,"type"])},"display-name":Qc,availability:Qc})}},"base-properties":Qc,availability:Qc,audiences:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})},undiscriminatedUnion:o=>{AN(o,{docs:QL(r,n),discriminated:Qc,union:c=>{for(let[f,u]of c.entries()){let s=[...n,`union[${f}]`];typeof u!="string"&&AN(u,{docs:QL(r,s),type:l=>{i(l,[...n,"type"])},"display-name":Qc,validation:Qc})}},availability:Qc,audiences:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})},enum:o=>{AN(o,{docs:QL(r,n),enum:c=>{for(let f of c){let u=[...n,typeof f=="string"?f:f.name??f.value];typeof f!="string"&&AN(f,{docs:QL(r,u),name:Qc,value:Qc,casing:Qc})}},availability:Qc,audiences:Qc,default:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})}})}function UtS({errorDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.errorDeclaration?.({errorName:n,declaration:i},a),yOL({errorName:n,declaration:i,visitor:t,nodePathForError:a})}}function yOL({errorName:e,declaration:t,visitor:r,nodePathForError:n}){let i=l6r(r);typeof t=="string"?i(t,n):AN(t,{docs:QL(r,n),"status-code":Qc,type:a=>{if(a==null)return;let o=[...n,"type"];typeof a=="string"?i(a,o):oJ_({typeName:e,declaration:a,visitor:r,nodePathForType:o})},examples:a=>{if(a!=null)for(let o of a){let c=[...n,"type"];r.exampleError?.({errorName:e,declaration:t,example:o},c)}}})}function VtS({imports:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e))t.import?.({importPath:i,importedAs:n},[...r,n])}function WtS({webhook:e,visitor:t,nodePathForWebhook:r}){let n=l6r(t);AN(e,{"display-name":Qc,method:Qc,examples:Qc,headers:i=>{vOL({headers:i,visitor:t,nodePath:[...r,"headers"]})},payload:i=>{let a=[...r,"payload"];if(typeof i=="string"){n(i,a,{location:"requestReference"});return}if(bOL(i)){n(i.type,[...a,"type"],{location:"requestReference"});return}let o=[...a];t.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:i},o),AN(i,{name:Qc,extends:c=>{if(c==null)return;let f=typeof c=="string"?[c]:c;for(let u of f){let s=[...o,"extends",u];t.extension?.(u,s),n(u,s)}},properties:c=>{if(c!=null)for(let[f,u]of Object.entries(c)){let s=[...o,"properties",f];typeof u=="string"?n(u,s,{location:Bhe.InlinedRequestProperty}):AN(u,{name:Qc,docs:QL(t,s),availability:Qc,type:l=>{n(l,[...s,"type"],{_default:u.default,validation:u.validation,location:Bhe.InlinedRequestProperty})},audiences:Qc,encoding:Qc,default:Qc,validation:Qc,access:Qc})}}})},audiences:Qc,availability:Qc,docs:QL(t,r)})}function vOL({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=l6r(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.header?.({headerKey:i,header:a},o),typeof a=="string"?n(a,o):AN(a,{name:Qc,availability:Qc,type:c=>{n(c,o,{_default:a.default,validation:a.validation})},docs:QL(t,o),audiences:Qc,encoding:Qc,env:Qc,default:Qc,validation:Qc})}}function bOL(e){return e.type!=null}function Nme(e,t){AN(e,{docs:QL(t,[]),imports:r=>{VtS({imports:r,visitor:t,nodePath:["imports"]})},types:r=>{LtS({typeDeclarations:r,visitor:t,nodePath:["types"]})},service:r=>{r!=null&&ztS({service:r,visitor:t,nodePath:["service"]})},webhooks:r=>{for(let[n,i]of Object.entries(r??{}))WtS({webhook:i,visitor:t,nodePathForWebhook:["webhooks",n]})},channel:Qc,errors:r=>{UtS({errorDeclarations:r,visitor:t,nodePath:["errors"]})}})}function sJ_(e,t){AN(e,{docs:Qc,imports:Qc,types:Qc,service:Qc,webhooks:Qc,errors:Qc,channel:Qc,export:r=>{t.export?.(typeof r=="string"?r:r?.dependency,["export"])},navigation:r=>{t.navigation?.(r,["navigation"])}})}function uJ_(e,t){t.file?.(e,[]),AN(e,{version:Qc,product:Qc,name:Qc,"default-url":Qc,"display-name":Qc,imports:Qc,auth:Qc,"idempotency-headers":Qc,"auth-schemes":r=>Object.entries(r??{}).map(([n,i])=>{tff(i)&&t.oauth?.({name:n,oauth:i},["auth-scheme",n])}),pagination:Qc,"default-environment":r=>{t.defaultEnvironment?.(r,["default-environment"])},docs:Qc,headers:Qc,environments:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.environment?.({environmentId:n,environment:i},["environments",n])},"error-discrimination":r=>{t.errorDiscrimination?.(r,["error-discrimination"])},audiences:Qc,errors:r=>{if(r!=null)for(let n of r)t.errorReference?.(n,["errors",n])},"base-path":Qc,"path-parameters":r=>{s4s({pathParameters:r,visitor:t,nodePath:["path-parameters"]})},variables:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.variableDeclaration?.({variableId:n,variable:i},["variables",n])}})}var djl=new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$");function HtS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let u of r){let s=u.definitionFile?.[a];if(s!=null){let l=s(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:f,message:m.message})))}}};return{[a]:o}}return{...i("docs"),...i("import"),...i("typeReference"),...i("typeDeclaration"),...i("typeName"),...i("httpService"),...i("httpEndpoint"),...i("pathParameter"),...i("queryParameter"),...i("streamCondition"),...i("header"),...i("errorDeclaration"),...i("errorReference"),...i("exampleType"),...i("exampleTypeReference"),...i("exampleHttpEndpointCall"),...i("exampleCodeSample"),...i("exampleHeaders"),...i("examplePathParameters"),...i("exampleQueryParameters"),...i("exampleRequest"),...i("exampleResponse"),...i("variableReference"),...i("extension"),...i("serviceBaseUrl"),...i("endpointBaseUrl"),...i("exampleError")}}function GtS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let u of r){let s=u.packageMarker?.[a];if(s!=null){let l=s(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:f,message:m.message})))}}};return{[a]:o}}return{...i("export"),...i("navigation")}}function JtS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let u of r){let s=u.rootApiFile?.[a];if(s!=null){let l=s(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:f,message:m.message})))}}};return{[a]:o}}return{...i("file"),...i("oauth"),...i("defaultEnvironment"),...i("environment"),...i("errorDiscrimination"),...i("errorReference"),...i("variableDeclaration"),...i("variableReference"),...i("pathParameter")}}var cJ_={name:"content-type-only-for-multipart",DISABLE_RULE:!1,create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>{if(e.request==null)return[];if(tca(e.request)!=null)return[];if(typeof e.request!="string"&&e.request.body!=null&&BU(e.request.body)){let r=[];for(let[n,i]of Object.entries(e.request.body.properties??{}))typeof i!="string"&&i["content-type"]!=null&&r.push({severity:"fatal",message:`${n} has content-type, but the request is not multipart`});return r}return[]}}})};var y3=EIe({generationLanguage:void 0,keywords:void 0,smartCasing:!1});var lJ_={name:"exploded-form-data-is-array",create:({workspace:e})=>{let t=new VF(e);return{definitionFile:{httpEndpoint:({endpoint:r},{relativeFilepath:n,contents:i})=>{if(r.request==null||typeof r.request=="string"||r.request?.body==null||typeof r.request.body=="string")return[];if(!gOL(r.request.body))return[];let a=[];for(let[o,c]of Object.entries(r.request.body.properties??{})){if(typeof c=="string"||c.style!=="exploded")continue;let f=cD({relativeFilepath:n,definitionFile:i,casingsGenerator:y3,rootApiFile:e.definition.rootApiFile.contents}),u=t.resolveType({type:c.type,file:f});if(u==null)return[];KtS(u)||a.push({message:`${o} is exploded and must be a list. Did you mean list<${c.type}>?`,severity:"error"})}return a}}}}};function KtS(e){return e._type!=="container"?!1:e.container._type==="list"?!0:e.container._type==="optional"||e.container._type==="nullable"?KtS(e.container.itemType):!1}function gOL(e){return e?.properties!=null}var fJ_={name:"import-file-exists",create:({workspace:e})=>{let t=Object.keys(iji(e.definition)),r=new Set;return t.forEach(n=>{let i=Wl(e.definition.absoluteFilePath,nu.of(n));r.add(i)}),{definitionFile:{import:({importedAs:n,importPath:i},{relativeFilepath:a})=>{let o=[],c=Wl(e.definition.absoluteFilePath,Qg(a),nu.of(i));return r.has(c)||o.push({severity:"fatal",message:`Import ${Mf.bold(n)} points to non-existent path ${Mf.bold(i)}.`}),o}}}}};function pjl(e){return e.definition.rootApiFile.contents.environments==null?[]:Object.values(e.definition.rootApiFile.contents.environments).reduce((t,r)=>{if(lit(r))for(let n of Object.keys(r.urls))t.includes(n)||t.push(n);return t},[])}var dJ_={name:"matching-environment-urls",create:({workspace:e})=>{let t=pjl(e);return t.length===0?{}:{rootApiFile:{environment:({environmentId:r,environment:n})=>{let i=[],a=o=>{i.push({severity:"fatal",message:`Environment ${r} is missing URL for ${Mf.bold(o)}`})};return J9r(n,{singleBaseUrl:()=>{for(let o of t)a(o)},multipleBaseUrls:o=>{for(let c of t)o.urls[c]==null&&a(c)}}),i}}}}};var pJ_={name:"no-circular-imports",DISABLE_RULE:!0,create:({workspace:e})=>{let t=mOL(e.definition.namedDefinitionFiles);return{definitionFile:{import:({importPath:r},{relativeFilepath:n})=>{let i=t[n];if(i==null)return[];let a=F5i({referencedIn:n,importPath:nu.of(r)});return i.filter(({chainWithoutStartingFilepath:c})=>c.length===0||c[0]===a).map(c=>({severity:"fatal",message:c.chainWithoutStartingFilepath.length===0?"A file cannot import itself":`Circular import detected: ${[c.startingFilepath,...c.chainWithoutStartingFilepath,c.startingFilepath].join(" -> ")}`}))}}}}};function mOL(e){let t={};for(let r of kTr(e))t[r]=$tS(r,[r],e);return t}function $tS(e,t,r){let n=[],i=r[e];if(i==null)return[];if(i.contents.imports!=null)for(let a of Object.values(i.contents.imports)){let o=F5i({referencedIn:e,importPath:nu.of(a)});t.includes(o)?t[0]===o&&t[0]===OOL(t)&&n.push({startingFilepath:o,chainWithoutStartingFilepath:t.slice(1)}):n.push(...$tS(o,[...t,o],r))}return n}function OOL(e){return e.reduce((t,r)=>r<t?r:t)}var _jl=class{workspace;typeResolver;constructor(t){this.workspace=t,this.typeResolver=new VF(t)}isTypeComplex(t,r){let n=cD({relativeFilepath:r.relativeFilepath,definitionFile:r.contents,casingsGenerator:y3,rootApiFile:this.workspace.definition.rootApiFile.contents}),i=this.typeResolver.resolveType({type:t,file:n});if(i==null)return;let a=new Set;return this.isResolvedReferenceComplex({type:i,file:n,visited:a})}isResolvedReferenceComplex({type:t,file:r,visited:n}){switch(t._type){case"container":return this.isResolvedContainerComplex({type:t.container,file:r,visited:n});case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":return!1;case"unknown":return!0;default:ku(t)}}isResolvedContainerComplex({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return(this.isResolvedReferenceComplex({type:t.keyType,file:r,visited:n})||this.isResolvedReferenceComplex({type:t.valueType,file:r,visited:n}))&&!(t.keyType._type==="primitive"&&t.keyType.primitive.v1==="STRING"&&t.valueType._type==="unknown");case"optional":case"nullable":case"list":case"set":return this.isResolvedReferenceComplex({type:t.itemType,file:r,visited:n});default:ku(t)}}isNamedTypeComplex({type:t,file:r,visited:n}){if(n.has(t.rawName))return!1;if(n.add(t.rawName),M6i(t.declaration))return!0;if(Uqr(t.declaration))return!1;if(DN(t.declaration))return this.objectHasComplexProperties({typeName:t.rawName,objectDeclaration:t.declaration,file:r,visited:n});if(gZa(t.declaration)){for(let i of t.declaration.union){let a=typeof i=="string"?i:i.type,o=this.isTypeComplex(a,{contents:r.definitionFile,relativeFilepath:r.relativeFilepath});if(o!=null&&o)return!0}return!1}ku(t.declaration)}objectHasComplexProperties({typeName:t,objectDeclaration:r,file:n,visited:i}){return Pat({typeName:t,objectDeclaration:r,typeResolver:this.typeResolver,definitionFile:n.definitionFile,workspace:this.workspace,filepathOfDeclaration:n.relativeFilepath,smartCasing:!1}).some(o=>this.isComplex({type:o.resolvedPropertyType,file:n,visited:i}))}isComplex({type:t,file:r,visited:n}){switch(t._type){case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":case"unknown":return!1;case"container":return this.isComplexContainer({type:t.container,file:r,visited:n});default:ku(t)}}isComplexContainer({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return this.isComplex({type:t.keyType,file:r,visited:n})||this.isComplex({type:t.valueType,file:r,visited:n});case"optional":case"nullable":case"list":case"set":return this.isComplex({type:t.itemType,file:r,visited:n});default:ku(t)}}};var _J_={name:"no-complex-query-params",create:({workspace:e})=>{let t=new _jl(e);return{definitionFile:{queryParameter:({queryParameter:r},n)=>{let i=typeof r=="string"?r:r.type,a=t.isTypeComplex(i,n);return a!=null&&a?[{severity:"fatal",message:`${i} is not a valid type for a query parameter`}]:[]}}}}};var hJ_={name:"no-conflicting-endpoint-parameters",create:()=>({definitionFile:{pathParameter:({pathParameterKey:e})=>e===MJu?[{severity:"fatal",message:`Path parameter ${Mf.bold(e)} is not suitable for code generation, because it can conflict with the request body parameter.`}]:[]}})};function u4s({service:e,endpoint:t}){return e["base-path"]+t.path}var hjl=class{root=new yJ_;registerEndpoint(t){this.root.insert(this.getPathPartsForEndpoint(t),t)}getConflictingEndpoints(t){return this.root.getMatchingEndpoints(this.getPathPartsForEndpoint(t)).filter(r=>!(r.relativeFilepath===t.relativeFilepath&&r.endpointId===t.endpointId)&&r.endpoint.method===t.endpoint.method)}getPathPartsForEndpoint(t){return u4s({service:t.service,endpoint:t.endpoint}).split("/").filter(r=>r.length>0)}},yJ_=class e{childPaths={};childPathParam;endpointsThatEndWithThisNode=[];insert(t,r){let[n,...i]=t;if(n==null){this.endpointsThatEndWithThisNode.push(r);return}(this.isPathParam(n)?this.childPathParam??=new e:this.childPaths[n]??=new e).insert(i,r)}getMatchingEndpoints(t){let[r,...n]=t;if(r==null)return this.endpointsThatEndWithThisNode;let i=[];if(this.isPathParam(r))i.push(...Object.values(this.childPaths).flatMap(a=>a.getMatchingEndpoints(n)));else{let a=this.childPaths[r];a!=null&&i.push(...a.getMatchingEndpoints(n))}return this.childPathParam!=null&&i.push(...this.childPathParam.getMatchingEndpoints(n)),i}isPathParam(t){return t.startsWith("{")&&t.endsWith("}")}};var vJ_={name:"no-conflicting-endpoint-paths",create:({workspace:e})=>{let t=new hjl;return ute(e,(r,n)=>{Nme(n,{httpEndpoint:({service:i,endpointId:a,endpoint:o})=>{t.registerEndpoint({service:i,endpointId:a,endpoint:o,relativeFilepath:r})}})}),{definitionFile:{httpEndpoint:({service:r,endpoint:n,endpointId:i},{relativeFilepath:a})=>{let o=t.getConflictingEndpoints({service:r,endpointId:i,endpoint:n,relativeFilepath:a});return o.length===0?[]:[{severity:"warning",message:[`Endpoint path ${u4s({service:r,endpoint:n})} conflicts with other endpoints:`,...o.map(c=>` - ${c.relativeFilepath} -> ${c.endpointId} ${Mf.dim(u4s({service:c.service,endpoint:c.endpoint}))}`)].join(`
3089
+ Note: it may take a few minutes after publishing for Ask Fern settings to reflect expected state.`))}}async function aJ_({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:a,instanceUrl:o,preview:c,disableTemplates:f,skipUpload:u}){let s=n.config.instances;if(n.config=Ozi(n.config,{onError:A=>i.failAndThrow(A)},{substituteAsEmpty:c}),s.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(s.length>1&&o==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${s[0]?.url})`);return}let l=s.find(A=>A.url===o)??s[0];if(l==null){i.failAndThrow(`No docs instance with url ${o}. Failed to register.`);return}let m=[];l.customDomain!=null&&(typeof l.customDomain=="string"?m.push(l.customDomain):Array.isArray(l.customDomain)&&m.push(...l.customDomain)),await i.runInteractiveTask({name:l.url},async()=>{await xtS({docsWorkspace:n,customDomains:m,domain:l.url,token:a,organization:e,context:i,apiWorkspaces:t,ossWorkspaces:r,preview:c,editThisPage:l.editThisPage,isPrivate:l.private,disableTemplates:f,skipUpload:u,targetAudiences:l.audiences?Array.isArray(l.audiences)?l.audiences:[l.audiences]:void 0})})}var QrS=Wi(e7i(),1);var Bhe={RequestReference:"requestReference",InlinedRequestProperty:"inlinedRequestProperty",Response:"response",StreamingResponse:"streamingResponse"};function QL(e,t){return r=>{r!=null&&e.docs?.(r,[...t,"docs"])}}function aCr({example:e,visitor:t,nodePath:r}){if(typeof e=="string")e.startsWith("$")&&t.exampleTypeReference?.(e,r);else if(Lq(e))for(let n of Object.values(e))aCr({example:n,visitor:t,nodePath:r});else if(Array.isArray(e))for(let n of e)aCr({example:n,visitor:t,nodePath:r})}function l6r(e){return(t,r,{_default:n,validation:i,location:a}={})=>{e.typeReference?.({typeReference:t,_default:n,validation:i,location:a,nodePath:r},r)}}function ztS({service:e,visitor:t,nodePath:r}){t.httpService?.(e,r),AN(e,{url:n=>{t.serviceBaseUrl?.(n,[...r,"url"])},"base-path":Qc,"display-name":Qc,availability:Qc,headers:n=>{QtS({headers:n,visitor:t,nodePath:[...r,"headers"]})},audiences:Qc,auth:Qc,"path-parameters":n=>{s4s({pathParameters:n,visitor:t,nodePath:[...r,"path-parameters"]})},endpoints:n=>{for(let[i,a]of Object.entries(n)){let o=[...r,"endpoints",i];_OL({endpointId:i,endpoint:a,service:e,visitor:t,nodePathForEndpoint:o})}},idempotent:Qc,transport:Qc,source:Qc})}function _OL({endpointId:e,endpoint:t,service:r,visitor:n,nodePathForEndpoint:i}){let a=l6r(n);n.httpEndpoint?.({endpointId:e,endpoint:t,service:r},i),AN(t,{docs:QL(n,i),"display-name":Qc,availability:Qc,"base-path":Qc,path:Qc,idempotent:Qc,url:o=>{n.endpointBaseUrl?.({baseUrl:o,service:r},[...i,"url"])},"path-parameters":o=>{s4s({pathParameters:o,visitor:n,nodePath:[...i,"path-parameters"]})},request:o=>{if(o==null)return;let c=[...i,"request"];if(typeof o=="string"){a(o,c,{location:"requestReference"});return}AN(o,{name:Qc,docs:QL(n,c),"path-parameters":f=>{s4s({pathParameters:f,visitor:n,nodePath:[...c,"path-parameters"]})},"query-parameters":f=>{if(f!=null)for(let[u,s]of Object.entries(f)){let l=[...c,"query-parameters",u];n.queryParameter?.({queryParameterKey:u,queryParameter:s},l),typeof s=="string"?a(s,l):AN(s,{name:Qc,docs:QL(n,l),availability:Qc,type:m=>{a(m,[...l,"type"],{_default:s.default,validation:s.validation})},"allow-multiple":Qc,audiences:Qc,encoding:Qc,default:Qc,validation:Qc})}},"content-type":Qc,headers:f=>{QtS({headers:f,visitor:n,nodePath:[...c,"headers"]})},body:f=>{if(f==null)return;let u=[...c,"body"];typeof f=="string"?a(f,u,{location:"requestReference"}):BU(f)?(n.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:f},u),AN(f,{extends:s=>{if(s==null)return;let l=typeof s=="string"?[s]:s;for(let m of l){let A=[...u,"extends",m];n.extension?.(m,A),a(m,A)}},properties:s=>{if(s!=null)for(let[l,m]of Object.entries(s)){let A=[...u,"properties",l];typeof m=="string"?a(m,A,{location:Bhe.InlinedRequestProperty}):AN(m,{name:Qc,docs:QL(n,A),availability:Qc,type:P=>{a(P,[...A,"type"],{location:Bhe.InlinedRequestProperty,_default:m.default,validation:m.validation})},style:Qc,"content-type":Qc,audiences:Qc,encoding:Qc,default:Qc,validation:Qc})}},"extra-properties":Qc})):(QL(n,u)(f.docs),a(f.type,u))}})},audiences:Qc,method:Qc,auth:Qc,"stream-condition":o=>{n.streamCondition?.({streamCondition:o,endpoint:t},[...i,"stream-condition"])},"response-stream":o=>{o!=null&&(typeof o=="string"?a(o,[...i,"response-stream"],{location:Bhe.StreamingResponse}):a(o.type,[...i,"response-stream"],{location:Bhe.StreamingResponse}))},response:o=>{if(o==null)return;let c=[...i,"response"];typeof o=="string"?a(o,c,{location:Bhe.Response}):AN(o,{docs:QL(n,c),type:f=>{f!=null&&a(f,[...c,"type"],{location:Bhe.Response})},property:Qc,"status-code":Qc})},errors:o=>{if(o!=null)for(let c of o){let f=[...i,"errors",typeof c=="string"?c:c.error];typeof c=="string"?n.errorReference?.(c,f):AN(c,{docs:QL(n,f),error:u=>{n.errorReference?.(u,[...f,"error"])}})}},examples:o=>{if(o!=null)for(let[c,f]of o.entries())hOL({nodePathForExample:[...i,{key:"examples",arrayIndex:c}],visitor:n,service:r,endpoint:t,example:f})},pagination:Qc,source:Qc,transport:Qc,retries:Qc})}function hOL({nodePathForExample:e,visitor:t,service:r,endpoint:n,example:i}){if(i.headers==null&&i["path-parameters"]==null&&i["query-parameters"]==null&&i.request==null&&i.response==null&&i["code-samples"]!=null)return;t.exampleHttpEndpointCall?.({service:r,endpoint:n,example:i},e);let a=[...e,"headers"];if(t.exampleHeaders?.({service:r,endpoint:n,examples:i.headers},a),i.headers!=null)for(let s of Object.values(i.headers))aCr({example:s,visitor:t,nodePath:a});let o=[...e,"path-parameters"];if(t.examplePathParameters?.({service:r,endpoint:n,examples:i["path-parameters"]},o),i["path-parameters"]!=null)for(let s of Object.values(i["path-parameters"]))aCr({example:s,visitor:t,nodePath:o});let c=[...e,"query-parameters"];if(t.exampleQueryParameters?.({service:r,endpoint:n,examples:i["query-parameters"]},c),i["query-parameters"]!=null)for(let s of Object.values(i["query-parameters"]))aCr({example:s,visitor:t,nodePath:c});let f=[...e,"request"];t.exampleRequest?.({service:r,endpoint:n,example:i.request},f),i.request!=null&&aCr({example:i.request,visitor:t,nodePath:f});let u=[...e,"response"];if(t.exampleResponse?.({service:r,endpoint:n,example:i.response},u),i.response!=null&&rca(n,i.response,{body:s=>{s.body!=null&&aCr({example:s.body,visitor:t,nodePath:u}),s.error!=null&&t.errorReference?.(s.error,[...u,"error"])},stream:s=>{for(let l of s.stream)aCr({example:l,visitor:t,nodePath:u})},events:s=>{for(let{data:l}of s.stream)aCr({example:l,visitor:t,nodePath:u})}}),i["code-samples"]!=null)for(let[s,l]of i["code-samples"].entries())t.exampleCodeSample?.({service:r,endpoint:n,example:i,sample:l},[...e,{key:"code-samples",arrayIndex:s}])}function s4s({pathParameters:e,visitor:t,nodePath:r}){if(e==null)return;let n=l6r(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.pathParameter?.({pathParameterKey:i,pathParameter:a},o),bZa(a)?typeof a=="string"?t.variableReference?.(a,o):AN(a,{docs:QL(t,o),variable:c=>t.variableReference?.(c,[...o,"variable"]),availability:Qc}):typeof a=="string"?n(a,o):AN(a,{docs:QL(t,o),type:c=>{n(c,[...o,"type"],{_default:a.default,validation:a.validation})},availability:Qc,encoding:Qc,default:Qc,validation:Qc,name:Qc,audiences:Qc})}}function QtS({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=l6r(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.header?.({headerKey:i,header:a},o),typeof a=="string"?n(a,o):AN(a,{name:Qc,availability:Qc,type:c=>{n(c,o,{_default:a.default,validation:a.validation})},docs:QL(t,o),audiences:Qc,encoding:Qc,env:Qc,default:Qc,validation:Qc})}}function LtS({typeDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.typeName?.(n,a),oJ_({typeName:n,declaration:i,visitor:t,nodePathForType:a})}}function oJ_({typeName:e,declaration:t,visitor:r,nodePathForType:n}){let i=l6r(r);r.typeDeclaration?.({typeName:{isInlined:!1,name:e},declaration:t,nodePath:n},n);let a=o=>{if(o!=null)for(let[c,f]of o.entries()){let u=[...n,{key:"examples",arrayIndex:c}];r.exampleType?.({typeName:e,typeDeclaration:t,example:f},u),aCr({example:f.value,nodePath:u,visitor:r})}};Uee(t,{alias:o=>{typeof o=="string"?i(o,n):AN(o,{type:c=>{i(c,[...n,"type"])},docs:QL(r,n),availability:Qc,audiences:Qc,examples:a,validation:Qc,encoding:Qc,source:Qc,inline:Qc})},object:o=>{AN(o,{docs:QL(r,n),extends:c=>{if(c==null)return;let f=typeof c=="string"?[c]:c;for(let u of f){let s=[...n,"extends",u];r.extension?.(u,s),i(u,s)}},properties:c=>{if(c!=null)for(let[f,u]of Object.entries(c)){let s=[...n,"properties",f];typeof u=="string"?i(u,s):AN(u,{name:Qc,docs:QL(r,s),availability:Qc,type:l=>{i(l,[...s,"type"],{_default:u.default,validation:u.validation})},audiences:Qc,encoding:Qc,default:Qc,validation:Qc,access:Qc})}},"extra-properties":Qc,availability:Qc,audiences:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})},discriminatedUnion:o=>{AN(o,{docs:QL(r,n),discriminant:Qc,extends:c=>{if(c==null)return;let f=typeof c=="string"?[c]:c;for(let u of f){let s=[...n,"extends",u];r.extension?.(u,s),i(u,s)}},union:c=>{for(let[f,u]of Object.entries(c)){let s=[...n,"union",f];typeof u=="string"?i(u,s):AN(u,{docs:QL(r,s),name:Qc,key:Qc,type:l=>{typeof l=="string"&&i(l,[...n,"type"])},"display-name":Qc,availability:Qc})}},"base-properties":Qc,availability:Qc,audiences:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})},undiscriminatedUnion:o=>{AN(o,{docs:QL(r,n),discriminated:Qc,union:c=>{for(let[f,u]of c.entries()){let s=[...n,`union[${f}]`];typeof u!="string"&&AN(u,{docs:QL(r,s),type:l=>{i(l,[...n,"type"])},"display-name":Qc,validation:Qc})}},availability:Qc,audiences:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})},enum:o=>{AN(o,{docs:QL(r,n),enum:c=>{for(let f of c){let u=[...n,typeof f=="string"?f:f.name??f.value];typeof f!="string"&&AN(f,{docs:QL(r,u),name:Qc,value:Qc,casing:Qc})}},availability:Qc,audiences:Qc,default:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})}})}function UtS({errorDeclarations:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e)){let a=[...r,n];t.errorDeclaration?.({errorName:n,declaration:i},a),yOL({errorName:n,declaration:i,visitor:t,nodePathForError:a})}}function yOL({errorName:e,declaration:t,visitor:r,nodePathForError:n}){let i=l6r(r);typeof t=="string"?i(t,n):AN(t,{docs:QL(r,n),"status-code":Qc,type:a=>{if(a==null)return;let o=[...n,"type"];typeof a=="string"?i(a,o):oJ_({typeName:e,declaration:a,visitor:r,nodePathForType:o})},examples:a=>{if(a!=null)for(let o of a){let c=[...n,"type"];r.exampleError?.({errorName:e,declaration:t,example:o},c)}}})}function VtS({imports:e,visitor:t,nodePath:r}){if(e!=null)for(let[n,i]of Object.entries(e))t.import?.({importPath:i,importedAs:n},[...r,n])}function WtS({webhook:e,visitor:t,nodePathForWebhook:r}){let n=l6r(t);AN(e,{"display-name":Qc,method:Qc,examples:Qc,headers:i=>{vOL({headers:i,visitor:t,nodePath:[...r,"headers"]})},payload:i=>{let a=[...r,"payload"];if(typeof i=="string"){n(i,a,{location:"requestReference"});return}if(bOL(i)){n(i.type,[...a,"type"],{location:"requestReference"});return}let o=[...a];t.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:i},o),AN(i,{name:Qc,extends:c=>{if(c==null)return;let f=typeof c=="string"?[c]:c;for(let u of f){let s=[...o,"extends",u];t.extension?.(u,s),n(u,s)}},properties:c=>{if(c!=null)for(let[f,u]of Object.entries(c)){let s=[...o,"properties",f];typeof u=="string"?n(u,s,{location:Bhe.InlinedRequestProperty}):AN(u,{name:Qc,docs:QL(t,s),availability:Qc,type:l=>{n(l,[...s,"type"],{_default:u.default,validation:u.validation,location:Bhe.InlinedRequestProperty})},audiences:Qc,encoding:Qc,default:Qc,validation:Qc,access:Qc})}}})},audiences:Qc,availability:Qc,docs:QL(t,r)})}function vOL({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=l6r(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.header?.({headerKey:i,header:a},o),typeof a=="string"?n(a,o):AN(a,{name:Qc,availability:Qc,type:c=>{n(c,o,{_default:a.default,validation:a.validation})},docs:QL(t,o),audiences:Qc,encoding:Qc,env:Qc,default:Qc,validation:Qc})}}function bOL(e){return e.type!=null}function Nme(e,t){AN(e,{docs:QL(t,[]),imports:r=>{VtS({imports:r,visitor:t,nodePath:["imports"]})},types:r=>{LtS({typeDeclarations:r,visitor:t,nodePath:["types"]})},service:r=>{r!=null&&ztS({service:r,visitor:t,nodePath:["service"]})},webhooks:r=>{for(let[n,i]of Object.entries(r??{}))WtS({webhook:i,visitor:t,nodePathForWebhook:["webhooks",n]})},channel:Qc,errors:r=>{UtS({errorDeclarations:r,visitor:t,nodePath:["errors"]})}})}function sJ_(e,t){AN(e,{docs:Qc,imports:Qc,types:Qc,service:Qc,webhooks:Qc,errors:Qc,channel:Qc,export:r=>{t.export?.(typeof r=="string"?r:r?.dependency,["export"])},navigation:r=>{t.navigation?.(r,["navigation"])}})}function uJ_(e,t){t.file?.(e,[]),AN(e,{version:Qc,product:Qc,name:Qc,"default-url":Qc,"display-name":Qc,imports:Qc,auth:Qc,"idempotency-headers":Qc,"auth-schemes":r=>Object.entries(r??{}).map(([n,i])=>{tff(i)&&t.oauth?.({name:n,oauth:i},["auth-scheme",n])}),pagination:Qc,"default-environment":r=>{t.defaultEnvironment?.(r,["default-environment"])},docs:Qc,headers:Qc,environments:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.environment?.({environmentId:n,environment:i},["environments",n])},"error-discrimination":r=>{t.errorDiscrimination?.(r,["error-discrimination"])},audiences:Qc,errors:r=>{if(r!=null)for(let n of r)t.errorReference?.(n,["errors",n])},"base-path":Qc,"path-parameters":r=>{s4s({pathParameters:r,visitor:t,nodePath:["path-parameters"]})},variables:r=>{if(r!=null)for(let[n,i]of Object.entries(r))t.variableDeclaration?.({variableId:n,variable:i},["variables",n])}})}var djl=new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$");function HtS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let u of r){let s=u.definitionFile?.[a];if(s!=null){let l=s(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:f,message:m.message})))}}};return{[a]:o}}return{...i("docs"),...i("import"),...i("typeReference"),...i("typeDeclaration"),...i("typeName"),...i("httpService"),...i("httpEndpoint"),...i("pathParameter"),...i("queryParameter"),...i("streamCondition"),...i("header"),...i("errorDeclaration"),...i("errorReference"),...i("exampleType"),...i("exampleTypeReference"),...i("exampleHttpEndpointCall"),...i("exampleCodeSample"),...i("exampleHeaders"),...i("examplePathParameters"),...i("exampleQueryParameters"),...i("exampleRequest"),...i("exampleResponse"),...i("variableReference"),...i("extension"),...i("serviceBaseUrl"),...i("endpointBaseUrl"),...i("exampleError")}}function GtS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let u of r){let s=u.packageMarker?.[a];if(s!=null){let l=s(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:f,message:m.message})))}}};return{[a]:o}}return{...i("export"),...i("navigation")}}function JtS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let u of r){let s=u.rootApiFile?.[a];if(s!=null){let l=s(c,{relativeFilepath:e,contents:t});n(l.map(m=>({severity:m.severity,relativeFilepath:e,nodePath:f,message:m.message})))}}};return{[a]:o}}return{...i("file"),...i("oauth"),...i("defaultEnvironment"),...i("environment"),...i("errorDiscrimination"),...i("errorReference"),...i("variableDeclaration"),...i("variableReference"),...i("pathParameter")}}var cJ_={name:"content-type-only-for-multipart",DISABLE_RULE:!1,create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>{if(e.request==null)return[];if(tca(e.request)!=null)return[];if(typeof e.request!="string"&&e.request.body!=null&&BU(e.request.body)){let r=[];for(let[n,i]of Object.entries(e.request.body.properties??{}))typeof i!="string"&&i["content-type"]!=null&&r.push({severity:"fatal",message:`${n} has content-type, but the request is not multipart`});return r}return[]}}})};var y3=EIe({generationLanguage:void 0,keywords:void 0,smartCasing:!1});var lJ_={name:"exploded-form-data-is-array",create:({workspace:e})=>{let t=new VF(e);return{definitionFile:{httpEndpoint:({endpoint:r},{relativeFilepath:n,contents:i})=>{if(r.request==null||typeof r.request=="string"||r.request?.body==null||typeof r.request.body=="string")return[];if(!gOL(r.request.body))return[];let a=[];for(let[o,c]of Object.entries(r.request.body.properties??{})){if(typeof c=="string"||c.style!=="exploded")continue;let f=cD({relativeFilepath:n,definitionFile:i,casingsGenerator:y3,rootApiFile:e.definition.rootApiFile.contents}),u=t.resolveType({type:c.type,file:f});if(u==null)return[];KtS(u)||a.push({message:`${o} is exploded and must be a list. Did you mean list<${c.type}>?`,severity:"error"})}return a}}}}};function KtS(e){return e._type!=="container"?!1:e.container._type==="list"?!0:e.container._type==="optional"||e.container._type==="nullable"?KtS(e.container.itemType):!1}function gOL(e){return e?.properties!=null}var fJ_={name:"import-file-exists",create:({workspace:e})=>{let t=Object.keys(iji(e.definition)),r=new Set;return t.forEach(n=>{let i=Wl(e.definition.absoluteFilePath,nu.of(n));r.add(i)}),{definitionFile:{import:({importedAs:n,importPath:i},{relativeFilepath:a})=>{let o=[],c=Wl(e.definition.absoluteFilePath,Qg(a),nu.of(i));return r.has(c)||o.push({severity:"fatal",message:`Import ${Mf.bold(n)} points to non-existent path ${Mf.bold(i)}.`}),o}}}}};function pjl(e){return e.definition.rootApiFile.contents.environments==null?[]:Object.values(e.definition.rootApiFile.contents.environments).reduce((t,r)=>{if(lit(r))for(let n of Object.keys(r.urls))t.includes(n)||t.push(n);return t},[])}var dJ_={name:"matching-environment-urls",create:({workspace:e})=>{let t=pjl(e);return t.length===0?{}:{rootApiFile:{environment:({environmentId:r,environment:n})=>{let i=[],a=o=>{i.push({severity:"fatal",message:`Environment ${r} is missing URL for ${Mf.bold(o)}`})};return J9r(n,{singleBaseUrl:()=>{for(let o of t)a(o)},multipleBaseUrls:o=>{for(let c of t)o.urls[c]==null&&a(c)}}),i}}}}};var pJ_={name:"no-circular-imports",DISABLE_RULE:!0,create:({workspace:e})=>{let t=mOL(e.definition.namedDefinitionFiles);return{definitionFile:{import:({importPath:r},{relativeFilepath:n})=>{let i=t[n];if(i==null)return[];let a=F5i({referencedIn:n,importPath:nu.of(r)});return i.filter(({chainWithoutStartingFilepath:c})=>c.length===0||c[0]===a).map(c=>({severity:"fatal",message:c.chainWithoutStartingFilepath.length===0?"A file cannot import itself":`Circular import detected: ${[c.startingFilepath,...c.chainWithoutStartingFilepath,c.startingFilepath].join(" -> ")}`}))}}}}};function mOL(e){let t={};for(let r of kTr(e))t[r]=$tS(r,[r],e);return t}function $tS(e,t,r){let n=[],i=r[e];if(i==null)return[];if(i.contents.imports!=null)for(let a of Object.values(i.contents.imports)){let o=F5i({referencedIn:e,importPath:nu.of(a)});t.includes(o)?t[0]===o&&t[0]===OOL(t)&&n.push({startingFilepath:o,chainWithoutStartingFilepath:t.slice(1)}):n.push(...$tS(o,[...t,o],r))}return n}function OOL(e){return e.reduce((t,r)=>r<t?r:t)}var _jl=class{workspace;typeResolver;constructor(t){this.workspace=t,this.typeResolver=new VF(t)}isTypeComplex(t,r){let n=cD({relativeFilepath:r.relativeFilepath,definitionFile:r.contents,casingsGenerator:y3,rootApiFile:this.workspace.definition.rootApiFile.contents}),i=this.typeResolver.resolveType({type:t,file:n});if(i==null)return;let a=new Set;return this.isResolvedReferenceComplex({type:i,file:n,visited:a})}isResolvedReferenceComplex({type:t,file:r,visited:n}){switch(t._type){case"container":return this.isResolvedContainerComplex({type:t.container,file:r,visited:n});case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":return!1;case"unknown":return!1;default:ku(t)}}isResolvedContainerComplex({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return(this.isResolvedReferenceComplex({type:t.keyType,file:r,visited:n})||this.isResolvedReferenceComplex({type:t.valueType,file:r,visited:n}))&&!(t.keyType._type==="primitive"&&t.keyType.primitive.v1==="STRING"&&t.valueType._type==="unknown");case"optional":case"nullable":case"list":case"set":return this.isResolvedReferenceComplex({type:t.itemType,file:r,visited:n});default:ku(t)}}isNamedTypeComplex({type:t,file:r,visited:n}){if(n.has(t.rawName))return!1;if(n.add(t.rawName),M6i(t.declaration))return!0;if(Uqr(t.declaration))return!1;if(DN(t.declaration))return this.objectHasComplexProperties({typeName:t.rawName,objectDeclaration:t.declaration,file:r,visited:n});if(gZa(t.declaration)){for(let i of t.declaration.union){let a=typeof i=="string"?i:i.type,o=this.isTypeComplex(a,{contents:r.definitionFile,relativeFilepath:r.relativeFilepath});if(o!=null&&o)return!0}return!1}ku(t.declaration)}objectHasComplexProperties({typeName:t,objectDeclaration:r,file:n,visited:i}){return Pat({typeName:t,objectDeclaration:r,typeResolver:this.typeResolver,definitionFile:n.definitionFile,workspace:this.workspace,filepathOfDeclaration:n.relativeFilepath,smartCasing:!1}).some(o=>this.isComplex({type:o.resolvedPropertyType,file:n,visited:i}))}isComplex({type:t,file:r,visited:n}){switch(t._type){case"named":return this.isNamedTypeComplex({type:t,file:r,visited:n});case"primitive":case"unknown":return!1;case"container":return this.isComplexContainer({type:t.container,file:r,visited:n});default:ku(t)}}isComplexContainer({type:t,file:r,visited:n}){switch(t._type){case"literal":return!1;case"map":return this.isComplex({type:t.keyType,file:r,visited:n})||this.isComplex({type:t.valueType,file:r,visited:n});case"optional":case"nullable":case"list":case"set":return this.isComplex({type:t.itemType,file:r,visited:n});default:ku(t)}}};var _J_={name:"no-complex-query-params",create:({workspace:e})=>{let t=new _jl(e);return{definitionFile:{queryParameter:({queryParameter:r},n)=>{let i=typeof r=="string"?r:r.type,a=t.isTypeComplex(i,n);return a!=null&&a?[{severity:"fatal",message:`${i} is not a valid type for a query parameter`}]:[]}}}}};var hJ_={name:"no-conflicting-endpoint-parameters",create:()=>({definitionFile:{pathParameter:({pathParameterKey:e})=>e===MJu?[{severity:"fatal",message:`Path parameter ${Mf.bold(e)} is not suitable for code generation, because it can conflict with the request body parameter.`}]:[]}})};function u4s({service:e,endpoint:t}){return e["base-path"]+t.path}var hjl=class{root=new yJ_;registerEndpoint(t){this.root.insert(this.getPathPartsForEndpoint(t),t)}getConflictingEndpoints(t){return this.root.getMatchingEndpoints(this.getPathPartsForEndpoint(t)).filter(r=>!(r.relativeFilepath===t.relativeFilepath&&r.endpointId===t.endpointId)&&r.endpoint.method===t.endpoint.method)}getPathPartsForEndpoint(t){return u4s({service:t.service,endpoint:t.endpoint}).split("/").filter(r=>r.length>0)}},yJ_=class e{childPaths={};childPathParam;endpointsThatEndWithThisNode=[];insert(t,r){let[n,...i]=t;if(n==null){this.endpointsThatEndWithThisNode.push(r);return}(this.isPathParam(n)?this.childPathParam??=new e:this.childPaths[n]??=new e).insert(i,r)}getMatchingEndpoints(t){let[r,...n]=t;if(r==null)return this.endpointsThatEndWithThisNode;let i=[];if(this.isPathParam(r))i.push(...Object.values(this.childPaths).flatMap(a=>a.getMatchingEndpoints(n)));else{let a=this.childPaths[r];a!=null&&i.push(...a.getMatchingEndpoints(n))}return this.childPathParam!=null&&i.push(...this.childPathParam.getMatchingEndpoints(n)),i}isPathParam(t){return t.startsWith("{")&&t.endsWith("}")}};var vJ_={name:"no-conflicting-endpoint-paths",create:({workspace:e})=>{let t=new hjl;return ute(e,(r,n)=>{Nme(n,{httpEndpoint:({service:i,endpointId:a,endpoint:o})=>{t.registerEndpoint({service:i,endpointId:a,endpoint:o,relativeFilepath:r})}})}),{definitionFile:{httpEndpoint:({service:r,endpoint:n,endpointId:i},{relativeFilepath:a})=>{let o=t.getConflictingEndpoints({service:r,endpointId:i,endpoint:n,relativeFilepath:a});return o.length===0?[]:[{severity:"warning",message:[`Endpoint path ${u4s({service:r,endpoint:n})} conflicts with other endpoints:`,...o.map(c=>` - ${c.relativeFilepath} -> ${c.endpointId} ${Mf.dim(u4s({service:c.service,endpoint:c.endpoint}))}`)].join(`
3090
3090
  `)}]}}}}};var bJ_={name:"no-conflicting-request-wrapper-properties",create:({workspace:e})=>({definitionFile:{httpEndpoint:({endpoint:t,service:r},{contents:n,relativeFilepath:i})=>{let a=AOL({endpoint:t,service:r,relativeFilepath:i,definitionFile:n,workspace:e}),o=[];for(let[c,f]of Object.entries(a))f.length<=1||o.push({severity:"fatal",message:`Multiple request properties have the name ${Mf.bold(c)}. This is not suitable for code generation. Use the "name" property to deconflict.
3091
3091
  `+f.map(u=>` - ${POL(u)}`).join(`
3092
3092
  `)});return o}}})};function AOL({endpoint:e,service:t,relativeFilepath:r,definitionFile:n,workspace:i}){let a={},o=(c,f)=>{(a[c]??=[]).push(f)};if(e.request!=null&&typeof e.request!="string"&&e.request.body!=null&&!BU(e.request.body)&&BJu({request:e.request,file:cD({relativeFilepath:r,definitionFile:n,casingsGenerator:y3,rootApiFile:i.definition.rootApiFile.contents}),typeResolver:new VF(i)})&&o(ass,{type:"referenced-body",propertyName:ass}),t.headers!=null)for(let[c,f]of Object.entries(t.headers))o(AGr({headerKey:c,header:f}).name,{type:"service-header",headerKey:c,header:f});if(e.request!=null&&typeof e.request!="string"){if(e.request.headers!=null)for(let[c,f]of Object.entries(e.request.headers))o(AGr({headerKey:c,header:f}).name,{type:"endpoint-header",headerKey:c,header:f});if(e.request["query-parameters"]!=null)for(let[c,f]of Object.entries(e.request["query-parameters"]))o(rEi({queryParameterKey:c,queryParameter:f}).name,{type:"endpoint-query-parameter",queryParameterKey:c,queryParameter:f});if(e.request.body!=null&&BU(e.request.body)){let c=Pat({typeName:void 0,objectDeclaration:{extends:e.request.body.extends,properties:e.request.body.properties??{}},filepathOfDeclaration:r,definitionFile:n,workspace:i,typeResolver:new VF(i),smartCasing:!1});for(let f of c)o(f.name,{type:"inlined-body",property:f})}}return a}function POL(e){switch(e.type){case"service-header":return`Service header "${e.headerKey}"`;case"endpoint-header":return`Endpoint header "${e.headerKey}"`;case"endpoint-query-parameter":return`Query Parameter "${e.queryParameterKey}"`;case"inlined-body":return`Body property: ${Gco({property:e.property,prefixBreadcrumbs:["<Request Body>"]})}`;case"referenced-body":return`Body property "${e.propertyName}"`;default:ku(e)}}var gJ_=Wi(require("path"),1);var mJ_={name:"no-duplicate-declarations",create:({workspace:e,logger:t})=>{let r=wOL(e),n={},i=({declaredName:a,relativeFilepath:o})=>{let c=gJ_.default.dirname(o),f=r[c]?.[a];if(f==null)return t.error(`Could not find declarations for name: ${a}. This is an error in the Fern validator.`),[];let u=n[c]??=new Set;if(!u.has(a))return u.add(a),[];let s=f.indexOf(o);return f.filter((m,A)=>A!==s).map(m=>({severity:"fatal",message:`${a} is already declared in ${m===o?"this file":m}`}))};return{definitionFile:{typeName:(a,{relativeFilepath:o})=>i({declaredName:a,relativeFilepath:o}),errorDeclaration:({errorName:a},{relativeFilepath:o})=>i({declaredName:a,relativeFilepath:o}),httpEndpoint:({endpoint:a},{relativeFilepath:o})=>typeof a.request!="string"&&a.request?.name!=null?i({declaredName:a.request.name,relativeFilepath:o}):[]}}}};function wOL(e){let t={};return ute(e,(r,n)=>{let i=gJ_.default.dirname(r),a=t[i]??={},o=c=>{(a[c]??=[]).push(r)};Nme(n,{typeName:c=>{o(c)},errorDeclaration:({errorName:c})=>{o(c)},httpEndpoint:({endpoint:c})=>{typeof c.request!="string"&&c.request?.name!=null&&o(c.request.name)}})}),t}function c4s(e){let t=new Set,r=new Set,n=[];for(let i of e)t.has(i)&&!r.has(i)&&(r.add(i),n.push(i)),t.add(i);return n}var OJ_={name:"no-duplicate-enum-values",create:()=>({definitionFile:{typeDeclaration:({declaration:e})=>Uqr(e)?c4s(e.enum.map(r=>typeof r=="string"?r:r.value)).map(r=>({severity:"fatal",message:`Duplicated enum value: ${Mf.bold(r)}.`})):[]}})};var AJ_={name:"no-duplicate-example-names",create:()=>({definitionFile:{typeDeclaration:({declaration:e})=>{if(typeof e=="string"||e.examples==null)return[];let t=e.examples.map(r=>r.name).filter(pj);return c4s(t).map(r=>({severity:"fatal",message:`Duplicate example name: ${r}`}))},httpEndpoint:({endpoint:e})=>{if(e.examples==null)return[];let t=e.examples.map(r=>r.name).filter(pj);return c4s(t).map(r=>({severity:"fatal",message:`Duplicate example name: ${r}`}))}}})};function YtS(e){if(!e.isInlined)return e.name;switch(e.location){case"inlinedRequest":return"<Inlined Request>";default:ku(e.location)}}var PJ_={name:"no-duplicate-field-names",create:({workspace:e})=>{let t=new VF(e);return{definitionFile:{typeDeclaration:({typeName:r,declaration:n},{relativeFilepath:i,contents:a})=>{let o=[];return Uee(n,{alias:__t,enum:c=>{let f=XtS(c.enum,u=>Yco(u).name);for(let u of f)o.push({severity:"fatal",message:`Name "${u}" is used by multiple values.`})},object:c=>{let f=YtS(r),u=Pat({typeName:f,objectDeclaration:c,filepathOfDeclaration:i,definitionFile:a,workspace:e,typeResolver:t,smartCasing:!1}),s=sef(u,l=>l.name);for(let[l,m]of Object.entries(s))if(m.length>1){let A=[`Object has multiple properties named "${l}":`,...m.map(P=>` - ${Gco({property:P,prefixBreadcrumbs:[f]})}`)].join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.107.0",
3
+ "version": "0.107.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",