fern-api 0.101.1 → 0.101.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +3 -3
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -2163,7 +2163,7 @@ ${M1y.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&x0f(th
|
|
|
2163
2163
|
`+pla.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?pla.default.cyan(Q1y(t,this.opt.mask)):pla.default.italic(pla.default.dim("[hidden]")):this.opt.mask?Q1y(t,this.opt.mask):pla.default.italic(pla.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 hCs=Gi(lse(),1);var QEy=Gi(gmf(),1),pCs=require("child_process"),Qeo=require("fs"),dCs=Gi(require("path"),1),LEy=Gi(require("os"),1),UEy=require("crypto"),nOf=Gi(xEy(),1);var cCs=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var N$o=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var lCs=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var fCs=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function _Cs(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 zEy(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function zdC(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=zdC(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??LEy.default.tmpdir(),r=(0,UEy.randomUUID)(),n=zEy(this.fileOptions.prefix),i=zEy(this.fileOptions.postfix),a=`${n}${r}${i}`,o=dCs.default.resolve(t,a),c=dCs.default.resolve(t)+dCs.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,Qeo.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new cCs(t)}}readTemporaryFile(){try{let t=(0,Qeo.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,QEy.detect)(t)??"utf8";nOf.default.encodingExists(r)||(r="utf8"),this.text=nOf.default.decode(t,r)}}catch(t){throw new lCs(t)}}removeTemporaryFile(){try{(0,Qeo.unlinkSync)(this.tempFile)}catch(t){throw new fCs(t)}}launchEditor(){try{let t=(0,pCs.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new N$o(t)}}launchEditorAsync(t){try{(0,pCs.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new N$o(r)}}};var VEy=Gi(_it(),1);var F$o=class extends fse{_run(t){this.done=t,this.editorResult=new VEy.Subject;let r=Fbe(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"?hCs.default.dim("Received"):hCs.default.dim("Press <enter> to launch your preferred editor."),t&&(r=hCs.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),_Cs(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 KEy=require("stream");var GEy=Gi(require("readline"),1),JEy=Gi(HEy(),1),vla=class{constructor(t){this.rl||=GEy.default.createInterface(LdC(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 LdC(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 JEy.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var x$o=class extends vla{constructor(t={}){super(t),this.log=new KEy.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return O$o(this.rl,this.bottomBar.split(`
|
|
2164
2164
|
`).length),this}updateBottomBar(t){return O$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&&FDs(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var i6=Gi(_it(),1),XEy=Gi(UKo(),1);var yCs=Gi(_it(),1),$Ey=Gi(UKo(),1),vCs=function(e,t,r){return typeof e[t]!="function"?(0,yCs.of)(e):(0,yCs.from)((0,$Ey.default)(e[t])(r).then(n=>(e[t]=n,e)))};var YEy={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}},Leo=class extends vla{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,i6.from)(t):(0,i6.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,i6.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,i6.from)([t]),this.process=n.pipe((0,i6.concatMap)(this.processQuestion.bind(this)),(0,i6.publish)()),this.process.connect(),this.process.pipe((0,i6.reduce)((i,a)=>(YEy.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,i6.defer)(()=>(0,i6.of)(t).pipe((0,i6.concatMap)(this.setDefaultType.bind(this)),(0,i6.concatMap)(this.filterIfRunnable.bind(this)),(0,i6.concatMap)(()=>vCs(t,"message",this.answers)),(0,i6.concatMap)(()=>vCs(t,"default",this.answers)),(0,i6.concatMap)(()=>vCs(t,"choices",this.answers)),(0,i6.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,i6.defer)(()=>(0,i6.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,i6.defer)(()=>(0,i6.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&YEy.get(this.answers,t.name)!==void 0)return i6.EMPTY;if(t.when===!1)return i6.EMPTY;if(typeof t.when!="function")return(0,i6.of)(t);let{answers:r}=this;return(0,i6.defer)(()=>(0,i6.from)((0,XEy.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,i6.filter)(n=>n!=null)))}};function ZEy(e){let t=function(r,n){let i;try{i=new Leo(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",P$o),this.registerPrompt("input",dla),this.registerPrompt("number",w$o),this.registerPrompt("confirm",j$o),this.registerPrompt("rawlist",E$o),this.registerPrompt("expand",S$o),this.registerPrompt("checkbox",D$o),this.registerPrompt("password",C$o),this.registerPrompt("editor",F$o)},t.restoreDefaultPrompts(),t}var oOf=ZEy();function VdC(e,t){oOf.registerPrompt(e,t)}function WdC(){oOf.restoreDefaultPrompts()}var HdC={prompt:oOf,ui:{BottomBar:x$o,Prompt:Leo},createPromptModule:ZEy,registerPrompt:VdC,restoreDefaultPrompts:WdC,Separator:v3e},bCs=HdC;var eto=require("path"),MDy=require("fs"),BDy=require("readline"),rDy="posthog-node";function bhC(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[xCs.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(A=>({...A,stacktrace:A.stacktrace?{...A.stacktrace,type:"raw",frames:(A.stacktrace.frames||[]).map(P=>({...P,platform:"node:javascript"}))}:void 0})),m={$exception_message:u[0]?.value||a.message,$exception_type:u[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:u[0]?.value||a.message,$sentry_exception_type:u[0]?.type,$sentry_tags:a.tags};return t&&r&&(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 xCs=class{constructor(t,r,n,i){this.name=rDy,this.name=rDy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(bhC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};xCs.POSTHOG_ID_TAG="posthog_distinct_id";var TCs="0123456789abcdef",zCs=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+=TCs.charAt(this.bytes[r]>>>4),t+=TCs.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+=TCs.charAt(this.bytes[r]>>>4),t+=TCs.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}},WOf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??ghC()}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 zCs.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,zCs.ofInner(t)}},ghC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),nDy,HOf=()=>mhC().toString(),mhC=()=>(nDy||(nDy=new WOf)).generate();function OhC(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 AhC(e,t){global.process.on("uncaughtException",OhC(e,t))}function PhC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var qCs,iDy,RCs;function whC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return RCs&&r.length===iDy||(iDy=r.length,RCs=r.reduce((n,i)=>{qCs||(qCs={});let a=qCs[i];if(a)n[a[0]]=a[1];else{let o=e(i);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[i];if(s&&u){n[s]=u,qCs[i]=[s,u];break}}}return n},{})),RCs}function jhC(e){return typeof Event<"u"&&TDy(e,Event)}function EhC(e){return qDy(e,"Object")}function kOf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return TDy(e,Error)}}function TDy(e,t){try{return e instanceof t}catch{return!1}}function ShC(e){return qDy(e,"ErrorEvent")}function qDy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function DhC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=RDy(a,r,n);return{$exception_list:await Promise.all(o.map(async s=>{let u=await RhC(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function RDy(e,t,r){let n=ChC(e,t,r);return n.cause?[n,...RDy(e,n.cause,r)]:[n]}function ChC(e,t,r){if(kOf(t))return t;if(e.synthetic=!0,EhC(t)){let i=IhC(t);if(i)return i;let a=MhC(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 IhC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(kOf(r))return r}}function MhC(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=ThC(e);if(ShC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=BhC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function BhC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function ThC(e,t=40){let r=Object.keys(qhC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return aDy(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:aDy(a,t)}return""}function aDy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function qhC(e){return kOf(e)?{message:e.message,name:e.name,stack:e.stack,...oDy(e)}:jhC(e)?{type:e.type,target:uDy(e.target),currentTarget:uDy(e.currentTarget),...oDy(e)}:e}function oDy(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 uDy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function RhC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=NhC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function NhC(e,t){return FhC(e(t.stack||"",1),e)}function FhC(e,t){let r=whC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var xhC=2e3,Xeo=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await DhC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||HOf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(AhC(this.onException.bind(this),this.onFatalError.bind(this)),PhC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(xhC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function zhC(e=process.argv[1]?(0,eto.dirname)(process.argv[1]):process.cwd(),t=eto.sep==="\\"){let r=t?sDy(e):e;return n=>{if(!n)return;let i=t?sDy(n):n,{dir:a,base:o,ext:c}=eto.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${f}`:f}return f}}function sDy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var QCs=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)}}},FCs=new QCs(25),NDy=new QCs(20),eAf=7,QhC=1e3,LhC=1e4;async function UhC(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"||GhC(o)||JhC(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(NDy.get(i))continue;let a=t[i];if(!a)continue;a.sort((f,s)=>f-s);let o=$hC(a);if(o.every(f=>KhC(i,f)))continue;let c=YhC(FCs,i,{});n.push(VhC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&WhC(e,FCs),FCs.reduce(),e}function VhC(e,t,r){return new Promise(n=>{let i=(0,MDy.createReadStream)(e),a=(0,BDy.createInterface)({input:i});function o(){i.destroy(),n()}let c=0,f=0,s=t[f];if(s===void 0){o();return}let u=s[0],l=s[1];function m(){NDy.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<u)&&(r[c]=XhC(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}u=P[0],l=P[1]}})})}function WhC(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;HhC(r.lineno,r,n)}}function HhC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=FDy(e);i<e;i++){let a=r[i];if(a===void 0){cDy(t);return}t.pre_context.push(a)}if(r[e]===void 0){cDy(t);return}t.context_line=r[e];let n=xDy(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 cDy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function GhC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function JhC(e){return e.lineno!==void 0&&e.lineno>LhC||e.colno!==void 0&&e.colno>QhC}function KhC(e,t){let r=FCs.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 $hC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=lDy(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=lDy(a)),t++}return i}function lDy(e){return[FDy(e),xDy(e)]}function FDy(e){return Math.max(1,e-eAf)}function xDy(e){return e+eAf}function YhC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function XhC(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 ZhC="4.18.0",A3e;(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"})(A3e||(A3e={}));var fDy;(function(e){e.Left="left",e.Right="right",e.Center="center"})(fDy||(fDy={}));var dDy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(dDy||(dDy={}));var pDy;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(pDy||(pDy={}));var _Dy;(function(e){e.Html="html",e.Text="text"})(_Dy||(_Dy={}));var hDy;(function(e){e.Number="number",e.Emoji="emoji"})(hDy||(hDy={}));var yDy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(yDy||(yDy={}));var vDy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(vDy||(vDy={}));var bDy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(bDy||(bDy={}));var gDy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(gDy||(gDy={}));var khC=e=>{if("flags"in e){let t=tyC(e.flags),r=ryC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,zDy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,eyC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function eyC(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 tyC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,tAf(r)]).filter(([,t])=>t!==void 0)),ryC=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?zDy(n):void 0]}))},tAf=e=>e===void 0?void 0:e.variant??e.enabled,zDy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},nyC=1,iyC=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"]),ayC="utf8";function oyC(e,t){if(!e||typeof e!="string"||uyC(e))throw new Error(t)}function uyC(e){return e.trim().length===0}function syC(e){return e?.replace(/\/+$/,"")}async function cyC(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 mDy(){return new Date().getTime()}function UOf(){return new Date().toISOString()}function LCs(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function lyC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function fyC(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 dyC(e,t=0,r){let n=fyC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function ODy(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var K$o=String.fromCharCode,ADy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",NCs={};function pyC(e,t){if(!NCs[e]){NCs[e]={};for(let r=0;r<e.length;r++)NCs[e][e.charAt(r)]=r}return NCs[e][t]}var $eo={compressToBase64:function(e){if(e==null)return"";let t=$eo._compress(e,6,function(r){return ADy.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:$eo._decompress(e.length,32,function(t){return pyC(ADy,e.charAt(t))})},compress:function(e){return $eo._compress(e,16,function(t){return K$o(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],o,c,f="",s="",u="",l=2,m=3,A=2,P=0,C=0,M;for(M=0;M<e.length;M+=1)if(f=e.charAt(M),Object.prototype.hasOwnProperty.call(n,f)||(n[f]=m++,i[f]=!0),s=u+f,Object.prototype.hasOwnProperty.call(n,s))u=s;else{if(Object.prototype.hasOwnProperty.call(i,u)){if(u.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=u.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=u.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[u]}else for(c=n[u],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[s]=m++,u=String(f)}if(u!==""){if(Object.prototype.hasOwnProperty.call(i,u)){if(u.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=u.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=u.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[u]}else for(c=n[u],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:$eo._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,s="",u,l,m,A,P,C,M;for(u=0;u<3;u+=1)n[u]=u;for(m=0,P=Math.pow(2,2),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;M=K$o(m);break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;M=K$o(m);break;case 2:return""}for(n[3]=M,l=M,i.push(M);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,f),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;switch(M=m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=K$o(m),M=c-1,o--;break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)A=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(A>0?1:0)*C,C<<=1;n[c++]=K$o(m),M=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,f),f++),n[M])s=n[M];else if(M===c)s=l+l.charAt(0);else return null;i.push(s),n[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,f),f++)}}},GOf=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)}},Zeo=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()}},$$o=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function PDy(e){if(e instanceof Zeo){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 VOf(e){return typeof e=="object"&&(e instanceof Zeo||e instanceof $$o)}function wDy(e){return typeof e=="object"&&e instanceof Zeo&&e.status===413}var JOf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(JOf||(JOf={}));var KOf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new GOf,this._isInitialized=!1,oyC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=syC(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:VOf},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(A3e.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(A3e.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(A3e.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=HOf();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=dyC(this.apiKey,nyC,iyC)?`${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(s=>s.json()).then(s=>khC(s)).catch(s=>{this._events.emit("error",s)})}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=tAf(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(JOf.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(A3e.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(A3e.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(A3e.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(A3e.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(A3e.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=LCs(()=>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:UOf()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${mDy()}&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($eo.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:UOf(),uuid:n?.uuid?n.uuid:HOf()};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 PDy(t)})}async flush(){let t=ODy([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),ODy([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(A3e.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(A3e.Queue)||[]).slice(i.length);this.setPersistedProperty(A3e.Queue,A),t=A},c={api_key:this.apiKey,batch:a,sent_at:UOf()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${mDy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,u=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent($eo.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:m=>wDy(m)?!1:VOf(m)};try{await this.fetchWithRetry(s,u,l)}catch(m){if(wDy(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 $$o||o(),this._events.emit("error",m),m}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let u=new AbortController;return setTimeout(()=>u.abort(),s),u.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,ayC)}catch{c=new TextEncoder().encode(o).length}return await cyC(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(u){throw new $$o(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new Zeo(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(A3e.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!VOf(i))throw i;await PDy(i)}};return Promise.race([new Promise((i,a)=>{LCs(()=>{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}},$Of=lyC();if(!$Of){let e=tDy();$Of=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 QDy=$Of,UCs=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()}},LDy=new UCs(async()=>{try{return await import("crypto")}catch{return}});async function _yC(){return await LDy.getValue()}var hyC=new UCs(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await LDy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function yyC(){return await hyC.getValue()}async function vyC(e){let t=await _yC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await yyC();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 byC=60*1e3,gyC=1152921504606847e3,myC=["is_not"],Yeo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},dse=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},YOf=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||QDy,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 dse?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 s=await this.computeFlagLocally(f,t,r,n,i);a[f.key]=s;let u=await this.computeFeatureFlagPayloadLocally(f.key,s);u&&(o[f.key]=u)}catch(s){s instanceof dse||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new dse("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 dse("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 s=a[f];return await this.matchFeatureFlagProperties(t,n[f],s)}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((s,u)=>{let l=!!s.variant,m=!!u.variant;return l&&m?0:l?-1:m?1:0});for(let s of f)try{if(await this.isConditionMatch(t,r,s,n)){let u=s.variant,l=i.multivariate?.variants||[];u&&l.some(m=>m.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof dse)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new dse("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,s=!1;if(f==="cohort"?s=VDy(c,i,this.cohorts,this.debugMode):s=UDy(c,i,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await jDy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await jDy(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(byC,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 Yeo(`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 Yeo(`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 Yeo(`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 Yeo&&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=LCs(()=>{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=LCs(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function jDy(e,t,r=""){let n=await vyC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/gyC}function UDy(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 dse("Operator is_not_set is not supported")}else throw new dse(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!myC.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function f(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(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 EDy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return EDy(String(i))&&String(o).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof i=="number"?i:null;if(typeof i=="string")try{s=parseFloat(i)}catch{}return s!=null&&o!=null?typeof o=="string"?f(o,String(i),a):f(o,s,a):f(String(o),String(i),a)}case"is_date_after":case"is_date_before":{let s=OyC(String(i));if(s==null&&(s=SDy(i)),s==null)throw new dse(`Invalid date: ${i}`);let u=SDy(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new dse(`Unknown operator: ${a}`)}}function VDy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new dse("can't match cohort without a given cohort property value");let a=r[i];return WDy(a,t,r,n)}function WDy(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=WDy(c,t,r,n);if(i==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof dse)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new dse("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=VDy(c,t,r,n):f=UDy(c,t);let s=c.negation||!1;if(i==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof dse)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new dse("can't match cohort without a given cohort property value");return i==="AND"}}function EDy(e){try{return new RegExp(e),!0}catch{return!1}}function SDy(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 dse(`${e} is in an invalid date format`)}else throw new dse(`The date provided ${e} must be a string, number, or date object`)}function OyC(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 XOf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},AyC=100,DDy=30*1e3,PyC=50*1e3,ZOf=class extends KOf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new XOf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,AyC):DDy,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 YOf({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 Xeo(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||PyC}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):QDy(t,r)}getLibraryVersion(){return ZhC}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:s}=t,u=A=>{super.captureStateless(r,n,A,{timestamp:c,disableGeoip:f,uuid:s})},l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags,m=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[M,T]of Object.entries(A))P[`$feature/${M}`]=T;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{u({...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:s}=t,u=A=>super.captureStatelessImmediate(r,n,A,{timestamp:c,disableGeoip:f,uuid:s}),l=async(A,P,C)=>(await super.getFeatureFlagsStateless(A,P,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let A={};for(let[P,C]of Object.entries(a||{}))A[P]=String(C);return await this.getAllFlags(r,{groups:A,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(A=>{let P={};if(A)for(let[M,T]of Object.entries(A))P[`$feature/${M}`]=T;let C=Object.keys(A||{}).filter(M=>A?.[M]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(A=>{u({...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=DDy){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:s}=n||{},u=this.addLocalPersonAndGroupProperties(r,i,f,s);f=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,f,s),m=l!==void 0,A,P;if(!m&&!o){let M=await super.getFeatureFlagDetailStateless(t,r,i,f,s,a);if(M===void 0)return;P=M.response,l=tAf(P),A=M?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id:A},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:o}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:s,groupProperties:u}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=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,s,u,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 s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,o,c),u={},l={},m=!0;if(s&&(u=s.response,l=s.payloads,m=s.fallbackToDecide),m&&!a){let A=await super.getFeatureFlagsAndPayloadsStateless(t,n,o,c,i);u={...u,...A.flags||{}},l={...l,...A.payloads||{}}}return{featureFlags:u,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");Xeo.captureException(this,t,{syntheticException:i},r,n)}},CDy=/\(error: (.*)\)/,HDy=50,GDy="?";function wyC(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,s;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,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||GDy,c=f?`${f}.${s}`:s);let u=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&i[5]&&!l&&(u=i[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:IDy(i[3]),colno:IDy(i[4]),in_app:jyC(u||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function jyC(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 IDy(e){return parseInt(e||"",10)||void 0}function EyC(e){return[90,wyC(e)]}function SyC(e){let r=[EyC(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 s=CDy.test(f)?f.replace(CDy,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=HDy)break}}return DyC(a)}}function DyC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,HDy).map(r=>({...r,filename:r.filename||CyC(t).filename,function:r.function||GDy}))}function CyC(e){return e[e.length-1]||{}}Xeo.stackParser=SyC(zhC());Xeo.frameModifiers=[UhC];var keo=class extends ZOf{getLibraryId(){return"posthog-node"}};var VCs=class{posthog;constructor({posthogApiKey:t}){this.posthog=new keo(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.101.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Y$o=class{async sendEvent(){}async identify(){}async flush(){}};var tto=require("fs/promises"),YDy=require("os"),XDy=require("path");var JDy=Gi(require("crypto")),HCs=new Uint8Array(256),WCs=HCs.length;function rAf(){return WCs>HCs.length-16&&(JDy.default.randomFillSync(HCs),WCs=0),HCs.slice(WCs,WCs+=16)}var zbe=[];for(let e=0;e<256;++e)zbe.push((e+256).toString(16).slice(1));function KDy(e,t=0){return zbe[e[t+0]]+zbe[e[t+1]]+zbe[e[t+2]]+zbe[e[t+3]]+"-"+zbe[e[t+4]]+zbe[e[t+5]]+"-"+zbe[e[t+6]]+zbe[e[t+7]]+"-"+zbe[e[t+8]]+zbe[e[t+9]]+"-"+zbe[e[t+10]]+zbe[e[t+11]]+zbe[e[t+12]]+zbe[e[t+13]]+zbe[e[t+14]]+zbe[e[t+15]]}var $Dy=Gi(require("crypto")),nAf={randomUUID:$Dy.default.randomUUID};function IyC(e,t,r){if(nAf.randomUUID&&!t&&!e)return nAf.randomUUID();e=e||{};let n=e.random||(e.rng||rAf)();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 KDy(n)}var yit=IyC;var MyC="id",ByC=".fern",X$o=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new keo(r),this.userId=t==null?void 0:Ohf(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.101.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=kl(L_.of((0,YDy.homedir)()),ds.of(ByC),ds.of(MyC));await Qv(t)||(await(0,tto.mkdir)((0,XDy.dirname)(t),{recursive:!0}),await(0,tto.writeFile)(t,yit())),this.persistedDistinctId=(await(0,tto.readFile)(t)).toString()}return this.persistedDistinctId}};var iAf;async function rto(){return iAf==null&&(iAf=await TyC()),iAf}async function TyC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Y$o;let r=await nws();return r!=null?new X$o({token:r,posthogApiKey:e}):await rka()!=null?new VCs({posthogApiKey:e}):new X$o({token:void 0,posthogApiKey:e})}catch{return new Y$o}}function Z$o(e,t){return function(){return e.apply(t,arguments)}}var{toString:qyC}=Object.prototype,{getPrototypeOf:oAf}=Object,{iterator:JCs,toStringTag:kDy}=Symbol,KCs=(e=>t=>{let r=qyC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),oRr=e=>(e=e.toLowerCase(),t=>KCs(t)===e),$Cs=e=>t=>typeof t===e,{isArray:ito}=Array,nto=$Cs("undefined");function k$o(e){return e!==null&&!nto(e)&&e.constructor!==null&&!nto(e.constructor)&&P3e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var eCy=oRr("ArrayBuffer");function RyC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&eCy(e.buffer),t}var NyC=$Cs("string"),P3e=$Cs("function"),tCy=$Cs("number"),eYo=e=>e!==null&&typeof e=="object",FyC=e=>e===!0||e===!1,GCs=e=>{if(KCs(e)!=="object")return!1;let t=oAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(kDy in e)&&!(JCs in e)},xyC=e=>{if(!eYo(e)||k$o(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},zyC=oRr("Date"),QyC=oRr("File"),LyC=oRr("Blob"),UyC=oRr("FileList"),VyC=e=>eYo(e)&&P3e(e.pipe),WyC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||P3e(e.append)&&((t=KCs(e))==="formdata"||t==="object"&&P3e(e.toString)&&e.toString()==="[object FormData]"))},HyC=oRr("URLSearchParams"),[GyC,JyC,KyC,$yC]=["ReadableStream","Request","Response","Headers"].map(oRr),YyC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function tYo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),ito(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(k$o(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function rCy(e,t){if(k$o(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Pla=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,nCy=e=>!nto(e)&&e!==Pla;function aAf(){let{caseless:e,skipUndefined:t}=nCy(this)&&this||{},r={},n=(i,a)=>{let o=e&&rCy(r,a)||a;GCs(r[o])&&GCs(i)?r[o]=aAf(r[o],i):GCs(i)?r[o]=aAf({},i):ito(i)?r[o]=i.slice():(!t||!nto(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&tYo(arguments[i],n);return r}var XyC=(e,t,r,{allOwnKeys:n}={})=>(tYo(t,(i,a)=>{r&&P3e(i)?e[a]=Z$o(i,r):e[a]=i},{allOwnKeys:n}),e),ZyC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),kyC=(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)},evC=(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&&oAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},tvC=(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},rvC=e=>{if(!e)return null;if(ito(e))return e;let t=e.length;if(!tCy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},nvC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&oAf(Uint8Array)),ivC=(e,t)=>{let n=(e&&e[JCs]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},avC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},ovC=oRr("HTMLFormElement"),uvC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),ZDy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),svC=oRr("RegExp"),iCy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};tYo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},cvC=e=>{iCy(e,(t,r)=>{if(P3e(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(P3e(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+"'")})}})},lvC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return ito(e)?n(e):n(String(e).split(t)),r},fvC=()=>{},dvC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pvC(e){return!!(e&&P3e(e.append)&&e[kDy]==="FormData"&&e[JCs])}var _vC=e=>{let t=new Array(10),r=(n,i)=>{if(eYo(n)){if(t.indexOf(n)>=0)return;if(k$o(n))return n;if(!("toJSON"in n)){t[i]=n;let a=ito(n)?[]:{};return tYo(n,(o,c)=>{let f=r(o,i+1);!nto(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},hvC=oRr("AsyncFunction"),yvC=e=>e&&(eYo(e)||P3e(e))&&P3e(e.then)&&P3e(e.catch),aCy=((e,t)=>e?setImmediate:t?((r,n)=>(Pla.addEventListener("message",({source:i,data:a})=>{i===Pla&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Pla.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",P3e(Pla.postMessage)),vvC=typeof queueMicrotask<"u"?queueMicrotask.bind(Pla):typeof process<"u"&&process.nextTick||aCy,bvC=e=>e!=null&&P3e(e[JCs]),Zf={isArray:ito,isArrayBuffer:eCy,isBuffer:k$o,isFormData:WyC,isArrayBufferView:RyC,isString:NyC,isNumber:tCy,isBoolean:FyC,isObject:eYo,isPlainObject:GCs,isEmptyObject:xyC,isReadableStream:GyC,isRequest:JyC,isResponse:KyC,isHeaders:$yC,isUndefined:nto,isDate:zyC,isFile:QyC,isBlob:LyC,isRegExp:svC,isFunction:P3e,isStream:VyC,isURLSearchParams:HyC,isTypedArray:nvC,isFileList:UyC,forEach:tYo,merge:aAf,extend:XyC,trim:YyC,stripBOM:ZyC,inherits:kyC,toFlatObject:evC,kindOf:KCs,kindOfTest:oRr,endsWith:tvC,toArray:rvC,forEachEntry:ivC,matchAll:avC,isHTMLForm:ovC,hasOwnProperty:ZDy,hasOwnProp:ZDy,reduceDescriptors:iCy,freezeMethods:cvC,toObjectSet:lvC,toCamelCase:uvC,noop:fvC,toFiniteNumber:dvC,findKey:rCy,global:Pla,isContextDefined:nCy,isSpecCompliantForm:pvC,toJSONObject:_vC,isAsyncFn:hvC,isThenable:yvC,setImmediate:aCy,asap:vvC,isIterable:bvC};function ato(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(ato,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 oCy=ato.prototype,uCy={};["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=>{uCy[e]={value:e}});Object.defineProperties(ato,uCy);Object.defineProperty(oCy,"isAxiosError",{value:!0});ato.from=(e,t,r,n,i,a)=>{let o=Object.create(oCy);Zf.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return ato.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=ato;var sCy=Gi(oca(),1),YCs=sCy.default;function uAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function lCy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function cCy(e,t,r){return e?e.concat(t).map(function(i,a){return i=lCy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function gvC(e){return Zf.isArray(e)&&!e.some(uAf)}var mvC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function OvC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(YCs||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Zf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||u,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 s(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 u(P,C,M){let T=P;if(P&&!M&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&gvC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=lCy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?cCy([C],q,a):o===null?C:C+"[]",s(U))}),!1}return uAf(P)?!0:(t.append(cCy(M,C,a),s(P)),!1)}let l=[],m=Object.assign(mvC,{defaultVisitor:u,convertValue:s,isVisitable:uAf});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 X7i=OvC;function fCy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function dCy(e,t){this._pairs=[],e&&X7i(e,this,t)}var pCy=dCy.prototype;pCy.append=function(t,r){this._pairs.push([t,r])};pCy.toString=function(t){let r=t?function(n){return t.call(this,n,fCy)}:fCy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var _Cy=dCy;function AvC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function wla(e,t,r){if(!t)return e;let n=r&&r.encode||AvC;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 _Cy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var sAf=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)})}},cAf=sAf;var oto={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var bCy=Gi(require("crypto"),1);var hCy=Gi(require("url"),1),yCy=hCy.default.URLSearchParams;var lAf="abcdefghijklmnopqrstuvwxyz",vCy="0123456789",gCy={DIGIT:vCy,ALPHA:lAf,ALPHA_DIGIT:lAf+lAf.toUpperCase()+vCy},PvC=(e=16,t=gCy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);bCy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},mCy={isNode:!0,classes:{URLSearchParams:yCy,FormData:YCs,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:gCy,generateString:PvC,protocols:["http","https","file","data"]};var pAf={};yf(pAf,{hasBrowserEnv:()=>dAf,hasStandardBrowserEnv:()=>wvC,hasStandardBrowserWebWorkerEnv:()=>jvC,navigator:()=>fAf,origin:()=>EvC});var dAf=typeof window<"u"&&typeof document<"u",fAf=typeof navigator=="object"&&navigator||void 0,wvC=dAf&&(!fAf||["ReactNative","NativeScript","NS"].indexOf(fAf.product)<0),jvC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",EvC=dAf&&window.location.href||"http://localhost";var n8={...pAf,...mCy};function _Af(e,t){return X7i(e,new n8.classes.URLSearchParams,{visitor:function(r,n,i,a){return n8.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function SvC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function DvC(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 CvC(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]=DvC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(SvC(n),i,r,0)}),r}return null}var XCs=CvC;function IvC(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 hAf={transitional:oto,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(XCs(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 _Af(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return X7i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),IvC(t)):t}],transformResponse:[function(t){let r=this.transitional||hAf.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:n8.classes.FormData,Blob:n8.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=>{hAf.headers[e]={}});var uto=hAf;var MvC=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"]),OCy=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 s=CDy.test(f)?f.replace(CDy,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=HDy)break}}return DyC(a)}}function DyC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,HDy).map(r=>({...r,filename:r.filename||CyC(t).filename,function:r.function||GDy}))}function CyC(e){return e[e.length-1]||{}}Xeo.stackParser=SyC(zhC());Xeo.frameModifiers=[UhC];var keo=class extends ZOf{getLibraryId(){return"posthog-node"}};var VCs=class{posthog;constructor({posthogApiKey:t}){this.posthog=new keo(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.101.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Y$o=class{async sendEvent(){}async identify(){}async flush(){}};var tto=require("fs/promises"),YDy=require("os"),XDy=require("path");var JDy=Gi(require("crypto")),HCs=new Uint8Array(256),WCs=HCs.length;function rAf(){return WCs>HCs.length-16&&(JDy.default.randomFillSync(HCs),WCs=0),HCs.slice(WCs,WCs+=16)}var zbe=[];for(let e=0;e<256;++e)zbe.push((e+256).toString(16).slice(1));function KDy(e,t=0){return zbe[e[t+0]]+zbe[e[t+1]]+zbe[e[t+2]]+zbe[e[t+3]]+"-"+zbe[e[t+4]]+zbe[e[t+5]]+"-"+zbe[e[t+6]]+zbe[e[t+7]]+"-"+zbe[e[t+8]]+zbe[e[t+9]]+"-"+zbe[e[t+10]]+zbe[e[t+11]]+zbe[e[t+12]]+zbe[e[t+13]]+zbe[e[t+14]]+zbe[e[t+15]]}var $Dy=Gi(require("crypto")),nAf={randomUUID:$Dy.default.randomUUID};function IyC(e,t,r){if(nAf.randomUUID&&!t&&!e)return nAf.randomUUID();e=e||{};let n=e.random||(e.rng||rAf)();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 KDy(n)}var yit=IyC;var MyC="id",ByC=".fern",X$o=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new keo(r),this.userId=t==null?void 0:Ohf(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.101.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=kl(L_.of((0,YDy.homedir)()),ds.of(ByC),ds.of(MyC));await Qv(t)||(await(0,tto.mkdir)((0,XDy.dirname)(t),{recursive:!0}),await(0,tto.writeFile)(t,yit())),this.persistedDistinctId=(await(0,tto.readFile)(t)).toString()}return this.persistedDistinctId}};var iAf;async function rto(){return iAf==null&&(iAf=await TyC()),iAf}async function TyC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Y$o;let r=await nws();return r!=null?new X$o({token:r,posthogApiKey:e}):await rka()!=null?new VCs({posthogApiKey:e}):new X$o({token:void 0,posthogApiKey:e})}catch{return new Y$o}}function Z$o(e,t){return function(){return e.apply(t,arguments)}}var{toString:qyC}=Object.prototype,{getPrototypeOf:oAf}=Object,{iterator:JCs,toStringTag:kDy}=Symbol,KCs=(e=>t=>{let r=qyC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),oRr=e=>(e=e.toLowerCase(),t=>KCs(t)===e),$Cs=e=>t=>typeof t===e,{isArray:ito}=Array,nto=$Cs("undefined");function k$o(e){return e!==null&&!nto(e)&&e.constructor!==null&&!nto(e.constructor)&&P3e(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var eCy=oRr("ArrayBuffer");function RyC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&eCy(e.buffer),t}var NyC=$Cs("string"),P3e=$Cs("function"),tCy=$Cs("number"),eYo=e=>e!==null&&typeof e=="object",FyC=e=>e===!0||e===!1,GCs=e=>{if(KCs(e)!=="object")return!1;let t=oAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(kDy in e)&&!(JCs in e)},xyC=e=>{if(!eYo(e)||k$o(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},zyC=oRr("Date"),QyC=oRr("File"),LyC=oRr("Blob"),UyC=oRr("FileList"),VyC=e=>eYo(e)&&P3e(e.pipe),WyC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||P3e(e.append)&&((t=KCs(e))==="formdata"||t==="object"&&P3e(e.toString)&&e.toString()==="[object FormData]"))},HyC=oRr("URLSearchParams"),[GyC,JyC,KyC,$yC]=["ReadableStream","Request","Response","Headers"].map(oRr),YyC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function tYo(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),ito(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(k$o(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function rCy(e,t){if(k$o(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Pla=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,nCy=e=>!nto(e)&&e!==Pla;function aAf(){let{caseless:e,skipUndefined:t}=nCy(this)&&this||{},r={},n=(i,a)=>{let o=e&&rCy(r,a)||a;GCs(r[o])&&GCs(i)?r[o]=aAf(r[o],i):GCs(i)?r[o]=aAf({},i):ito(i)?r[o]=i.slice():(!t||!nto(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&tYo(arguments[i],n);return r}var XyC=(e,t,r,{allOwnKeys:n}={})=>(tYo(t,(i,a)=>{r&&P3e(i)?e[a]=Z$o(i,r):e[a]=i},{allOwnKeys:n}),e),ZyC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),kyC=(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)},evC=(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&&oAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},tvC=(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},rvC=e=>{if(!e)return null;if(ito(e))return e;let t=e.length;if(!tCy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},nvC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&oAf(Uint8Array)),ivC=(e,t)=>{let n=(e&&e[JCs]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},avC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},ovC=oRr("HTMLFormElement"),uvC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),ZDy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),svC=oRr("RegExp"),iCy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};tYo(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},cvC=e=>{iCy(e,(t,r)=>{if(P3e(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(P3e(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+"'")})}})},lvC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return ito(e)?n(e):n(String(e).split(t)),r},fvC=()=>{},dvC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function pvC(e){return!!(e&&P3e(e.append)&&e[kDy]==="FormData"&&e[JCs])}var _vC=e=>{let t=new Array(10),r=(n,i)=>{if(eYo(n)){if(t.indexOf(n)>=0)return;if(k$o(n))return n;if(!("toJSON"in n)){t[i]=n;let a=ito(n)?[]:{};return tYo(n,(o,c)=>{let f=r(o,i+1);!nto(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},hvC=oRr("AsyncFunction"),yvC=e=>e&&(eYo(e)||P3e(e))&&P3e(e.then)&&P3e(e.catch),aCy=((e,t)=>e?setImmediate:t?((r,n)=>(Pla.addEventListener("message",({source:i,data:a})=>{i===Pla&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Pla.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",P3e(Pla.postMessage)),vvC=typeof queueMicrotask<"u"?queueMicrotask.bind(Pla):typeof process<"u"&&process.nextTick||aCy,bvC=e=>e!=null&&P3e(e[JCs]),Zf={isArray:ito,isArrayBuffer:eCy,isBuffer:k$o,isFormData:WyC,isArrayBufferView:RyC,isString:NyC,isNumber:tCy,isBoolean:FyC,isObject:eYo,isPlainObject:GCs,isEmptyObject:xyC,isReadableStream:GyC,isRequest:JyC,isResponse:KyC,isHeaders:$yC,isUndefined:nto,isDate:zyC,isFile:QyC,isBlob:LyC,isRegExp:svC,isFunction:P3e,isStream:VyC,isURLSearchParams:HyC,isTypedArray:nvC,isFileList:UyC,forEach:tYo,merge:aAf,extend:XyC,trim:YyC,stripBOM:ZyC,inherits:kyC,toFlatObject:evC,kindOf:KCs,kindOfTest:oRr,endsWith:tvC,toArray:rvC,forEachEntry:ivC,matchAll:avC,isHTMLForm:ovC,hasOwnProperty:ZDy,hasOwnProp:ZDy,reduceDescriptors:iCy,freezeMethods:cvC,toObjectSet:lvC,toCamelCase:uvC,noop:fvC,toFiniteNumber:dvC,findKey:rCy,global:Pla,isContextDefined:nCy,isSpecCompliantForm:pvC,toJSONObject:_vC,isAsyncFn:hvC,isThenable:yvC,setImmediate:aCy,asap:vvC,isIterable:bvC};function ato(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(ato,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 oCy=ato.prototype,uCy={};["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=>{uCy[e]={value:e}});Object.defineProperties(ato,uCy);Object.defineProperty(oCy,"isAxiosError",{value:!0});ato.from=(e,t,r,n,i,a)=>{let o=Object.create(oCy);Zf.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return ato.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=ato;var sCy=Gi(oca(),1),YCs=sCy.default;function uAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function lCy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function cCy(e,t,r){return e?e.concat(t).map(function(i,a){return i=lCy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function gvC(e){return Zf.isArray(e)&&!e.some(uAf)}var mvC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function OvC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(YCs||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,M){return!Zf.isUndefined(M[C])});let n=r.metaTokens,i=r.visitor||u,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 s(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 u(P,C,M){let T=P;if(P&&!M&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&gvC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=lCy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?cCy([C],q,a):o===null?C:C+"[]",s(U))}),!1}return uAf(P)?!0:(t.append(cCy(M,C,a),s(P)),!1)}let l=[],m=Object.assign(mvC,{defaultVisitor:u,convertValue:s,isVisitable:uAf});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 X7i=OvC;function fCy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function dCy(e,t){this._pairs=[],e&&X7i(e,this,t)}var pCy=dCy.prototype;pCy.append=function(t,r){this._pairs.push([t,r])};pCy.toString=function(t){let r=t?function(n){return t.call(this,n,fCy)}:fCy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var _Cy=dCy;function AvC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function wla(e,t,r){if(!t)return e;let n=r&&r.encode||AvC;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 _Cy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var sAf=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)})}},cAf=sAf;var oto={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var bCy=Gi(require("crypto"),1);var hCy=Gi(require("url"),1),yCy=hCy.default.URLSearchParams;var lAf="abcdefghijklmnopqrstuvwxyz",vCy="0123456789",gCy={DIGIT:vCy,ALPHA:lAf,ALPHA_DIGIT:lAf+lAf.toUpperCase()+vCy},PvC=(e=16,t=gCy.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);bCy.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},mCy={isNode:!0,classes:{URLSearchParams:yCy,FormData:YCs,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:gCy,generateString:PvC,protocols:["http","https","file","data"]};var pAf={};yf(pAf,{hasBrowserEnv:()=>dAf,hasStandardBrowserEnv:()=>wvC,hasStandardBrowserWebWorkerEnv:()=>jvC,navigator:()=>fAf,origin:()=>EvC});var dAf=typeof window<"u"&&typeof document<"u",fAf=typeof navigator=="object"&&navigator||void 0,wvC=dAf&&(!fAf||["ReactNative","NativeScript","NS"].indexOf(fAf.product)<0),jvC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",EvC=dAf&&window.location.href||"http://localhost";var n8={...pAf,...mCy};function _Af(e,t){return X7i(e,new n8.classes.URLSearchParams,{visitor:function(r,n,i,a){return n8.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function SvC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function DvC(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 CvC(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]=DvC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(SvC(n),i,r,0)}),r}return null}var XCs=CvC;function IvC(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 hAf={transitional:oto,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(XCs(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 _Af(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return X7i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),IvC(t)):t}],transformResponse:[function(t){let r=this.transitional||hAf.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:n8.classes.FormData,Blob:n8.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=>{hAf.headers[e]={}});var uto=hAf;var MvC=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"]),OCy=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]&&MvC[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var ACy=Symbol("internals");function rYo(e){return e&&String(e).trim().toLowerCase()}function ZCs(e){return e===!1||e==null?e:Zf.isArray(e)?e.map(ZCs):String(e)}function BvC(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 TvC=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function yAf(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 qvC(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function RvC(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 sto=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,f,s){let u=rYo(f);if(!u)throw new Error("header name must be a non-empty string");let l=Zf.findKey(i,u);(!l||i[l]===void 0||s===!0||s===void 0&&i[l]!==!1)&&(i[l||f]=ZCs(c))}let o=(c,f)=>Zf.forEach(c,(s,u)=>a(s,u,f));if(Zf.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(Zf.isString(t)&&(t=t.trim())&&!TvC(t))o(OCy(t),r);else if(Zf.isObject(t)&&Zf.isIterable(t)){let c={},f,s;for(let u of t){if(!Zf.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(f=c[s])?Zf.isArray(f)?[...f,u[1]]:[f,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=rYo(t),t){let n=Zf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return BvC(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=rYo(t),t){let n=Zf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||yAf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=rYo(o),o){let c=Zf.findKey(n,o);c&&(!r||yAf(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||yAf(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]=ZCs(i),delete r[a];return}let c=t?qvC(a):String(a).trim();c!==a&&delete r[a],r[c]=ZCs(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[ACy]=this[ACy]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=rYo(o);n[c]||(RvC(i,o),n[c]=!0)}return Zf.isArray(t)?t.forEach(a):a(t),this}};sto.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Zf.reduceDescriptors(sto.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Zf.freezeMethods(sto);var J$=sto;function nYo(e,t){let r=this||uto,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 iYo(e){return!!(e&&e.__CANCEL__)}function PCy(e,t,r){xm.call(this,e??"canceled",xm.ERR_CANCELED,t,r),this.name="CanceledError"}Zf.inherits(PCy,xm,{__CANCEL__:!0});var vit=PCy;function NVr(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 bAf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function jla(e,t,r){let n=!vAf(t);return e&&(n||r==!1)?bAf(e,t):t}var zCy=Gi(gCs(),1),QCy=Gi(require("http"),1),LCy=Gi(require("https"),1),UCy=Gi(require("util"),1),VCy=Gi(gOf(),1),TPi=Gi(require("zlib"),1);var Ela="1.12.2";function aYo(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var NvC=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function gAf(e,t,r){let n=r&&r.Blob||n8.classes.Blob,i=aYo(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=NvC.exec(e);if(!a)throw new xm("Invalid URL",xm.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],s=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([s],{type:o})}return s}throw new xm("Unsupported protocol "+i,xm.ERR_NOT_SUPPORT)}var Dla=Gi(require("stream"),1);var wCy=Gi(require("stream"),1);var mAf=Symbol("internals"),OAf=class extends wCy.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[mAf]={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[mAf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[mAf],a=i.maxRate,o=this.readableHighWaterMark,c=i.timeWindow,f=1e3/c,s=a/f,u=i.minChunkSize!==!1?Math.max(i.minChunkSize,s*.01):0,l=(A,P)=>{let C=Buffer.byteLength(A);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(A)?process.nextTick(P):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(P)}},m=(A,P)=>{let C=Buffer.byteLength(A),M=null,T=o,z,U=0;if(a){let q=Date.now();(!i.ts||(U=q-i.ts)>=c)&&(i.ts=q,z=s-i.bytes,i.bytes=z<0?-z:0,U=0),z=s-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,A)},c-U);z<T&&(T=z)}T&&C>T&&C-T>u&&(M=A.subarray(T),A=A.subarray(0,T)),l(A,M?()=>{process.nextTick(P,null,M)}:P)};m(t,function A(P,C){if(P)return n(P);C?m(C,A):n(null)})}},AAf=OAf;var WCy=require("events");var ECy=Gi(require("util"),1),SCy=require("stream");var{asyncIterator:jCy}=Symbol,FvC=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[jCy]?yield*e[jCy]():yield e},kCs=FvC;var xvC=n8.ALPHABET.ALPHA_DIGIT+"-_",oYo=typeof TextEncoder=="function"?new TextEncoder:new ECy.default.TextEncoder,Sla=`\r
|
|
2169
2169
|
`,zvC=oYo.encode(Sla),QvC=2,PAf=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)}"`:""}${Sla}`;i?r=oYo.encode(String(r).replace(/\r?\n|\r\n?/g,Sla)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Sla}`,this.headers=oYo.encode(a+Sla),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+QvC,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Zf.isTypedArray(t)?yield t:yield*kCs(t),yield zvC}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},LvC=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+n8.generateString(i,xvC)}=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=oYo.encode("--"+a+Sla),c=oYo.encode("--"+a+"--"+Sla),f=c.byteLength,s=Array.from(e.entries()).map(([l,m])=>{let A=new PAf(l,m);return f+=A.size,A});f+=o.byteLength*s.length,f=Zf.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(u["Content-Length"]=f),t&&t(u),SCy.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},DCy=LvC;var CCy=Gi(require("stream"),1),wAf=class extends CCy.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)}},ICy=wAf;var UvC=(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,MCy=UvC;function VvC(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 s=Date.now(),u=n[a];o||(o=s),r[i]=f,n[i]=s;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),s-o<t)return;let A=u&&s-u;return A?Math.round(m*1e3/A):void 0}}var BCy=VvC;function WvC(e,t){let r=0,n=1e3/t,i,a,o=(s,u=Date.now())=>{r=u,i=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=n?o(s,u):(i=s,a||(a=setTimeout(()=>{a=null,o(i)},n-l)))},()=>i&&o(i)]}var TCy=WvC;var BPi=(e,t,r=3)=>{let n=0,i=BCy(50,250);return TCy(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-n,s=i(f),u=o<=c;n=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},cto=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},lto=e=>(...t)=>Zf.asap(()=>e(...t));function jAf(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,s=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--):s(f)&&(c++,f-=3)),c===1&&f>=0&&(n.charCodeAt(f)===61||s(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var qCy={flush:TPi.default.constants.Z_SYNC_FLUSH,finishFlush:TPi.default.constants.Z_SYNC_FLUSH},HvC={flush:TPi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:TPi.default.constants.BROTLI_OPERATION_FLUSH},RCy=Zf.isFunction(TPi.default.createBrotliDecompress),{http:GvC,https:JvC}=VCy.default,KvC=/https:?/,NCy=n8.protocols.map(e=>e+":"),FCy=(e,[t,r])=>(e.on("end",r).on("error",r),t);function $vC(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function HCy(e,t,r){let n=t;if(!n&&n!==!1){let i=zCy.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){HCy(a,t,a.href)}}var YvC=typeof process<"u"&&Zf.kindOf(process)==="process",XvC=e=>new Promise((t,r)=>{let n,i,a=(f,s)=>{i||(i=!0,n&&n(f,s))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>n=f).catch(c)}),ZvC=({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)}},xCy=(e,t)=>ZvC(Zf.isObject(e)?e:{address:e,family:t}),GCy=YvC&&function(t){return XvC(async function(n,i,a){let{data:o,lookup:c,family:f}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),m,A=!1,P;if(c){let Se=MCy(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=>xCy(Ft)):[xCy($t,rt)];bt.all?ze(Me,nr):ze(Me,nr[0].address,nr[0].family)})}}let C=new WCy.EventEmitter,M=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Se,jt)=>{m=!0,jt&&(A=!0,M())});function T(Se){C.emit("abort",!Se||Se.type?new vit(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=jla(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,n8.hasBrowserEnv?n8.origin:void 0),q=U.protocol||NCy[0];if(q==="data:"){if(t.maxContentLength>-1){let jt=String(t.url||z||"");if(jAf(jt)>t.maxContentLength)return i(new xm("maxContentLength size of "+t.maxContentLength+" exceeded",xm.ERR_BAD_RESPONSE,t))}let Se;if(l!=="GET")return NVr(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=gAf(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(jt){throw xm.from(jt,xm.ERR_BAD_REQUEST,t)}return s==="text"?(Se=Se.toString(u),(!u||u==="utf8")&&(Se=Zf.stripBOM(Se))):s==="stream"&&(Se=Dla.default.Readable.from(Se)),NVr(n,i,{data:Se,status:200,statusText:"OK",headers:new J$,config:t})}if(NCy.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/"+Ela,!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=DCy(o,jt=>{V.set(jt)},{tag:`axios-${Ela}-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 UCy.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=Dla.default.Readable.from(kCs(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 Oe=Zf.toFiniteNumber(V.getContentLength());Zf.isArray(X)?(k=X[0],ne=X[1]):k=ne=X,o&&($||k)&&(Zf.isStream(o)||(o=Dla.default.Readable.from(o,{objectMode:!1})),o=Dla.default.pipeline([o,new AAf({maxRate:Zf.toFiniteNumber(k)})],Zf.noop),$&&o.on("progress",FCy(o,cto(Oe,BPi(lto($),!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 me;try{me=wla(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"+(RCy?", br":""),!1);let be={path:me,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:ve,protocol:q,family:f,beforeRedirect:$vC,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,HCy(be,t.proxy,q+"//"+U.hostname+(U.port?":"+U.port:"")+be.path));let Ie,Be=KvC.test(be.protocol);if(be.agent=Be?t.httpsAgent:t.httpAgent,t.transport?Ie=t.transport:t.maxRedirects===0?Ie=Be?LCy.default:QCy.default:(t.maxRedirects&&(be.maxRedirects=t.maxRedirects),t.beforeRedirect&&(be.beforeRedirects.config=t.beforeRedirect),Ie=Be?JvC:GvC),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 AAf({maxRate:Zf.toFiniteNumber(ne)});re&&Ft.on("progress",FCy(Ft,cto(ze,BPi(lto(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(TPi.default.createUnzip(qCy)),delete jt.headers["content-encoding"];break;case"deflate":bt.push(new ICy),bt.push(TPi.default.createUnzip(qCy)),delete jt.headers["content-encoding"];break;case"br":RCy&&(bt.push(TPi.default.createBrotliDecompress(HvC)),delete jt.headers["content-encoding"])}Me=bt.length>1?Dla.default.pipeline(bt,Zf.noop):bt[0];let rt=Dla.default.finished(Me,()=>{rt(),M()}),nr={status:jt.statusCode,statusText:jt.statusMessage,headers:new J$(jt.headers),config:t,request:$t};if(s==="stream")nr.data=Me,NVr(n,i,nr);else{let Ft=[],Xe=0;Me.on("data",function(ur){Ft.push(ur),Xe+=ur.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 ur=new xm("stream has been aborted",xm.ERR_BAD_RESPONSE,t,$t);Me.destroy(ur),i(ur)}),Me.on("error",function(ur){P.destroyed||i(xm.from(ur,null,t,$t))}),Me.on("end",function(){try{let ur=Ft.length===1?Ft[0]:Buffer.concat(Ft);s!=="arraybuffer"&&(ur=ur.toString(u),(!u||u==="utf8")&&(ur=Zf.stripBOM(ur))),nr.data=ur}catch(ur){return i(xm.from(ur,null,t,nr.request,nr))}NVr(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||oto;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 vit("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var JCy=n8.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,n8.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(n8.origin),n8.navigator&&/(msie|trident)/i.test(n8.navigator.userAgent)):()=>!0;var KCy=n8.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 $Cy=e=>e instanceof J$?{...e}:e;function uRr(e,t){t=t||{};let r={};function n(s,u,l,m){return Zf.isPlainObject(s)&&Zf.isPlainObject(u)?Zf.merge.call({caseless:m},s,u):Zf.isPlainObject(u)?Zf.merge({},u):Zf.isArray(u)?u.slice():u}function i(s,u,l,m){if(Zf.isUndefined(u)){if(!Zf.isUndefined(s))return n(void 0,s,l,m)}else return n(s,u,l,m)}function a(s,u){if(!Zf.isUndefined(u))return n(void 0,u)}function o(s,u){if(Zf.isUndefined(u)){if(!Zf.isUndefined(s))return n(void 0,s)}else return n(void 0,u)}function c(s,u,l){if(l in t)return n(s,u);if(l in e)return n(void 0,s)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>i($Cy(s),$Cy(u),l,!0)};return Zf.forEach(Object.keys({...e,...t}),function(u){let l=f[u]||i,m=l(e[u],t[u],u);Zf.isUndefined(m)&&l!==c||(r[u]=m)}),r}var eIs=e=>{let t=uRr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=J$.from(o),t.url=wla(jla(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(n8.hasStandardBrowserEnv||n8.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Zf.isFunction(r.getHeaders)){let f=r.getHeaders(),s=["content-type","content-length"];Object.entries(f).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(n8.hasStandardBrowserEnv&&(n&&Zf.isFunction(n)&&(n=n(t)),n||n!==!1&&JCy(t.url))){let f=i&&a&&KCy.read(a);f&&o.set(i,f)}return t};var kvC=typeof XMLHttpRequest<"u",YCy=kvC&&function(e){return new Promise(function(r,n){let i=eIs(e),a=i.data,o=J$.from(i.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:s}=i,u,l,m,A,P;function C(){A&&A(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let M=new XMLHttpRequest;M.open(i.method.toUpperCase(),i.url,!0),M.timeout=i.timeout;function T(){if(!M)return;let U=J$.from("getAllResponseHeaders"in M&&M.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?M.responseText:M.response,status:M.status,statusText:M.statusText,headers:U,config:e,request:M};NVr(function(re){r(re),C()},function(re){n(re),C()},V),M=null}"onloadend"in M?M.onloadend=T:M.onreadystatechange=function(){!M||M.readyState!==4||M.status===0&&!(M.responseURL&&M.responseURL.indexOf("file:")===0)||setTimeout(T)},M.onabort=function(){M&&(n(new xm("Request aborted",xm.ECONNABORTED,e,M)),M=null)},M.onerror=function(q){let V=q&&q.message?q.message:"Network Error",$=new xm(V,xm.ERR_NETWORK,e,M);$.event=q||null,n($),M=null},M.ontimeout=function(){let q=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||oto;i.timeoutErrorMessage&&(q=i.timeoutErrorMessage),n(new xm(q,V.clarifyTimeoutError?xm.ETIMEDOUT:xm.ECONNABORTED,e,M)),M=null},a===void 0&&o.setContentType(null),"setRequestHeader"in M&&Zf.forEach(o.toJSON(),function(q,V){M.setRequestHeader(V,q)}),Zf.isUndefined(i.withCredentials)||(M.withCredentials=!!i.withCredentials),c&&c!=="json"&&(M.responseType=i.responseType),s&&([m,P]=BPi(s,!0),M.addEventListener("progress",m)),f&&M.upload&&([l,A]=BPi(f),M.upload.addEventListener("progress",l),M.upload.addEventListener("loadend",A)),(i.cancelToken||i.signal)&&(u=U=>{M&&(n(!U||U.type?new vit(null,e,M):U),M.abort(),M=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));let z=aYo(i.url);if(z&&n8.protocols.indexOf(z)===-1){n(new xm("Unsupported protocol "+z+":",xm.ERR_BAD_REQUEST,e));return}M.send(a||null)})};var ebC=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(s){if(!i){i=!0,c();let u=s instanceof Error?s:this.reason;n.abort(u instanceof xm?u:new vit(u instanceof Error?u.message:u))}},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(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=n;return f.unsubscribe=()=>Zf.asap(c),f}},XCy=ebC;var tbC=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},rbC=async function*(e,t){for await(let r of nbC(e))yield*tbC(r,t)},nbC=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()}},EAf=(e,t,r,n)=>{let i=rbC(e,t),a=0,o,c=f=>{o||(o=!0,n&&n(f))};return new ReadableStream({async pull(f){try{let{done:s,value:u}=await i.next();if(s){c(),f.close();return}let l=u.byteLength;if(r){let m=a+=l;r(m)}f.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(f){return c(f),i.return()}},{highWaterMark:2})};var ZCy=64*1024,{isFunction:tIs}=Zf,ibC=(({Request:e,Response:t})=>({Request:e,Response:t}))(Zf.global),{ReadableStream:kCy,TextEncoder:eIy}=Zf.global,tIy=(e,...t)=>{try{return!!e(...t)}catch{return!1}},abC=e=>{e=Zf.merge.call({skipUndefined:!0},ibC,e);let{fetch:t,Request:r,Response:n}=e,i=t?tIs(t):typeof fetch=="function",a=tIs(r),o=tIs(n);if(!i)return!1;let c=i&&tIs(kCy),f=i&&(typeof eIy=="function"?(P=>C=>P.encode(C))(new eIy):async P=>new Uint8Array(await new r(P).arrayBuffer())),s=a&&c&&tIy(()=>{let P=!1,C=new r(n8.origin,{body:new kCy,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),u=o&&c&&tIy(()=>Zf.isReadableStream(new n("").body)),l={stream:u&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,M)=>{let T=C&&C[P];if(T)return T.call(C);throw new xm(`Response type '${P}' is not supported`,xm.ERR_NOT_SUPPORT,M)})});let m=async P=>{if(P==null)return 0;if(Zf.isBlob(P))return P.size;if(Zf.isSpecCompliantForm(P))return(await new r(n8.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(Zf.isArrayBufferView(P)||Zf.isArrayBuffer(P))return P.byteLength;if(Zf.isURLSearchParams(P)&&(P=P+""),Zf.isString(P))return(await f(P)).byteLength},A=async(P,C)=>{let M=Zf.toFiniteNumber(P.getContentLength());return M??m(C)};return async P=>{let{url:C,method:M,data:T,signal:z,cancelToken:U,timeout:q,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:X,withCredentials:k="same-origin",fetchOptions:ne}=eIs(P),Oe=t||fetch;re=re?(re+"").toLowerCase():"text";let ve=XCy([z,U&&U.toAbortSignal()],q),me=null,be=ve&&ve.unsubscribe&&(()=>{ve.unsubscribe()}),Ie;try{if($&&s&&M!=="get"&&M!=="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]=cto(Ie,BPi(lto($)));T=EAf(Me.body,ZCy,rt,nr)}}Zf.isString(k)||(k=k?"include":"omit");let Be=a&&"credentials"in r.prototype,Se={...ne,signal:ve,method:M.toUpperCase(),headers:X.normalize().toJSON(),body:T,duplex:"half",credentials:Be?k:void 0};me=a&&new r(C,Se);let jt=await(a?Oe(me,ne):Oe(C,Se)),bt=u&&(re==="stream"||re==="response");if(u&&(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&&cto($t,BPi(lto(V),!0))||[];jt=new n(EAf(jt.body,ZCy,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)=>{NVr(Me,$t,{data:ze,headers:J$.from(jt.headers),status:jt.status,statusText:jt.statusText,config:P,request:me})})}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,me),{cause:Be.cause||Be}):xm.from(Be,Be&&Be.code,P,me)}}},obC=new Map,SAf=e=>{let t=e?e.env:{},{fetch:r,Request:n,Response:i}=t,a=[n,i,r],o=a.length,c=o,f,s,u=obC;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:abC(t)),u=s;return s},uKU=SAf();var DAf={http:GCy,xhr:YCy,fetch:{get:SAf}};Zf.forEach(DAf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var rIy=e=>`- ${e}`,sbC=e=>Zf.isFunction(e)||e===null||e===!1,rIs={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,!sbC(n)&&(i=DAf[(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,s])=>`adapter ${f} `+(s===!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}${kio}`});function m3s({message:e,error:t,logger:r,logLevel:n=iE.Err
|
|
|
2404
2404
|
Run ${Kf.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
2405
2405
|
Run ${Kf.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),dto(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function RNf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!YYy(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 $YC(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Kf.dim(c.currentVersion)+Kf.reset(" \u2192 ")+Kf.green(c.latestVersion);return i+=`
|
|
2407
|
-
`,n?dto(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function $YC(e){let r=await new $Yy.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 YYC({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await ZYy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let m=N4i(u.name,l),A=await Dqr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await ZYy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=N4i(s.name,u),m=await Dqr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:u});m!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function ZYy({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 xqr({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 s of f.generators)n!=null&&s.name!==n||await r(a.workspaceName,f.groupName,s,o)}})}))}function kYy(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=Q3e(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 w3s({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await YYC({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...kYy(s,f,t.logger));else o.push(...kYy(c.versions,void 0,t.logger))}return o}var Jko=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 nao=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var NNf=(()=>{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})(),eXy=typeof globalThis.AbortController=="function",tXy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",rXy=typeof globalThis.ReadableStream=="function",nXy=typeof globalThis.FormData=="function",j3s=["get","post","put","patch","head","delete"],XYC=()=>{};XYC();var iXy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},E3s=2147483647,aXy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,S3s=Symbol("stop"),oXy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},uXy={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 ZYC=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=aXy,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},sXy=(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))}}))},cXy=(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(sXy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},lXy=(e,t,r)=>{if(!e.body)return e;let n=ZYC(r??e.body);return new Request(e,{duplex:"half",body:sXy(e.body,n,t)})};var iao=e=>e!==null&&typeof e=="object";var Kko=(...e)=>{for(let t of e)if((!iao(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return zNf({},...e)},FNf=(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 D3s(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:zNf(e[r]??[],t[r]??[])}var xNf=(e={},t={})=>({beforeRequest:D3s(e,t,"beforeRequest"),beforeRetry:D3s(e,t,"beforeRetry"),afterResponse:D3s(e,t,"afterResponse"),beforeError:D3s(e,t,"beforeError")}),zNf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(iao(i)){for(let[a,o]of Object.entries(i))iao(o)&&a in t&&(o=zNf(t[a],o)),t={...t,[a]:o};iao(i.hooks)&&(n=xNf(n,i.hooks),t.hooks=n),iao(i.headers)&&(r=FNf(r,i.headers),t.headers=r)}return t};var dXy=e=>j3s.includes(e)?e.toUpperCase():e,kYC=["get","put","head","delete","options","trace"],eXC=[408,413,429,500,502,503,504],tXC=[413,429,503],fXy={limit:2,methods:kYC,statusCodes:eXC,afterStatusCodes:tXC,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},pXy=(e={})=>{if(typeof e=="number")return{...fXy,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{...fXy,...e}};async function QNf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new nao(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function LNf(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 _Xy=(e,t)=>{let r={};for(let n in t)!(n in uXy)&&!(n in oXy)&&!(n in e)&&(r[n]=t[n]);return r},hXy=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 $ko=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>E3s)throw new RangeError(`The \`timeout\` option cannot be greater than ${E3s}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let s=await f(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new Jko(c,n.request,n._options);for(let s of n._options.hooks.beforeError)f=await s(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!rXy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return cXy(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(iXy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:FNf(this._input.headers,r.headers),hooks:xNf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:dXy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:pXy(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(eXy&&tXy){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(NNf&&(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),hXy(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);(nXy&&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(!NNf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=lXy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof nao)throw t;if(t instanceof Jko){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),E3s);if(this._retryCount<1)throw r;await LNf(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})===S3s)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=_Xy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):QNf(this._originalRequest,t,this.abortController,this._options)}};var UNf=e=>{let t=(r,n)=>$ko.create(r,Kko(e,n));for(let r of j3s)t[r]=(n,i)=>$ko.create(n,Kko(e,i,{method:r}));return t.create=r=>UNf(Kko(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),UNf(Kko(e,r))),t.stop=S3s,t},rXC=UNf(),yXy=rXC;var zXy=Gi(xXy(),1);function JNf(e){let t=(0,zXy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var TZy=Gi(BZy(),1),qZy=Gi(JTr(),1),oFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},uFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function sFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??JNf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,TZy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await yXy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new oFf(e):l}if(t.allVersions)return s;let u=new uFf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,P]of Object.entries(s.versions))P.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=qZy.default.maxSatisfying(A,r),!r)throw u}let{time:m}=s;if(s=s.versions[r],s.time=m,!s)throw u}return s}async function teu(e,t){let{version:r}=await sFf(e.toLowerCase(),t);return r}async function A2i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:teu(e.packageName,{version:t?"prerelease":"latest"})}var RZy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Q3s=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=iE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new P3s(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.101.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Kf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new oie}failWithoutThrowing(t,r){this.didSucceed=!1,m3s({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await rto()).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 XYy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2407
|
+
`,n?dto(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function $YC(e){let r=await new $Yy.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 YYC({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await ZYy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let m=N4i(u.name,l),A=await Dqr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:l});A!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:A})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await ZYy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=N4i(s.name,u),m=await Dqr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:u});m!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function ZYy({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 xqr({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 s of f.generators)n!=null&&s.name!==n||await r(a.workspaceName,f.groupName,s,o)}})}))}function kYy(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=Q3e(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 w3s({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await YYC({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...kYy(s,f,t.logger));else o.push(...kYy(c.versions,void 0,t.logger))}return o}var Jko=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 nao=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var NNf=(()=>{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})(),eXy=typeof globalThis.AbortController=="function",tXy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",rXy=typeof globalThis.ReadableStream=="function",nXy=typeof globalThis.FormData=="function",j3s=["get","post","put","patch","head","delete"],XYC=()=>{};XYC();var iXy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},E3s=2147483647,aXy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,S3s=Symbol("stop"),oXy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},uXy={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 ZYC=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=aXy,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},sXy=(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))}}))},cXy=(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(sXy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},lXy=(e,t,r)=>{if(!e.body)return e;let n=ZYC(r??e.body);return new Request(e,{duplex:"half",body:sXy(e.body,n,t)})};var iao=e=>e!==null&&typeof e=="object";var Kko=(...e)=>{for(let t of e)if((!iao(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return zNf({},...e)},FNf=(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 D3s(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:zNf(e[r]??[],t[r]??[])}var xNf=(e={},t={})=>({beforeRequest:D3s(e,t,"beforeRequest"),beforeRetry:D3s(e,t,"beforeRetry"),afterResponse:D3s(e,t,"afterResponse"),beforeError:D3s(e,t,"beforeError")}),zNf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(iao(i)){for(let[a,o]of Object.entries(i))iao(o)&&a in t&&(o=zNf(t[a],o)),t={...t,[a]:o};iao(i.hooks)&&(n=xNf(n,i.hooks),t.hooks=n),iao(i.headers)&&(r=FNf(r,i.headers),t.headers=r)}return t};var dXy=e=>j3s.includes(e)?e.toUpperCase():e,kYC=["get","put","head","delete","options","trace"],eXC=[408,413,429,500,502,503,504],tXC=[413,429,503],fXy={limit:2,methods:kYC,statusCodes:eXC,afterStatusCodes:tXC,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},pXy=(e={})=>{if(typeof e=="number")return{...fXy,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{...fXy,...e}};async function QNf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new nao(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function LNf(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 _Xy=(e,t)=>{let r={};for(let n in t)!(n in uXy)&&!(n in oXy)&&!(n in e)&&(r[n]=t[n]);return r},hXy=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 $ko=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>E3s)throw new RangeError(`The \`timeout\` option cannot be greater than ${E3s}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let s=await f(n.request,n._options,n._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new Jko(c,n.request,n._options);for(let s of n._options.hooks.beforeError)f=await s(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!rXy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return cXy(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(iXy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:FNf(this._input.headers,r.headers),hooks:xNf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:dXy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:pXy(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(eXy&&tXy){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(NNf&&(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),hXy(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);(nXy&&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(!NNf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=lXy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof nao)throw t;if(t instanceof Jko){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),E3s);if(this._retryCount<1)throw r;await LNf(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})===S3s)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=_Xy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):QNf(this._originalRequest,t,this.abortController,this._options)}};var UNf=e=>{let t=(r,n)=>$ko.create(r,Kko(e,n));for(let r of j3s)t[r]=(n,i)=>$ko.create(n,Kko(e,i,{method:r}));return t.create=r=>UNf(Kko(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),UNf(Kko(e,r))),t.stop=S3s,t},rXC=UNf(),yXy=rXC;var zXy=Gi(xXy(),1);function JNf(e){let t=(0,zXy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var TZy=Gi(BZy(),1),qZy=Gi(JTr(),1),oFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},uFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function sFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??JNf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,TZy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await yXy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new oFf(e):l}if(t.allVersions)return s;let u=new uFf(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(n&&!l)for(let[A,P]of Object.entries(s.versions))P.deprecated&&delete s.versions[A];if(!l){let A=Object.keys(s.versions);if(r=qZy.default.maxSatisfying(A,r),!r)throw u}let{time:m}=s;if(s=s.versions[r],s.time=m,!s)throw u}return s}async function teu(e,t){let{version:r}=await sFf(e.toLowerCase(),t);return r}async function A2i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:teu(e.packageName,{version:t?"prerelease":"latest"})}var RZy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],Q3s=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=iE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new P3s(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.101.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Kf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new oie}failWithoutThrowing(t,r){this.didSucceed=!1,m3s({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await rto()).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 XYy({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=Wkl(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 Lko(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 oie}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await rto()).sendEvent(t)}logger=W5r((t,...r)=>this.log(t,...r));stderr=W5r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=NZy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?NZy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=RZy[this.numTasks++%RZy.length],o=Kf.hex(a)(i);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===LV.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=>$zi.indexOf(i.level)>=$zi.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===iE.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 A2i({cliEnvironment:this.environment,includePreReleases:t}),n=Q3e(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await w3s({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await wNf({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Kf.yellow("?"),style:{answer:i=>Kf.cyan(i),message:i=>Kf.bold(i),highlight:i=>Kf.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
|
|
2410
2410
|
Cancelled by user.`),new oie):n}}async getInput(t){return await mNf({message:t.message,default:t.default})}};function NZy(e){return`[${e}]:`}var MRr=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 Wit=class extends MRr{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 ovt={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 reu({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??ovt.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??ovt.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??ovt.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??ovt.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??ovt.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??ovt.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??ovt.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??ovt.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??ovt.respectForwardCompatibleEnums,wrapReferencesToNullableInOptional:t?.wrapReferencesToNullableInOptional??e?.wrapReferencesToNullableInOptional??ovt.wrapReferencesToNullableInOptional,coerceOptionalSchemasToNullable:t?.coerceOptionalSchemasToNullable??e?.coerceOptionalSchemasToNullable??ovt.coerceOptionalSchemasToNullable,groupEnvironmentsByHost:t?.groupEnvironmentsByHost??e?.groupEnvironmentsByHost??ovt.groupEnvironmentsByHost}}var hwe={openapi:e=>({...e,type:"openapi",_visit:function(t){return hwe._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return hwe._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 fao={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return fao._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var Vde={basic:e=>({...e,type:"basic",_visit:function(t){return Vde._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return Vde._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return Vde._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return Vde._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return Vde._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 qS={primitive:e=>({value:e,type:"primitive",_visit:function(t){return qS._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return qS._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return qS._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return qS._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return qS._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return qS._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return qS._visit(this,t)}}),null:e=>({...e,type:"null",_visit:function(t){return qS._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return qS._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 P2i={boolean:e=>({value:e,type:"boolean",_visit:function(t){return P2i._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return P2i._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 w2i={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return w2i._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return w2i._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 L3s={};yf(L3s,{Availability:()=>Wde,CustomCodeSample:()=>IWr,EndpointExample:()=>uvt,EndpointResponseExample:()=>svt,HttpMethod:()=>Gde,LiteralSchemaValue:()=>oW,MultipartRequestPropertyEncoding:()=>fFf,MultipartSchema:()=>MWr,OneOfSchema:()=>BWr,Pagination:()=>Hit,PrimitiveSchemaValue:()=>Gq,Request:()=>BRr,Response:()=>Wbe,RetriesConfiguration:()=>neu,Schema:()=>f1,SupportedSdkLanguage:()=>Hde,WebhookHttpMethod:()=>lFf,WebsocketMessageOrigin:()=>cFf});var cFf={Client:"client",Server:"server",_visit:(e,t)=>{switch(e){case cFf.Client:return t.client();case cFf.Server:return t.server();default:return t._other()}}};var lFf={Get:"GET",Post:"POST",_visit:(e,t)=>{switch(e){case lFf.Get:return t.get();case lFf.Post:return t.post();default:return t._other()}}};var Wde={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case Wde.GenerallyAvailable:return t.generallyAvailable();case Wde.Beta:return t.beta();case Wde.Deprecated:return t.deprecated();default:return t._other()}}};var neu={disabled:e=>({value:e,type:"disabled",_visit:function(t){return neu._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"disabled":return t.disabled(e.value);default:return t._other(e)}}};var Hit={cursor:e=>({...e,type:"cursor",_visit:function(t){return Hit._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Hit._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Hit._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 IWr={language:e=>({...e,type:"language",_visit:function(t){return IWr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return IWr._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 Hde={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 Hde.Curl:return t.curl();case Hde.Python:return t.python();case Hde.Javascript:return t.javascript();case Hde.Typescript:return t.typescript();case Hde.Go:return t.go();case Hde.Ruby:return t.ruby();case Hde.Csharp:return t.csharp();case Hde.Java:return t.java();case Hde.Js:return t.js();case Hde.Node:return t.node();case Hde.Ts:return t.ts();case Hde.Nodets:return t.nodets();case Hde.Golang:return t.golang();case Hde.Dotnet:return t.dotnet();case Hde.Jvm:return t.jvm();default:return t._other()}}};var uvt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return uvt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return uvt._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 svt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return svt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return svt._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 Gde={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case Gde.Get:return t.get();case Gde.Post:return t.post();case Gde.Put:return t.put();case Gde.Patch:return t.patch();case Gde.Delete:return t.delete();case Gde.Head:return t.head();case Gde.Options:return t.options();case Gde.Trace:return t.trace();default:return t._other()}}};var BRr={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return BRr._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return BRr._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return BRr._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return BRr._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 MWr={file:e=>({...e,type:"file",_visit:function(t){return MWr._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return MWr._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 Wbe={file:e=>({...e,type:"file",_visit:function(t){return Wbe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Wbe._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return Wbe._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return Wbe._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return Wbe._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return Wbe._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return Wbe._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 f1={primitive:e=>({...e,type:"primitive",_visit:function(t){return f1._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return f1._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return f1._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return f1._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return f1._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return f1._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return f1._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return f1._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return f1._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return f1._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return f1._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 Gq={int:e=>({...e,type:"int",_visit:function(t){return Gq._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Gq._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Gq._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Gq._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Gq._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Gq._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Gq._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Gq._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Gq._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Gq._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Gq._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 oW={boolean:e=>({value:e,type:"boolean",_visit:function(t){return oW._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return oW._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 BWr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return BWr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return BWr._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 mIe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return mIe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return mIe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return mIe._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return mIe._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 h9={file:e=>({...e,type:"file",_visit:function(t){return h9._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return h9._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return h9._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return h9._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return h9._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return h9._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return h9._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 Git={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Git._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Git._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 Wj={};yf(Wj,{AllOfPropertyConflict:()=>Fao,ArraySchema:()=>i4s,ArraySchemaWithExample:()=>R4s,Availability:()=>X3s,Base64WithExample:()=>I4s,BasicSecurityScheme:()=>k3s,BearerSecurityScheme:()=>ezs,BooleanSchema:()=>Zzs,BooleanWithExample:()=>M4s,BytesResponse:()=>Sao,CasingOverrides:()=>nzs,CommonProperty:()=>d4s,CommonPropertyWithExample:()=>W4s,CursorPagination:()=>Rzs,CustomCodeSample:()=>Tzs,CustomCodeSampleLanguage:()=>Izs,CustomCodeSampleSdk:()=>Bzs,CustomPagination:()=>Fzs,DateWithExample:()=>C4s,DatetimeWithExample:()=>D4s,DiscriminatedOneOfSchema:()=>l4s,DiscriminatedOneOfSchemaWithExample:()=>U4s,DoubleSchema:()=>Yzs,DoubleWithExample:()=>E4s,Encoding:()=>Y3s,Endpoint:()=>xzs,EndpointExample:()=>Mao,EndpointResponseExample:()=>Czs,EndpointSdkName:()=>RWr,EndpointSecurity:()=>gao,EndpointWithExample:()=>dky,EnumSchema:()=>yao,EnumSchemaWithExample:()=>T4s,EnumValue:()=>S2i,ErrorExample:()=>wzs,FernExample:()=>Ezs,FileResponse:()=>jao,FileSchema:()=>yzs,FloatWithExample:()=>j4s,FormUrlEncodedRequest:()=>Ozs,FullEndpointExample:()=>qzs,FullExample:()=>GQ,FullObjectExample:()=>fzs,FullOneOfExample:()=>pzs,GlobalHeader:()=>e4s,Header:()=>C2i,HeaderExample:()=>Iao,HeaderSecurityScheme:()=>tzs,HeaderWithExample:()=>B2i,HttpEndpointServer:()=>Dao,HttpError:()=>jzs,HttpErrorWithExample:()=>m4s,HttpMethod:()=>mao,IdempotencyHeader:()=>t4s,Int64WithExample:()=>A4s,IntSchema:()=>Kzs,IntWithExample:()=>O4s,JsonRequest:()=>mzs,JsonRequestWithExample:()=>y4s,JsonResponse:()=>Eao,JsonResponseWithExample:()=>Qao,KeyValuePair:()=>dzs,LiteralExample:()=>czs,LiteralSchema:()=>Nao,LiteralSchemaValue:()=>r4s,LongSchema:()=>$zs,MapSchema:()=>a4s,MapSchemaWithExample:()=>N4s,MultipartRequest:()=>wao,MultipartRequestProperty:()=>gzs,MultipartRequestPropertyEncoding:()=>bzs,MultipartSchema:()=>vzs,NamedFullExample:()=>lvt,Namespace:()=>izs,NamespaceId:()=>szs,NullExample:()=>lzs,NullableSchema:()=>u4s,NullableSchemaWithExample:()=>x4s,OauthSecurityScheme:()=>ozs,ObjectProperty:()=>c4s,ObjectPropertyConflictInfo:()=>xao,ObjectPropertyWithExample:()=>L4s,ObjectSchema:()=>n4s,ObjectSchemaWithExample:()=>z4s,OctetStreamRequest:()=>Pao,OffsetPagination:()=>Nzs,OneOfSchema:()=>s4s,OneOfSchemaWithExample:()=>Q4s,OpenApiIntermediateRepresentation:()=>lky,OpenApiSource:()=>G3s,OptionalSchema:()=>o4s,OptionalSchemaWithExample:()=>F4s,Pagination:()=>Bao,ParseFormUrlEncodedRequest:()=>v4s,ParseMultipartRequest:()=>h4s,ParseOctetStreamRequest:()=>_4s,PathParameter:()=>Oao,PathParameterExample:()=>Szs,PathParameterWithExample:()=>p4s,PrimitiveExample:()=>bao,PrimitiveSchema:()=>M2i,PrimitiveSchemaValue:()=>kzs,PrimitiveSchemaValueWithExample:()=>B4s,PrimitiveSchemaWithExample:()=>Lao,PropertyKey:()=>vao,ProtobufEncoding:()=>$3s,ProtobufSource:()=>J3s,QueryParameter:()=>Aao,QueryParameterExample:()=>Cao,QueryParameterWithExample:()=>zao,QuerySecurityScheme:()=>rzs,ReferencedSchema:()=>NWr,Request:()=>Azs,RequestWithExample:()=>b4s,Response:()=>Pzs,ResponseWithExample:()=>g4s,RetriesConfiguration:()=>Tao,Schema:()=>$I,SchemaId:()=>OIe,SchemaWithExample:()=>o6,Schemas:()=>Jzs,SdkGroup:()=>azs,SdkGroupInfo:()=>_zs,SdkGroupName:()=>D2i,SecurityScheme:()=>uzs,SecuritySchemeId:()=>hao,Server:()=>ueu,Source:()=>K3s,StatusCode:()=>TWr,StreamingResponseExample:()=>Dzs,StringSchema:()=>Xzs,StringSchemaWithExample:()=>S4s,SupportedSdkLanguage:()=>Mzs,Tag:()=>Z3s,TagId:()=>AIe,Tags:()=>hzs,TextResponse:()=>I2i,Uint64WithExample:()=>w4s,UintWithExample:()=>P4s,UnDiscriminatedOneOfSchema:()=>f4s,UnDiscriminatedOneOfSchemaWithExample:()=>V4s,UnknownSchemaWithExample:()=>q4s,Webhook:()=>zzs,WebhookExampleCall:()=>Rao,WebhookHttpMethod:()=>qao,WebhookWithExample:()=>pky,WebsocketChannel:()=>Gzs,WebsocketHandshake:()=>Qzs,WebsocketHandshakeWithExample:()=>fky,WebsocketMessageExample:()=>Wzs,WebsocketMessageOrigin:()=>Lzs,WebsocketMessageSchema:()=>Uzs,WebsocketServer:()=>Vzs,WebsocketSessionExample:()=>Hzs,WithAvailability:()=>nw,WithDescription:()=>bv,WithEncoding:()=>U3e,WithInline:()=>a6,WithName:()=>jD,WithNamespace:()=>RS,WithSdkGroupName:()=>$M,WithSdkMethodName:()=>qWr,WithSource:()=>AP,WithStatusCode:()=>cvt,WithTitle:()=>KM,commons:()=>yFf,example:()=>vFf,finalIr:()=>bFf,parseIr:()=>gFf});var yFf={};yf(yFf,{BasicSecurityScheme:()=>k3s,BearerSecurityScheme:()=>ezs,Encoding:()=>Y3s,HeaderSecurityScheme:()=>tzs,Namespace:()=>izs,NamespaceId:()=>szs,OauthSecurityScheme:()=>ozs,OpenApiSource:()=>G3s,ProtobufEncoding:()=>$3s,ProtobufSource:()=>J3s,QuerySecurityScheme:()=>rzs,SchemaId:()=>OIe,SdkGroup:()=>azs,SdkGroupName:()=>D2i,SecurityScheme:()=>uzs,SecuritySchemeId:()=>hao,Server:()=>ueu,Source:()=>K3s,StatusCode:()=>TWr,Tag:()=>Z3s,TagId:()=>AIe,WithAvailability:()=>nw,WithDescription:()=>bv,WithEncoding:()=>U3e,WithInline:()=>a6,WithName:()=>jD,WithNamespace:()=>RS,WithSdkGroupName:()=>$M,WithSdkMethodName:()=>qWr,WithSource:()=>AP,WithStatusCode:()=>cvt,WithTitle:()=>KM});var Wr={};yf(Wr,{JsonError:()=>dao,ParseError:()=>pao,any:()=>XZy,bigint:()=>xZy,boolean:()=>ZZy,booleanLiteral:()=>YZy,date:()=>zZy,discriminant:()=>uky,enum_:()=>V3s,getObjectLikeUtils:()=>TRr,getObjectUtils:()=>Lda,getSchemaUtils:()=>HQ,isProperty:()=>E2i,lazy:()=>QZy,lazyObject:()=>JZy,list:()=>H3s,number:()=>kZy,object:()=>W3s,objectWithoutOptionalProperties:()=>GZy,optional:()=>dFf,property:()=>UZy,record:()=>nky,set:()=>iky,string:()=>eky,stringLiteral:()=>$Zy,transform:()=>pFf,undiscriminatedUnion:()=>oky,union:()=>cky,unknown:()=>tky,withParsedProperties:()=>hFf});var Jq={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 s8(e,t){return`Expected ${t}. Received ${sZC(e)}.`}function sZC(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 Jde(e){return{...e,json:FZy(e.json),parse:FZy(e.parse)}}function FZy(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(`
|
|
@@ -3085,7 +3085,7 @@ If you believe this is an error, please contact support@buildwithfern.com`),orgN
|
|
|
3085
3085
|
`):void 0);for(let i of t.logs.slice(this.lengthOfLastLogs))this.context.logger.log(VbL(i.level),i.message);this.lengthOfLastLogs=t.logs.length;let n=i=>{this.context.logger.debug(`Generated files. ${iqi("View here",i,{fallback:(a,o)=>`${a}: ${o}`})}`)};return await t.status._visit({notStarted:Qc,running:Qc,failed:({message:i,s3PreSignedReadUrl:a})=>{a!=null&&n(a),this.context.failAndThrow(i)},finished:async i=>{if(i.s3PreSignedReadUrlV2!=null){n(i.s3PreSignedReadUrlV2);let a=this.getAbsolutePathToLocalOutput();a!=null&&await LbL({s3PreSignedReadUrl:i.s3PreSignedReadUrlV2,absolutePathToLocalOutput:a,context:this.context})}if(this.absolutePathToPreview==null)for(let a of r)this.context.logger.info(`Published ${a}`);this.#e=!0,this.#t=i.createdSnippets!=null?i.createdSnippets:!1,this.#r=i.snippetsS3PreSignedReadUrl},_other:()=>{this.context.logger.warn("Received unknown update type: "+t.status.type)}}),this.#e?{createdSnippets:this.#t,snippetsS3PreSignedReadUrl:this.#r}:void 0}getAbsolutePathToLocalOutput(){return this.absolutePathToPreview!=null?kl(this.absolutePathToPreview,ds.of(YH_.default.basename(this.generatorInvocation.name))):this.generatorInvocation.absolutePathToLocalOutput}#e=!1;get isFinished(){return this.#e}#t=!1;get createdSnippets(){return this.#t}#r=void 0;get snippetsS3PreSignedReadUrl(){return this.#r}};async function LbL({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t,context:r}){try{await UbL({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}),r.logger.info(Kf.green(`Downloaded to ${t}`))}catch(n){r.failAndThrow("Failed to download files",n)}}async function UbL({s3PreSignedReadUrl:e,absolutePathToLocalOutput:t}){let r=await DZ.get(e,{responseType:"stream"}),n=await wkE.default.dir({prefix:"fern",unsafeCleanup:!0}),i=YH_.default.join(n.path,"output.zip");await(0,PkE.pipeline)(r.data,(0,AkE.createWriteStream)(i)),await Qv(t)&&await(0,HPl.rm)(t,{recursive:!0}),await(0,HPl.mkdir)(t,{recursive:!0}),await(0,OkE.default)(i,t)}function VbL(e){switch(e){case"DEBUG":return iE.Debug;case"INFO":return iE.Info;case"WARN":return iE.Warn;case"ERROR":return iE.Error;default:return iE.Info}}var JPl=require("fs/promises"),jkE=Gi(TCe(),1),WbL="proto.zip",GPl=class{sourceTypes;context;sources;constructor(t,r){this.context=t,this.sources=Object.fromEntries(r.map(n=>[n.id,n])),this.sourceTypes=new Set(Object.values(this.sources).map(n=>n.type))}async uploadSources(t){for(let[r,n]of Object.entries(t)){let i=this.getSourceOrThrow(r);await this.uploadSource(i,n.uploadUrl)}return this.convertFdrSourceUploadsToSourceConfig(t)}async uploadSource(t,r){let n=await this.getUploadCommand(t),i=await(0,JPl.readFile)(n.absoluteFilePath),a=await fetch(r,{method:"PUT",body:i,headers:{"Content-Type":"application/octet-stream"}});await n.cleanup(),a.ok||this.context.failAndThrow(`Failed to upload source file: ${t.absoluteFilePath}. Status: ${a.status}, ${a.statusText}`)}async getUploadCommand(t){if(t.type==="protobuf"){let r=await this.zipSource(t.absoluteFilePath);return{absoluteFilePath:r,cleanup:async()=>{this.context.logger.debug(`Removing ${r}`),await(0,JPl.unlink)(r)}}}return{absoluteFilePath:t.absoluteFilePath,cleanup:async()=>{}}}async zipSource(t){let r=await jkE.default.dir(),n=kl(L_.of(r.path),ds.of(WbL));return this.context.logger.debug(`Zipping source ${t} into ${n}`),await oG(this.context.logger,"zip",["-r",n,"."],{cwd:t,doNotPipeOutput:!0}),n}convertFdrSourceUploadsToSourceConfig(t){let r=[];for(let[n,i]of Object.entries(t))switch(this.getSourceOrThrow(n).type){case"protobuf":r.push(Vxe.proto({id:n,protoRootUrl:i.downloadUrl}));continue;case"openapi":r.push(Vxe.openapi());continue;case"asyncapi":continue}return{sources:r}}getSourceOrThrow(t){let r=this.sources[t];return r==null&&this.context.failAndThrow(`Internal error; server responded with source id "${t}" which does not exist in the workspace.`),r}};async function EkE({projectConfig:e,organization:t,workspace:r,interactiveTaskContext:n,generatorInvocation:i,version:a,audiences:o,shouldLogS3Url:c,token:f,whitelabel:s,irVersionOverride:u,absolutePathToPreview:l,readme:m}){let A=Cca({token:f.value}),P=tw.getPackageName({generatorInvocation:i}),C=l!=null,M=Ie=>yzi(Ie,{onError:Be=>n.failAndThrow(Be)},{substituteAsEmpty:C}),T=M(i),z=UPl({apiName:r.definition.rootApiFile.contents.name,organization:t,generatorInvocation:T}),U=dG({workspace:r,generationLanguage:i.language,keywords:i.keywords,smartCasing:i.smartCasing,exampleGeneration:{disabled:i.disableExamples,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!1},audiences:o,readme:m,packageName:P,version:a??await GbL({fdr:A,packageName:P,generatorInvocation:i}),context:n,sourceResolver:new uG(n,r),dynamicGeneratorConfig:z}),V=await ZCe({token:f.value}).organization.get(DR.OrganizationId(e.organization));V.ok&&V.body.isWhitelabled&&(U.readmeConfig==null&&(U.readmeConfig=KbL),U.readmeConfig.whiteLabel=!0);let $=r.getSources(),re=zIe({ir:U,snippetsConfig:{typescriptSdk:void 0,pythonSdk:void 0,javaSdk:void 0,rubySdk:void 0,goSdk:void 0,csharpSdk:void 0,phpSdk:void 0,swiftSdk:void 0,rustSdk:void 0},context:n}),X=await A.api.v1.register.registerApiDefinition({orgId:XH_.FernRegistry.OrgId(t),apiId:XH_.FernRegistry.ApiId(U.apiName.originalName),definition:re,sources:$.length>0?JbL($):void 0}),k,ne;X.ok&&(k=X.body.apiDefinitionId,ne=X.body.sources);let Oe=new GPl(n,$);if(ne==null&&Oe.sourceTypes.has("protobuf")&&(X.ok||n.failAndThrow(`Failed to register API definition: ${JSON.stringify(X.error.content)}`),n.failAndThrow("Did not successfully upload Protobuf source files.")),ne!=null){n.logger.debug("Uploading source files ...");let Ie=await Oe.uploadSources(ne);n.logger.debug("Setting IR source configuration ..."),U.sourceConfig=Ie}let ve=await _kE({projectConfig:e,workspace:r,organization:t,generatorInvocation:T,context:n,version:a,intermediateRepresentation:{...U,fdrApiDefinitionId:k,publishConfig:HbL({generatorInvocation:T})},shouldLogS3Url:c,token:f,whitelabel:s!=null?M(s):void 0,irVersionOverride:u,absolutePathToPreview:l});n.logger.debug(`Job ID: ${ve.jobId}`);let me=ve.taskIds[0];if(me==null){n.failAndThrow("Did not receive a task ID.");return}n.logger.debug(`Task ID: ${me}`);let be=new WPl({job:ve,taskId:me,generatorInvocation:i,interactiveTaskContext:n,absolutePathToPreview:l});return await vkE({job:ve,taskHandler:be,taskId:me,context:n})}function HbL({generatorInvocation:e}){return e.outputMode._visit({downloadFiles:()=>{},github:()=>{},githubV2:()=>{},publish:()=>{},publishV2:t=>t._visit({mavenOverride:()=>{},pypiOverride:()=>{},nugetOverride:()=>{},npmOverride:()=>{},rubyGemsOverride:()=>{},cratesOverride:()=>{},postman:r=>{let n;return e.raw?.output?.location==="postman"&&(n=e.raw.output?.["collection-id"]),np.PublishingConfig.direct({target:np.PublishTarget.postman({apiKey:r.apiKey,workspaceId:r.workspaceId,collectionId:n})})},_other:()=>{}}),_other:()=>{}})}async function GbL({fdr:e,packageName:t,generatorInvocation:r}){if(r.language==null)return;let n;switch(r.language){case"csharp":n="Csharp";break;case"go":n="Go";break;case"java":n="Java";break;case"python":n="Python";break;case"ruby":n="Ruby";break;case"typescript":n="TypeScript";break;case"php":n="Php";break;case"swift":n="Swift";break;default:return}if(t==null)return;let i=await e.sdks.versions.computeSemanticVersion({githubRepository:r.outputMode.type==="githubV2"?`${r.outputMode.githubV2.owner}/${r.outputMode.githubV2.repo}`:void 0,language:n,package:t});if(i.ok)return i.body.version}function JbL(e){return Object.fromEntries(Object.values(e).map(t=>[t.id,{type:t.type==="protobuf"?"proto":t.type}]))}var KbL={defaultEndpoint:void 0,bannerLink:void 0,introduction:void 0,apiReferenceLink:void 0,apiName:void 0,disabledFeatures:void 0,whiteLabel:void 0,customSections:void 0,features:void 0,exampleStyle:void 0};async function ZH_({projectConfig:e,organization:t,workspace:r,context:n,generatorGroup:i,version:a,shouldLogS3Url:o,token:c,whitelabel:f,absolutePathToPreview:s,mode:u}){if(i.generators.length===0)return n.logger.warn("No generators specified."),null;let l=[],m=[];return l.push(...i.generators.map(P=>n.runInteractiveTask({name:P.name},async C=>{let M=$oo(P),T=await r.toFernWorkspace({context:n},M),z=await EkE({projectConfig:e,organization:t,workspace:T,interactiveTaskContext:C,generatorInvocation:{...P,outputMode:P.outputMode._visit({downloadFiles:()=>P.outputMode,github:U=>KPl.FernFiddle.OutputMode.github({...U,makePr:u==="pull-request"}),githubV2:U=>u==="pull-request"?KPl.FernFiddle.OutputMode.githubV2(KPl.FernFiddle.GithubOutputModeV2.pullRequest(U)):P.outputMode,publish:()=>P.outputMode,publishV2:()=>P.outputMode,_other:()=>P.outputMode})},version:a,audiences:i.audiences,shouldLogS3Url:o,token:c,whitelabel:f,readme:P.readme,irVersionOverride:P.irVersionOverride,absolutePathToPreview:s});z!=null&&z.createdSnippets&&(m.push(P),P.absolutePathToLocalSnippets!=null&&z.snippetsS3PreSignedReadUrl!=null&&await skE({snippetsS3PreSignedReadUrl:z.snippetsS3PreSignedReadUrl,absolutePathToLocalSnippetJSON:P.absolutePathToLocalSnippets,context:C}))}))),(await Promise.all(l)).some(P=>!P)&&n.failAndThrow(),{snippetsProducedBy:m}}var Zvi=Gi(eit(),1);var zeS=require("fs/promises");var CG_=Gi(PJo(),1);var mFo=(e,t,r)=>JSON.stringify(e,t,r);function $zu(e,t){return JSON.parse(e,t)}var Qd=class e extends Error{constructor({message:t,statusCode:r,body:n,rawResponse:i}){super($bL({message:t,statusCode:r,body:n})),Object.setPrototypeOf(this,e.prototype),this.statusCode=r,this.body=n,this.rawResponse=i}};function $bL({message:e,statusCode:t,body:r}){let n=[];return e!=null&&n.push(e),t!=null&&n.push(`Status code: ${t.toString()}`),r!=null&&n.push(`Body: ${mFo(r,void 0,2)}`),n.join(`
|
|
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 YbL={arrayFormat:"indices",encode:!0};function SkE(e,t){if(e===void 0||e===null)return"";let r=String(e);return t?encodeURIComponent(r):r}function kH_(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 s=r.arrayFormat==="indices"?`${o}[${c}]`:o;n.push(...kH_(f,s,r))}else{let s=r.arrayFormat==="indices"?`${o}[${c}]`:o,u=r.encode?encodeURIComponent(s):s;n.push(`${u}=${SkE(f,r.encode)}`)}}}else if(typeof a=="object"&&a!==null){if(Object.keys(a).length===0)continue;n.push(...kH_(a,o,r))}else{let c=r.encode?encodeURIComponent(o):o;n.push(`${c}=${SkE(a,r.encode)}`)}}return n}function $Pl(e,t){return e==null||typeof e!="object"?"":kH_(e,"",Object.assign(Object.assign({},YbL),t)).join("&")}function DkE(e,t){let r=$Pl(t,{arrayFormat:"repeat"});return r?`${e}?${r}`:e}function CkE(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 IkE(e){return e.body!=null}var XbL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})};function YPl(e,t){return XbL(this,void 0,void 0,function*(){if(!IkE(e))return;switch(t){case"binary-response":return CkE(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 $zu(r)}catch{return{ok:!1,error:{reason:"non-json",statusCode:e.status,rawBody:r}}}})}var ZbL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})};function MkE(e){return ZbL(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 YPl(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?$zu(a):void 0;default:if(i.startsWith("application/vnd.")&&i.endsWith("+json")){let o=yield e.text();return o.length>0?$zu(o):void 0}return yield e.text()}})}var kbL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})};function BkE(){return kbL(this,void 0,void 0,function*(){return fetch})}var egL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})};function TkE(e){return egL(this,arguments,void 0,function*({body:t,type:r}){return r.includes("json")?mFo(t):t})}var tgL="timeout";function qkE(e){let t=new AbortController,r=setTimeout(()=>t.abort(tgL),e);return{signal:t.signal,abortId:r}}function RkE(...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 rgL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},NkE=(e,t,r,n,i,a,o,c,f)=>rgL(void 0,void 0,void 0,function*(){let s=[],u;if(a!=null){let{signal:A,abortId:P}=qkE(a);u=P,s.push(A)}o!=null&&s.push(o);let l=RkE(s),m=yield e(t,{method:r,headers:n,body:i,signal:l,credentials:c?"include":void 0,duplex:f});return u!=null&&clearTimeout(u),m});var Yzu;typeof globalThis.Headers<"u"?Yzu=globalThis.Headers:Yzu=class FkE{constructor(t){if(this.headers=new Map,t)if(t instanceof FkE)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 eG_={headers:new Yzu,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},tG_={headers:new Yzu,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function rG_(e){return{headers:e.headers,redirected:e.redirected,status:e.status,statusText:e.statusText,type:e.type,url:e.url}}var ngL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})};function igL(e){let t=1+(Math.random()*2-1)*.2;return e*t}function xkE(e){return ngL(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=igL(a);yield new Promise(c=>setTimeout(c,o)),n=yield t()}return n})}var agL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},k_={get:e=>agL(void 0,void 0,void 0,function*(){return typeof e=="function"?e():e})};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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})};function ogL(e){return nG_(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 ugL(e){return nG_(this,void 0,void 0,function*(){let t=DkE(e.url,e.queryParameters),r=yield TkE({body:e.body,type:e.requestType==="json"?"json":"other"}),n=yield BkE();try{let i=yield xkE(()=>nG_(this,void 0,void 0,function*(){return NkE(n,t,e.method,yield ogL(e),r,e.timeoutMs,e.abortSignal,e.withCredentials,e.duplex)}),e.maxRetries);return i.status>=200&&i.status<400?{ok:!0,body:yield YPl(i,e.responseType),headers:i.headers,rawResponse:rG_(i)}:{ok:!1,error:{reason:"status-code",statusCode:i.status,body:yield MkE(i)},rawResponse:rG_(i)}}catch(i){return e.abortSignal!=null&&e.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:eG_}:i instanceof Error&&i.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:eG_}:i instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:i.message},rawResponse:tG_}:{ok:!1,error:{reason:"unknown",errorMessage:mFo(i)},rawResponse:tG_}}})}var zA=ugL;var sgL=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((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 sgL(this,void 0,void 0,function*(){return yield this.innerPromise})}};var XPl=cgL();function cgL(){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:()=>QkE,toQueryString:()=>$Pl});function QkE(e,...t){if(!e)return"";if(t.length===0)return e;if(e.includes("://")){let r;try{r=new URL(e)}catch{return zkE(e,...t)}let n=t[t.length-1],i=n&&n.endsWith("/");for(let a of t){let o=UkE(a);o&&(r.pathname=LkE(r.pathname,o))}return i&&!r.pathname.endsWith("/")&&(r.pathname+="/"),r.toString()}return zkE(e,...t)}function zkE(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=UkE(a);o&&(r=LkE(r,o))}return i&&!r.endsWith("/")&&(r+="/"),r}function LkE(e,t){return e.endsWith("/")?e+t:e+"/"+t}function UkE(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 sP(...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 I5a=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},ZPl=class{constructor(t={}){this._options=t}getAnalyticsHistogram(t,r={},n){return dA.fromPromise(this.__getAnalyticsHistogram(t,r,n))}__getAnalyticsHistogram(t){return I5a(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:f,end_date:s,group_by:u}=n,l={};f!=null&&(l.start_date=f),s!=null&&(l.end_date=s),u!=null&&(l.group_by=u);let m=wA((a=this._options)===null||a===void 0?void 0:a.headers,sP({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 I5a(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 s=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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,"analytics/insights/generate_all"),method:"POST",headers:s,queryParameters:Object.assign(Object.assign({},f),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 /analytics/insights/generate_all.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}triggerScheduledInsightsGeneration(t){return dA.fromPromise(this.__triggerScheduledInsightsGeneration(t))}__triggerScheduledInsightsGeneration(t){return I5a(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,sP({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 I5a(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 I5a(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,sP({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 I5a(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{start_date:f,end_date:s}=n,u={};f!=null&&(u.start_date=f),s!=null&&(u.end_date=s);let l=wA((a=this._options)===null||a===void 0?void 0:a.headers,sP({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({},u),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 I5a(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var VkE=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},kPl=class{constructor(t={}){this._options=t}postChatCompletion(t,r,n){return dA.fromPromise(this.__postChatCompletion(t,r,n))}__postChatCompletion(t,r,n){return VkE(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 VkE(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var WkE=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},ewl=class{constructor(t={}){this._options=t}getConversationById(t,r,n){return dA.fromPromise(this.__getConversationById(t,r,n))}__getConversationById(t,r,n){return WkE(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 WkE(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var iG_=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},twl=class{constructor(t={}){this._options=t}createDiscordIntegration(t,r){return dA.fromPromise(this.__createDiscordIntegration(t,r))}__createDiscordIntegration(t,r){return iG_(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,sP({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,"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(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 /discord/install.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}handleDiscordInstallCallback(t){return dA.fromPromise(this.__handleDiscordInstallCallback(t))}__handleDiscordInstallCallback(t){return iG_(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,sP({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 iG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var aqi=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},rwl=class{constructor(t={}){this._options=t}createDocument(t,r,n){return dA.fromPromise(this.__createDocument(t,r,n))}__createDocument(t,r,n){return aqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 aqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 aqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 aqi(this,arguments,void 0,function*(n,i,a={},o){var c,f,s;let u=wA((c=this._options)===null||c===void 0?void 0:c.headers,sP({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield zA({url:PA.join((s=(f=yield k_.get(this._options.baseUrl))!==null&&f!==void 0?f:yield k_.get(this._options.environment))!==null&&s!==void 0?s:cP.Production,`document/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:u,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 aqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 aqi(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 aqi(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:f,limit:s}=n,u={};f!=null&&(u.page=f.toString()),s!=null&&(u.limit=s.toString());let l=wA((a=this._options)===null||a===void 0?void 0:a.headers,sP({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({},u),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 aqi(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 aqi(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var nwl=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},iwl=class{constructor(t={}){this._options=t}createEditingSession(t,r){return dA.fromPromise(this.__createEditingSession(t,r))}__createEditingSession(t,r){return nwl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 nwl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 nwl(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,sP({Authorization:yield this._getAuthorizationHeader()}),i?.headers),s=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(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 PUT /editing-sessions/{editing_id}.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}_getAuthorizationHeader(){return nwl(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var aG_=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},awl=class{constructor(t={}){this._options=t}createFeedback(t,r,n){return dA.fromPromise(this.__createFeedback(t,r,n))}__createFeedback(t,r,n){return aG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 aG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 aG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var OFo=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},owl=class{constructor(t={}){this._options=t}createGuidance(t,r,n){return dA.fromPromise(this.__createGuidance(t,r,n))}__createGuidance(t,r,n){return OFo(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 OFo(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 OFo(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 OFo(this,arguments,void 0,function*(n,i,a={},o){var c,f,s;let u=wA((c=this._options)===null||c===void 0?void 0:c.headers,sP({Authorization:yield this._getAuthorizationHeader()}),o?.headers),l=yield zA({url:PA.join((s=(f=yield k_.get(this._options.baseUrl))!==null&&f!==void 0?f:yield k_.get(this._options.environment))!==null&&s!==void 0?s:cP.Production,`guidance/${encodeURIComponent(n)}/${encodeURIComponent(i)}`),method:"PATCH",headers:u,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 OFo(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:f,limit:s}=n,u={};f!=null&&(u.page=f.toString()),s!=null&&(u.limit=s.toString());let l=wA((a=this._options)===null||a===void 0?void 0:a.headers,sP({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({},u),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 OFo(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var HkE=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},uwl=class{constructor(t={}){this._options=t}check(t){return dA.fromPromise(this.__check(t))}__check(t){return HkE(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,sP({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 HkE(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var swl=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},cwl=class{constructor(t={}){this._options=t}reconstructQueryIndex(t,r){return dA.fromPromise(this.__reconstructQueryIndex(t,r))}__reconstructQueryIndex(t,r){return swl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 swl(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 swl(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 swl(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var oG_=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},lwl=class{constructor(t={}){this._options=t}getMcpSemanticQuery(t,r,n){return dA.fromPromise(this.__getMcpSemanticQuery(t,r,n))}__getMcpSemanticQuery(t,r,n){return oG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 oG_(this,void 0,void 0,function*(){var i,a,o;let c=wA((i=this._options)===null||i===void 0?void 0:i.headers,sP({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 oG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var uG_=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},fwl=class{constructor(t={}){this._options=t}createQuery(t,r){return dA.fromPromise(this.__createQuery(t,r))}__createQuery(t,r){return uG_(this,void 0,void 0,function*(){var n,i,a;let{domain:o,body:c}=t,f={};f.domain=o;let s=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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,"queries"),method:"POST",headers:s,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(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 /queries.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getRecentQueries(t,r={},n){return dA.fromPromise(this.__getRecentQueries(t,r,n))}__getRecentQueries(t){return uG_(this,arguments,void 0,function*(r,n={},i){var a,o,c;let{page:f,limit:s,cutoff_time:u,include_assistant:l,start_date:m,end_date:A}=n,P={};f!=null&&(P.page=f.toString()),s!=null&&(P.limit=s.toString()),u!=null&&(P.cutoff_time=u),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,sP({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,`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(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 /queries/{domain}.");case"unknown":throw new Qd({message:M.error.errorMessage,rawResponse:M.rawResponse})}})}_getAuthorizationHeader(){return uG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var sG_=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},dwl=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 sG_(this,void 0,void 0,function*(){var o,c,f;let s=wA((o=this._options)===null||o===void 0?void 0:o.headers,sP({Authorization:yield this._getAuthorizationHeader()}),a?.headers),u=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:s,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(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 /scribe/callback/slack/{team_id}/{channel_id}/{thread_ts}.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}editCallback(t,r,n,i,a){return dA.fromPromise(this.__editCallback(t,r,n,i,a))}__editCallback(t,r,n,i,a){return sG_(this,void 0,void 0,function*(){var o,c,f;let s=wA((o=this._options)===null||o===void 0?void 0:o.headers,sP({Authorization:yield this._getAuthorizationHeader()}),a?.headers),u=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:s,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(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 /scribe/callback/slack/edit/{team_id}/{channel_id}/{thread_ts}.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}_getAuthorizationHeader(){return sG_(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var Yvi=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},pwl=class{constructor(t={}){this._options=t}getSettings(t,r){return dA.fromPromise(this.__getSettings(t,r))}__getSettings(t,r){return Yvi(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,sP({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"),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(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 /settings/ask-ai.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getDocsSettings(t,r){return dA.fromPromise(this.__getDocsSettings(t,r))}__getDocsSettings(t,r){return Yvi(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,sP({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/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(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 /settings/ask-ai/docs.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getSlackSettings(t,r){return dA.fromPromise(this.__getSlackSettings(t,r))}__getSlackSettings(t,r){return Yvi(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,sP({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/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(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 /settings/ask-ai/slack.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}getDiscordSettings(t,r){return dA.fromPromise(this.__getDiscordSettings(t,r))}__getDiscordSettings(t,r){return Yvi(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,sP({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/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(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 /settings/ask-ai/discord.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}enableAskAi(t,r){return dA.fromPromise(this.__enableAskAi(t,r))}__enableAskAi(t,r){return Yvi(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 Yvi(this,void 0,void 0,function*(){var n,i,a;let{domain:o,org_name:c,preview:f,locations:s}=t,u={};u.domain=o,u.org_name=c,f!=null&&(u.preview=f.toString()),s!=null&&(Array.isArray(s)?u.locations=s.map(A=>A):u.locations=s);let l=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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({},u),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 Yvi(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 s=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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/reindex"),method:"POST",headers:s,queryParameters:Object.assign(Object.assign({},f),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 /settings/ask-ai/reindex.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getToggleStatus(t,r){return dA.fromPromise(this.__getToggleStatus(t,r))}__getToggleStatus(t,r){return Yvi(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,sP({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/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(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 /settings/ask-ai/toggle/status.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}reindexPreviewCallback(t,r){return dA.fromPromise(this.__reindexPreviewCallback(t,r))}__reindexPreviewCallback(t,r){return Yvi(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 Yvi(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var wea=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(u){try{s(n.next(u))}catch(l){o(l)}}function f(u){try{s(n.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):i(u.value).then(c,f)}s((n=n.apply(e,t||[])).next())})},_wl=class{constructor(t={}){this._options=t}createSlackIntegration(t,r){return dA.fromPromise(this.__createSlackIntegration(t,r))}__createSlackIntegration(t,r){return wea(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,sP({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/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(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 /slack/install.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}handleSlackEvents(t){return dA.fromPromise(this.__handleSlackEvents(t))}__handleSlackEvents(t){return wea(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,sP({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 wea(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,sP({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 wea(this,void 0,void 0,function*(){var r,n,i;let a=wA((r=this._options)===null||r===void 0?void 0:r.headers,sP({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 wea(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 s=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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/oauth/callback"),method:"GET",headers:s,queryParameters:Object.assign(Object.assign({},f),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/oauth/callback.");case"unknown":throw new Qd({message:u.error.errorMessage,rawResponse:u.rawResponse})}})}getSlackInstallLink(t,r){return dA.fromPromise(this.__getSlackInstallLink(t,r))}__getSlackInstallLink(t,r){return wea(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,sP({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/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(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/get-install.");case"unknown":throw new Qd({message:s.error.errorMessage,rawResponse:s.rawResponse})}})}listSlackIntegrations(t,r){return dA.fromPromise(this.__listSlackIntegrations(t,r))}__listSlackIntegrations(t,r){return wea(this,void 0,void 0,function*(){var n,i,a;let o=wA((n=this._options)===null||n===void 0?void 0:n.headers,sP({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 wea(this,void 0,void 0,function*(){let t=yield k_.get(this._options.token);if(t!=null)return`Bearer ${t}`})}};var Xzu=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":XPl.type,"X-Fern-Runtime-Version":XPl.version},t?.headers)})}get analytics(){var t;return(t=this._analytics)!==null&&t!==void 0?t:this._analytics=new ZPl(this._options)}get chat(){var t;return(t=this._chat)!==null&&t!==void 0?t:this._chat=new kPl(this._options)}get conversation(){var t;return(t=this._conversation)!==null&&t!==void 0?t:this._conversation=new ewl(this._options)}get discord(){var t;return(t=this._discord)!==null&&t!==void 0?t:this._discord=new twl(this._options)}get document(){var t;return(t=this._document)!==null&&t!==void 0?t:this._document=new rwl(this._options)}get editingSessions(){var t;return(t=this._editingSessions)!==null&&t!==void 0?t:this._editingSessions=new iwl(this._options)}get feedback(){var t;return(t=this._feedback)!==null&&t!==void 0?t:this._feedback=new awl(this._options)}get guidance(){var t;return(t=this._guidance)!==null&&t!==void 0?t:this._guidance=new owl(this._options)}get health(){var t;return(t=this._health)!==null&&t!==void 0?t:this._health=new uwl(this._options)}get index(){var t;return(t=this._index)!==null&&t!==void 0?t:this._index=new cwl(this._options)}get mcp(){var t;return(t=this._mcp)!==null&&t!==void 0?t:this._mcp=new lwl(this._options)}get query(){var t;return(t=this._query)!==null&&t!==void 0?t:this._query=new fwl(this._options)}get scribe(){var t;return(t=this._scribe)!==null&&t!==void 0?t:this._scribe=new dwl(this._options)}get settings(){var t;return(t=this._settings)!==null&&t!==void 0?t:this._settings=new pwl(this._options)}get slack(){var t;return(t=this._slack)!==null&&t!==void 0?t:this._slack=new _wl(this._options)}};function GkE({token:e}){return new Xzu({baseUrl:"https://fai.buildwithfern.com",token:e})}var BeS=Gi(MeS(),1);var TeS=require("util"),Y0L=(0,TeS.promisify)(BeS.default);async function qeS(e,t,r){let n=_Wo(e,t),i=[];for(let a of n){let o=await Promise.all(a.map(async c=>{try{let f=await Y0L(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 X0L=10,ReS=10;async function QeS({token:e,organization:t,docsWorkspace:r,domain:n,customDomains:i,apiWorkspaces:a,ossWorkspaces:o,context:c,preview:f,editThisPage:s,isPrivate:u=!1,disableTemplates:l=!1,skipUpload:m=!1,targetAudiences:A}){let P=Cca({token:e.value}),C=u?{type:"private",authType:"sso"}:{type:"public"},M,T=i[0]??n,z=Z0L(n),U=r.config.experimental?.dynamicSnippets,q=f||U,$=await new WNr({domain:n,docsWorkspace:r,ossWorkspaces:o,apiWorkspaces:a,taskContext:c,editThisPage:s,uploadFiles:async X=>{let k=new Map(X.map(Ie=>[Ie.absoluteFilePath,Ie])),Oe=X.map(Ie=>({...Ie,mediaType:CG_.lookup(Ie.absoluteFilePath)})).filter(Ie=>Ie.mediaType!==!1).filter(Ie=>Y8.parse(Ie.mediaType)?.isImage()??!1).map(Ie=>Ie.absoluteFilePath),ve=await qeS(Oe,X0L,c),me=[];[...ve.values()].forEach(Ie=>{let Be=k.get(Ie.filePath);if(Be==null)return;let Se={filePath:Zvi.FernRegistry.docs.v1.write.FilePath(Mcs(Be.relativeFilePath)),width:Ie.width,height:Ie.height,blurDataUrl:Ie.blurDataUrl,alt:void 0,fileHash:void 0};me.push(Se)});let be=X.filter(({absoluteFilePath:Ie})=>!ve.has(Ie)).map(({relativeFilePath:Ie})=>Mcs(Ie));if(f){let Ie=await P.docs.v2.write.startDocsPreviewRegister({orgId:Zvi.FernRegistry.OrgId(t),authConfig:u?{type:"private",authType:"sso"}:{type:"public"},filepaths:be.map(Be=>Zvi.FernRegistry.docs.v1.write.FilePath(Be)),images:me,basePath:z});return Ie.ok?(T=Ie.body.previewUrl,M=Ie.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs preview"):await NeS(Ie.body.uploadUrls,r.absoluteFilePath,c,ReS),FeS(Ie.body.uploadUrls,r.absoluteFilePath)):await xeS(Ie.error,c)}else{let Ie=await P.docs.v2.write.startDocsRegister({domain:n,customDomains:i,authConfig:C,apiId:Zvi.FernRegistry.ApiId(""),orgId:Zvi.FernRegistry.OrgId(t),filepaths:be.map(Be=>Zvi.FernRegistry.docs.v1.write.FilePath(Be)),images:me});return Ie.ok?(M=Ie.body.docsRegistrationId,m?c.logger.debug("Skip-upload mode: skipping file uploads for docs"):await NeS(Ie.body.uploadUrls,r.absoluteFilePath,c,ReS),FeS(Ie.body.uploadUrls,r.absoluteFilePath)):xeS(Ie.error,c)}},registerApi:async({ir:X,snippetsConfig:k,playgroundConfig:ne,apiName:Oe,workspace:ve})=>{let me=zIe({ir:X,snippetsConfig:k,playgroundConfig:ne,context:c}),be;U&&(be=await k0L({workspace:ve,organization:t,context:c,snippetsConfig:k}));let Ie=await P.api.v1.register.registerApiDefinition({orgId:Zvi.FernRegistry.OrgId(t),apiId:Zvi.FernRegistry.ApiId(X.apiName.originalName),definition:me,definitionV2:void 0,dynamicIRs:be});if(Ie.ok)return c.logger.debug(`Registered API Definition ${Oe}: ${Ie.body.apiDefinitionId}`),Ie.body.dynamicIRs&&be&&(m?c.logger.debug("Skip-upload mode: skipping dynamic IR uploads"):await emL({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 Oe!=null?c.failAndThrow(`Failed to publish docs because API definition (${Oe}) 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
|
-
${JSON.stringify(Ie.error)}`)}},targetAudiences:A}).resolve();if(M==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(Zvi.FernRegistry.docs.v1.write.DocsRegistrationId(M),{docsDefinition:$,excludeApis:!
|
|
3088
|
+
${JSON.stringify(Ie.error)}`)}},targetAudiences:A}).resolve();if(M==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(Zvi.FernRegistry.docs.v1.write.DocsRegistrationId(M),{docsDefinition:$,excludeApis:!1});if(re.ok){let X=Tse(T);await tmL({docsDefinition:$,organization:t,token:e,url:X.replace("https://",""),context:c,fdr:P,isPreview:f,domain:n,customDomains:i});let k=iqi(X,X);c.logger.info(Kf.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 ${M} does not exist.`);default:return c.failAndThrow("Failed to publish docs to "+n,re.error)}}async function NeS(e,t,r,n){let i=Date.now(),a=Object.keys(e).length;r.logger.debug(`Start uploading ${a} files...`);let o=_Wo(Object.entries(e),n),c=0;for(let s of o){await Promise.all(s.map(async([l,{uploadUrl:m}])=>{let A=ds.of(l),P=wj(t,A);try{let C=CG_.lookup(P);await DZ.put(m,await(0,zeS.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 u=Date.now();c+=s.length,r.logger.debug(`Uploaded ${c}/${a} files in ${u-i}ms`)}let f=Date.now();r.logger.debug(`Finished uploading ${a} files in ${f-i}ms`)}function FeS(e,t){let r=[];for(let[n,i]of Object.entries(e)){let a=ds.of(n),o=wj(t,a);r.push({relativeFilePath:a,absoluteFilePath:o,fileId:i.fileId})}return r}async function xeS(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 Z0L(e){try{return new URL(Tse(e)).pathname}catch{return}}async function k0L({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=UPl({apiName:e.workspaceName??"",organization:t,generatorInvocation:c}),s="";if(f?.outputConfig.type==="publish")switch(f.outputConfig.value.type){case"npm":case"nuget":case"pypi":case"rubygems":s=f.outputConfig.value.packageName;break;case"maven":s=f.outputConfig.value.coordinate;break;case"go":s=f.outputConfig.value.repoUrl;break;case"swift":s=f.outputConfig.value.repoUrl;break;case"crates":s=f.outputConfig.value.packageName;break}if(c.language==="php"&&c.config&&typeof c.config=="object"&&"packageName"in c.config&&(s=c.config.packageName??""),!!c.language&&c.language&&a[c.language]===s){let u=dG({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:s,version:void 0,context:r,sourceResolver:new uG(r,e),dynamicGeneratorConfig:f}),l=ruu({ir:u,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 emL({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 tmL({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 s=GkE({token:r.value}),u=o?[Tse(n).replace("https://","")]:[Tse(c).replace("https://",""),...f.map(m=>Tse(m).replace("https://",""))];if(i.logger.debug(`Enabling Ask AI for domain${u.length>1?"s":""}: ${u.join(", ")}`),e.config.aiChatConfig.location.includes("docs"))for(let m of u){let A=new URL(Tse(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 s.settings.enableAskAi({domains:u,org_name:t,locations:e.config.aiChatConfig.location,preview:o})).success&&i.logger.info(Kf.green(`${o?"":`Ask Fern enabled for ${u.join(", ")}. `}
|
|
3089
3089
|
Note: it may take a few minutes after publishing for Ask Fern settings to reflect expected state.`))}}async function IG_({organization:e,apiWorkspaces:t,ossWorkspaces:r,docsWorkspace:n,context:i,token:a,instanceUrl:o,preview:c,disableTemplates:f,skipUpload:s}){let u=n.config.instances;if(n.config=yzi(n.config,{onError:A=>i.failAndThrow(A)},{substituteAsEmpty:c}),u.length===0){i.failAndThrow("No instances specified in docs.yml! Cannot register docs.");return}if(u.length>1&&o==null){i.failAndThrow(`More than one docs instances. Please specify one (e.g. --instance ${u[0]?.url})`);return}let l=u.find(A=>A.url===o)??u[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 QeS({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:s,targetAudiences:l.audiences?Array.isArray(l.audiences)?l.audiences:[l.audiences]:void 0})})}var UtS=Gi(Y6i(),1);var Ihe={RequestReference:"requestReference",InlinedRequestProperty:"inlinedRequestProperty",Response:"response",StreamingResponse:"streamingResponse"};function QL(e,t){return r=>{r!=null&&e.docs?.(r,[...t,"docs"])}}function ZDr({example:e,visitor:t,nodePath:r}){if(typeof e=="string")e.startsWith("$")&&t.exampleTypeReference?.(e,r);else if(PR(e))for(let n of Object.values(e))ZDr({example:n,visitor:t,nodePath:r});else if(Array.isArray(e))for(let n of e)ZDr({example:n,visitor:t,nodePath:r})}function a6r(e){return(t,r,{_default:n,validation:i,location:a}={})=>{e.typeReference?.({typeReference:t,_default:n,validation:i,location:a,nodePath:r},r)}}function LeS({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=>{UeS({headers:n,visitor:t,nodePath:[...r,"headers"]})},audiences:Qc,auth:Qc,"path-parameters":n=>{e4u({pathParameters:n,visitor:t,nodePath:[...r,"path-parameters"]})},endpoints:n=>{for(let[i,a]of Object.entries(n)){let o=[...r,"endpoints",i];rmL({endpointId:i,endpoint:a,service:e,visitor:t,nodePathForEndpoint:o})}},idempotent:Qc,transport:Qc,source:Qc})}function rmL({endpointId:e,endpoint:t,service:r,visitor:n,nodePathForEndpoint:i}){let a=a6r(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=>{e4u({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=>{e4u({pathParameters:f,visitor:n,nodePath:[...c,"path-parameters"]})},"query-parameters":f=>{if(f!=null)for(let[s,u]of Object.entries(f)){let l=[...c,"query-parameters",s];n.queryParameter?.({queryParameterKey:s,queryParameter:u},l),typeof u=="string"?a(u,l):AN(u,{name:Qc,docs:QL(n,l),availability:Qc,type:m=>{a(m,[...l,"type"],{_default:u.default,validation:u.validation})},"allow-multiple":Qc,audiences:Qc,encoding:Qc,default:Qc,validation:Qc})}},"content-type":Qc,headers:f=>{UeS({headers:f,visitor:n,nodePath:[...c,"headers"]})},body:f=>{if(f==null)return;let s=[...c,"body"];typeof f=="string"?a(f,s,{location:"requestReference"}):IU(f)?(n.typeDeclaration?.({typeName:{isInlined:!0,location:"inlinedRequest"},declaration:f},s),AN(f,{extends:u=>{if(u==null)return;let l=typeof u=="string"?[u]:u;for(let m of l){let A=[...s,"extends",m];n.extension?.(m,A),a(m,A)}},properties:u=>{if(u!=null)for(let[l,m]of Object.entries(u)){let A=[...s,"properties",l];typeof m=="string"?a(m,A,{location:Ihe.InlinedRequestProperty}):AN(m,{name:Qc,docs:QL(n,A),availability:Qc,type:P=>{a(P,[...A,"type"],{location:Ihe.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,s)(f.docs),a(f.type,s))}})},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:Ihe.StreamingResponse}):a(o.type,[...i,"response-stream"],{location:Ihe.StreamingResponse}))},response:o=>{if(o==null)return;let c=[...i,"response"];typeof o=="string"?a(o,c,{location:Ihe.Response}):AN(o,{docs:QL(n,c),type:f=>{f!=null&&a(f,[...c,"type"],{location:Ihe.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:s=>{n.errorReference?.(s,[...f,"error"])}})}},examples:o=>{if(o!=null)for(let[c,f]of o.entries())nmL({nodePathForExample:[...i,{key:"examples",arrayIndex:c}],visitor:n,service:r,endpoint:t,example:f})},pagination:Qc,source:Qc,transport:Qc,retries:Qc})}function nmL({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 u of Object.values(i.headers))ZDr({example:u,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 u of Object.values(i["path-parameters"]))ZDr({example:u,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 u of Object.values(i["query-parameters"]))ZDr({example:u,visitor:t,nodePath:c});let f=[...e,"request"];t.exampleRequest?.({service:r,endpoint:n,example:i.request},f),i.request!=null&&ZDr({example:i.request,visitor:t,nodePath:f});let s=[...e,"response"];if(t.exampleResponse?.({service:r,endpoint:n,example:i.response},s),i.response!=null&&ksa(n,i.response,{body:u=>{u.body!=null&&ZDr({example:u.body,visitor:t,nodePath:s}),u.error!=null&&t.errorReference?.(u.error,[...s,"error"])},stream:u=>{for(let l of u.stream)ZDr({example:l,visitor:t,nodePath:s})},events:u=>{for(let{data:l}of u.stream)ZDr({example:l,visitor:t,nodePath:s})}}),i["code-samples"]!=null)for(let[u,l]of i["code-samples"].entries())t.exampleCodeSample?.({service:r,endpoint:n,example:i,sample:l},[...e,{key:"code-samples",arrayIndex:u}])}function e4u({pathParameters:e,visitor:t,nodePath:r}){if(e==null)return;let n=a6r(t);for(let[i,a]of Object.entries(e)){let o=[...r,i];t.pathParameter?.({pathParameterKey:i,pathParameter:a},o),dZa(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 UeS({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=a6r(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 VeS({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),MG_({typeName:n,declaration:i,visitor:t,nodePathForType:a})}}function MG_({typeName:e,declaration:t,visitor:r,nodePathForType:n}){let i=a6r(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 s=[...n,{key:"examples",arrayIndex:c}];r.exampleType?.({typeName:e,typeDeclaration:t,example:f},s),ZDr({example:f.value,nodePath:s,visitor:r})}};Qee(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 s of f){let u=[...n,"extends",s];r.extension?.(s,u),i(s,u)}},properties:c=>{if(c!=null)for(let[f,s]of Object.entries(c)){let u=[...n,"properties",f];typeof s=="string"?i(s,u):AN(s,{name:Qc,docs:QL(r,u),availability:Qc,type:l=>{i(l,[...u,"type"],{_default:s.default,validation:s.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 s of f){let u=[...n,"extends",s];r.extension?.(s,u),i(s,u)}},union:c=>{for(let[f,s]of Object.entries(c)){let u=[...n,"union",f];typeof s=="string"?i(s,u):AN(s,{docs:QL(r,u),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,s]of c.entries()){let u=[...n,`union[${f}]`];typeof s!="string"&&AN(s,{docs:QL(r,u),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 s=[...n,typeof f=="string"?f:f.name??f.value];typeof f!="string"&&AN(f,{docs:QL(r,s),name:Qc,value:Qc,casing:Qc})}},availability:Qc,audiences:Qc,default:Qc,encoding:Qc,source:Qc,examples:a,inline:Qc})}})}function WeS({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),imL({errorName:n,declaration:i,visitor:t,nodePathForError:a})}}function imL({errorName:e,declaration:t,visitor:r,nodePathForError:n}){let i=a6r(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):MG_({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 HeS({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 GeS({webhook:e,visitor:t,nodePathForWebhook:r}){let n=a6r(t);AN(e,{"display-name":Qc,method:Qc,examples:Qc,headers:i=>{amL({headers:i,visitor:t,nodePath:[...r,"headers"]})},payload:i=>{let a=[...r,"payload"];if(typeof i=="string"){n(i,a,{location:"requestReference"});return}if(omL(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 s of f){let u=[...o,"extends",s];t.extension?.(s,u),n(s,u)}},properties:c=>{if(c!=null)for(let[f,s]of Object.entries(c)){let u=[...o,"properties",f];typeof s=="string"?n(s,u,{location:Ihe.InlinedRequestProperty}):AN(s,{name:Qc,docs:QL(t,u),availability:Qc,type:l=>{n(l,[...u,"type"],{_default:s.default,validation:s.validation,location:Ihe.InlinedRequestProperty})},audiences:Qc,encoding:Qc,default:Qc,validation:Qc,access:Qc})}}})},audiences:Qc,availability:Qc,docs:QL(t,r)})}function amL({headers:e,visitor:t,nodePath:r}){if(e==null)return;let n=a6r(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 omL(e){return e.type!=null}function Bme(e,t){AN(e,{docs:QL(t,[]),imports:r=>{HeS({imports:r,visitor:t,nodePath:["imports"]})},types:r=>{VeS({typeDeclarations:r,visitor:t,nodePath:["types"]})},service:r=>{r!=null&&LeS({service:r,visitor:t,nodePath:["service"]})},webhooks:r=>{for(let[n,i]of Object.entries(r??{}))GeS({webhook:i,visitor:t,nodePathForWebhook:["webhooks",n]})},channel:Qc,errors:r=>{WeS({errorDeclarations:r,visitor:t,nodePath:["errors"]})}})}function BG_(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 TG_(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])=>{Clf(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=>{e4u({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 Hwl=new RegExp("^[a-zA-Z][a-zA-Z0-9_]*$");function JeS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let s of r){let u=s.definitionFile?.[a];if(u!=null){let l=u(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 KeS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let s of r){let u=s.packageMarker?.[a];if(u!=null){let l=u(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 $eS({relativeFilepath:e,contents:t,allRuleVisitors:r,addViolations:n}){function i(a){let o=(c,f)=>{for(let s of r){let u=s.rootApiFile?.[a];if(u!=null){let l=u(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 qG_={name:"content-type-only-for-multipart",DISABLE_RULE:!1,create:()=>({definitionFile:{httpEndpoint:({endpoint:e})=>{if(e.request==null)return[];if(Zsa(e.request)!=null)return[];if(typeof e.request!="string"&&e.request.body!=null&&IU(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=gIe({generationLanguage:void 0,keywords:void 0,smartCasing:!1});var RG_={name:"exploded-form-data-is-array",create:({workspace:e})=>{let t=new UF(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(!umL(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=sD({relativeFilepath:n,definitionFile:i,casingsGenerator:y3,rootApiFile:e.definition.rootApiFile.contents}),s=t.resolveType({type:c.type,file:f});if(s==null)return[];YeS(s)||a.push({message:`${o} is exploded and must be a list. Did you mean list<${c.type}>?`,severity:"error"})}return a}}}}};function YeS(e){return e._type!=="container"?!1:e.container._type==="list"?!0:e.container._type==="optional"||e.container._type==="nullable"?YeS(e.container.itemType):!1}function umL(e){return e?.properties!=null}var NG_={name:"import-file-exists",create:({workspace:e})=>{let t=Object.keys(kwi(e.definition)),r=new Set;return t.forEach(n=>{let i=kl(e.definition.absoluteFilePath,ds.of(n));r.add(i)}),{definitionFile:{import:({importedAs:n,importPath:i},{relativeFilepath:a})=>{let o=[],c=kl(e.definition.absoluteFilePath,Qg(a),ds.of(i));return r.has(c)||o.push({severity:"fatal",message:`Import ${Kf.bold(n)} points to non-existent path ${Kf.bold(i)}.`}),o}}}}};function Gwl(e){return e.definition.rootApiFile.contents.environments==null?[]:Object.values(e.definition.rootApiFile.contents.environments).reduce((t,r)=>{if(uit(r))for(let n of Object.keys(r.urls))t.includes(n)||t.push(n);return t},[])}var FG_={name:"matching-environment-urls",create:({workspace:e})=>{let t=Gwl(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 ${Kf.bold(o)}`})};return V9r(n,{singleBaseUrl:()=>{for(let o of t)a(o)},multipleBaseUrls:o=>{for(let c of t)o.urls[c]==null&&a(c)}}),i}}}}};var xG_={name:"no-circular-imports",DISABLE_RULE:!0,create:({workspace:e})=>{let t=smL(e.definition.namedDefinitionFiles);return{definitionFile:{import:({importPath:r},{relativeFilepath:n})=>{let i=t[n];if(i==null)return[];let a=T5i({referencedIn:n,importPath:ds.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 smL(e){let t={};for(let r of GTr(e))t[r]=XeS(r,[r],e);return t}function XeS(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=T5i({referencedIn:e,importPath:ds.of(a)});t.includes(o)?t[0]===o&&t[0]===cmL(t)&&n.push({startingFilepath:o,chainWithoutStartingFilepath:t.slice(1)}):n.push(...XeS(o,[...t,o],r))}return n}function cmL(e){return e.reduce((t,r)=>r<t?r:t)}var Jwl=class{workspace;typeResolver;constructor(t){this.workspace=t,this.typeResolver=new UF(t)}isTypeComplex(t,r){let n=sD({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:ks(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:ks(t)}}isNamedTypeComplex({type:t,file:r,visited:n}){if(n.has(t.rawName))return!1;if(n.add(t.rawName),S6i(t.declaration))return!0;if(Rqr(t.declaration))return!1;if(Gx(t.declaration))return this.objectHasComplexProperties({typeName:t.rawName,objectDeclaration:t.declaration,file:r,visited:n});if(pZa(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}ks(t.declaration)}objectHasComplexProperties({typeName:t,objectDeclaration:r,file:n,visited:i}){return UNr({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:ks(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:ks(t)}}};var zG_={name:"no-complex-query-params",create:({workspace:e})=>{let t=new Jwl(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 QG_={name:"no-conflicting-endpoint-parameters",create:()=>({definitionFile:{pathParameter:({pathParameterKey:e})=>e===lJs?[{severity:"fatal",message:`Path parameter ${Kf.bold(e)} is not suitable for code generation, because it can conflict with the request body parameter.`}]:[]}})};function t4u({service:e,endpoint:t}){return e["base-path"]+t.path}var Kwl=class{root=new LG_;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 t4u({service:t.service,endpoint:t.endpoint}).split("/").filter(r=>r.length>0)}},LG_=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 UG_={name:"no-conflicting-endpoint-paths",create:({workspace:e})=>{let t=new Kwl;return ote(e,(r,n)=>{Bme(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 ${t4u({service:r,endpoint:n})} conflicts with other endpoints:`,...o.map(c=>` - ${c.relativeFilepath} -> ${c.endpointId} ${Kf.dim(t4u({service:c.service,endpoint:c.endpoint}))}`)].join(`
|
|
3090
3090
|
`)}]}}}}};var VG_={name:"no-conflicting-request-wrapper-properties",create:({workspace:e})=>({definitionFile:{httpEndpoint:({endpoint:t,service:r},{contents:n,relativeFilepath:i})=>{let a=lmL({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 ${Kf.bold(c)}. This is not suitable for code generation. Use the "name" property to deconflict.
|
|
3091
3091
|
`+f.map(s=>` - ${fmL(s)}`).join(`
|