fern-api 0.115.3 → 0.115.4
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 +13 -3
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -2430,7 +2430,7 @@ ${hAy.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&X0f(th
|
|
|
2430
2430
|
`+Mua.default.red(">> ")+t),this.screen.render(r,n)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Mua.default.cyan(wAy(t,this.opt.mask)):Mua.default.italic(Mua.default.dim("[hidden]")):this.opt.mask?wAy(t,this.opt.mask):Mua.default.italic(Mua.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var KSu=$i(mse(),1);var wPy=$i(Bmf(),1),HSu=require("child_process"),RZa=require("fs"),GSu=$i(require("path"),1),jPy=$i(require("os"),1),EPy=require("crypto"),yOf=$i(APy(),1);var USu=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var p$o=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var VSu=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var WSu=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function JSu(e="",t,r){let n=new vOf(e,r);n.runAsync((i,a)=>{if(i)setImmediate(t,i,void 0);else try{n.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function PPy(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function rDC(e){let t=[],r="";for(let n=0;n<e.length;n++){let i=e.charAt(n);n>0&&i===" "&&e[n-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${i}`}return r.length>0&&t.push(r),t}var vOf=class{text="";tempFile;editor;lastExitStatus=0;fileOptions={};get temp_file(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile}get last_exit_status(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus}constructor(t="",r){this.text=t,r&&(this.fileOptions=r),this.determineEditor(),this.createTemporaryFile()}run(){return this.launchEditor(),this.readTemporaryFile(),this.text}runAsync(t){try{this.launchEditorAsync(()=>{try{this.readTemporaryFile(),setImmediate(t,void 0,this.text)}catch(r){setImmediate(t,r,void 0)}})}catch(r){setImmediate(t,r,void 0)}}cleanup(){this.removeTemporaryFile()}determineEditor(){let t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:process.platform.startsWith("win")?"notepad":"vim",r=rDC(t).map(i=>i.replace("\\ "," ")),n=r.shift();this.editor={args:r,bin:n}}createTemporaryFile(){try{let t=this.fileOptions.dir??jPy.default.tmpdir(),r=(0,EPy.randomUUID)(),n=PPy(this.fileOptions.prefix),i=PPy(this.fileOptions.postfix),a=`${n}${r}${i}`,o=GSu.default.resolve(t,a),c=GSu.default.resolve(t)+GSu.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let f={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(f.mode=this.fileOptions.mode),(0,RZa.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new USu(t)}}readTemporaryFile(){try{let t=(0,RZa.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,wPy.detect)(t)??"utf8";yOf.default.encodingExists(r)||(r="utf8"),this.text=yOf.default.decode(t,r)}}catch(t){throw new VSu(t)}}removeTemporaryFile(){try{(0,RZa.unlinkSync)(this.tempFile)}catch(t){throw new WSu(t)}}launchEditor(){try{let t=(0,HSu.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new p$o(t)}}launchEditorAsync(t){try{(0,HSu.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",n=>{this.lastExitStatus=n,setImmediate(t)})}catch(r){throw new p$o(r)}}};var SPy=$i(Nrt(),1);var _$o=class extends Ose{_run(t){this.done=t,this.editorResult=new SPy.Subject;let r=Hve(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let n=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,i=this.handleSubmitEvents(this.editorResult);return i.success.forEach(this.onEnd.bind(this)),i.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,n?this.render():this.startExternalEditor(),this}render(t){let r="",n=this.getQuestion();n+=this.status==="answered"?KSu.default.dim("Received"):KSu.default.dim("Press <enter> to launch your preferred editor."),t&&(r=KSu.default.red(">> ")+t),this.screen.render(n,r)}startExternalEditor(){this.rl.pause(),JSu(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(t,r){this.rl.resume(),t?this.editorResult.error(t):this.editorResult.next(r)}onEnd(t){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=t.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(t){this.render(t.isValid)}};var BPy=require("stream");var IPy=$i(require("readline"),1),MPy=$i(CPy(),1),Rua=class{constructor(t){this.rl||=IPy.default.createInterface(iDC(t)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&typeof this.activePrompt.close=="function"&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}};function iDC(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let i=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw i.isTtyError=!0,i}let r=new MPy.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var h$o=class extends Rua{constructor(t={}){super(t),this.log=new BPy.Writable({write:(r,n,i)=>{this.writeLog(r),i()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return ZKo(this.rl,this.bottomBar.split(`
|
|
2431
2431
|
`).length),this}updateBottomBar(t){return ZKo(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=t,this.render(),this.rl.output.mute(),this}writeLog(t){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(t.toString())),this.render(),this.rl.output.mute(),this}enforceLF(t){return/[\n\r]$/.test(t)?t:t+`
|
|
2432
2432
|
`}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&ySu(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var W4=$i(Nrt(),1),RPy=$i(gKo(),1);var $Su=$i(Nrt(),1),TPy=$i(gKo(),1),YSu=function(e,t,r){return typeof e[t]!="function"?(0,$Su.of)(e):(0,$Su.from)((0,TPy.default)(e[t])(r).then(n=>(e[t]=n,e)))};var qPy={set:(e,t="",r)=>{let n=e;t.split(".").forEach((i,a,o)=>{i==="__proto__"||i==="constructor"||(a===o.length-1?n[i]=r:(!(i in n)||typeof n[i]!="object")&&(n[i]={}),n=n[i])})},get:(e,t="",r)=>{let n=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),i=n(/[,[\]]+?/)||n(/[,.[\]]+?/);return i===void 0||i===e?r:i}},NZa=class extends Rua{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let n;return Array.isArray(t)?n=(0,W4.from)(t):(0,W4.isObservable)(t)?n=t:Object.values(t).every(i=>typeof i=="object"&&!Array.isArray(i)&&i!=null)?n=(0,W4.from)(Object.entries(t).map(([i,a])=>({name:i,...a}))):n=(0,W4.from)([t]),this.process=n.pipe((0,W4.concatMap)(this.processQuestion.bind(this)),(0,W4.publish)()),this.process.connect(),this.process.pipe((0,W4.reduce)((i,a)=>(qPy.set(i,a.name,a.answer),i),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,W4.defer)(()=>(0,W4.of)(t).pipe((0,W4.concatMap)(this.setDefaultType.bind(this)),(0,W4.concatMap)(this.filterIfRunnable.bind(this)),(0,W4.concatMap)(()=>YSu(t,"message",this.answers)),(0,W4.concatMap)(()=>YSu(t,"default",this.answers)),(0,W4.concatMap)(()=>YSu(t,"choices",this.answers)),(0,W4.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,W4.defer)(()=>(0,W4.from)(this.activePrompt.run().then(n=>({name:t.name,answer:n}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,W4.defer)(()=>(0,W4.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&qPy.get(this.answers,t.name)!==void 0)return W4.EMPTY;if(t.when===!1)return W4.EMPTY;if(typeof t.when!="function")return(0,W4.of)(t);let{answers:r}=this;return(0,W4.defer)(()=>(0,W4.from)((0,RPy.default)(t.when)(r).then(n=>{if(n)return t})).pipe((0,W4.filter)(n=>n!=null)))}};function NPy(e){let t=function(r,n){let i;try{i=new NZa(t.prompts,e)}catch(o){return Promise.reject(o)}let a=i.run(r,n);return a.ui=i,a};return t.prompts={},t.registerPrompt=function(r,n){return t.prompts[r]=n,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",e$o),this.registerPrompt("input",Iua),this.registerPrompt("number",t$o),this.registerPrompt("confirm",r$o),this.registerPrompt("rawlist",n$o),this.registerPrompt("expand",i$o),this.registerPrompt("checkbox",a$o),this.registerPrompt("password",o$o),this.registerPrompt("editor",_$o)},t.restoreDefaultPrompts(),t}var gOf=NPy();function oDC(e,t){gOf.registerPrompt(e,t)}function sDC(){gOf.restoreDefaultPrompts()}var uDC={prompt:gOf,ui:{BottomBar:h$o,Prompt:NZa},createPromptModule:NPy,registerPrompt:oDC,restoreDefaultPrompts:sDC,Separator:oxe},XSu=uDC;var $Za=require("path"),hjy=require("fs"),yjy=require("readline"),Qwy="posthog-node";function RIC(e,{organization:t,projectId:r,prefix:n,severityAllowList:i=["error"]}={}){return a=>{if(!(i==="*"||i.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[vDu.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=u;let s=a.exception?.values||[],l=s.map(O=>({...O,stacktrace:O.stacktrace?{...O.stacktrace,type:"raw",frames:(O.stacktrace.frames||[]).map(P=>({...P,platform:"node:javascript"}))}:void 0})),m={$exception_message:s[0]?.value||a.message,$exception_type:s[0]?.type,$exception_personURL:u,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:s[0]?.value||a.message,$sentry_exception_type:s[0]?.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:m}),a}}var vDu=class{constructor(t,r,n,i){this.name=Qwy,this.name=Qwy,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(RIC(t,{organization:r,projectId:c,prefix:n,severityAllowList:i}))}}};vDu.POSTHOG_ID_TAG="posthog_distinct_id";var dDu="0123456789abcdef",bDu=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,n,i){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(i)||t<0||r<0||n<0||i<0||t>0xffffffffffff||r>4095||n>1073741823||i>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|n>>>24,a[9]=n>>>16,a[10]=n>>>8,a[11]=n,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let n=new Uint8Array(16);for(let i=0;i<16;i+=4){let a=parseInt(r.substring(2*i,2*i+8),16);n[i+0]=a>>>24,n[i+1]=a>>>16,n[i+2]=a>>>8,n[i+3]=a}return new e(n)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=dDu.charAt(this.bytes[r]>>>4),t+=dDu.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=dDu.charAt(this.bytes[r]>>>4),t+=dDu.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let n=this.bytes[r]-t.bytes[r];if(n!==0)return Math.sign(n)}return 0}},nAf=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??NIC()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let n=this.generateOrAbortCore(t,r);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(t,r)),n}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return bDu.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,bDu.ofInner(t)}},NIC=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Lwy,iAf=()=>FIC().toString(),FIC=()=>(Lwy||(Lwy=new nAf)).generate();function xIC(e,t){let r=!1;return Object.assign(n=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(n,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function zIC(e,t){global.process.on("uncaughtException",xIC(e,t))}function QIC(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var pDu,Uwy,_Du;function LIC(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return _Du&&r.length===Uwy||(Uwy=r.length,_Du=r.reduce((n,i)=>{pDu||(pDu={});let a=pDu[i];if(a)n[a[0]]=a[1];else{let o=e(i);for(let c=o.length-1;c>=0;c--){let u=o[c]?.filename,s=t[i];if(u&&s){n[u]=s,pDu[i]=[u,s];break}}}return n},{})),_Du}function UIC(e){return typeof Event<"u"&&vjy(e,Event)}function VIC(e){return bjy(e,"Object")}function dAf(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return vjy(e,Error)}}function vjy(e,t){try{return e instanceof t}catch{return!1}}function WIC(e){return bjy(e,"ErrorEvent")}function bjy(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function GIC(e,t,r,n){let a=n&&n.mechanism||{handled:!0,type:"generic"},o=gjy(a,r,n);return{$exception_list:await Promise.all(o.map(async u=>{let s=await ZIC(e,t,u);return s.value=s.value||"",s.type=s.type||"Error",s.mechanism=a,s}))}}function gjy(e,t,r){let n=HIC(e,t,r);return n.cause?[n,...gjy(e,n.cause,r)]:[n]}function HIC(e,t,r){if(dAf(t))return t;if(e.synthetic=!0,VIC(t)){let i=JIC(t);if(i)return i;let a=KIC(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let n=r?.syntheticException||new Error(t);return n.message=`${t}`,n}function JIC(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(dAf(r))return r}}function KIC(e){if("name"in e&&typeof e.name=="string"){let n=`'${e.name}' captured as exception`;return"message"in e&&typeof e.message=="string"&&(n+=` with message '${e.message}'`),n}else if("message"in e&&typeof e.message=="string")return e.message;let t=YIC(e);if(WIC(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=$IC(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function $IC(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function YIC(e,t=40){let r=Object.keys(XIC(e));r.sort();let n=r[0];if(!n)return"[object has no keys]";if(n.length>=t)return Vwy(n,t);for(let i=r.length;i>0;i--){let a=r.slice(0,i).join(", ");if(!(a.length>t))return i===r.length?a:Vwy(a,t)}return""}function Vwy(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function XIC(e){return dAf(e)?{message:e.message,name:e.name,stack:e.stack,...Wwy(e)}:UIC(e)?{type:e.type,target:Gwy(e.target),currentTarget:Gwy(e.currentTarget),...Wwy(e)}:e}function Wwy(e){if(typeof e=="object"&&e!==null){let t={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}else return{}}function Gwy(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function ZIC(e,t,r){let n={type:r.name||r.constructor.name,value:r.message},i=kIC(e,r);for(let a of t)i=await a(i);return i.length&&(n.stacktrace={frames:i,type:"raw"}),n}function kIC(e,t){return eMC(e(t.stack||"",1),e)}function eMC(e,t){let r=LIC(t);return e.forEach(n=>{n.filename&&(n.chunk_id=r[n.filename])}),e}var tMC=2e3,HZa=class e{static async captureException(t,r,n,i,a){let o={...a};i||(o.$process_person_profile=!1);let c=await GIC(this.stackParser,this.frameModifiers,r,n);t.capture({event:"$exception",distinctId:i||iAf(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(zIC(this.onException.bind(this),this.onFatalError.bind(this)),QIC(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(tMC)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function rMC(e=process.argv[1]?(0,$Za.dirname)(process.argv[1]):process.cwd(),t=$Za.sep==="\\"){let r=t?Hwy(e):e;return n=>{if(!n)return;let i=t?Hwy(n):n,{dir:a,base:o,ext:c}=$Za.posix.parse(i);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let u=a.lastIndexOf("/node_modules");if(u>-1)return`${a.slice(u+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let s=a.slice(r.length+1).replace(/\//g,".");return s?`${s}:${f}`:f}return f}}function Hwy(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var gDu=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}},yDu=new gDu(25),mjy=new gDu(20),pAf=7,nMC=1e3,iMC=1e4;async function aMC(e){let t={};for(let i=e.length-1;i>=0;i--){let a=e[i],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||cMC(o)||lMC(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let n=[];for(let i of r){if(mjy.get(i))continue;let a=t[i];if(!a)continue;a.sort((f,u)=>f-u);let o=dMC(a);if(o.every(f=>fMC(i,f)))continue;let c=pMC(yDu,i,{});n.push(oMC(i,o,c))}return await Promise.all(n).catch(()=>{}),e&&e.length>0&&sMC(e,yDu),yDu.reduce(),e}function oMC(e,t,r){return new Promise(n=>{let i=(0,hjy.createReadStream)(e),a=(0,yjy.createInterface)({input:i});function o(){i.destroy(),n()}let c=0,f=0,u=t[f];if(u===void 0){o();return}let s=u[0],l=u[1];function m(){mjy.set(e,1),a.close(),a.removeAllListeners(),o()}i.on("error",m),a.on("error",m),a.on("close",o),a.on("line",O=>{if(c++,!(c<s)&&(r[c]=_MC(O,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let P=t[f];if(P===void 0){a.close(),a.removeAllListeners();return}s=P[0],l=P[1]}})})}function sMC(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let n=t.get(r.filename);if(n===void 0)continue;uMC(r.lineno,r,n)}}function uMC(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let i=Ojy(e);i<e;i++){let a=r[i];if(a===void 0){Jwy(t);return}t.pre_context.push(a)}if(r[e]===void 0){Jwy(t);return}t.context_line=r[e];let n=Ajy(e);t.post_context=[];for(let i=e+1;i<=n;i++){let a=r[i];if(a===void 0)break;t.post_context.push(a)}}function Jwy(e){delete e.pre_context,delete e.context_line,delete e.post_context}function cMC(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function lMC(e){return e.lineno!==void 0&&e.lineno>iMC||e.colno!==void 0&&e.colno>nMC}function fMC(e,t){let r=yDu.get(e);if(r===void 0)return!1;for(let n=t[0];n<=t[1];n++)if(r[n]===void 0)return!1;return!0}function dMC(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let n=Kwy(r),i=[];for(;;){if(t===e.length-1){i.push(n);break}let a=e[t+1];if(typeof a!="number")break;a<=n[1]?n[1]=a+pAf:(i.push(n),n=Kwy(a)),t++}return i}function Kwy(e){return[Ojy(e),Ajy(e)]}function Ojy(e){return Math.max(1,e-pAf)}function Ajy(e){return e+pAf}function pMC(e,t,r){let n=e.get(t);return n===void 0?(e.set(t,r),r):n}function _MC(e,t){let r=e,n=r.length;if(n<=150)return r;t>n&&(t=n);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,n);return a>n-5&&(a=n),a===n&&(i=Math.max(a-140,0)),r=r.slice(i,a),i>0&&(r=`...${r}`),a<n&&(r+="..."),r}var hMC="4.18.0",fxe;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(fxe||(fxe={}));var $wy;(function(e){e.Left="left",e.Right="right",e.Center="center"})($wy||($wy={}));var Ywy;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(Ywy||(Ywy={}));var Xwy;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(Xwy||(Xwy={}));var Zwy;(function(e){e.Html="html",e.Text="text"})(Zwy||(Zwy={}));var kwy;(function(e){e.Number="number",e.Emoji="emoji"})(kwy||(kwy={}));var ejy;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(ejy||(ejy={}));var tjy;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(tjy||(tjy={}));var rjy;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(rjy||(rjy={}));var njy;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(njy||(njy={}));var yMC=e=>{if("flags"in e){let t=bMC(e.flags),r=gMC(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([i,a])=>[i,Pjy(a)])),n=Object.fromEntries(Object.entries(t).map(([i,a])=>[i,vMC(i,a,r[i])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:n}}};function vMC(e,t,r){return{key:e,enabled:typeof t=="string"?!0:t,variant:typeof t=="string"?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var bMC=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,_Af(r)]).filter(([,t])=>t!==void 0)),gMC=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let n=t[r];return n.enabled&&n.metadata&&n.metadata.payload!==void 0}).map(r=>{let n=t[r].metadata?.payload;return[r,n?Pjy(n):void 0]}))},_Af=e=>e===void 0?void 0:e.variant??e.enabled,Pjy=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},mMC=1,OMC=new Set(["61be3dd8","96f6df5f","8cfdba9b","bf027177","e59430a8","7fa5500b","569798e9","04809ff7","0ebc61a5","32de7f98","3beeb69a","12d34ad9","733853ec","0645bb64","5dcbee21","b1f95fa3","2189e408","82b460c2","3a8cc979","29ef8843","2cdbf767","38084b54","50f9f8de","41d0df91","5c236689","c11aedd3","ada46672","f4331ee1","42fed62a","c957462c","d62f705a","e0162666","01b3e5cf","441cef7f","bb9cafee","8f348eb0","b2553f3a","97469d7d","39f21a76","03706dcc","27d50569","307584a7","6433e92e","150c7fbb","49f57f22","3772f65b","01eb8256","3c9e9234","f853c7f7","c0ac4b67","cd609d40","10ca9b1a","8a87f11b","8e8e5216","1f6b63b3","db7943dd","79b7164c","07f78e33","2d21b6fd","952db5ee","a7d3b43f","1924dd9c","84e1b8f6","dff631b6","c5aa8a79","fa133a95","498a4508","24748755","98f3d658","21bbda67","7dbfed69","be3ec24c","fc80b8e2","75cc0998"]),AMC="utf8";function PMC(e,t){if(!e||typeof e!="string"||wMC(e))throw new Error(t)}function wMC(e){return e.trim().length===0}function jMC(e){return e?.replace(/\/+$/,"")}async function EMC(e,t){let r=null;for(let n=0;n<t.retryCount+1;n++){n>0&&await new Promise(i=>setTimeout(i,t.retryDelay));try{return await e()}catch(i){if(r=i,!t.retryCheck(i))throw i}}throw r}function ijy(){return new Date().getTime()}function tAf(){return new Date().toISOString()}function mDu(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function SMC(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function DMC(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return(t>>>0).toString(16).padStart(8,"0")}function CMC(e,t=0,r){let n=DMC(e);return r?.has(n)?!1:parseInt(n,16)/4294967295<t}function ajy(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var j$o=String.fromCharCode,ojy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",hDu={};function IMC(e,t){if(!hDu[e]){hDu[e]={};for(let r=0;r<e.length;r++)hDu[e][e.charAt(r)]=r}return hDu[e][t]}var WZa={compressToBase64:function(e){if(e==null)return"";let t=WZa._compress(e,6,function(r){return ojy.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:WZa._decompress(e.length,32,function(t){return IMC(ojy,e.charAt(t))})},compress:function(e){return WZa._compress(e,16,function(t){return j$o(t)})},_compress:function(e,t,r){if(e==null)return"";let n={},i={},a=[],o,c,f="",u="",s="",l=2,m=3,O=2,P=0,C=0,I;for(I=0;I<e.length;I+=1)if(f=e.charAt(I),Object.prototype.hasOwnProperty.call(n,f)||(n[f]=m++,i[f]=!0),u=s+f,Object.prototype.hasOwnProperty.call(n,u))s=u;else{if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<O;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<O;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[s]}else for(c=n[s],o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,O),O++),n[u]=m++,s=String(f)}if(s!==""){if(Object.prototype.hasOwnProperty.call(i,s)){if(s.charCodeAt(0)<256){for(o=0;o<O;o++)P=P<<1,C==t-1?(C=0,a.push(r(P)),P=0):C++;for(c=s.charCodeAt(0),o=0;o<8;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}else{for(c=1,o=0;o<O;o++)P=P<<1|c,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=0;for(c=s.charCodeAt(0),o=0;o<16;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1}l--,l==0&&(l=Math.pow(2,O),O++),delete i[s]}else for(c=n[s],o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;l--,l==0&&(l=Math.pow(2,O),O++)}for(c=2,o=0;o<O;o++)P=P<<1|c&1,C==t-1?(C=0,a.push(r(P)),P=0):C++,c=c>>1;for(;;)if(P=P<<1,C==t-1){a.push(r(P));break}else C++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:WZa._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let n=[],i=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,u="",s,l,m,O,P,C,I;for(s=0;s<3;s+=1)n[s]=s;for(m=0,P=Math.pow(2,2),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;switch(m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;I=j$o(m);break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;I=j$o(m);break;case 2:return""}for(n[3]=I,l=I,i.push(I);;){if(a.index>e)return"";for(m=0,P=Math.pow(2,f),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;switch(I=m){case 0:for(m=0,P=Math.pow(2,8),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;n[c++]=j$o(m),I=c-1,o--;break;case 1:for(m=0,P=Math.pow(2,16),C=1;C!=P;)O=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),m|=(O>0?1:0)*C,C<<=1;n[c++]=j$o(m),I=c-1,o--;break;case 2:return i.join("")}if(o==0&&(o=Math.pow(2,f),f++),n[I])u=n[I];else if(I===c)u=l+l.charAt(0);else return null;i.push(u),n[c++]=l+u.charAt(0),o--,l=u,o==0&&(o=Math.pow(2,f),f++)}}},aAf=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(n=>n!==r)}}emit(t,r){for(let n of this.events[t]||[])n(r);for(let n of this.events["*"]||[])n(t,r)}},JZa=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},E$o=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function sjy(e){if(e instanceof JZa){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function rAf(e){return typeof e=="object"&&(e instanceof JZa||e instanceof E$o)}function ujy(e){return typeof e=="object"&&e instanceof JZa&&e.status===413}var oAf;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(oAf||(oAf={}));var sAf=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new aAf,this._isInitialized=!1,PMC(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=jMC(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.preloadFeatureFlags=r?.preloadFeatureFlags??!0,this.defaultOptIn=r?.defaultOptIn??!0,this.disableSurveys=r?.disableSurveys??!1,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:rAf},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r?.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(fxe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(fxe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(fxe.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(n,i)=>console.log("PostHog Debug",n,i));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=iAf();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,n){this.wrap(()=>{let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",i,n)})}async identifyStatelessImmediate(t,r,n){let i={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",i,n)}captureStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:n});this.enqueue("capture",a,i)})}async captureStatelessImmediate(t,r,n,i){let a=this.buildPayload({distinct_id:t,event:r,properties:n});await this.sendImmediate("capture",a,i)}aliasStateless(t,r,n,i){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});this.enqueue("alias",a,i)})}async aliasStatelessImmediate(t,r,n,i){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...n||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,i)}groupIdentifyStateless(t,r,n,i,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:n||{},...o||{}}});this.enqueue("capture",c,i)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,n={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(i=>i.json()).catch(i=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",i)),this._events.emit("error",i)})}async getDecide(t,r={},n={},i={},a={}){await this._initPromise;let c=CMC(this.apiKey,mMC,OMC)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:n,group_properties:i,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(u=>u.json()).then(u=>yMC(u)).catch(u=>{this._events.emit("error",u)})}async getFeatureFlagStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,n,i,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=_Af(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,n,i,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,n={},i={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,n,i,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},n={},i={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)).payloads}async getFeatureFlagsStateless(t,r={},n={},i={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,n,i,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,n,i,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},n={},i={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,n,i,c);if(f!==void 0)return f.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),f.quotaLimited?.includes(oAf.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},i=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return i&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(i))),i??[]}get props(){return this._props||(this._props=this.getPersistedProperty(fxe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(fxe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(fxe.Props,this.props)})}enqueue(t,r,n){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i=this.prepareMessage(t,r,n),a=this.getPersistedProperty(fxe.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:i}),this.setPersistedProperty(fxe.Queue,a),this._events.emit(t,i),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=mDu(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,n){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let i={api_key:this.apiKey,batch:[this.prepareMessage(t,r,n)],sent_at:tAf()};this.historicalMigration&&(i.historical_migration=!0);let a=JSON.stringify(i),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${ijy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,c=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(WZa.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,n){let i={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:tAf(),uuid:n?.uuid?n.uuid:iAf()};return(n?.disableGeoip??this.disableGeoip)&&(i.properties||(i.properties={}),i.properties.$geoip_disable=!0),i.distinctId&&(i.distinct_id=i.distinctId,delete i.distinctId),i}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await sjy(t)})}async flush(){let t=ajy([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),ajy([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(fxe.Queue)||[];if(!t.length)return;let r=[],n=t.length;for(;t.length>0&&r.length<n;){let i=t.slice(0,this.maxBatchSize),a=i.map(m=>m.message),o=()=>{let O=(this.getPersistedProperty(fxe.Queue)||[]).slice(i.length);this.setPersistedProperty(fxe.Queue,O),t=O},c={api_key:this.apiKey,batch:a,sent_at:tAf()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${ijy()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,s=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(WZa.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:m=>ujy(m)?!1:rAf(m)};try{await this.fetchWithRetry(u,s,l)}catch(m){if(ujy(m)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw m instanceof E$o||o(),this._events.emit("error",m),m}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,n,i){var a;(a=AbortSignal).timeout??(a.timeout=function(u){let s=new AbortController;return setTimeout(()=>s.abort(),u),s.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,AMC)}catch{c=new TextEncoder().encode(o).length}return await EMC(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(i??this.requestTimeout),...r})}catch(s){throw new E$o(s)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new JZa(f,c);return f},{...this._retryOptions,...n})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let n=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(fxe.Queue)||[]).length===0||(await this.flush(),r)););}catch(i){if(!rAf(i))throw i;await sjy(i)}};return Promise.race([new Promise((i,a)=>{mDu(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),n()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},uAf=SMC();if(!uAf){let e=zwy();uAf=async(t,r)=>{let n=await e.request({url:t,headers:r.headers,method:r.method.toLowerCase(),data:r.body,signal:r.signal,validateStatus:()=>!0});return{status:n.status,text:async()=>n.data,json:async()=>n.data}}}var wjy=uAf,ODu=class{constructor(t){this.factory=t}async getValue(){return this.value!==void 0?this.value:(this.initializationPromise===void 0&&(this.initializationPromise=(async()=>{try{let t=await this.factory();return this.value=t,t}finally{this.initializationPromise=void 0}})()),this.initializationPromise)}isInitialized(){return this.value!==void 0}async waitForInitialization(){this.isInitialized()||await this.getValue()}},jjy=new ODu(async()=>{try{return await import("crypto")}catch{return}});async function MMC(){return await jjy.getValue()}var BMC=new ODu(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await jjy.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function TMC(){return await BMC.getValue()}async function qMC(e){let t=await MMC();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await TMC();if(r){let n=await r.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(a=>a.toString(16).padStart(2,"0")).join("")}throw new Error("No crypto implementation available. Tried Node Crypto API and Web SubtleCrypto API")}var RMC=60*1e3,NMC=1152921504606847e3,FMC=["is_not"],GZa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},Ase=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},cAf=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:n,timeout:i,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=i,this.projectApiKey=n,this.host=a,this.poller=void 0,this.fetch=c.fetch||wjy,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,n={},i={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,n,i,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof Ase?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let n;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(n=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),n==null)return null;try{return JSON.parse(n)}catch{return n}}}async getAllFlagsAndPayloads(t,r={},n={},i={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let u=await this.computeFlagLocally(f,t,r,n,i);a[f.key]=u;let s=await this.computeFeatureFlagPayloadLocally(f.key,u);s&&(o[f.key]=s)}catch(u){u instanceof Ase||u instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${u}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,n={},i={},a={}){if(t.ensure_experience_continuity)throw new Ase("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let f=this.groupTypeMapping[String(c)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new Ase("Flag has unknown group type index");if(!(f in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[f];return await this.matchFeatureFlagProperties(t,n[f],u)}else return await this.matchFeatureFlagProperties(t,r,i)}async matchFeatureFlagProperties(t,r,n){let i=t.filters||{},a=i.groups||[],o=!1,c,f=[...a].sort((u,s)=>{let l=!!u.variant,m=!!s.variant;return l&&m?0:l?-1:m?1:0});for(let u of f)try{if(await this.isConditionMatch(t,r,u,n)){let s=u.variant,l=i.multivariate?.variants||[];s&&l.some(m=>m.key===s)?c=s:c=await this.getMatchingVariant(t,r)||!0;break}}catch(s){if(s instanceof Ase)o=!0;else throw s}if(c!==void 0)return c;if(o)throw new Ase("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,n,i){let a=n.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((n.properties||[]).length>0){for(let c of n.properties){let f=c.type,u=!1;if(f==="cohort"?u=Sjy(c,i,this.cohorts,this.debugMode):u=Ejy(c,i,o),!u)return!1}if(a==null)return!0}return!(a!=null&&await cjy(t.key,r)>a/100)}async getMatchingVariant(t,r){let n=await cjy(t.key,r,"variant"),i=this.variantLookupTable(t).find(a=>n>=a.valueMin&&n<a.valueMax);if(i)return i.key}variantLookupTable(t){let r=[],n=0,i=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{i=n+c.rollout_percentage/100,r.push({valueMin:n,valueMax:i,key:c.key}),n=i}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(RMC,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new GZa(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new GZa(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new GZa(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((n,i)=>(n[i.key]=i,n),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof GZa&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let i=new AbortController;n=mDu(()=>{i.abort()},this.timeout),r.signal=i.signal}try{return await this.fetch(t,r)}finally{clearTimeout(n)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,n=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;i=mDu(()=>{a.abort()},this.timeout),n.signal=a.signal}try{return this.fetch(r,n)}finally{clearTimeout(i)}}};async function cjy(e,t,r=""){let n=await qMC(`${e}.${t}${r}`);return parseInt(n.slice(0,15),16)/NMC}function Ejy(e,t,r){let n=e.key,i=e.value,a=e.operator||"exact";if(n in t){if(a==="is_not_set")throw new Ase("Operator is_not_set is not supported")}else throw new Ase(`Property ${n} not found in propertyValues`);let o=t[n];if(o==null&&!FMC.includes(a))return r&&r(`Property ${n} cannot have a value of null/undefined with the ${a} operator`),!1;function c(u,s){return Array.isArray(u)?u.map(l=>String(l).toLowerCase()).includes(String(s).toLowerCase()):String(u).toLowerCase()===String(s).toLowerCase()}function f(u,s,l){if(l==="gt")return u>s;if(l==="gte")return u>=s;if(l==="lt")return u<s;if(l==="lte")return u<=s;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(i,o);case"is_not":return!c(i,o);case"is_set":return n in t;case"icontains":return String(o).toLowerCase().includes(String(i).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(i).toLowerCase());case"regex":return ljy(String(i))&&String(o).match(String(i))!==null;case"not_regex":return ljy(String(i))&&String(o).match(String(i))===null;case"gt":case"gte":case"lt":case"lte":{let u=typeof i=="number"?i:null;if(typeof i=="string")try{u=parseFloat(i)}catch{}return u!=null&&o!=null?typeof o=="string"?f(o,String(i),a):f(o,u,a):f(String(o),String(i),a)}case"is_date_after":case"is_date_before":{let u=xMC(String(i));if(u==null&&(u=fjy(i)),u==null)throw new Ase(`Invalid date: ${i}`);let s=fjy(o);return["is_date_before"].includes(a)?s<u:s>u}default:throw new Ase(`Unknown operator: ${a}`)}}function Sjy(e,t,r,n=!1){let i=String(e.value);if(!(i in r))throw new Ase("can't match cohort without a given cohort property value");let a=r[i];return Djy(a,t,r,n)}function Djy(e,t,r,n=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=Djy(c,t,r,n);if(i==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof Ase)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new Ase("Can't match cohort without a given cohort property value");return i==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=Sjy(c,t,r,n):f=Ejy(c,t);let u=c.negation||!1;if(i==="AND"){if(!f&&!u||f&&u)return!1}else if(f&&!u||!f&&u)return!0}catch(f){if(f instanceof Ase)n&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new Ase("can't match cohort without a given cohort property value");return i==="AND"}}function ljy(e){try{return new RegExp(e),!0}catch{return!1}}function fjy(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new Ase(`${e} is in an invalid date format`)}else throw new Ase(`The date provided ${e} must be a string, number, or date object`)}function xMC(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),n=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let i=parseInt(r.groups.number);if(i>=1e4)return null;let a=r.groups.interval;if(a=="h")n.setUTCHours(n.getUTCHours()-i);else if(a=="d")n.setUTCDate(n.getUTCDate()-i);else if(a=="w")n.setUTCDate(n.getUTCDate()-i*7);else if(a=="m")n.setUTCMonth(n.getUTCMonth()-i);else if(a=="y")n.setUTCFullYear(n.getUTCFullYear()-i);else return null;return n}else return null}var lAf=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},zMC=100,djy=30*1e3,QMC=50*1e3,fAf=class extends sAf{constructor(t,r={}){if(super(t,r),this._memoryStorage=new lAf,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,zMC):djy,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');this.featureFlagsPoller=new cAf({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new HZa(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||QMC}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):wjy(t,r)}getLibraryVersion(){return hMC}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=O=>{super.captureStateless(r,n,O,{timestamp:c,disableGeoip:f,uuid:u})},l=async(O,P,C)=>(await super.getFeatureFlagsStateless(O,P,void 0,void 0,C)).flags,m=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let O={};for(let[P,C]of Object.entries(a||{}))O[P]=String(C);return await this.getAllFlags(r,{groups:O,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(O=>{let P={};if(O)for(let[I,T]of Object.entries(O))P[`$feature/${I}`]=T;let C=Object.keys(O||{}).filter(I=>O?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(O=>{s({...O,...i,$groups:a})});this.addPendingPromise(m)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:n,properties:i,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:u}=t,s=O=>super.captureStatelessImmediate(r,n,O,{timestamp:c,disableGeoip:f,uuid:u}),l=async(O,P,C)=>(await super.getFeatureFlagsStateless(O,P,void 0,void 0,C)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(n==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let O={};for(let[P,C]of Object.entries(a||{}))O[P]=String(C);return await this.getAllFlags(r,{groups:O,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(O=>{let P={};if(O)for(let[I,T]of Object.entries(O))P[`$feature/${I}`]=T;let C=Object.keys(O||{}).filter(I=>O?.[I]!==!1).sort();return C.length>0&&(P.$active_feature_flags=C),P}).catch(()=>({})).then(O=>{s({...O,...i,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:i},{disableGeoip:n})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:n}){let i=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:i},{disableGeoip:n})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=djy){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let n=setTimeout(()=>{i(),r(!1)},t),i=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(n),i(),r(a>0)})})}async getFeatureFlag(t,r,n){let{groups:i,disableGeoip:a}=n||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:u}=n||{},s=this.addLocalPersonAndGroupProperties(r,i,f,u);f=s.allPersonProperties,u=s.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,i,f,u),m=l!==void 0,O,P;if(!m&&!o){let I=await super.getFeatureFlagDetailStateless(t,r,i,f,u,a);if(I===void 0)return;P=I.response,l=_Af(P),O=I?.requestId}let C=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(C))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(C):this.distinctIdHasSentFlagCalls[r]=[C],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:P?.metadata?.id,$feature_flag_version:P?.metadata?.version,$feature_flag_reason:P?.reason?.description??P?.reason?.code,locally_evaluated:m,[`$feature/${t}`]:l,$feature_flag_request_id:O},groups:i,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,n,i){let{groups:a,disableGeoip:o}=i||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:u,groupProperties:s}=i||{},l=this.addLocalPersonAndGroupProperties(r,a,u,s);u=l.allPersonProperties,s=l.allGroupProperties;let m;return this.featureFlagsPoller!==void 0&&(n||(n=await this.getFeatureFlag(t,r,{...i,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),n&&(m=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,n))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(m!==void 0)&&!c&&(m=await super.getFeatureFlagPayloadStateless(t,r,a,u,s,o)),m}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,n){let i=await this.getFeatureFlag(t,r,n);if(i!==void 0)return!!i||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:n,disableGeoip:i}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,n,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,n,o,c),s={},l={},m=!0;if(u&&(s=u.response,l=u.payloads,m=u.fallbackToDecide),m&&!a){let O=await super.getFeatureFlagsAndPayloadsStateless(t,n,o,c,i);s={...s,...O.flags||{}},l={...l,...O.payloads||{}}}return{featureFlags:s,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:n,distinctId:i,disableGeoip:a}){super.groupIdentifyStateless(t,r,n,{disableGeoip:a},i)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,n,i){let a={distinct_id:t,...n||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...i?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,n){let i=new Error("PostHog syntheticException");HZa.captureException(this,t,{syntheticException:i},r,n)}},pjy=/\(error: (.*)\)/,Cjy=50,Ijy="?";function LMC(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return n=>{let i=n.match(r);if(i){let a,o,c,f,u;if(i[1]){c=i[1];let m=c.lastIndexOf(".");if(c[m-1]==="."&&m--,m>0){a=c.slice(0,m),o=c.slice(m+1);let O=a.indexOf(".Module");O>0&&(c=c.slice(O+1),a=a.slice(0,O))}f=void 0}o&&(f=a,u=o),o==="<anonymous>"&&(u=void 0,c=void 0),c===void 0&&(u=u||Ijy,c=f?`${f}.${u}`:u);let s=i[2]?.startsWith("file://")?i[2].slice(7):i[2],l=i[5]==="native";return s?.match(/\/[A-Z]:/)&&(s=s.slice(1)),!s&&i[5]&&!l&&(s=i[5]),{filename:s?decodeURI(s):void 0,module:e?e(s):void 0,function:c,lineno:_jy(i[3]),colno:_jy(i[4]),in_app:UMC(s||"",l),platform:"node:javascript"}}if(n.match(t))return{filename:n,platform:"node:javascript"}}}function UMC(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes("node_modules/")}function _jy(e){return parseInt(e||"",10)||void 0}function VMC(e){return[90,LMC(e)]}function WMC(e){let r=[VMC(e)].sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0)=>{let a=[],o=n.split(`
|
|
2433
|
-
`);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=pjy.test(f)?f.replace(pjy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=Cjy)break}}return GMC(a)}}function GMC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,Cjy).map(r=>({...r,filename:r.filename||HMC(t).filename,function:r.function||Ijy}))}function HMC(e){return e[e.length-1]||{}}HZa.stackParser=WMC(rMC());HZa.frameModifiers=[aMC];var KZa=class extends fAf{getLibraryId(){return"posthog-node"}};var ADu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new KZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.115.3",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var S$o=class{async sendEvent(){}async identify(){}async flush(){}};var YZa=require("fs/promises"),qjy=require("os"),Rjy=require("path");var Mjy=$i(require("crypto")),wDu=new Uint8Array(256),PDu=wDu.length;function hAf(){return PDu>wDu.length-16&&(Mjy.default.randomFillSync(wDu),PDu=0),wDu.slice(PDu,PDu+=16)}var Kve=[];for(let e=0;e<256;++e)Kve.push((e+256).toString(16).slice(1));function Bjy(e,t=0){return Kve[e[t+0]]+Kve[e[t+1]]+Kve[e[t+2]]+Kve[e[t+3]]+"-"+Kve[e[t+4]]+Kve[e[t+5]]+"-"+Kve[e[t+6]]+Kve[e[t+7]]+"-"+Kve[e[t+8]]+Kve[e[t+9]]+"-"+Kve[e[t+10]]+Kve[e[t+11]]+Kve[e[t+12]]+Kve[e[t+13]]+Kve[e[t+14]]+Kve[e[t+15]]}var Tjy=$i(require("crypto")),yAf={randomUUID:Tjy.default.randomUUID};function JMC(e,t,r){if(yAf.randomUUID&&!t&&!e)return yAf.randomUUID();e=e||{};let n=e.random||(e.rng||hAf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Bjy(n)}var xrt=JMC;var KMC="id",$MC=".fern",D$o=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new KZa(r),this.userId=t==null?void 0:Fhf(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.115.3",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ql(F_.of((0,qjy.homedir)()),ru.of($MC),ru.of(KMC));await Vv(t)||(await(0,YZa.mkdir)((0,Rjy.dirname)(t),{recursive:!0}),await(0,YZa.writeFile)(t,xrt())),this.persistedDistinctId=(await(0,YZa.readFile)(t)).toString()}return this.persistedDistinctId}};var vAf;async function XZa(){return vAf==null&&(vAf=await YMC()),vAf}async function YMC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new S$o;let r=await LAu();return r!=null?new D$o({token:r,posthogApiKey:e}):await eXa()!=null?new ADu({posthogApiKey:e}):new D$o({token:void 0,posthogApiKey:e})}catch{return new S$o}}function C$o(e,t){return function(){return e.apply(t,arguments)}}var{toString:XMC}=Object.prototype,{getPrototypeOf:gAf}=Object,{iterator:EDu,toStringTag:Fjy}=Symbol,SDu=(e=>t=>{let r=XMC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),YTr=e=>(e=e.toLowerCase(),t=>SDu(t)===e),DDu=e=>t=>typeof t===e,{isArray:kZa}=Array,ZZa=DDu("undefined");function I$o(e){return e!==null&&!ZZa(e)&&e.constructor!==null&&!ZZa(e.constructor)&&dxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var xjy=YTr("ArrayBuffer");function ZMC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xjy(e.buffer),t}var kMC=DDu("string"),dxe=DDu("function"),zjy=DDu("number"),M$o=e=>e!==null&&typeof e=="object",eBC=e=>e===!0||e===!1,jDu=e=>{if(SDu(e)!=="object")return!1;let t=gAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Fjy in e)&&!(EDu in e)},tBC=e=>{if(!M$o(e)||I$o(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rBC=YTr("Date"),nBC=YTr("File"),iBC=YTr("Blob"),aBC=YTr("FileList"),oBC=e=>M$o(e)&&dxe(e.pipe),sBC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||dxe(e.append)&&((t=SDu(e))==="formdata"||t==="object"&&dxe(e.toString)&&e.toString()==="[object FormData]"))},uBC=YTr("URLSearchParams"),[cBC,lBC,fBC,dBC]=["ReadableStream","Request","Response","Headers"].map(YTr),pBC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function B$o(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),kZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(I$o(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function Qjy(e,t){if(I$o(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Lua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ljy=e=>!ZZa(e)&&e!==Lua;function bAf(){let{caseless:e,skipUndefined:t}=Ljy(this)&&this||{},r={},n=(i,a)=>{let o=e&&Qjy(r,a)||a;jDu(r[o])&&jDu(i)?r[o]=bAf(r[o],i):jDu(i)?r[o]=bAf({},i):kZa(i)?r[o]=i.slice():(!t||!ZZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&B$o(arguments[i],n);return r}var _BC=(e,t,r,{allOwnKeys:n}={})=>(B$o(t,(i,a)=>{r&&dxe(i)?e[a]=C$o(i,r):e[a]=i},{allOwnKeys:n}),e),hBC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),yBC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},vBC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&gAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},bBC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},gBC=e=>{if(!e)return null;if(kZa(e))return e;let t=e.length;if(!zjy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},mBC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&gAf(Uint8Array)),OBC=(e,t)=>{let n=(e&&e[EDu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ABC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},PBC=YTr("HTMLFormElement"),wBC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),Njy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),jBC=YTr("RegExp"),Ujy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};B$o(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},EBC=e=>{Ujy(e,(t,r)=>{if(dxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(dxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},SBC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return kZa(e)?n(e):n(String(e).split(t)),r},DBC=()=>{},CBC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function IBC(e){return!!(e&&dxe(e.append)&&e[Fjy]==="FormData"&&e[EDu])}var MBC=e=>{let t=new Array(10),r=(n,i)=>{if(M$o(n)){if(t.indexOf(n)>=0)return;if(I$o(n))return n;if(!("toJSON"in n)){t[i]=n;let a=kZa(n)?[]:{};return B$o(n,(o,c)=>{let f=r(o,i+1);!ZZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},BBC=YTr("AsyncFunction"),TBC=e=>e&&(M$o(e)||dxe(e))&&dxe(e.then)&&dxe(e.catch),Vjy=((e,t)=>e?setImmediate:t?((r,n)=>(Lua.addEventListener("message",({source:i,data:a})=>{i===Lua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Lua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",dxe(Lua.postMessage)),qBC=typeof queueMicrotask<"u"?queueMicrotask.bind(Lua):typeof process<"u"&&process.nextTick||Vjy,RBC=e=>e!=null&&dxe(e[EDu]),Zf={isArray:kZa,isArrayBuffer:xjy,isBuffer:I$o,isFormData:sBC,isArrayBufferView:ZMC,isString:kMC,isNumber:zjy,isBoolean:eBC,isObject:M$o,isPlainObject:jDu,isEmptyObject:tBC,isReadableStream:cBC,isRequest:lBC,isResponse:fBC,isHeaders:dBC,isUndefined:ZZa,isDate:rBC,isFile:nBC,isBlob:iBC,isRegExp:jBC,isFunction:dxe,isStream:oBC,isURLSearchParams:uBC,isTypedArray:mBC,isFileList:aBC,forEach:B$o,merge:bAf,extend:_BC,trim:pBC,stripBOM:hBC,inherits:yBC,toFlatObject:vBC,kindOf:SDu,kindOfTest:YTr,endsWith:bBC,toArray:gBC,forEachEntry:OBC,matchAll:ABC,isHTMLForm:PBC,hasOwnProperty:Njy,hasOwnProp:Njy,reduceDescriptors:Ujy,freezeMethods:EBC,toObjectSet:SBC,toCamelCase:wBC,noop:DBC,toFiniteNumber:CBC,findKey:Qjy,global:Lua,isContextDefined:Ljy,isSpecCompliantForm:IBC,toJSONObject:MBC,isAsyncFn:BBC,isThenable:TBC,setImmediate:Vjy,asap:qBC,isIterable:RBC};function eka(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(eka,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var Wjy=eka.prototype,Gjy={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Gjy[e]={value:e}});Object.defineProperties(eka,Gjy);Object.defineProperty(Wjy,"isAxiosError",{value:!0});eka.from=(e,t,r,n,i,a)=>{let o=Object.create(Wjy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return eka.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Lm=eka;var Hjy=$i(jsa(),1),CDu=Hjy.default;function mAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function Kjy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function Jjy(e,t,r){return e?e.concat(t).map(function(i,a){return i=Kjy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function NBC(e){return Zf.isArray(e)&&!e.some(mAf)}var FBC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function xBC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(CDu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new Lm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&NBC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=Kjy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?Jjy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return mAf(P)?!0:(t.append(Jjy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(FBC,{defaultVisitor:s,convertValue:u,isVisitable:mAf});function O(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&O(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return O(e),t}var S4i=xBC;function $jy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Yjy(e,t){this._pairs=[],e&&S4i(e,this,t)}var Xjy=Yjy.prototype;Xjy.append=function(t,r){this._pairs.push([t,r])};Xjy.toString=function(t){let r=t?function(n){return t.call(this,n,$jy)}:$jy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var Zjy=Yjy;function zBC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Uua(e,t,r){if(!t)return e;let n=r&&r.encode||zBC;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new Zjy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var OAf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},AAf=OAf;var tka={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var r1y=$i(require("crypto"),1);var kjy=$i(require("url"),1),e1y=kjy.default.URLSearchParams;var PAf="abcdefghijklmnopqrstuvwxyz",t1y="0123456789",n1y={DIGIT:t1y,ALPHA:PAf,ALPHA_DIGIT:PAf+PAf.toUpperCase()+t1y},QBC=(e=16,t=n1y.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);r1y.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},i1y={isNode:!0,classes:{URLSearchParams:e1y,FormData:CDu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:n1y,generateString:QBC,protocols:["http","https","file","data"]};var EAf={};yf(EAf,{hasBrowserEnv:()=>jAf,hasStandardBrowserEnv:()=>LBC,hasStandardBrowserWebWorkerEnv:()=>UBC,navigator:()=>wAf,origin:()=>VBC});var jAf=typeof window<"u"&&typeof document<"u",wAf=typeof navigator=="object"&&navigator||void 0,LBC=jAf&&(!wAf||["ReactNative","NativeScript","NS"].indexOf(wAf.product)<0),UBC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VBC=jAf&&window.location.href||"http://localhost";var G7={...EAf,...i1y};function SAf(e,t){return S4i(e,new G7.classes.URLSearchParams,{visitor:function(r,n,i,a){return G7.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function WBC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GBC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function HBC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=GBC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(WBC(n),i,r,0)}),r}return null}var IDu=HBC;function JBC(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var DAf={transitional:tka,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(IDu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return SAf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return S4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),JBC(t)):t}],transformResponse:[function(t){let r=this.transitional||DAf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Lm.from(c,Lm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:G7.classes.FormData,Blob:G7.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{DAf.headers[e]={}});var rka=DAf;var KBC=Zf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),a1y=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2433
|
+
`);for(let c=i;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let u=pjy.test(f)?f.replace(pjy,"$1"):f;if(!u.match(/\S*Error: /)){for(let s of r){let l=s(u);if(l){a.push(l);break}}if(a.length>=Cjy)break}}return GMC(a)}}function GMC(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,Cjy).map(r=>({...r,filename:r.filename||HMC(t).filename,function:r.function||Ijy}))}function HMC(e){return e[e.length-1]||{}}HZa.stackParser=WMC(rMC());HZa.frameModifiers=[aMC];var KZa=class extends fAf{getLibraryId(){return"posthog-node"}};var ADu=class{posthog;constructor({posthogApiKey:t}){this.posthog=new KZa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.115.4",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var S$o=class{async sendEvent(){}async identify(){}async flush(){}};var YZa=require("fs/promises"),qjy=require("os"),Rjy=require("path");var Mjy=$i(require("crypto")),wDu=new Uint8Array(256),PDu=wDu.length;function hAf(){return PDu>wDu.length-16&&(Mjy.default.randomFillSync(wDu),PDu=0),wDu.slice(PDu,PDu+=16)}var Kve=[];for(let e=0;e<256;++e)Kve.push((e+256).toString(16).slice(1));function Bjy(e,t=0){return Kve[e[t+0]]+Kve[e[t+1]]+Kve[e[t+2]]+Kve[e[t+3]]+"-"+Kve[e[t+4]]+Kve[e[t+5]]+"-"+Kve[e[t+6]]+Kve[e[t+7]]+"-"+Kve[e[t+8]]+Kve[e[t+9]]+"-"+Kve[e[t+10]]+Kve[e[t+11]]+Kve[e[t+12]]+Kve[e[t+13]]+Kve[e[t+14]]+Kve[e[t+15]]}var Tjy=$i(require("crypto")),yAf={randomUUID:Tjy.default.randomUUID};function JMC(e,t,r){if(yAf.randomUUID&&!t&&!e)return yAf.randomUUID();e=e||{};let n=e.random||(e.rng||hAf)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Bjy(n)}var xrt=JMC;var KMC="id",$MC=".fern",D$o=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new KZa(r),this.userId=t==null?void 0:Fhf(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.115.4",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Ql(F_.of((0,qjy.homedir)()),ru.of($MC),ru.of(KMC));await Vv(t)||(await(0,YZa.mkdir)((0,Rjy.dirname)(t),{recursive:!0}),await(0,YZa.writeFile)(t,xrt())),this.persistedDistinctId=(await(0,YZa.readFile)(t)).toString()}return this.persistedDistinctId}};var vAf;async function XZa(){return vAf==null&&(vAf=await YMC()),vAf}async function YMC(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new S$o;let r=await LAu();return r!=null?new D$o({token:r,posthogApiKey:e}):await eXa()!=null?new ADu({posthogApiKey:e}):new D$o({token:void 0,posthogApiKey:e})}catch{return new S$o}}function C$o(e,t){return function(){return e.apply(t,arguments)}}var{toString:XMC}=Object.prototype,{getPrototypeOf:gAf}=Object,{iterator:EDu,toStringTag:Fjy}=Symbol,SDu=(e=>t=>{let r=XMC.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),YTr=e=>(e=e.toLowerCase(),t=>SDu(t)===e),DDu=e=>t=>typeof t===e,{isArray:kZa}=Array,ZZa=DDu("undefined");function I$o(e){return e!==null&&!ZZa(e)&&e.constructor!==null&&!ZZa(e.constructor)&&dxe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var xjy=YTr("ArrayBuffer");function ZMC(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xjy(e.buffer),t}var kMC=DDu("string"),dxe=DDu("function"),zjy=DDu("number"),M$o=e=>e!==null&&typeof e=="object",eBC=e=>e===!0||e===!1,jDu=e=>{if(SDu(e)!=="object")return!1;let t=gAf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Fjy in e)&&!(EDu in e)},tBC=e=>{if(!M$o(e)||I$o(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},rBC=YTr("Date"),nBC=YTr("File"),iBC=YTr("Blob"),aBC=YTr("FileList"),oBC=e=>M$o(e)&&dxe(e.pipe),sBC=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||dxe(e.append)&&((t=SDu(e))==="formdata"||t==="object"&&dxe(e.toString)&&e.toString()==="[object FormData]"))},uBC=YTr("URLSearchParams"),[cBC,lBC,fBC,dBC]=["ReadableStream","Request","Response","Headers"].map(YTr),pBC=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function B$o(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,i;if(typeof e!="object"&&(e=[e]),kZa(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(I$o(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(n=0;n<o;n++)c=a[n],t.call(null,e[c],c,e)}}function Qjy(e,t){if(I$o(e))return null;t=t.toLowerCase();let r=Object.keys(e),n=r.length,i;for(;n-- >0;)if(i=r[n],t===i.toLowerCase())return i;return null}var Lua=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ljy=e=>!ZZa(e)&&e!==Lua;function bAf(){let{caseless:e,skipUndefined:t}=Ljy(this)&&this||{},r={},n=(i,a)=>{let o=e&&Qjy(r,a)||a;jDu(r[o])&&jDu(i)?r[o]=bAf(r[o],i):jDu(i)?r[o]=bAf({},i):kZa(i)?r[o]=i.slice():(!t||!ZZa(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&B$o(arguments[i],n);return r}var _BC=(e,t,r,{allOwnKeys:n}={})=>(B$o(t,(i,a)=>{r&&dxe(i)?e[a]=C$o(i,r):e[a]=i},{allOwnKeys:n}),e),hBC=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),yBC=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},vBC=(e,t,r,n)=>{let i,a,o,c={};if(t=t||{},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!n||n(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&gAf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},bBC=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},gBC=e=>{if(!e)return null;if(kZa(e))return e;let t=e.length;if(!zjy(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},mBC=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&gAf(Uint8Array)),OBC=(e,t)=>{let n=(e&&e[EDu]).call(e),i;for(;(i=n.next())&&!i.done;){let a=i.value;t.call(e,a[0],a[1])}},ABC=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},PBC=YTr("HTMLFormElement"),wBC=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),Njy=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),jBC=YTr("RegExp"),Ujy=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};B$o(r,(i,a)=>{let o;(o=t(i,a,e))!==!1&&(n[a]=o||i)}),Object.defineProperties(e,n)},EBC=e=>{Ujy(e,(t,r)=>{if(dxe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(dxe(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},SBC=(e,t)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return kZa(e)?n(e):n(String(e).split(t)),r},DBC=()=>{},CBC=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function IBC(e){return!!(e&&dxe(e.append)&&e[Fjy]==="FormData"&&e[EDu])}var MBC=e=>{let t=new Array(10),r=(n,i)=>{if(M$o(n)){if(t.indexOf(n)>=0)return;if(I$o(n))return n;if(!("toJSON"in n)){t[i]=n;let a=kZa(n)?[]:{};return B$o(n,(o,c)=>{let f=r(o,i+1);!ZZa(f)&&(a[c]=f)}),t[i]=void 0,a}}return n};return r(e,0)},BBC=YTr("AsyncFunction"),TBC=e=>e&&(M$o(e)||dxe(e))&&dxe(e.then)&&dxe(e.catch),Vjy=((e,t)=>e?setImmediate:t?((r,n)=>(Lua.addEventListener("message",({source:i,data:a})=>{i===Lua&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),Lua.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",dxe(Lua.postMessage)),qBC=typeof queueMicrotask<"u"?queueMicrotask.bind(Lua):typeof process<"u"&&process.nextTick||Vjy,RBC=e=>e!=null&&dxe(e[EDu]),Zf={isArray:kZa,isArrayBuffer:xjy,isBuffer:I$o,isFormData:sBC,isArrayBufferView:ZMC,isString:kMC,isNumber:zjy,isBoolean:eBC,isObject:M$o,isPlainObject:jDu,isEmptyObject:tBC,isReadableStream:cBC,isRequest:lBC,isResponse:fBC,isHeaders:dBC,isUndefined:ZZa,isDate:rBC,isFile:nBC,isBlob:iBC,isRegExp:jBC,isFunction:dxe,isStream:oBC,isURLSearchParams:uBC,isTypedArray:mBC,isFileList:aBC,forEach:B$o,merge:bAf,extend:_BC,trim:pBC,stripBOM:hBC,inherits:yBC,toFlatObject:vBC,kindOf:SDu,kindOfTest:YTr,endsWith:bBC,toArray:gBC,forEachEntry:OBC,matchAll:ABC,isHTMLForm:PBC,hasOwnProperty:Njy,hasOwnProp:Njy,reduceDescriptors:Ujy,freezeMethods:EBC,toObjectSet:SBC,toCamelCase:wBC,noop:DBC,toFiniteNumber:CBC,findKey:Qjy,global:Lua,isContextDefined:Ljy,isSpecCompliantForm:IBC,toJSONObject:MBC,isAsyncFn:BBC,isThenable:TBC,setImmediate:Vjy,asap:qBC,isIterable:RBC};function eka(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Zf.inherits(eka,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Zf.toJSONObject(this.config),code:this.code,status:this.status}}});var Wjy=eka.prototype,Gjy={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Gjy[e]={value:e}});Object.defineProperties(eka,Gjy);Object.defineProperty(Wjy,"isAxiosError",{value:!0});eka.from=(e,t,r,n,i,a)=>{let o=Object.create(Wjy);Zf.toFlatObject(e,o,function(s){return s!==Error.prototype},u=>u!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return eka.call(o,c,f,r,n,i),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var Lm=eka;var Hjy=$i(jsa(),1),CDu=Hjy.default;function mAf(e){return Zf.isPlainObject(e)||Zf.isArray(e)}function Kjy(e){return Zf.endsWith(e,"[]")?e.slice(0,-2):e}function Jjy(e,t,r){return e?e.concat(t).map(function(i,a){return i=Kjy(i),!r&&a?"["+i+"]":i}).join(r?".":""):t}function NBC(e){return Zf.isArray(e)&&!e.some(mAf)}var FBC=Zf.toFlatObject(Zf,{},null,function(t){return/^is[A-Z]/.test(t)});function xBC(e,t,r){if(!Zf.isObject(e))throw new TypeError("target must be an object");t=t||new(CDu||FormData),r=Zf.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,I){return!Zf.isUndefined(I[C])});let n=r.metaTokens,i=r.visitor||s,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Zf.isSpecCompliantForm(t);if(!Zf.isFunction(i))throw new TypeError("visitor must be a function");function u(P){if(P===null)return"";if(Zf.isDate(P))return P.toISOString();if(Zf.isBoolean(P))return P.toString();if(!f&&Zf.isBlob(P))throw new Lm("Blob is not supported. Use a Buffer instead.");return Zf.isArrayBuffer(P)||Zf.isTypedArray(P)?f&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function s(P,C,I){let T=P;if(P&&!I&&typeof P=="object"){if(Zf.endsWith(C,"{}"))C=n?C:C.slice(0,-2),P=JSON.stringify(P);else if(Zf.isArray(P)&&NBC(P)||(Zf.isFileList(P)||Zf.endsWith(C,"[]"))&&(T=Zf.toArray(P)))return C=Kjy(C),T.forEach(function(U,q){!(Zf.isUndefined(U)||U===null)&&t.append(o===!0?Jjy([C],q,a):o===null?C:C+"[]",u(U))}),!1}return mAf(P)?!0:(t.append(Jjy(I,C,a),u(P)),!1)}let l=[],m=Object.assign(FBC,{defaultVisitor:s,convertValue:u,isVisitable:mAf});function O(P,C){if(!Zf.isUndefined(P)){if(l.indexOf(P)!==-1)throw Error("Circular reference detected in "+C.join("."));l.push(P),Zf.forEach(P,function(T,z){(!(Zf.isUndefined(T)||T===null)&&i.call(t,T,Zf.isString(z)?z.trim():z,C,m))===!0&&O(T,C?C.concat(z):[z])}),l.pop()}}if(!Zf.isObject(e))throw new TypeError("data must be an object");return O(e),t}var S4i=xBC;function $jy(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Yjy(e,t){this._pairs=[],e&&S4i(e,this,t)}var Xjy=Yjy.prototype;Xjy.append=function(t,r){this._pairs.push([t,r])};Xjy.toString=function(t){let r=t?function(n){return t.call(this,n,$jy)}:$jy;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var Zjy=Yjy;function zBC(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Uua(e,t,r){if(!t)return e;let n=r&&r.encode||zBC;Zf.isFunction(r)&&(r={serialize:r});let i=r&&r.serialize,a;if(i?a=i(t,r):a=Zf.isURLSearchParams(t)?t.toString():new Zjy(t,r).toString(n),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var OAf=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){Zf.forEach(this.handlers,function(n){n!==null&&t(n)})}},AAf=OAf;var tka={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var r1y=$i(require("crypto"),1);var kjy=$i(require("url"),1),e1y=kjy.default.URLSearchParams;var PAf="abcdefghijklmnopqrstuvwxyz",t1y="0123456789",n1y={DIGIT:t1y,ALPHA:PAf,ALPHA_DIGIT:PAf+PAf.toUpperCase()+t1y},QBC=(e=16,t=n1y.ALPHA_DIGIT)=>{let r="",{length:n}=t,i=new Uint32Array(e);r1y.default.randomFillSync(i);for(let a=0;a<e;a++)r+=t[i[a]%n];return r},i1y={isNode:!0,classes:{URLSearchParams:e1y,FormData:CDu,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:n1y,generateString:QBC,protocols:["http","https","file","data"]};var EAf={};yf(EAf,{hasBrowserEnv:()=>jAf,hasStandardBrowserEnv:()=>LBC,hasStandardBrowserWebWorkerEnv:()=>UBC,navigator:()=>wAf,origin:()=>VBC});var jAf=typeof window<"u"&&typeof document<"u",wAf=typeof navigator=="object"&&navigator||void 0,LBC=jAf&&(!wAf||["ReactNative","NativeScript","NS"].indexOf(wAf.product)<0),UBC=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VBC=jAf&&window.location.href||"http://localhost";var G7={...EAf,...i1y};function SAf(e,t){return S4i(e,new G7.classes.URLSearchParams,{visitor:function(r,n,i,a){return G7.isNode&&Zf.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function WBC(e){return Zf.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function GBC(e){let t={},r=Object.keys(e),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}function HBC(e){function t(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&Zf.isArray(i)?i.length:o,f?(Zf.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!c):((!i[o]||!Zf.isObject(i[o]))&&(i[o]=[]),t(r,n,i[o],a)&&Zf.isArray(i[o])&&(i[o]=GBC(i[o])),!c)}if(Zf.isFormData(e)&&Zf.isFunction(e.entries)){let r={};return Zf.forEachEntry(e,(n,i)=>{t(WBC(n),i,r,0)}),r}return null}var IDu=HBC;function JBC(e,t,r){if(Zf.isString(e))try{return(t||JSON.parse)(e),Zf.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var DAf={transitional:tka,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=Zf.isObject(t);if(a&&Zf.isHTMLForm(t)&&(t=new FormData(t)),Zf.isFormData(t))return i?JSON.stringify(IDu(t)):t;if(Zf.isArrayBuffer(t)||Zf.isBuffer(t)||Zf.isStream(t)||Zf.isFile(t)||Zf.isBlob(t)||Zf.isReadableStream(t))return t;if(Zf.isArrayBufferView(t))return t.buffer;if(Zf.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return SAf(t,this.formSerializer).toString();if((c=Zf.isFileList(t))||n.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return S4i(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),JBC(t)):t}],transformResponse:[function(t){let r=this.transitional||DAf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Zf.isResponse(t)||Zf.isReadableStream(t))return t;if(t&&Zf.isString(t)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?Lm.from(c,Lm.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:G7.classes.FormData,Blob:G7.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Zf.forEach(["delete","get","head","post","put","patch"],e=>{DAf.headers[e]={}});var rka=DAf;var KBC=Zf.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),a1y=e=>{let t={},r,n,i;return e&&e.split(`
|
|
2434
2434
|
`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||t[r]&&KBC[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var o1y=Symbol("internals");function T$o(e){return e&&String(e).trim().toLowerCase()}function MDu(e){return e===!1||e==null?e:Zf.isArray(e)?e.map(MDu):String(e)}function $BC(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var YBC=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function CAf(e,t,r,n,i){if(Zf.isFunction(n))return n.call(this,t,r);if(i&&(t=r),!!Zf.isString(t)){if(Zf.isString(n))return t.indexOf(n)!==-1;if(Zf.isRegExp(n))return n.test(t)}}function XBC(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function ZBC(e,t){let r=Zf.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(i,a,o){return this[n].call(this,t,i,a,o)},configurable:!0})})}var nka=class{constructor(t){t&&this.set(t)}set(t,r,n){let i=this;function a(c,f,u){let s=T$o(f);if(!s)throw new Error("header name must be a non-empty string");let l=Zf.findKey(i,s);(!l||i[l]===void 0||u===!0||u===void 0&&i[l]!==!1)&&(i[l||f]=MDu(c))}let o=(c,f)=>Zf.forEach(c,(u,s)=>a(u,s,f));if(Zf.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(Zf.isString(t)&&(t=t.trim())&&!YBC(t))o(a1y(t),r);else if(Zf.isObject(t)&&Zf.isIterable(t)){let c={},f,u;for(let s of t){if(!Zf.isArray(s))throw TypeError("Object iterator must return a key-value pair");c[u=s[0]]=(f=c[u])?Zf.isArray(f)?[...f,s[1]]:[f,s[1]]:s[1]}o(c,r)}else t!=null&&a(r,t,n);return this}get(t,r){if(t=T$o(t),t){let n=Zf.findKey(this,t);if(n){let i=this[n];if(!r)return i;if(r===!0)return $BC(i);if(Zf.isFunction(r))return r.call(this,i,n);if(Zf.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=T$o(t),t){let n=Zf.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||CAf(this,this[n],n,r)))}return!1}delete(t,r){let n=this,i=!1;function a(o){if(o=T$o(o),o){let c=Zf.findKey(n,o);c&&(!r||CAf(n,n[c],c,r))&&(delete n[c],i=!0)}}return Zf.isArray(t)?t.forEach(a):a(t),i}clear(t){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!t||CAf(this,this[a],a,t,!0))&&(delete this[a],i=!0)}return i}normalize(t){let r=this,n={};return Zf.forEach(this,(i,a)=>{let o=Zf.findKey(n,a);if(o){r[o]=MDu(i),delete r[a];return}let c=t?XBC(a):String(a).trim();c!==a&&delete r[a],r[c]=MDu(i),n[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return Zf.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=t&&Zf.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
2435
2435
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(i=>n.set(i)),n}static accessor(t){let n=(this[o1y]=this[o1y]={accessors:{}}).accessors,i=this.prototype;function a(o){let c=T$o(o);n[c]||(ZBC(i,o),n[c]=!0)}return Zf.isArray(t)?t.forEach(a):a(t),this}};nka.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);Zf.reduceDescriptors(nka.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}});Zf.freezeMethods(nka);var b$=nka;function q$o(e,t){let r=this||rka,n=t||r,i=b$.from(n.headers),a=n.data;return Zf.forEach(e,function(c){a=c.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function R$o(e){return!!(e&&e.__CANCEL__)}function s1y(e,t,r){Lm.call(this,e??"canceled",Lm.ERR_CANCELED,t,r),this.name="CanceledError"}Zf.inherits(s1y,Lm,{__CANCEL__:!0});var zrt=s1y;function IUr(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new Lm("Request failed with status code "+r.status,[Lm.ERR_BAD_REQUEST,Lm.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function IAf(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function MAf(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Vua(e,t,r){let n=!IAf(t);return e&&(n||r==!1)?MAf(e,t):t}var P1y=$i(ZSu(),1),w1y=$i(require("http"),1),j1y=$i(require("https"),1),E1y=$i(require("util"),1),S1y=$i(BOf(),1),zAi=$i(require("zlib"),1);var Wua="1.12.2";function N$o(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var kBC=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function BAf(e,t,r){let n=r&&r.Blob||G7.classes.Blob,i=N$o(e);if(t===void 0&&n&&(t=!0),i==="data"){e=i.length?e.slice(i.length+1):e;let a=kBC.exec(e);if(!a)throw new Lm("Invalid URL",Lm.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],u=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!n)throw new Lm("Blob is not supported",Lm.ERR_NOT_SUPPORT);return new n([u],{type:o})}return u}throw new Lm("Unsupported protocol "+i,Lm.ERR_NOT_SUPPORT)}var Hua=$i(require("stream"),1);var u1y=$i(require("stream"),1);var TAf=Symbol("internals"),qAf=class extends u1y.default.Transform{constructor(t){t=Zf.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!Zf.isUndefined(i[n])),super({readableHighWaterMark:t.chunkSize});let r=this[TAf]={timeWindow:t.timeWindow,chunkSize:t.chunkSize,maxRate:t.maxRate,minChunkSize:t.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(t){let r=this[TAf];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,n){let i=this[TAf],a=i.maxRate,o=this.readableHighWaterMark,c=i.timeWindow,f=1e3/c,u=a/f,s=i.minChunkSize!==!1?Math.max(i.minChunkSize,u*.01):0,l=(O,P)=>{let C=Buffer.byteLength(O);i.bytesSeen+=C,i.bytes+=C,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(O)?process.nextTick(P):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(P)}},m=(O,P)=>{let C=Buffer.byteLength(O),I=null,T=o,z,U=0;if(a){let q=Date.now();(!i.ts||(U=q-i.ts)>=c)&&(i.ts=q,z=u-i.bytes,i.bytes=z<0?-z:0,U=0),z=u-i.bytes}if(a){if(z<=0)return setTimeout(()=>{P(null,O)},c-U);z<T&&(T=z)}T&&C>T&&C-T>s&&(I=O.subarray(T),O=O.subarray(0,T)),l(O,I?()=>{process.nextTick(P,null,I)}:P)};m(t,function O(P,C){if(P)return n(P);C?m(C,O):n(null)})}},RAf=qAf;var D1y=require("events");var l1y=$i(require("util"),1),f1y=require("stream");var{asyncIterator:c1y}=Symbol,eTC=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[c1y]?yield*e[c1y]():yield e},BDu=eTC;var tTC=G7.ALPHABET.ALPHA_DIGIT+"-_",F$o=typeof TextEncoder=="function"?new TextEncoder:new l1y.default.TextEncoder,Gua=`\r
|
|
2436
2436
|
`,rTC=F$o.encode(Gua),nTC=2,NAf=class{constructor(t,r){let{escapeName:n}=this.constructor,i=Zf.isString(r),a=`Content-Disposition: form-data; name="${n(t)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${Gua}`;i?r=F$o.encode(String(r).replace(/\r?\n|\r\n?/g,Gua)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Gua}`,this.headers=F$o.encode(a+Gua),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+nTC,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;Zf.isTypedArray(t)?yield t:yield*BDu(t),yield rTC}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},iTC=(e,t,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+G7.generateString(i,tTC)}=r||{};if(!Zf.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=F$o.encode("--"+a+Gua),c=F$o.encode("--"+a+"--"+Gua),f=c.byteLength,u=Array.from(e.entries()).map(([l,m])=>{let O=new NAf(l,m);return f+=O.size,O});f+=o.byteLength*u.length,f=Zf.toFiniteNumber(f);let s={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(s["Content-Length"]=f),t&&t(s),f1y.Readable.from((async function*(){for(let l of u)yield o,yield*l.encode();yield c})())},d1y=iTC;var p1y=$i(require("stream"),1),FAf=class extends p1y.default.Transform{__transform(t,r,n){this.push(t),n()}_transform(t,r,n){if(t.length!==0&&(this._transform=this.__transform,t[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(t,r,n)}},_1y=FAf;var aTC=(e,t)=>Zf.isAsyncFn(e)?function(...r){let n=r.pop();e.apply(this,r).then(i=>{try{t?n(null,...t(i)):n(null,i)}catch(a){n(a)}},n)}:e,h1y=aTC;function oTC(e,t){e=e||10;let r=new Array(e),n=new Array(e),i=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let u=Date.now(),s=n[a];o||(o=u),r[i]=f,n[i]=u;let l=a,m=0;for(;l!==i;)m+=r[l++],l=l%e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),u-o<t)return;let O=s&&u-s;return O?Math.round(m*1e3/O):void 0}}var y1y=oTC;function sTC(e,t){let r=0,n=1e3/t,i,a,o=(u,s=Date.now())=>{r=s,i=null,a&&(clearTimeout(a),a=null),e(...u)};return[(...u)=>{let s=Date.now(),l=s-r;l>=n?o(u,s):(i=u,a||(a=setTimeout(()=>{a=null,o(i)},n-l)))},()=>i&&o(i)]}var v1y=sTC;var xAi=(e,t,r=3)=>{let n=0,i=y1y(50,250);return v1y(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-n,u=i(f),s=o<=c;n=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:u||void 0,estimated:u&&c&&s?(c-o)/u:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},ika=(e,t)=>{let r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},aka=e=>(...t)=>Zf.asap(()=>e(...t));function xAf(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),n=e.slice(t+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let m=0;m<o;m++)if(n.charCodeAt(m)===37&&m+2<o){let O=n.charCodeAt(m+1),P=n.charCodeAt(m+2);(O>=48&&O<=57||O>=65&&O<=70||O>=97&&O<=102)&&(P>=48&&P<=57||P>=65&&P<=70||P>=97&&P<=102)&&(a-=2,m+=2)}let c=0,f=o-1,u=m=>m>=2&&n.charCodeAt(m-2)===37&&n.charCodeAt(m-1)===51&&(n.charCodeAt(m)===68||n.charCodeAt(m)===100);f>=0&&(n.charCodeAt(f)===61?(c++,f--):u(f)&&(c++,f-=3)),c===1&&f>=0&&(n.charCodeAt(f)===61||u(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(n,"utf8")}var b1y={flush:zAi.default.constants.Z_SYNC_FLUSH,finishFlush:zAi.default.constants.Z_SYNC_FLUSH},uTC={flush:zAi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:zAi.default.constants.BROTLI_OPERATION_FLUSH},g1y=Zf.isFunction(zAi.default.createBrotliDecompress),{http:cTC,https:lTC}=S1y.default,fTC=/https:?/,m1y=G7.protocols.map(e=>e+":"),O1y=(e,[t,r])=>(e.on("end",r).on("error",r),t);function dTC(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function C1y(e,t,r){let n=t;if(!n&&n!==!1){let i=P1y.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){(n.auth.username||n.auth.password)&&(n.auth=(n.auth.username||"")+":"+(n.auth.password||""));let a=Buffer.from(n.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+a}e.headers.host=e.hostname+(e.port?":"+e.port:"");let i=n.hostname||n.host;e.hostname=i,e.host=i,e.port=n.port,e.path=r,n.protocol&&(e.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}e.beforeRedirects.proxy=function(a){C1y(a,t,a.href)}}var pTC=typeof process<"u"&&Zf.kindOf(process)==="process",_TC=e=>new Promise((t,r)=>{let n,i,a=(f,u)=>{i||(i=!0,n&&n(f,u))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>n=f).catch(c)}),hTC=({address:e,family:t})=>{if(!Zf.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},A1y=(e,t)=>hTC(Zf.isObject(e)?e:{address:e,family:t}),I1y=pTC&&function(t){return _TC(async function(n,i,a){let{data:o,lookup:c,family:f}=t,{responseType:u,responseEncoding:s}=t,l=t.method.toUpperCase(),m,O=!1,P;if(c){let Ee=h1y(c,Ot=>Zf.isArray(Ot)?Ot:[Ot]);c=(Ot,vt,xe)=>{Ee(Ot,vt,(Be,Jt,pt)=>{if(Be)return xe(Be);let vr=Zf.isArray(Jt)?Jt.map(Gt=>A1y(Gt)):[A1y(Jt,pt)];vt.all?xe(Be,vr):xe(Be,vr[0].address,vr[0].family)})}}let C=new D1y.EventEmitter,I=()=>{t.cancelToken&&t.cancelToken.unsubscribe(T),t.signal&&t.signal.removeEventListener("abort",T),C.removeAllListeners()};a((Ee,Ot)=>{m=!0,Ot&&(O=!0,I())});function T(Ee){C.emit("abort",!Ee||Ee.type?new zrt(null,t,P):Ee)}C.once("abort",i),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(T),t.signal&&(t.signal.aborted?T():t.signal.addEventListener("abort",T)));let z=Vua(t.baseURL,t.url,t.allowAbsoluteUrls),U=new URL(z,G7.hasBrowserEnv?G7.origin:void 0),q=U.protocol||m1y[0];if(q==="data:"){if(t.maxContentLength>-1){let Ot=String(t.url||z||"");if(xAf(Ot)>t.maxContentLength)return i(new Lm("maxContentLength size of "+t.maxContentLength+" exceeded",Lm.ERR_BAD_RESPONSE,t))}let Ee;if(l!=="GET")return IUr(n,i,{status:405,statusText:"method not allowed",headers:{},config:t});try{Ee=BAf(t.url,u==="blob",{Blob:t.env&&t.env.Blob})}catch(Ot){throw Lm.from(Ot,Lm.ERR_BAD_REQUEST,t)}return u==="text"?(Ee=Ee.toString(s),(!s||s==="utf8")&&(Ee=Zf.stripBOM(Ee))):u==="stream"&&(Ee=Hua.default.Readable.from(Ee)),IUr(n,i,{data:Ee,status:200,statusText:"OK",headers:new b$,config:t})}if(m1y.indexOf(q)===-1)return i(new Lm("Unsupported protocol "+q,Lm.ERR_BAD_REQUEST,t));let V=b$.from(t.headers).normalize();V.set("User-Agent","axios/"+Wua,!1);let{onUploadProgress:$,onDownloadProgress:re}=t,Y=t.maxRate,k,ne;if(Zf.isSpecCompliantForm(o)){let Ee=V.getContentType(/boundary=([-_\w\d]{10,70})/i);o=d1y(o,Ot=>{V.set(Ot)},{tag:`axios-${Wua}-boundary`,boundary:Ee&&Ee[1]||void 0})}else if(Zf.isFormData(o)&&Zf.isFunction(o.getHeaders)){if(V.set(o.getHeaders()),!V.hasContentLength())try{let Ee=await E1y.default.promisify(o.getLength).call(o);Number.isFinite(Ee)&&Ee>=0&&V.setContentLength(Ee)}catch{}}else if(Zf.isBlob(o)||Zf.isFile(o))o.size&&V.setContentType(o.type||"application/octet-stream"),V.setContentLength(o.size||0),o=Hua.default.Readable.from(BDu(o));else if(o&&!Zf.isStream(o)){if(!Buffer.isBuffer(o))if(Zf.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(Zf.isString(o))o=Buffer.from(o,"utf-8");else return i(new Lm("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Lm.ERR_BAD_REQUEST,t));if(V.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return i(new Lm("Request body larger than maxBodyLength limit",Lm.ERR_BAD_REQUEST,t))}let me=Zf.toFiniteNumber(V.getContentLength());Zf.isArray(Y)?(k=Y[0],ne=Y[1]):k=ne=Y,o&&($||k)&&(Zf.isStream(o)||(o=Hua.default.Readable.from(o,{objectMode:!1})),o=Hua.default.pipeline([o,new RAf({maxRate:Zf.toFiniteNumber(k)})],Zf.noop),$&&o.on("progress",O1y(o,ika(me,xAi(aka($),!1,3)))));let _e;if(t.auth){let Ee=t.auth.username||"",Ot=t.auth.password||"";_e=Ee+":"+Ot}if(!_e&&U.username){let Ee=U.username,Ot=U.password;_e=Ee+":"+Ot}_e&&V.delete("authorization");let ve;try{ve=Uua(U.pathname+U.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Ee){let Ot=new Error(Ee.message);return Ot.config=t,Ot.url=t.url,Ot.exists=!0,i(Ot)}V.set("Accept-Encoding","gzip, compress, deflate"+(g1y?", br":""),!1);let pe={path:ve,method:l,headers:V.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:_e,protocol:q,family:f,beforeRedirect:dTC,beforeRedirects:{}};!Zf.isUndefined(c)&&(pe.lookup=c),t.socketPath?pe.socketPath=t.socketPath:(pe.hostname=U.hostname.startsWith("[")?U.hostname.slice(1,-1):U.hostname,pe.port=U.port,C1y(pe,t.proxy,q+"//"+U.hostname+(U.port?":"+U.port:"")+pe.path));let De,Ce=fTC.test(pe.protocol);if(pe.agent=Ce?t.httpsAgent:t.httpAgent,t.transport?De=t.transport:t.maxRedirects===0?De=Ce?j1y.default:w1y.default:(t.maxRedirects&&(pe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(pe.beforeRedirects.config=t.beforeRedirect),De=Ce?lTC:cTC),t.maxBodyLength>-1?pe.maxBodyLength=t.maxBodyLength:pe.maxBodyLength=1/0,t.insecureHTTPParser&&(pe.insecureHTTPParser=t.insecureHTTPParser),P=De.request(pe,function(Ot){if(P.destroyed)return;let vt=[Ot],xe=+Ot.headers["content-length"];if(re||ne){let Gt=new RAf({maxRate:Zf.toFiniteNumber(ne)});re&&Gt.on("progress",O1y(Gt,ika(xe,xAi(aka(re),!0,3)))),vt.push(Gt)}let Be=Ot,Jt=Ot.req||P;if(t.decompress!==!1&&Ot.headers["content-encoding"])switch((l==="HEAD"||Ot.statusCode===204)&&delete Ot.headers["content-encoding"],(Ot.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":vt.push(zAi.default.createUnzip(b1y)),delete Ot.headers["content-encoding"];break;case"deflate":vt.push(new _1y),vt.push(zAi.default.createUnzip(b1y)),delete Ot.headers["content-encoding"];break;case"br":g1y&&(vt.push(zAi.default.createBrotliDecompress(uTC)),delete Ot.headers["content-encoding"])}Be=vt.length>1?Hua.default.pipeline(vt,Zf.noop):vt[0];let pt=Hua.default.finished(Be,()=>{pt(),I()}),vr={status:Ot.statusCode,statusText:Ot.statusMessage,headers:new b$(Ot.headers),config:t,request:Jt};if(u==="stream")vr.data=Be,IUr(n,i,vr);else{let Gt=[],Xe=0;Be.on("data",function(kt){Gt.push(kt),Xe+=kt.length,t.maxContentLength>-1&&Xe>t.maxContentLength&&(O=!0,Be.destroy(),i(new Lm("maxContentLength size of "+t.maxContentLength+" exceeded",Lm.ERR_BAD_RESPONSE,t,Jt)))}),Be.on("aborted",function(){if(O)return;let kt=new Lm("stream has been aborted",Lm.ERR_BAD_RESPONSE,t,Jt);Be.destroy(kt),i(kt)}),Be.on("error",function(kt){P.destroyed||i(Lm.from(kt,null,t,Jt))}),Be.on("end",function(){try{let kt=Gt.length===1?Gt[0]:Buffer.concat(Gt);u!=="arraybuffer"&&(kt=kt.toString(s),(!s||s==="utf8")&&(kt=Zf.stripBOM(kt))),vr.data=kt}catch(kt){return i(Lm.from(kt,null,t,vr.request,vr))}IUr(n,i,vr)})}C.once("abort",Gt=>{Be.destroyed||(Be.emit("error",Gt),Be.destroy())})}),C.once("abort",Ee=>{i(Ee),P.destroy(Ee)}),P.on("error",function(Ot){i(Lm.from(Ot,null,t,P))}),P.on("socket",function(Ot){Ot.setKeepAlive(!0,1e3*60)}),t.timeout){let Ee=parseInt(t.timeout,10);if(Number.isNaN(Ee)){i(new Lm("error trying to parse `config.timeout` to int",Lm.ERR_BAD_OPTION_VALUE,t,P));return}P.setTimeout(Ee,function(){if(m)return;let vt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",xe=t.transitional||tka;t.timeoutErrorMessage&&(vt=t.timeoutErrorMessage),i(new Lm(vt,xe.clarifyTimeoutError?Lm.ETIMEDOUT:Lm.ECONNABORTED,t,P)),T()})}if(Zf.isStream(o)){let Ee=!1,Ot=!1;o.on("end",()=>{Ee=!0}),o.once("error",vt=>{Ot=!0,P.destroy(vt)}),o.on("close",()=>{!Ee&&!Ot&&T(new zrt("Request stream has been aborted",t,P))}),o.pipe(P)}else P.end(o)})};var M1y=G7.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,G7.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(G7.origin),G7.navigator&&/(msie|trident)/i.test(G7.navigator.userAgent)):()=>!0;var B1y=G7.hasStandardBrowserEnv?{write(e,t,r,n,i,a){let o=[e+"="+encodeURIComponent(t)];Zf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Zf.isString(n)&&o.push("path="+n),Zf.isString(i)&&o.push("domain="+i),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var T1y=e=>e instanceof b$?{...e}:e;function XTr(e,t){t=t||{};let r={};function n(u,s,l,m){return Zf.isPlainObject(u)&&Zf.isPlainObject(s)?Zf.merge.call({caseless:m},u,s):Zf.isPlainObject(s)?Zf.merge({},s):Zf.isArray(s)?s.slice():s}function i(u,s,l,m){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u,l,m)}else return n(u,s,l,m)}function a(u,s){if(!Zf.isUndefined(s))return n(void 0,s)}function o(u,s){if(Zf.isUndefined(s)){if(!Zf.isUndefined(u))return n(void 0,u)}else return n(void 0,s)}function c(u,s,l){if(l in t)return n(u,s);if(l in e)return n(void 0,u)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(u,s,l)=>i(T1y(u),T1y(s),l,!0)};return Zf.forEach(Object.keys({...e,...t}),function(s){let l=f[s]||i,m=l(e[s],t[s],s);Zf.isUndefined(m)&&l!==c||(r[s]=m)}),r}var TDu=e=>{let t=XTr({},e),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=b$.from(o),t.url=Uua(Vua(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Zf.isFormData(r)){if(G7.hasStandardBrowserEnv||G7.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(Zf.isFunction(r.getHeaders)){let f=r.getHeaders(),u=["content-type","content-length"];Object.entries(f).forEach(([s,l])=>{u.includes(s.toLowerCase())&&o.set(s,l)})}}if(G7.hasStandardBrowserEnv&&(n&&Zf.isFunction(n)&&(n=n(t)),n||n!==!1&&M1y(t.url))){let f=i&&a&&B1y.read(a);f&&o.set(i,f)}return t};var yTC=typeof XMLHttpRequest<"u",q1y=yTC&&function(e){return new Promise(function(r,n){let i=TDu(e),a=i.data,o=b$.from(i.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:u}=i,s,l,m,O,P;function C(){O&&O(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(s),i.signal&&i.signal.removeEventListener("abort",s)}let I=new XMLHttpRequest;I.open(i.method.toUpperCase(),i.url,!0),I.timeout=i.timeout;function T(){if(!I)return;let U=b$.from("getAllResponseHeaders"in I&&I.getAllResponseHeaders()),V={data:!c||c==="text"||c==="json"?I.responseText:I.response,status:I.status,statusText:I.statusText,headers:U,config:e,request:I};IUr(function(re){r(re),C()},function(re){n(re),C()},V),I=null}"onloadend"in I?I.onloadend=T:I.onreadystatechange=function(){!I||I.readyState!==4||I.status===0&&!(I.responseURL&&I.responseURL.indexOf("file:")===0)||setTimeout(T)},I.onabort=function(){I&&(n(new Lm("Request aborted",Lm.ECONNABORTED,e,I)),I=null)},I.onerror=function(q){let V=q&&q.message?q.message:"Network Error",$=new Lm(V,Lm.ERR_NETWORK,e,I);$.event=q||null,n($),I=null},I.ontimeout=function(){let q=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",V=i.transitional||tka;i.timeoutErrorMessage&&(q=i.timeoutErrorMessage),n(new Lm(q,V.clarifyTimeoutError?Lm.ETIMEDOUT:Lm.ECONNABORTED,e,I)),I=null},a===void 0&&o.setContentType(null),"setRequestHeader"in I&&Zf.forEach(o.toJSON(),function(q,V){I.setRequestHeader(V,q)}),Zf.isUndefined(i.withCredentials)||(I.withCredentials=!!i.withCredentials),c&&c!=="json"&&(I.responseType=i.responseType),u&&([m,P]=xAi(u,!0),I.addEventListener("progress",m)),f&&I.upload&&([l,O]=xAi(f),I.upload.addEventListener("progress",l),I.upload.addEventListener("loadend",O)),(i.cancelToken||i.signal)&&(s=U=>{I&&(n(!U||U.type?new zrt(null,e,I):U),I.abort(),I=null)},i.cancelToken&&i.cancelToken.subscribe(s),i.signal&&(i.signal.aborted?s():i.signal.addEventListener("abort",s)));let z=N$o(i.url);if(z&&G7.protocols.indexOf(z)===-1){n(new Lm("Unsupported protocol "+z+":",Lm.ERR_BAD_REQUEST,e));return}I.send(a||null)})};var vTC=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,i,a=function(u){if(!i){i=!0,c();let s=u instanceof Error?u:this.reason;n.abort(s instanceof Lm?s:new zrt(s instanceof Error?s.message:s))}},o=t&&setTimeout(()=>{o=null,a(new Lm(`timeout ${t} of ms exceeded`,Lm.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(a):u.removeEventListener("abort",a)}),e=null)};e.forEach(u=>u.addEventListener("abort",a));let{signal:f}=n;return f.unsubscribe=()=>Zf.asap(c),f}},R1y=vTC;var bTC=function*(e,t){let r=e.byteLength;if(!t||r<t){yield e;return}let n=0,i;for(;n<r;)i=n+t,yield e.slice(n,i),n=i},gTC=async function*(e,t){for await(let r of mTC(e))yield*bTC(r,t)},mTC=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},zAf=(e,t,r,n)=>{let i=gTC(e,t),a=0,o,c=f=>{o||(o=!0,n&&n(f))};return new ReadableStream({async pull(f){try{let{done:u,value:s}=await i.next();if(u){c(),f.close();return}let l=s.byteLength;if(r){let m=a+=l;r(m)}f.enqueue(new Uint8Array(s))}catch(u){throw c(u),u}},cancel(f){return c(f),i.return()}},{highWaterMark:2})};var N1y=64*1024,{isFunction:qDu}=Zf,OTC=(({Request:e,Response:t})=>({Request:e,Response:t}))(Zf.global),{ReadableStream:F1y,TextEncoder:x1y}=Zf.global,z1y=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ATC=e=>{e=Zf.merge.call({skipUndefined:!0},OTC,e);let{fetch:t,Request:r,Response:n}=e,i=t?qDu(t):typeof fetch=="function",a=qDu(r),o=qDu(n);if(!i)return!1;let c=i&&qDu(F1y),f=i&&(typeof x1y=="function"?(P=>C=>P.encode(C))(new x1y):async P=>new Uint8Array(await new r(P).arrayBuffer())),u=a&&c&&z1y(()=>{let P=!1,C=new r(G7.origin,{body:new F1y,method:"POST",get duplex(){return P=!0,"half"}}).headers.has("Content-Type");return P&&!C}),s=o&&c&&z1y(()=>Zf.isReadableStream(new n("").body)),l={stream:s&&(P=>P.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(P=>{!l[P]&&(l[P]=(C,I)=>{let T=C&&C[P];if(T)return T.call(C);throw new Lm(`Response type '${P}' is not supported`,Lm.ERR_NOT_SUPPORT,I)})});let m=async P=>{if(P==null)return 0;if(Zf.isBlob(P))return P.size;if(Zf.isSpecCompliantForm(P))return(await new r(G7.origin,{method:"POST",body:P}).arrayBuffer()).byteLength;if(Zf.isArrayBufferView(P)||Zf.isArrayBuffer(P))return P.byteLength;if(Zf.isURLSearchParams(P)&&(P=P+""),Zf.isString(P))return(await f(P)).byteLength},O=async(P,C)=>{let I=Zf.toFiniteNumber(P.getContentLength());return I??m(C)};return async P=>{let{url:C,method:I,data:T,signal:z,cancelToken:U,timeout:q,onDownloadProgress:V,onUploadProgress:$,responseType:re,headers:Y,withCredentials:k="same-origin",fetchOptions:ne}=TDu(P),me=t||fetch;re=re?(re+"").toLowerCase():"text";let _e=R1y([z,U&&U.toAbortSignal()],q),ve=null,pe=_e&&_e.unsubscribe&&(()=>{_e.unsubscribe()}),De;try{if($&&u&&I!=="get"&&I!=="head"&&(De=await O(Y,T))!==0){let Be=new r(C,{method:"POST",body:T,duplex:"half"}),Jt;if(Zf.isFormData(T)&&(Jt=Be.headers.get("content-type"))&&Y.setContentType(Jt),Be.body){let[pt,vr]=ika(De,xAi(aka($)));T=zAf(Be.body,N1y,pt,vr)}}Zf.isString(k)||(k=k?"include":"omit");let Ce=a&&"credentials"in r.prototype,Ee={...ne,signal:_e,method:I.toUpperCase(),headers:Y.normalize().toJSON(),body:T,duplex:"half",credentials:Ce?k:void 0};ve=a&&new r(C,Ee);let Ot=await(a?me(ve,ne):me(C,Ee)),vt=s&&(re==="stream"||re==="response");if(s&&(V||vt&&pe)){let Be={};["status","statusText","headers"].forEach(Gt=>{Be[Gt]=Ot[Gt]});let Jt=Zf.toFiniteNumber(Ot.headers.get("content-length")),[pt,vr]=V&&ika(Jt,xAi(aka(V),!0))||[];Ot=new n(zAf(Ot.body,N1y,pt,()=>{vr&&vr(),pe&&pe()}),Be)}re=re||"text";let xe=await l[Zf.findKey(l,re)||"text"](Ot,P);return!vt&&pe&&pe(),await new Promise((Be,Jt)=>{IUr(Be,Jt,{data:xe,headers:b$.from(Ot.headers),status:Ot.status,statusText:Ot.statusText,config:P,request:ve})})}catch(Ce){throw pe&&pe(),Ce&&Ce.name==="TypeError"&&/Load failed|fetch/i.test(Ce.message)?Object.assign(new Lm("Network Error",Lm.ERR_NETWORK,P,ve),{cause:Ce.cause||Ce}):Lm.from(Ce,Ce&&Ce.code,P,ve)}}},PTC=new Map,QAf=e=>{let t=e?e.env:{},{fetch:r,Request:n,Response:i}=t,a=[n,i,r],o=a.length,c=o,f,u,s=PTC;for(;c--;)f=a[c],u=s.get(f),u===void 0&&s.set(f,u=c?new Map:ATC(t)),s=u;return u},fdU=QAf();var LAf={http:I1y,xhr:q1y,fetch:{get:QAf}};Zf.forEach(LAf,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var Q1y=e=>`- ${e}`,jTC=e=>Zf.isFunction(e)||e===null||e===!1,RDu={getAdapter:(e,t)=>{e=Zf.isArray(e)?e:[e];let{length:r}=e,n,i,a={};for(let o=0;o<r;o++){n=e[o];let c;if(i=n,!jTC(n)&&(i=LAf[(c=String(n)).toLowerCase()],i===void 0))throw new Lm(`Unknown adapter '${c}'`);if(i&&(Zf.isFunction(i)||(i=i.get(t))))break;a[c||"#"+o]=i}if(!i){let o=Object.entries(a).map(([f,u])=>`adapter ${f} `+(u===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
|
|
@@ -2671,7 +2671,7 @@ ${q}${z}${V}${xro}`});function kFu({message:e,error:t,logger:r,logLevel:n=uE.Err
|
|
|
2671
2671
|
Run ${Mf.cyan("fern generator upgrade")} to upgrade your generators.`),i.length>2&&(r+=`
|
|
2672
2672
|
Run ${Mf.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),ska(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function JNf({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:n=!0}){if(!kGy(e))return;let i=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)i+=`
|
|
2673
2673
|
${await VpI(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Mf.dim(c.currentVersion)+Mf.reset(" \u2192 ")+Mf.green(c.latestVersion);return i+=`
|
|
2674
|
-
`,n?ska(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function VpI(e){let r=await new ZGy.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function WpI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=d3i(s.name,l),O=await bTr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});O!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=d3i(u.name,s),m=await bTr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await CTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function rHy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=Dxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function nxu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await WpI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...rHy(u,f,t.logger));else o.push(...rHy(c.versions,void 0,t.logger))}return o}var Ako=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var Uro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var KNf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),nHy=typeof globalThis.AbortController=="function",iHy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",aHy=typeof globalThis.ReadableStream=="function",oHy=typeof globalThis.FormData=="function",ixu=["get","post","put","patch","head","delete"],GpI=()=>{};GpI();var sHy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},axu=2147483647,uHy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,oxu=Symbol("stop"),cHy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},lHy={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var HpI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=uHy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},fHy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},dHy=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(fHy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},pHy=(e,t,r)=>{if(!e.body)return e;let n=HpI(r??e.body);return new Request(e,{duplex:"half",body:fHy(e.body,n,t)})};var Vro=e=>e!==null&&typeof e=="object";var Pko=(...e)=>{for(let t of e)if((!Vro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return XNf({},...e)},$Nf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function sxu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:XNf(e[r]??[],t[r]??[])}var YNf=(e={},t={})=>({beforeRequest:sxu(e,t,"beforeRequest"),beforeRetry:sxu(e,t,"beforeRetry"),afterResponse:sxu(e,t,"afterResponse"),beforeError:sxu(e,t,"beforeError")}),XNf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(Vro(i)){for(let[a,o]of Object.entries(i))Vro(o)&&a in t&&(o=XNf(t[a],o)),t={...t,[a]:o};Vro(i.hooks)&&(n=YNf(n,i.hooks),t.hooks=n),Vro(i.headers)&&(r=$Nf(r,i.headers),t.headers=r)}return t};var hHy=e=>ixu.includes(e)?e.toUpperCase():e,JpI=["get","put","head","delete","options","trace"],KpI=[408,413,429,500,502,503,504],$pI=[413,429,503],_Hy={limit:2,methods:JpI,statusCodes:KpI,afterStatusCodes:$pI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},yHy=(e={})=>{if(typeof e=="number")return{..._Hy,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{..._Hy,...e}};async function ZNf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Uro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function kNf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var vHy=(e,t)=>{let r={};for(let n in t)!(n in lHy)&&!(n in cHy)&&!(n in e)&&(r[n]=t[n]);return r},bHy=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var wko=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>axu)throw new RangeError(`The \`timeout\` option cannot be greater than ${axu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new Ako(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!aHy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return dHy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(sHy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:$Nf(this._input.headers,r.headers),hooks:YNf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:hHy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:yHy(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(nHy&&iHy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(KNf&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),bHy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(oHy&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!KNf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=pHy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Uro)throw t;if(t instanceof Ako){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),axu);if(this._retryCount<1)throw r;await kNf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===oxu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=vHy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):ZNf(this._originalRequest,t,this.abortController,this._options)}};var eFf=e=>{let t=(r,n)=>wko.create(r,Pko(e,n));for(let r of ixu)t[r]=(n,i)=>wko.create(n,Pko(e,i,{method:r}));return t.create=r=>eFf(Pko(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),eFf(Pko(e,r))),t.stop=oxu,t},YpI=eFf(),gHy=YpI;var UHy=$i(LHy(),1);function aFf(e){let t=(0,UHy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var NJy=$i(RJy(),1),FJy=$i(pqu(),1),bFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},gFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function mFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??aFf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,NJy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await gHy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new bFf(e):l}if(t.allVersions)return u;let s=new gFf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[O,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[O];if(!l){let O=Object.keys(u.versions);if(r=FJy.default.maxSatisfying(O,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function efa(e,t){let{version:r}=await mFf(e.toLowerCase(),t);return r}async function Y6i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:efa(e.packageName,{version:t?"prerelease":"latest"})}var xJy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],gxu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=uE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new rxu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.115.3"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Mf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Pne}failWithoutThrowing(t,r){this.didSucceed=!1,kFu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await XZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await eHy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2674
|
+
`,n?ska(i,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):i}async function VpI(e){let r=await new ZGy.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function WpI({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,u,s,l)=>{c.versions[u]==null&&(c.versions[u]={});let m=d3i(s.name,l),O=await bTr({generatorName:m,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:i,includeMajor:a,context:l});O!=null&&(c.versions[u][s.name]={previousVersion:s.version,latestVersion:O})},generatorFilter:r,groupFilter:n}),c}let o={type:"multiApi",versions:{}};return await tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,u,s)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=d3i(u.name,s),m=await bTr({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:i,includeMajor:a,context:s});m!=null&&(o.versions[c][f][u.name]={previousVersion:u.version,latestVersion:m})},generatorFilter:r,groupFilter:n}),o}async function tHy({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:n,groupFilter:i}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await CTr({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(i!=null&&f.groupName!==i))for(let u of f.generators)n!=null&&u.name!==n||await r(a.workspaceName,f.groupName,u,o)}})}))}function rHy(e,t,r){let n=[];for(let[i,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${i} has an upgrade available...`);let f=Dxe(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),n.push({generatorName:o,generatorGroup:i,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return n}async function nxu({project:e,cliContext:t,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a}){let o=[];if(e!=null){let c=await WpI({cliContext:t,project:e,generatorFilter:r,groupFilter:n,channel:i,includeMajor:a});if(c.type==="multiApi")for(let[f,u]of Object.entries(c.versions))o.push(...rHy(u,f,t.logger));else o.push(...rHy(c.versions,void 0,t.logger))}return o}var Ako=class extends Error{response;request;options;constructor(t,r,n){let i=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${i} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=n}};var Uro=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var KNf=(()=>{let e=!1,t=!1,r=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(r&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return e&&!t})(),nHy=typeof globalThis.AbortController=="function",iHy=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",aHy=typeof globalThis.ReadableStream=="function",oHy=typeof globalThis.FormData=="function",ixu=["get","post","put","patch","head","delete"],GpI=()=>{};GpI();var sHy={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},axu=2147483647,uHy=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,oxu=Symbol("stop"),cHy={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},lHy={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var HpI=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,n]of e)t+=uHy,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},fHy=(e,t,r)=>{let n,i=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),n){i+=n.byteLength;let c=t===0?0:i/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,r?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},n))}}))},dHy=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(fHy(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},pHy=(e,t,r)=>{if(!e.body)return e;let n=HpI(r??e.body);return new Request(e,{duplex:"half",body:fHy(e.body,n,t)})};var Vro=e=>e!==null&&typeof e=="object";var Pko=(...e)=>{for(let t of e)if((!Vro(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return XNf({},...e)},$Nf=(e={},t={})=>{let r=new globalThis.Headers(e),n=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[a,o]of i.entries())n&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function sxu(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:XNf(e[r]??[],t[r]??[])}var YNf=(e={},t={})=>({beforeRequest:sxu(e,t,"beforeRequest"),beforeRetry:sxu(e,t,"beforeRetry"),afterResponse:sxu(e,t,"afterResponse"),beforeError:sxu(e,t,"beforeError")}),XNf=(...e)=>{let t={},r={},n={};for(let i of e)if(Array.isArray(i))Array.isArray(t)||(t=[]),t=[...t,...i];else if(Vro(i)){for(let[a,o]of Object.entries(i))Vro(o)&&a in t&&(o=XNf(t[a],o)),t={...t,[a]:o};Vro(i.hooks)&&(n=YNf(n,i.hooks),t.hooks=n),Vro(i.headers)&&(r=$Nf(r,i.headers),t.headers=r)}return t};var hHy=e=>ixu.includes(e)?e.toUpperCase():e,JpI=["get","put","head","delete","options","trace"],KpI=[408,413,429,500,502,503,504],$pI=[413,429,503],_Hy={limit:2,methods:JpI,statusCodes:KpI,afterStatusCodes:$pI,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},yHy=(e={})=>{if(typeof e=="number")return{..._Hy,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{..._Hy,...e}};async function ZNf(e,t,r,n){return new Promise((i,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new Uro(e))},n.timeout);n.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function kNf(e,{signal:t}){return new Promise((r,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(t.reason)}let a=setTimeout(()=>{t?.removeEventListener("abort",i),r()},e)})}var vHy=(e,t)=>{let r={};for(let n in t)!(n in lHy)&&!(n in cHy)&&!(n in e)&&(r[n]=t[n]);return r},bHy=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var wko=class e{static create(t,r){let n=new e(t,r),i=async()=>{if(typeof n._options.timeout=="number"&&n._options.timeout>axu)throw new RangeError(`The \`timeout\` option cannot be greater than ${axu}`);await Promise.resolve();let c=await n._fetch();for(let f of n._options.hooks.afterResponse){let u=await f(n.request,n._options,n._decorateResponse(c.clone()));u instanceof globalThis.Response&&(c=u)}if(n._decorateResponse(c),!c.ok&&n._options.throwHttpErrors){let f=new Ako(c,n.request,n._options);for(let u of n._options.hooks.beforeError)f=await u(f);throw f}if(n._options.onDownloadProgress){if(typeof n._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!aHy)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return dHy(c.clone(),n._options.onDownloadProgress)}return c},o=(n._options.retry.methods.includes(n.request.method.toLowerCase())?n._retry(i):i()).finally(async()=>{let c=n._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),n.request.bodyUsed||f.push(n.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(sHy))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||f);let u=await o;if(c==="json"){if(u.status===204)return"";let s=await u.text();return s===""?"":r.parseJson?r.parseJson(s):JSON.parse(s)}return u[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:$Nf(this._input.headers,r.headers),hooks:YNf({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:hHy(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:yHy(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(nHy&&iHy){let n=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=n?AbortSignal.any([n,this.abortController.signal]):this.abortController.signal}if(KNf&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),bHy(this._options.searchParams)){let i="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);(oHy&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(a,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!KNf)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=pHy(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof Uro)throw t;if(t instanceof Ako){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this._options.retry.afterStatusCodes.includes(t.response.status)){let i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let a=this._options.retry.maxRetryAfter??i;return i<a?i:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let n=Math.min(this._calculateRetryDelay(r),axu);if(this._retryCount<1)throw r;await kNf(n,{signal:this._options.signal});for(let i of this._options.hooks.beforeRetry)if(await i({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===oxu)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let n=await r(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=vHy(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):ZNf(this._originalRequest,t,this.abortController,this._options)}};var eFf=e=>{let t=(r,n)=>wko.create(r,Pko(e,n));for(let r of ixu)t[r]=(n,i)=>wko.create(n,Pko(e,i,{method:r}));return t.create=r=>eFf(Pko(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),eFf(Pko(e,r))),t.stop=oxu,t},YpI=eFf(),gHy=YpI;var UHy=$i(LHy(),1);function aFf(e){let t=(0,UHy.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var NJy=$i(RJy(),1),FJy=$i(pqu(),1),bFf=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},gFf=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function mFf(e,t={}){let{version:r="latest"}=t,{omitDeprecated:n=!0}=t,i=e.split("/")[0],a=t.registryUrl??aFf(i),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,NJy.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let u;try{u=await gHy(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new bFf(e):l}if(t.allVersions)return u;let s=new gFf(e,r);if(u["dist-tags"][r]){let{time:l}=u;u=u.versions[u["dist-tags"][r]],u.time=l}else if(r){let l=!!u.versions[r];if(n&&!l)for(let[O,P]of Object.entries(u.versions))P.deprecated&&delete u.versions[O];if(!l){let O=Object.keys(u.versions);if(r=FJy.default.maxSatisfying(O,r),!r)throw s}let{time:m}=u;if(u=u.versions[r],u.time=m,!u)throw s}return u}async function efa(e,t){let{version:r}=await mFf(e.toLowerCase(),t);return r}async function Y6i({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:efa(e.packageName,{version:t?"prerelease":"latest"})}var xJy=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],gxu=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=uE.Info;isLocal;constructor(t,r,{isLocal:n}){this.ttyAwareLogger=new rxu(t,r),this.isLocal=n??!1;let i=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(i==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:i,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.115.4"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Mf.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new Pne}failWithoutThrowing(t,r){this.didSucceed=!1,kFu({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await XZa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((n,i)=>setTimeout(()=>i("Request timed out"),300))]),r=await eHy({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2675
2675
|
`)||(r+=`
|
|
2676
2676
|
`),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=fKl(t.map(n=>n.type==="docs"?"docs":n.workspaceName??"api"),n=>n.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new yko(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let n=this.addTaskWithInit(t).start(),i;try{i=await r(n)}catch(a){throw a.message.includes("globalThis")?(n.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),n.failWithoutThrowing()):n.failWithoutThrowing(void 0,a),new Pne}finally{n.finish()}return i}async instrumentPostHogEvent(t){this.isLocal||(await XZa()).sendEvent(t)}logger=G2r((t,...r)=>this.log(t,...r));stderr=G2r((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=zJy(t.type==="docs"?"docs":t.workspaceName??"api"),n=1+(this.longestWorkspaceName!=null?zJy(this.longestWorkspaceName):r).length,i=r.padEnd(n),a=xJy[this.numTasks++%xJy.length],o=Mf.hex(a)(i);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===yV.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let n=t.filter(i=>Mxi.indexOf(i.level)>=Mxi.indexOf(this.logLevel));this.ttyAwareLogger.log(n,{includeDebugInfo:this.logLevel===uE.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await Y6i({cliEnvironment:this.environment,includePreReleases:t}),n=Dxe(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(n?"Upgrade available.":"No upgrade available."));let i={isUpgradeAvailable:n,latestVersion:r},a=await nxu({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:i,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await NNf({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Mf.yellow("?"),style:{answer:i=>Mf.cyan(i),message:i=>Mf.bold(i),highlight:i=>Mf.cyan(i)}}})}catch(n){throw n?.name==="ExitPromptError"?(this.logger.info(`
|
|
2677
2677
|
Cancelled by user.`),new Pne):n}}async getInput(t){return await BNf({message:t.message,default:t.default})}};function zJy(e){return`[${e}]:`}var mqr=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:n,absoluteFilePath:i,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=n,this.absoluteFilePath=i,this.changelog=a}};function mxu(e,t,r,n){if(typeof r!="function")throw new Error("method for before hook must be a function");return n||(n={}),Array.isArray(t)?t.reverse().reduce((i,a)=>mxu.bind(null,e,a,i,n),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((i,a)=>a.hook.bind(null,i,n),r)():r(n))}function QJy(e,t,r,n){let i=n;e.registry[r]||(e.registry[r]=[]),t==="before"&&(n=(a,o)=>Promise.resolve().then(i.bind(null,o)).then(a.bind(null,o))),t==="after"&&(n=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,i(c,o))).then(()=>c)}),t==="error"&&(n=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>i(c,o))),e.registry[r].push({hook:n,orig:i})}function LJy(e,t,r){if(!e.registry[t])return;let n=e.registry[t].map(i=>i.orig).indexOf(r);n!==-1&&e.registry[t].splice(n,1)}var UJy=Function.bind,VJy=UJy.bind(UJy);function WJy(e,t,r){let n=VJy(LJy,null).apply(null,r?[t,r]:[t]);e.api={remove:n},e.remove=n,["before","error","after","wrap"].forEach(i=>{let a=r?[t,i,r]:[t,i];e[i]=e.api[i]=VJy(QJy,null).apply(null,a)})}function rhI(){let e=Symbol("Singular"),t={registry:{}},r=mxu.bind(null,t,e);return WJy(r,t,e),r}function nhI(){let e={registry:{}},t=mxu.bind(null,e);return WJy(t,e),t}var GJy={Singular:rhI,Collection:nhI};var ihI="0.0.0-development",ahI=`octokit-endpoint.js/${ihI} ${Nfe()}`,ohI={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":ahI},mediaType:{format:""}};function shI(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function uhI(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function KJy(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{uhI(t[n])?n in e?r[n]=KJy(e[n],t[n]):Object.assign(r,{[n]:t[n]}):Object.assign(r,{[n]:t[n]})}),r}function HJy(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function AFf(e,t,r){if(typeof t=="string"){let[i,a]=t.split(" ");r=Object.assign(a?{method:i,url:a}:{url:i},r)}else r=Object.assign({},t);r.headers=shI(r.headers),HJy(r),HJy(r.headers);let n=KJy(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(n.mediaType.previews=e.mediaType.previews.filter(i=>!n.mediaType.previews.includes(i)).concat(n.mediaType.previews)),n.mediaType.previews=(n.mediaType.previews||[]).map(i=>i.replace(/-preview/,""))),n}function chI(e,t){let r=/\?/.test(e)?"&":"?",n=Object.keys(t);return n.length===0?e:e+r+n.map(i=>i==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${i}=${encodeURIComponent(t[i])}`).join("&")}var lhI=/\{[^{}}]+\}/g;function fhI(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function dhI(e){let t=e.match(lhI);return t?t.map(fhI).reduce((r,n)=>r.concat(n),[]):[]}function JJy(e,t){let r={__proto__:null};for(let n of Object.keys(e))t.indexOf(n)===-1&&(r[n]=e[n]);return r}function $Jy(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function Xro(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Iko(e,t,r){return t=e==="+"||e==="#"?$Jy(t):Xro(t),r?Xro(r)+"="+t:t}function Yro(e){return e!=null}function OFf(e){return e===";"||e==="&"||e==="?"}function phI(e,t,r,n){var i=e[r],a=[];if(Yro(i)&&i!=="")if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")i=i.toString(),n&&n!=="*"&&(i=i.substring(0,parseInt(n,10))),a.push(Iko(t,i,OFf(t)?r:""));else if(n==="*")Array.isArray(i)?i.filter(Yro).forEach(function(o){a.push(Iko(t,o,OFf(t)?r:""))}):Object.keys(i).forEach(function(o){Yro(i[o])&&a.push(Iko(t,i[o],o))});else{let o=[];Array.isArray(i)?i.filter(Yro).forEach(function(c){o.push(Iko(t,c))}):Object.keys(i).forEach(function(c){Yro(i[c])&&(o.push(Xro(c)),o.push(Iko(t,i[c].toString())))}),OFf(t)?a.push(Xro(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?Yro(i)&&a.push(Xro(r)):i===""&&(t==="&"||t==="?")?a.push(Xro(r)+"="):i===""&&a.push("");return a}function _hI(e){return{expand:hhI.bind(null,e)}}function hhI(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(n,i,a){if(i){let c="",f=[];if(r.indexOf(i.charAt(0))!==-1&&(c=i.charAt(0),i=i.substr(1)),i.split(/,/g).forEach(function(u){var s=/([^:\*]*)(?::(\d+)|(\*))?/.exec(u);f.push(phI(t,c,s[1],s[2]||s[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return $Jy(a)}),e==="/"?e:e.replace(/\/$/,"")}function YJy(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),n=Object.assign({},e.headers),i,a=JJy(e,["method","baseUrl","url","headers","request","mediaType"]),o=dhI(r);r=_hI(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(s=>o.includes(s)).concat("baseUrl"),f=JJy(a,c);if(!/application\/octet-stream/i.test(n.accept)&&(e.mediaType.format&&(n.accept=n.accept.split(/,/).map(s=>s.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let s=n.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];n.accept=s.concat(e.mediaType.previews).map(l=>{let m=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${m}`}).join(",")}return["GET","HEAD"].includes(t)?r=chI(r,f):"data"in f?i=f.data:Object.keys(f).length&&(i=f),!n["content-type"]&&typeof i<"u"&&(n["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof i>"u"&&(i=""),Object.assign({method:t,url:r,headers:n},typeof i<"u"?{body:i}:null,e.request?{request:e.request}:null)}function yhI(e,t,r){return YJy(AFf(e,t,r))}function XJy(e,t){let r=AFf(e,t),n=yhI.bind(null,r);return Object.assign(n,{DEFAULTS:r,defaults:XJy.bind(null,r),merge:AFf.bind(null,r),parse:YJy})}var ZJy=XJy(null,ohI);var iKy=$i(rKy(),1);var Oqr=class extends Error{name;status;request;response;constructor(t,r,n){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in n&&(this.response=n.response);let i=Object.assign({},n.request);n.request.headers.authorization&&(i.headers=Object.assign({},n.request.headers,{authorization:n.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),i.url=i.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=i}};var vhI="10.0.6",bhI={headers:{"user-agent":`octokit-request.js/${vhI} ${Nfe()}`}};function ghI(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function nKy(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,n=e.request?.parseSuccessResponseBody!==!1,i=ghI(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,m])=>[l,String(m)])),o;try{o=await t(e.url,{method:e.method,body:i,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let m="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;m=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?m=l.cause.message:typeof l.cause=="string"&&(m=l.cause))}let O=new Oqr(m,500,{request:e});throw O.cause=l,O}let c=o.status,f=o.url,u={};for(let[l,m]of o.headers)u[l]=m;let s={url:f,status:c,headers:u,data:""};if("deprecation"in u){let l=u.link&&u.link.match(/<([^<>]+)>; rel="deprecation"/),m=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${u.sunset}${m?`. See ${m}`:""}`)}if(c===204||c===205)return s;if(e.method==="HEAD"){if(c<400)return s;throw new Oqr(o.statusText,c,{response:s,request:e})}if(c===304)throw s.data=await PFf(o),new Oqr("Not modified",c,{response:s,request:e});if(c>=400)throw s.data=await PFf(o),new Oqr(OhI(s.data),c,{response:s,request:e});return s.data=n?await PFf(o):o.body,s}async function PFf(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,iKy.safeParse)(t);if(mhI(r)){let n="";try{return n=await e.text(),JSON.parse(n)}catch{return n}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function mhI(e){return e.type==="application/json"||e.type==="application/scim+json"}function OhI(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function wFf(e,t){let r=e.defaults(t);return Object.assign(function(i,a){let o=r.merge(i,a);if(!o.request||!o.request.hook)return nKy(r.parse(o));let c=(f,u)=>nKy(r.parse(r.merge(f,u)));return Object.assign(c,{endpoint:r,defaults:wFf.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:wFf.bind(null,r)})}var V6=wFf(ZJy,bhI);var AhI="0.0.0-development";function PhI(e){return`Request failed due to following response errors:
|
|
@@ -3029,7 +3029,17 @@ ${m}
|
|
|
3029
3029
|
`)},e.heapify=function(t,r){var n=new e(r);return n.heapArray=t,n.init(),n},e.heappop=function(t,r){var n=new e(r);return n.heapArray=t,n.pop()},e.heappush=function(t,r,n){var i=new e(n);i.heapArray=t,i.push(r)},e.heappushpop=function(t,r,n){var i=new e(n);return i.heapArray=t,i.pushpop(r)},e.heapreplace=function(t,r,n){var i=new e(n);return i.heapArray=t,i.replace(r)},e.heaptop=function(t,r,n){r===void 0&&(r=1);var i=new e(n);return i.heapArray=t,i.top(r)},e.heapbottom=function(t,r,n){r===void 0&&(r=1);var i=new e(n);return i.heapArray=t,i.bottom(r)},e.nlargest=function(t,r,n){var i=new e(n);return i.heapArray=QCe([],WPe(r),!1),i.init(),i.top(t)},e.nsmallest=function(t,r,n){var i=new e(n);return i.heapArray=QCe([],WPe(r),!1),i.init(),i.bottom(t)},e.prototype.add=function(t){return this._sortNodeUp(this.heapArray.push(t)-1),this._applyLimit(),!0},e.prototype.addAll=function(t){var r,n=this.length;(r=this.heapArray).push.apply(r,QCe([],WPe(t),!1));for(var i=this.length;n<i;++n)this._sortNodeUp(n);return this._applyLimit(),!0},e.prototype.bottom=function(t){return t===void 0&&(t=1),this.heapArray.length===0||t<=0?[]:this.heapArray.length===1?[this.heapArray[0]]:t>=this.heapArray.length?QCe([],WPe(this.heapArray),!1):this._bottomN_push(~~t)},e.prototype.check=function(){var t=this;return this.heapArray.find(function(r,n){return!!t.getChildrenOf(n).find(function(i){return t.compare(r,i)>0})})},e.prototype.clear=function(){this.heapArray=[]},e.prototype.clone=function(){var t=new e(this.comparator());return t.heapArray=this.toArray(),t._limit=this._limit,t},e.prototype.comparator=function(){return this.compare},e.prototype.contains=function(t,r){return r===void 0&&(r=e.defaultIsEqual),this.indexOf(t,r)!==-1},e.prototype.init=function(t){t&&(this.heapArray=QCe([],WPe(t),!1));for(var r=e.getParentIndexOf(this.length-1);r>=0;--r)this._sortNodeDown(r);this._applyLimit()},e.prototype.isEmpty=function(){return this.length===0},e.prototype.indexOf=function(t,r){if(r===void 0&&(r=e.defaultIsEqual),this.heapArray.length===0)return-1;for(var n=[],i=0;i<this.heapArray.length;){var a=this.heapArray[i];if(r(a,t))return i;this.compare(a,t)<=0&&n.push.apply(n,QCe([],WPe(e.getChildrenIndexOf(i)),!1)),i=n.shift()||this.heapArray.length}return-1},e.prototype.indexOfEvery=function(t,r){if(r===void 0&&(r=e.defaultIsEqual),this.heapArray.length===0)return[];for(var n=[],i=[],a=0;a<this.heapArray.length;){var o=this.heapArray[a];r(o,t)?(i.push(a),n.push.apply(n,QCe([],WPe(e.getChildrenIndexOf(a)),!1))):this.compare(o,t)<=0&&n.push.apply(n,QCe([],WPe(e.getChildrenIndexOf(a)),!1)),a=n.shift()||this.heapArray.length}return i},e.prototype.leafs=function(){if(this.heapArray.length===0)return[];var t=e.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(t+1)},Object.defineProperty(e.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"limit",{get:function(){return this._limit},set:function(t){t<0||isNaN(t)?this._limit=0:this._limit=~~t,this._applyLimit()},enumerable:!1,configurable:!0}),e.prototype.setLimit=function(t){return this.limit=t,t<0||isNaN(t)?NaN:this._limit},e.prototype.peek=function(){return this.heapArray[0]},e.prototype.pop=function(){var t=this.heapArray.pop();return this.length>0&&t!==void 0?this.replace(t):t},e.prototype.push=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.length<1?!1:t.length===1?this.add(t[0]):this.addAll(t)},e.prototype.pushpop=function(t){var r;return this.compare(this.heapArray[0],t)<0&&(r=WPe([this.heapArray[0],t],2),t=r[0],this.heapArray[0]=r[1],this._sortNodeDown(0)),t},e.prototype.remove=function(t,r){var n=this;if(r===void 0&&(r=e.defaultIsEqual),!this.heapArray.length)return!1;if(t===void 0)return this.pop(),!0;for(var i=[0];i.length;){var a=i.shift();if(r(this.heapArray[a],t))return a===0?this.pop():a===this.heapArray.length-1?this.heapArray.pop():(this.heapArray.splice(a,1,this.heapArray.pop()),this._sortNodeUp(a),this._sortNodeDown(a)),!0;if(this.compare(this.heapArray[a],t)<=0){var o=e.getChildrenIndexOf(a).filter(function(c){return c<n.heapArray.length});i.push.apply(i,QCe([],WPe(o),!1))}}return!1},e.prototype.replace=function(t){var r=this.heapArray[0];return this.heapArray[0]=t,this._sortNodeDown(0),r},e.prototype.size=function(){return this.length},e.prototype.top=function(t){return t===void 0&&(t=1),this.heapArray.length===0||t<=0?[]:this.heapArray.length===1||t===1?[this.heapArray[0]]:t>=this.heapArray.length?QCe([],WPe(this.heapArray),!1):this._topN_push(~~t)},e.prototype.toArray=function(){return QCe([],WPe(this.heapArray),!1)},e.prototype.toString=function(){return this.heapArray.toString()},e.prototype.get=function(t){return this.heapArray[t]},e.prototype.getChildrenOf=function(t){var r=this;return e.getChildrenIndexOf(t).map(function(n){return r.heapArray[n]}).filter(function(n){return n!==void 0})},e.prototype.getParentOf=function(t){var r=e.getParentIndexOf(t);return this.heapArray[r]},e.prototype[Symbol.iterator]=function(){return gYI(this,function(t){switch(t.label){case 0:return this.length?[4,this.pop()]:[3,2];case 1:return t.sent(),[3,0];case 2:return[2]}})},e.prototype.iterator=function(){return this.toArray()},e.prototype._applyLimit=function(){if(this._limit>0&&this._limit<this.heapArray.length)for(var t=this.heapArray.length-this._limit;t;)this.heapArray.pop(),--t},e.prototype._bottomN_push=function(t){var r=new e(this.compare);r.limit=t,r.heapArray=this.heapArray.slice(-t),r.init();for(var n=this.heapArray.length-1-t,i=e.getParentIndexOf(n),a=[],o=n;o>i;--o)a.push(o);for(var c=this.heapArray;a.length;){var o=a.shift();this.compare(c[o],r.peek())>0&&(r.replace(c[o]),o%2&&a.push(e.getParentIndexOf(o)))}return r.toArray()},e.prototype._moveNode=function(t,r){var n=this.heapArray[t];this.heapArray[t]=this.heapArray[r],this.heapArray[r]=n},e.prototype._sortNodeDown=function(t){for(var r=this.heapArray.length,n=t,i=this.heapArray[t],a=2*t+1;a<r;){var o=a+1,c=o>=r||this.compare(this.heapArray[a],this.heapArray[o])<0?a:o;if(this.compare(this.heapArray[c],i)<0)this.heapArray[t]=this.heapArray[c],t=c,a=2*t+1;else break}t!==n&&(this.heapArray[t]=i)},e.prototype._sortNodeUp=function(t){for(var r=this.heapArray[t],n=t;t>0;){var i=e.getParentIndexOf(t);if(this.compare(r,this.heapArray[i])<0)this.heapArray[t]=this.heapArray[i],t=i;else break}t!==n&&(this.heapArray[t]=r)},e.prototype._topN_push=function(t){var r=new e(this._invertedCompare);r.limit=t;for(var n=[0],i=this.heapArray;n.length;){var a=n.shift();a<i.length&&(r.length<t?(r.push(i[a]),n.push.apply(n,QCe([],WPe(e.getChildrenIndexOf(a)),!1))):this.compare(i[a],r.peek())<0&&(r.replace(i[a]),n.push.apply(n,QCe([],WPe(e.getChildrenIndexOf(a)),!1))))}return r.toArray()},e.prototype._topN_fill=function(t){var r=this.heapArray,n=new e(this._invertedCompare);n.limit=t,n.heapArray=r.slice(0,t),n.init();for(var i=e.getParentIndexOf(t-1)+1,a=[],o=i;o<t;++o)a.push.apply(a,QCe([],WPe(e.getChildrenIndexOf(o).filter(function(c){return c<r.length})),!1));for((t-1)%2&&a.push(t);a.length;){var o=a.shift();o<r.length&&this.compare(r[o],n.peek())<0&&(n.replace(r[o]),a.push.apply(a,QCe([],WPe(e.getChildrenIndexOf(o)),!1)))}return n.toArray()},e.prototype._topN_heap=function(t){for(var r=this.clone(),n=[],i=0;i<t;++i)n.push(r.pop());return n},e.prototype._topIdxOf=function(t){if(!t.length)return-1;for(var r=0,n=t[r],i=1;i<t.length;++i){var a=this.compare(t[i],n);a<0&&(r=i,n=t[i])}return r},e.prototype._topOf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=new e(this.compare);return n.init(t),n.peek()},e})();function Hmv(e,t,r,n,i){if(r<=0)return[];let a=n??(c=>c),o=new Wmv(mYI);for(let c of t){let f=Gmv.default.get(a(e),a(c));i!=null&&f>i||(o.push({neighbor:c,distance:f}),o.size()>r&&o.pop())}return OYI(o).reverse().map(c=>c.neighbor)}function mYI(e,t){return e.distance!==t.distance?t.distance-e.distance:t.neighbor.localeCompare(e.neighbor)}function OYI(e){let t=[];for(;e.size()>0;){let r=e.pop();r&&t.push(r)}return t}var AYI=3,PYI=5;function Q9u(e,t){let r=Hmv(e,t,AYI,wYI,PYI),n=Array.from(t),i=`Failed to locate API section ${e}.`;switch(r.length){case 0:return i=`${i} No similar API sections found. Available API sections:`,n.length===0?`${i} []`:`${i} [
|
|
3030
3030
|
${n.map(a=>` ${a}`).join(`,
|
|
3031
3031
|
`)}
|
|
3032
|
-
]`;case 1:return`${i} Did you mean ${r[0]}?`;case 2:return`${i} Did you mean ${r[0]} or ${r[1]}?`;default:return`${i} Did you mean ${r[0]}, ${r[1]}, or ${r[2]}?`}}function L9u(e){return`API section ${e} is specified multiple times, however will be only rendered once.`}function wYI(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function U9u({children:e,findEndpointById:t,stringifyEndpointPathParts:r,disableEndpointPairs:n,apiDefinitionId:i}){if(n)return e;let a=[],o=new Map;return e.forEach(c=>{if(c.type!=="endpoint"){a.push(c);return}let f=t(c.endpointId);if(f==null)throw new Error(`Endpoint ${c.endpointId} not found`);let u=`${f.method} ${r(f)}`,s=o.get(u);if(o.set(u,c),s==null||s.isResponseStream===c.isResponseStream){a.push(c);return}let l=a.indexOf(s),m=c.isResponseStream?c:s,O=c.isResponseStream?s:c,P={id:fl.V1.NodeId(`${i}:${O.endpointId}+${m.endpointId}`),type:"endpointPair",stream:m,nonStream:O};a[l]=P}),a}function Jmv({left:e,right:t,findEndpointById:r,stringifyEndpointPathParts:n,disableEndpointPairs:i,apiDefinitionId:a}){return U9u({children:[...e,...t],findEndpointById:r,stringifyEndpointPathParts:n,disableEndpointPairs:i,apiDefinitionId:a}).filter(o=>o.type==="apiPackage"?o.children.length>0:!0)}function uoo(e,t){if(t!=null)return A3(e.absoluteFilePath,t)}function Kmv({docsWorkspace:e,page:t,parentSlug:r,idgen:n,markdownFilesToFullSlugs:i,markdownFilesToNoIndex:a,hideChildren:o,resolveIconFileId:c}){let f=fl.V1.PageId(uoo(e,t.absolutePath)),u=r.apply({fullSlug:i.get(t.absolutePath)?.split("/"),urlSlug:t.slug??s$(t.title)});return{id:n.get(f),type:"page",pageId:f,title:t.title,slug:u.get(),icon:c?c(t.icon):t.icon,hidden:o||t.hidden,noindex:t.noindex||a.get(t.absolutePath),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,availability:t.availability}}var V9u=class{apiSection;docsWorkspace;taskContext;markdownFilesToFullSlugs;markdownFilesToNoIndex;markdownFilesToTags;workspace;hideChildren;parentAvailability;apiDefinitionId;#e;#t=new Set;#r=new Set;#n=new Set;#i=new Set;#a=new Set;#o=new Map;#u=[];#s;#c;#f;disableEndpointPairs;collectedFileIds=new Map;constructor(t,r,n,i,a,o,c,f,u,s,l,m,O){this.apiSection=t,this.docsWorkspace=i,this.taskContext=a,this.markdownFilesToFullSlugs=o,this.markdownFilesToNoIndex=c,this.markdownFilesToTags=f,this.workspace=l,this.hideChildren=m,this.parentAvailability=O,this.disableEndpointPairs=i.config.experimental?.disableStreamToggle??!1,this.apiDefinitionId=fl.V1.ApiDefinitionId(r.id),this.#e=Q8i.create(r,a),this.collectedFileIds=s,this.#f=u,this.#s=this.apiSection.overviewAbsolutePath!=null?fl.V1.PageId(uoo(this.docsWorkspace,this.apiSection.overviewAbsolutePath)):void 0;let P=this.apiSection.overviewAbsolutePath!=null?this.markdownFilesToFullSlugs.get(this.apiSection.overviewAbsolutePath):void 0;this.#c=n.apply({fullSlug:P?.split("/"),skipUrlSlug:this.apiSection.skipUrlSlug,urlSlug:this.apiSection.slug??s$(this.apiSection.title)});let C=this.apiSection.availability??this.parentAvailability;this.apiSection.navigation!=null&&(this.#u=this.#d(this.apiSection.navigation,this.#e.api.rootPackage,this.#c,C)),this.#u=this.#g(this.#u.map(I=>this.#m(I,C)),this.#O(this.#e.api.rootPackage,this.#c,C))}get(){let t=fl.V1.followRedirects(this.#u),r=new Eda(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.workspace?.changelog?.files.map(n=>n.absoluteFilepath),this.docsWorkspace,this.#f).orUndefined();return{id:this.#f.get(this.apiDefinitionId),type:"apiReference",title:this.apiSection.title,apiDefinitionId:this.apiDefinitionId,overviewPageId:this.#s,paginated:this.apiSection.paginated,slug:this.#c.get(),icon:this.resolveIconFileId(this.apiSection.icon),hidden:this.hideChildren||this.apiSection.hidden,hideTitle:this.apiSection.flattened,showErrors:this.apiSection.showErrors,changelog:r?.toChangelogNode({parentSlug:this.#c,viewers:void 0,hidden:this.hideChildren}),children:this.#u,availability:this.apiSection.availability??this.parentAvailability,pointsTo:t,noindex:void 0,playground:this.#v(this.apiSection.playground),postmanCollectionUrl:this.apiSection.postman,authed:void 0,viewers:this.apiSection.viewers,orphaned:this.apiSection.orphaned,featureFlags:this.apiSection.featureFlags}}#d(t,r,n,i){r=this.#e.resolveSubpackage(r);let a=r!=null?Q8i.getSubpackageId(r):void 0;return t.map(o=>W9f(o)._visit({link:c=>({id:this.#f.get(c.url),type:"link",title:c.text,icon:this.resolveIconFileId(c.icon),url:fl.Url(c.url)}),page:c=>this.#p(c,n,i),package:c=>this.#l(c,n,i),section:c=>this.#_(c,n,i),item:({value:c})=>this.#y(c,a,n,i),endpoint:c=>this.#h(c,a,n,i)})).filter(hj)}#p(t,r,n){return Kmv({page:{...t,availability:t.availability??n},parentSlug:r,docsWorkspace:this.docsWorkspace,markdownFilesToFullSlugs:this.markdownFilesToFullSlugs,markdownFilesToNoIndex:this.markdownFilesToNoIndex,idgen:this.#f,hideChildren:this.hideChildren,resolveIconFileId:this.resolveIconFileId.bind(this)})}#l(t,r,n){let i=t.overviewAbsolutePath!=null?fl.V1.PageId(uoo(this.docsWorkspace,t.overviewAbsolutePath)):void 0,a=t.overviewAbsolutePath!=null?this.markdownFilesToFullSlugs.get(t.overviewAbsolutePath):void 0,o=t.availability??n,c=this.#e.getSubpackageByIdOrLocator(t.package);if(c!=null){let f=Q8i.getSubpackageId(c),u=this.#f.get(i??`${this.apiDefinitionId}:${f}`);this.#a.has(f)&&this.taskContext.logger.warn(L9u(t.package)),this.#a.add(f),this.#o.set(u,[f]);let s=t.slug??(pWr(c)?c.urlSlug:this.apiSection.slug??s$(this.apiSection.title)),l=r.apply({fullSlug:a?.split("/"),skipUrlSlug:t.skipUrlSlug,urlSlug:s}),m=this.#d(t.contents,c,l,o);return{id:u,type:"apiPackage",children:m,title:t.title??(pWr(c)?c.displayName??ooo(c.name):this.apiSection.title),slug:l.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,overviewPageId:i,availability:o,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}else{this.taskContext.logger.warn(Q9u(t.package,this.#e.subpackageLocators));let f=t.slug??s$(t.package),u=r.apply({fullSlug:a?.split("/"),skipUrlSlug:t.skipUrlSlug,urlSlug:f}),s=this.#d(t.contents,void 0,u,o);return{id:this.#f.get(i??`${this.apiDefinitionId}:${s$(t.package)}`),type:"apiPackage",children:s,title:t.title??t.package,slug:u.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,overviewPageId:i,availability:o,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}}#_(t,r,n){let i=t.overviewAbsolutePath!=null?fl.V1.PageId(uoo(this.docsWorkspace,t.overviewAbsolutePath)):void 0,a=t.overviewAbsolutePath!=null?this.markdownFilesToFullSlugs.get(t.overviewAbsolutePath):void 0,o=t.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(t.overviewAbsolutePath):void 0,c=this.#f.get(i??a??r.get()),f=t.referencedSubpackages.map(O=>{let P=this.#e.getSubpackageByIdOrLocator(O),C=P!=null?Q8i.getSubpackageId(P):void 0;if(C===void 0){this.taskContext.logger.error(Q9u(O,this.#e.subpackageLocators));return}return{subpackageId:C,locator:O}}).filter(O=>O!=null).filter(hj);this.#o.set(c,f.map(O=>O.subpackageId)),f.forEach(O=>{this.#a.has(O.subpackageId)&&this.taskContext.logger.error(L9u(O.locator)),this.#a.add(O.subpackageId)});let u=t.slug??s$(t.title),s=r.apply({fullSlug:a?.split("/"),skipUrlSlug:t.skipUrlSlug,urlSlug:u}),l=t.availability??n,m=this.#d(t.contents,void 0,s,l);return{id:c,type:"apiPackage",children:m,title:t.title,slug:s.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,overviewPageId:i,availability:l,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:o,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}#y(t,r,n,i){t=t.trim();let a=this.#e.getSubpackageByIdOrLocator(t)??this.#e.getSubpackageByIdOrLocator(YA(t));if(a!=null){let o=Q8i.getSubpackageId(a),c=this.#f.get(`${this.apiDefinitionId}:${o}`);this.#a.has(o)&&this.taskContext.logger.error(L9u(t)),this.#a.add(o),this.#o.set(c,[o]);let f=pWr(a)?a.urlSlug:"",u=n.apply({urlSlug:f});return{id:c,type:"apiPackage",children:[],title:pWr(a)?a.displayName??ooo(a.name):this.apiSection.title,slug:u.get(),icon:void 0,hidden:this.hideChildren,overviewPageId:void 0,availability:i,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}return this.#h({type:"endpoint",endpoint:t,title:void 0,icon:void 0,slug:void 0,hidden:void 0,availability:void 0,playground:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0},r,n,i)}#h(t,r,n,i){let a=(r!=null?this.#e.subpackages.get(gve.SubpackageId(r))?.endpoints.get(gve.EndpointId(t.endpoint)):void 0)??this.#e.endpointsByLocator.get(t.endpoint);if(a!=null){let f=this.#e.getEndpointId(a);if(f==null)this.taskContext.logger.debug(`Expected Endpoint ID for ${a.id} at path: ${z9u(a.method,a.path.parts)}. Got undefined.`);else{this.#t.has(f)&&this.taskContext.logger.error(`Duplicate endpoint found in the API Reference layout: ${f}`),this.#t.add(f);let u=t.slug!=null?n.append(t.slug):n.apply(a);return{id:this.#f.get(`${this.apiDefinitionId}:${f}`),type:"endpoint",method:a.method,endpointId:f,apiDefinitionId:this.apiDefinitionId,availability:t.availability??fl.V1.convertAvailability(a.availability)??i,isResponseStream:a.response?.type.type==="stream",title:t.title??a.name??VPe(a.path.parts),slug:u.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}}let o=(r!=null?this.#e.subpackages.get(gve.SubpackageId(r))?.webSockets.get(gve.WebSocketId(t.endpoint)):void 0)??this.#e.webSocketsByLocator.get(t.endpoint);if(o!=null){let f=this.#e.getWebSocketId(o);if(f==null)this.taskContext.logger.error(`Expected WebSocket ID for ${o.id}. Got undefined.`);else return this.#r.has(f)&&this.taskContext.logger.error(`Duplicate web socket found in the API Reference layout: ${f}`),this.#r.add(f),{id:this.#f.get(`${this.apiDefinitionId}:${f}`),type:"webSocket",webSocketId:f,title:t.title??o.name??VPe(o.path.parts),slug:(t.slug!=null?n.append(t.slug):n.apply(o)).get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,apiDefinitionId:this.apiDefinitionId,availability:fl.V1.convertAvailability(o.availability)??i,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}let c=(r!=null?this.#e.subpackages.get(gve.SubpackageId(r))?.webhooks.get(gve.WebhookId(t.endpoint)):void 0)??this.#e.webhooks.get(fl.V1.WebhookId(t.endpoint));if(c!=null){let f=this.#e.getWebhookId(c);if(f==null)this.taskContext.logger.error(`Expected Webhook ID for ${c.id}. Got undefined.`);else return this.#n.has(f)&&this.taskContext.logger.error(`Duplicate webhook found in the API Reference layout: ${f}`),this.#n.add(f),{id:this.#f.get(`${this.apiDefinitionId}:${f}`),type:"webhook",webhookId:f,method:c.method,title:t.title??c.name??(0,$mv.default)("/",...c.path),slug:(t.slug!=null?n.append(t.slug):n.apply(c)).get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,apiDefinitionId:this.apiDefinitionId,availability:i,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}this.taskContext.logger.error("Unknown identifier in the API Reference layout: ",t.endpoint)}#g(t,r){return Jmv({left:t,right:r,findEndpointById:n=>this.#e.endpoints.get(n),stringifyEndpointPathParts:n=>VPe(n.path.parts),disableEndpointPairs:this.disableEndpointPairs,apiDefinitionId:this.apiDefinitionId})}#m(t,r){return J9f({child:t,nodeIdToSubpackageId:this.#o,convertApiDefinitionPackageId:(n,i,a)=>this.#A(n,i,a),mergeAndFilterChildren:this.#g.bind(this)})}#O(t,r,n){let i=[];return t.endpoints.forEach(a=>{if(a.protocol?.type==="grpc"){let o=this.#e.getGrpcId(a);if(o==null){this.taskContext.logger.error(`Expected Grpc ID for ${a.id} at path: ${z9u(a.method,a.path.parts)}. Got undefined.`);return}if(this.#i.has(o))return;let c=r.apply(a);i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"grpc",grpcId:o,title:a.name??VPe(a.path.parts),method:a.protocol?.methodType??"UNARY",apiDefinitionId:this.apiDefinitionId,availability:n,slug:c.get(),icon:void 0,hidden:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}else{let o=this.#e.getEndpointId(a);if(o==null){this.taskContext.logger.debug(`Expected Endpoint ID for ${a.id} at path: ${z9u(a.method,a.path.parts)}. Got undefined.`);return}if(this.#t.has(o))return;let c=r.apply(a);i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"endpoint",method:a.method,endpointId:o,apiDefinitionId:this.apiDefinitionId,availability:fl.V1.convertAvailability(a.availability)??n,isResponseStream:a.response?.type.type==="stream",title:a.name??VPe(a.path.parts),slug:c.get(),icon:void 0,hidden:this.hideChildren,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}}),t.websockets.forEach(a=>{let o=this.#e.getWebSocketId(a);if(o==null){this.taskContext.logger.error(`Expected WebSocket ID for ${a.id}. Got undefined.`);return}this.#r.has(o)||i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"webSocket",webSocketId:o,title:a.name??VPe(a.path.parts),slug:r.apply(a).get(),icon:void 0,hidden:this.hideChildren,apiDefinitionId:this.apiDefinitionId,availability:fl.V1.convertAvailability(a.availability)??n,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}),t.webhooks.forEach(a=>{let o=this.#e.getWebhookId(a);if(o==null){this.taskContext.logger.error(`Expected Webhook ID for ${a.id}. Got undefined.`);return}this.#n.has(o)||i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"webhook",webhookId:o,method:a.method,title:a.name??ooo(a.id),slug:r.apply(a).get(),icon:void 0,hidden:this.hideChildren,apiDefinitionId:this.apiDefinitionId,availability:n,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}),t.subpackages.forEach(a=>{if(this.#a.has(a))return;let o=this.#e.getSubpackageByIdOrLocator(a);if(o==null){this.taskContext.logger.error(`Subpackage ${a} not found in ${this.apiDefinitionId}`);return}let c=pWr(o)?r.apply(o):r,f=this.#A(a,c,n);f.length>0&&i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${a}`),type:"apiPackage",children:f,title:pWr(o)?o.displayName??ooo(o.name):this.apiSection.title,slug:c.get(),icon:void 0,hidden:this.hideChildren,overviewPageId:void 0,availability:n,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}),i=this.mergeEndpointPairs(i),this.apiSection.alphabetized&&(i=i.sort((a,o)=>{let c=a.type==="endpointPair"?a.nonStream.title:a.title,f=o.type==="endpointPair"?o.nonStream.title:o.title;return c.localeCompare(f)})),i}#A(t,r,n){let i=t!=null?this.#e.resolveSubpackage(this.#e.getSubpackageByIdOrLocator(t)):void 0;return i==null?(this.taskContext.logger.debug(Q9u(t||"unknown",[])),[]):this.#O(i,r,n)}#v(t){return xmv(t)}mergeEndpointPairs(t){return U9u({children:t,findEndpointById:r=>this.#e.endpoints.get(r),stringifyEndpointPathParts:r=>VPe(r.path.parts),disableEndpointPairs:this.disableEndpointPairs,apiDefinitionId:this.apiDefinitionId})}getFileId(t){let r=this.collectedFileIds.get(t);return r??this.taskContext.failAndThrow("Failed to locate file after uploading: "+t)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}};var Ymv=$i(require("crypto"),1);function jYI(e){return Ymv.default.createHash("sha256").update(e).digest("hex")}var W9u=class e{static init(){return new e}constructor(){}#e=new Map;#t=new Set;#r(t){let r=this.#e.get(t)??0;return this.#e.set(t,r+1),jYI(r===0?t:`${t}-${r}`)}#n(t){let r=this.#r(t),n=0;for(;this.#t.has(r);)if(r=this.#r(t),n++,n>100)throw new Error(`Infinite loop detected for id: ${t}`);return r}get(t){return fl.V1.NodeId(this.#n(t))}};function Xmv(e){return e==null?{}:{pythonSdk:e.python!=null?{package:typeof e.python=="string"?e.python:e.python.package,version:typeof e.python=="string"?void 0:e.python.version}:void 0,typescriptSdk:e.typescript!=null?{package:typeof e.typescript=="string"?e.typescript:e.typescript.package,version:typeof e.typescript=="string"?void 0:e.typescript.version}:void 0,goSdk:e.go!=null?{githubRepo:typeof e.go=="string"?e.go:e.go.package,version:typeof e.go=="string"?void 0:e.go.version}:void 0,javaSdk:e.java!=null?{coordinate:typeof e.java=="string"?e.java:e.java.package,version:typeof e.java=="string"?void 0:e.java.version}:void 0,rubySdk:e.ruby!=null?{gem:typeof e.ruby=="string"?e.ruby:e.ruby.package,version:typeof e.ruby=="string"?void 0:e.ruby.version}:void 0,csharpSdk:e.csharp!=null?{package:typeof e.csharp=="string"?e.csharp:e.csharp.package,version:typeof e.csharp=="string"?void 0:e.csharp.version}:void 0,phpSdk:e.php!=null?{package:typeof e.php=="string"?e.php:e.php.package,version:typeof e.php=="string"?void 0:e.php.version}:void 0,swiftSdk:e.swift!=null?{package:typeof e.swift=="string"?e.swift:e.swift.package,version:typeof e.swift=="string"?void 0:e.swift.version}:void 0,rustSdk:e.rust!=null?{package:typeof e.rust=="string"?e.rust:e.rust.package,version:typeof e.rust=="string"?void 0:e.rust.version}:void 0}}function Zmv({auth:e,playgroundConfig:t,context:r}){if(e.schemes.length>0&&e.schemes[0]!=null){let n=e.schemes[0];return kmv({scheme:n,playgroundConfig:t,context:r})}}function kmv({scheme:e,playgroundConfig:t,context:r}){switch(e.type){case"basic":return{type:"basicAuth",passwordName:e.password.originalName,usernameName:e.username.originalName,description:e.docs};case"bearer":return{type:"bearerAuth",tokenName:e.token.originalName,description:e.docs};case"header":return{type:"header",headerWireValue:e.name.wireValue,nameOverride:e.name.name.originalName,prefix:e.prefix,description:e.docs};case"oauth":{let n=e.configuration.tokenEndpoint.responseProperties.accessToken.propertyPath?.map(i=>i.name.originalName).join(".")||"$.body.access_token";return t?.oauth?{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:Xh.EndpointId(e.configuration.tokenEndpoint.endpointReference.endpointId),accessTokenLocator:Xh.JqString(n),headerName:e.configuration.tokenHeader,tokenPrefix:e.configuration.tokenPrefix,description:e.docs}}}:{type:"bearerAuth",tokenName:"token",description:e.docs}}case"inferred":{e.tokenEndpoint.authenticatedRequestHeaders.length>1&&r.logger.warn("Inferred auth scheme has multiple authenticated request headers. Only the `Authentication` or first header will be pushed to FDR.");let n=e.tokenEndpoint.authenticatedRequestHeaders.find(a=>a.headerName.toLowerCase()==="authorization");if(n)return n.responseProperty.propertyPath!=null&&n.responseProperty.propertyPath.length>0&&r.logger.warn("Inferred Authentication header has a property path. The property wirevalue will be pushed to FDR without property path."),{type:"bearerAuth",tokenName:n.responseProperty.property.name.wireValue,description:e.docs};let i=e.tokenEndpoint.authenticatedRequestHeaders[0];return i?{type:"header",headerWireValue:i.headerName,prefix:i.valuePrefix,nameOverride:void 0,description:e.docs}:{type:"bearerAuth",tokenName:"token",description:e.docs}}default:ku(e)}}function eOv({auth:e,playgroundConfig:t,context:r}){let n={};for(let i of e.schemes){let a=kmv({scheme:i,playgroundConfig:t,context:r});a!=null&&(n[Xh.AuthSchemeId(i.key)]=a)}return n}function rOv(e){return e._visit({alias:t=>({type:"alias",value:a4(t.aliasOf)}),enum:t=>({type:"enum",default:t.default!=null?t.default.name.wireValue:void 0,values:t.values.map(r=>({description:r.docs??void 0,value:r.name.wireValue,availability:lie(r.availability)}))}),object:t=>({type:"object",extends:t.extends.map(r=>Xh.TypeId(r.typeId)),properties:t.properties.map(r=>({description:r.docs??void 0,key:Xh.PropertyKey(r.name.wireValue),valueType:a4(r.valueType),availability:lie(r.availability),propertyAccess:r.propertyAccess})),extraProperties:DYI(t.extraProperties)}),union:t=>{let r=t.baseProperties.map(n=>({key:Xh.PropertyKey(n.name.wireValue),valueType:a4(n.valueType),availability:lie(n.availability),description:n.docs,propertyAccess:n.propertyAccess}));return{type:"discriminatedUnion",discriminant:t.discriminant.wireValue,variants:t.types.map(n=>({description:n.docs??void 0,discriminantValue:n.discriminantValue.wireValue,displayName:n.displayName,availability:n.availability!=null?lie(n.availability):void 0,additionalProperties:np.types.SingleUnionTypeProperties._visit(n.shape,{samePropertiesAsObject:i=>({extends:[Xh.TypeId(i.typeId)],properties:r,extraProperties:void 0}),singleProperty:i=>({extends:[],properties:[{key:Xh.PropertyKey(i.name.wireValue),valueType:a4(i.type),description:void 0,availability:void 0,propertyAccess:void 0},...r],extraProperties:void 0}),noProperties:()=>({extends:[],properties:r,extraProperties:void 0}),_other:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+n.shape.propertiesType)}})}))}},undiscriminatedUnion:t=>({type:"undiscriminatedUnion",variants:t.members.map(r=>({typeName:r.type.type==="named"?r.type.name.originalName:void 0,description:r.docs??void 0,type:a4(r.type),availability:void 0,displayName:r.type.type==="named"?r.type.displayName:void 0}))}),_other:()=>{throw new Error("Unknown Type shape: "+e.type)}})}function a4(e){return e._visit({container:t=>np.types.ContainerType._visit(t,{list:r=>({type:"list",itemType:a4(r)}),map:({keyType:r,valueType:n})=>({type:"map",keyType:a4(r),valueType:a4(n)}),optional:r=>({type:"optional",itemType:a4(r),defaultValue:void 0}),nullable:r=>({type:"nullable",itemType:a4(r)}),set:r=>({type:"set",itemType:a4(r)}),literal:r=>np.types.Literal._visit(r,{boolean:n=>({type:"literal",value:{type:"booleanLiteral",value:n}}),string:n=>({type:"literal",value:{type:"stringLiteral",value:n}}),_other:()=>{throw new Error("Unknown literal type: "+r.type)}}),_other:()=>{throw new Error("Unknown container reference: "+t.type)}}),named:t=>({type:"id",value:Xh.TypeId(t.typeId),default:void 0}),primitive:t=>({type:"primitive",value:np.types.PrimitiveTypeV1._visit(t.v1,{integer:()=>SYI(t.v2),float:()=>tOv(t.v2),double:()=>tOv(t.v2),string:()=>EYI(t.v2),long:()=>({type:"long",default:t.v2?.type==="long"?t.v2.default:void 0,minimum:void 0,maximum:void 0}),boolean:()=>({type:"boolean",default:t.v2?.type==="boolean"?t.v2.default:void 0}),dateTime:()=>({type:"datetime",default:void 0}),date:()=>({type:"date",default:void 0}),uuid:()=>({type:"uuid",default:void 0}),base64:()=>({type:"base64",mimeType:void 0,default:void 0}),bigInteger:()=>({type:"bigInteger",default:t.v2?.type==="bigInteger"?t.v2.default:void 0}),uint:()=>({type:"uint"}),uint64:()=>({type:"uint64"}),_other:()=>{throw new Error("Unknown primitive: "+t.v1)}})}),unknown:()=>({type:"unknown"}),_other:()=>{throw new Error("Unknown Type reference: "+e.type)}})}function EYI(e){let t=e!=null&&e.type==="string"?e.validation:void 0;return{type:"string",format:t?.format,regex:t?.pattern,minLength:t?.minLength,maxLength:t?.maxLength,default:e!=null&&e.type==="string"?e.default:void 0}}function SYI(e){let t=e!=null&&e.type==="integer"?e.validation:void 0;return{type:"integer",minimum:t?.min,maximum:t?.max,default:e!=null&&e.type==="integer"?e.default:void 0}}function tOv(e){let t=e!=null&&e.type==="double"?e.validation:void 0;return{type:"double",minimum:t?.min,maximum:t?.max,default:e!=null&&e.type==="double"?e.default:void 0}}function DYI(e){return typeof e=="boolean"?e?Bh.unknown():void 0:typeof e=="string"?{type:"id",value:Xh.TypeId(e),default:void 0}:a4(e)}function Y9f(e,t){let r=e.service!=null?t.services[e.service]:void 0,n=e.webhooks!=null?t.webhookGroups[e.webhooks]:void 0,i=e.websocket!=null&&t.websocketChannels!=null?t.websocketChannels[e.websocket]:void 0;return{endpoints:r!=null?IYI(r,t):[],webhooks:n!=null?CYI(n):[],websockets:i!=null?[MYI(i,t)]:[],types:e.types.map(a=>Xh.TypeId(a)),subpackages:e.subpackages.map(a=>Xh.api.v1.SubpackageId(a)),pointsTo:e.navigationConfig!=null?Xh.api.v1.SubpackageId(e.navigationConfig.pointsTo):void 0}}function CYI(e){return e.map(t=>{let r=[];return t.v2Examples!=null?(r.push(...Object.values(t.v2Examples.userSpecifiedExamples)),r.push(...Object.values(t.v2Examples.autogeneratedExamples))):r.push(...t.examples?.map(n=>({payload:n.payload.jsonExample}))??[]),{description:t.docs??void 0,id:Xh.WebhookId(t.name.originalName),path:[],method:t.method,name:t.displayName??tia(t.name.originalName),headers:t.headers.map(n=>({description:n.docs??void 0,key:n.name.wireValue,type:a4(n.valueType),availability:lie(n.availability)})),payload:QYI(t.payload),examples:r}})}function IYI(e,t){let r=[];for(let n of e.endpoints){let i=n.autogeneratedExamples[0],a=[];if(n.v2Examples!=null){let c,f=n.v2Examples.userSpecifiedExamples,u=n.v2Examples.autogeneratedExamples,s=Object.values(f).map(m=>m.response?.statusCode).filter((m,O,P)=>P.indexOf(m)!==O).length>0;for(let[m,O]of Object.entries(f))c=aOv({shouldUseExampleName:s,exampleName:O.displayName??m,example:O,irEndpoint:n,irService:e,ir:t}),c!=null&&a.push(c);let l=Object.values(u).map(m=>m.response?.statusCode).filter((m,O,P)=>P.indexOf(m)!==O).length>0;for(let[m,O]of Object.entries(u))c=aOv({shouldUseExampleName:l,exampleName:O.displayName??m,example:O,irEndpoint:n,irService:e,ir:t}),c!=null&&a.push(c)}else if(n.userSpecifiedExamples.length>0)a.push(...n.userSpecifiedExamples.map(c=>$9f({userSpecifiedExample:c,...i!=null&&{autogeneratedExample:i},irEndpoint:n,ir:t})).filter(hj));else if(i!=null){let c=$9f({autogeneratedExample:i,irEndpoint:n,ir:t});c!=null&&a.push(c)}else if(n.response?.body?.type==="fileDownload"){let c=hro({ir:t,service:e,endpoint:{...n,response:void 0},typeDeclarations:t.types,skipOptionalRequestProperties:!0,generationResponse:{type:"success"}});if(c.type==="success"){let f=$9f({autogeneratedExample:c,irEndpoint:n,ir:t});if(f!=null){let u={...f,responseBodyV3:{type:"filename",value:"<bytes>"}};a.push(u)}}}let o={slug:void 0,availability:lie(n.availability??e.availability),auth:n.auth,authV2:BYI(n.security),multiAuth:TYI(n.security),description:n.docs??void 0,method:FYI(n.method),defaultEnvironment:t.environments?.defaultEnvironment!=null?Xh.EnvironmentId(t.environments.defaultEnvironment):void 0,environments:t.environments!=null?qYI({environmentsConfig:t.environments,endpoint:n}):void 0,id:Xh.EndpointId(n.name.originalName),originalEndpointId:n.id,name:n.displayName??tia(n.name.originalName),path:n.basePath!=null?{pathParameters:n.pathParameters.map(c=>({description:c.docs??void 0,key:Xh.PropertyKey(c.name.originalName),type:a4(c.valueType),availability:void 0,explode:void 0})),parts:[...coo(n.basePath),...coo(n.path)]}:{pathParameters:[...t.pathParameters,...e.pathParameters,...n.pathParameters].map(c=>({description:c.docs??void 0,key:Xh.PropertyKey(c.name.originalName),type:a4(c.valueType),availability:void 0,explode:void 0})),parts:[...t.basePath!=null?coo(t.basePath):[],...coo(e.basePath),...coo(n.path)]},queryParameters:n.queryParameters.map(c=>({description:c.docs??void 0,key:c.name.wireValue,type:a4(c.valueType),availability:lie(c.availability),explode:void 0})),headers:[...e.headers,...n.headers].map(c=>({description:c.docs??void 0,key:c.name.wireValue,type:a4(c.valueType),availability:lie(c.availability)})),request:n.requestBody!=null?nOv(n.requestBody):void 0,requestsV2:{requests:n.v2RequestBodies?.requestBodies?.map(nOv).filter(hj)},response:n.response!=null?iOv(n.response):void 0,responsesV2:{responses:n.v2Responses?.responses?.map(iOv).filter(hj)},errors:void 0,errorsV2:xYI(n.errors,t),examples:a,protocol:n.source?._visit({openapi:()=>({type:"rest"}),openrpc:()=>({type:"openrpc",methodName:n.id}),proto:c=>({type:"grpc",methodName:n.id,methodType:c.methodType}),_other:()=>{}}),includeInApiExplorer:void 0};r.push(o)}return r}function MYI(e,t){let r=[];if(e.v2Examples!=null&&(Object.keys(e.v2Examples.userSpecifiedExamples).length>0||Object.keys(e.v2Examples.autogeneratedExamples).length>0)){let n=Object.values(e.v2Examples.userSpecifiedExamples),i=Object.values(e.v2Examples.autogeneratedExamples),a=n.length>0?n[0]:i[0];a!=null&&r.push({name:"",description:"",path:a.baseUrl??"",pathParameters:a.pathParameters??{},queryParameters:a.queryParameters??{},headers:a.headers??{},messages:a.messages?.map(o=>({type:Xh.api.v1.WebSocketMessageId(o.type),body:o.body}))??[]})}else r=e.examples.map(n=>({name:n.name?.originalName,description:n.docs,path:n.url,pathParameters:n.pathParameters.reduce((i,a)=>(i[Xh.PropertyKey(a.name.originalName)]=a.value.jsonExample,i),{}),queryParameters:n.queryParameters.reduce((i,a)=>(i[a.name.wireValue]=a.value.jsonExample,i),{}),headers:n.headers.reduce((i,a)=>(i[a.name.wireValue]=a.value.jsonExample,i),{}),messages:n.messages.map(i=>({type:Xh.api.v1.WebSocketMessageId(i.type),body:i.body.jsonExample}))}));return{auth:e.auth,availability:lie(e.availability),description:e.docs??void 0,defaultEnvironment:t.environments?.defaultEnvironment!=null?Xh.EnvironmentId(t.environments.defaultEnvironment):void 0,environments:t.environments!=null?RYI({environmentsConfig:t.environments,channel:e}):[],id:Xh.WebSocketId(e.name.originalName),name:e.displayName??tia(e.name.originalName),path:{pathParameters:e.pathParameters.map(n=>({description:n.docs??void 0,key:Xh.PropertyKey(n.name.originalName),type:a4(n.valueType),availability:void 0,explode:void 0})),parts:coo(e.path)},headers:e.headers.map(n=>({key:n.name.wireValue,type:a4(n.valueType),description:n.docs,availability:lie(n.availability)})),queryParameters:e.queryParameters.map(n=>({description:n.docs??void 0,key:n.name.wireValue,type:a4(n.valueType),availability:lie(n.availability),explode:void 0})),messages:e.messages.map(n=>({type:Xh.api.v1.WebSocketMessageId(n.type),displayName:n.displayName,origin:n.origin,body:LYI(n.body),description:n.docs,availability:lie(n.availability)})),examples:r}}function BYI(e){if(e==null)return;if(e.length===0)return[];let t=new Set(e.flatMap(r=>Object.keys(r)));return Array.from(t).map(r=>Xh.AuthSchemeId(r))}function TYI(e){if(e!=null)return e.length===0?[]:e.map(t=>({schemes:Object.keys(t).map(r=>Xh.AuthSchemeId(r))}))}function lie(e){if(e!=null)switch(e.status){case"DEPRECATED":return Xh.Availability.Deprecated;case"PRE_RELEASE":return Xh.Availability.Beta;case"GENERAL_AVAILABILITY":return Xh.Availability.GenerallyAvailable;case"IN_DEVELOPMENT":return Xh.Availability.Beta;default:ku(e.status)}}function qYI({environmentsConfig:e,endpoint:t}){let r=e.environments,n=t.baseUrl,i=t.v2BaseUrls;switch(r.type){case"singleBaseUrl":return r.environments.map(a=>({id:Xh.EnvironmentId(a.id),baseUrl:a.url}));case"multipleBaseUrls":if(i!=null)return i.flatMap(o=>r.environments.map(c=>{let f=c.urls[o];if(f==null)throw new Error(`Encountered undefined server name "${o}" at endpoint ${t.method.toUpperCase()} ${t.path}. Expected environment ${c.id} to contain url for ${o}`);return{id:Xh.EnvironmentId(o),baseUrl:f}})).filter((o,c,f)=>c===f.findIndex(u=>u.id===o.id&&u.baseUrl===o.baseUrl));if(n==null)throw new Error(`Expected endpoint ${t.name.originalName} to have base url.`);return r.environments.map(a=>{let o=a.urls[n];if(o==null)throw new Error(`Encountered undefined server name "${n}" at endpoint ${t.method.toUpperCase()} ${t.path.head}. Expected environment ${a.id} to contain url for ${n}`);return{id:Xh.EnvironmentId(a.id),baseUrl:o}});default:ku(r)}}function RYI({environmentsConfig:e,channel:t}){let r=e.environments,n=t.baseUrl;switch(r.type){case"singleBaseUrl":return r.environments.map(i=>({id:Xh.EnvironmentId(i.id),baseUrl:NYI(i.url,"wss")}));case"multipleBaseUrls":if(n==null)throw new Error(`Expected channel ${t.name.originalName} to have base url.`);return r.environments.map(i=>{let a=i.urls[n];if(a==null)throw new Error(`Encountered undefined server name ${a} at channel ${t.name.originalName} ${t.path.head}. Expected environment ${i.id} to contain url for ${n}`);return{id:Xh.EnvironmentId(i.id),baseUrl:a}});default:ku(r)}}function NYI(e,t){return e.replace(/^[^:]+/,t)}function FYI(e){return np.http.HttpMethod._visit(e,{get:()=>Xh.HttpMethod.Get,post:()=>Xh.HttpMethod.Post,put:()=>Xh.HttpMethod.Put,patch:()=>Xh.HttpMethod.Patch,delete:()=>Xh.HttpMethod.Delete,head:()=>Xh.HttpMethod.Head,_other:()=>{throw new Error("Unknown http method: "+e)}})}function coo(e){let t=e.parts.flatMap(r=>[{type:"pathParameter",value:Xh.PropertyKey(r.pathParameter)},{type:"literal",value:r.tail}]);return[{type:"literal",value:e.head},...t]}function nOv(e){let t=np.http.HttpRequestBody._visit(e,{inlinedRequestBody:r=>({type:"json",contentType:r.contentType??T8.APPLICATION_JSON,shape:{type:"object",extends:r.extends.map(n=>Xh.TypeId(n.typeId)),properties:r.properties.map(n=>({description:n.docs??void 0,key:Xh.PropertyKey(n.name.wireValue),valueType:a4(n.valueType),availability:lie(n.availability),propertyAccess:n.propertyAccess})),extraProperties:r.extraProperties?{type:"unknown"}:void 0}}),reference:r=>({type:"json",contentType:r.contentType??T8.APPLICATION_JSON,shape:{type:"reference",value:a4(r.requestBodyType)},description:r.docs??void 0}),fileUpload:r=>({type:"fileUpload",value:{name:r.name.originalName,description:void 0,availability:void 0,properties:r.properties.map(n=>n._visit({file:i=>{let a=i._visit({file:o=>({type:"file",key:Xh.PropertyKey(o.key.wireValue),isOptional:o.isOptional,contentType:o.contentType,description:o.docs??void 0,availability:void 0}),fileArray:o=>({type:"fileArray",key:Xh.PropertyKey(o.key.wireValue),isOptional:o.isOptional,contentType:o.contentType,description:o.docs??void 0,availability:void 0}),_other:()=>{}});if(a!=null)return{type:"file",value:a}},bodyProperty:i=>({type:"bodyProperty",key:Xh.PropertyKey(i.name.wireValue),valueType:a4(i.valueType),contentType:i.contentType,description:i.docs??void 0,availability:lie(i.availability),exploded:i.style==="exploded",propertyAccess:void 0}),_other:()=>{}})).filter(hj)},contentType:r.contentType,description:r.docs??void 0}),bytes:r=>({type:"bytes",description:r.docs??void 0,availability:void 0,isOptional:r.isOptional,contentType:r.contentType}),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}});return t!=null?{type:t,description:e.docs}:void 0}function iOv(e){if(e.body==null)return;let t,r=np.http.HttpResponseBody._visit(e.body,{fileDownload:n=>(t=n.docs,{type:"fileDownload",contentType:void 0}),json:n=>(t=n.docs,{type:"reference",value:a4(n.responseBodyType)}),text:()=>{},bytes:()=>{},streamParameter:()=>{},streaming:n=>{if(n.type==="text")return t=n.docs,{type:"streamingText"};if(n.type==="json")return t=n.docs,{type:"stream",shape:{type:"reference",value:a4(n.payload)},terminator:n.terminator};if(n.type==="sse")return t=n.docs,{type:"stream",shape:{type:"reference",value:a4(n.payload)},terminator:n.terminator}},_other:()=>{throw new Error("Unknown HttpResponse: "+e.body)}});return r!=null?{type:r,statusCode:e.statusCode,description:t}:e.statusCode!=null?{statusCode:e.statusCode,description:t,type:{type:"object",extends:[],properties:[],extraProperties:void 0}}:void 0}function xYI(e,t){let r=[];if(t.errorDiscriminationStrategy.type==="statusCode")for(let n of e){let i=t.errors[n.error.errorId];i&&r.push({type:i.type==null?void 0:{type:"alias",value:a4(i.type)},statusCode:i.statusCode,description:i.docs??void 0,name:i.displayName??i.name.name.originalName,availability:void 0,examples:UYI(i)})}else for(let n of e){let i=t.errors[n.error.errorId];if(i){let a=[{key:Xh.PropertyKey(t.errorDiscriminationStrategy.discriminant.wireValue),valueType:{type:"literal",value:{type:"stringLiteral",value:i.discriminantValue.name.originalName}},description:i.docs,availability:void 0,propertyAccess:void 0}];i.type!=null&&a.push({key:Xh.PropertyKey(t.errorDiscriminationStrategy.contentProperty.wireValue),valueType:a4(i.type),description:i.docs,availability:void 0,propertyAccess:void 0}),r.push({type:i.type==null?void 0:{type:"object",extends:[],properties:a,extraProperties:void 0},statusCode:i.statusCode,description:i.docs??void 0,availability:void 0,name:i.displayName??i.name.name.originalName,examples:i.examples.map(o=>({name:o.name?.originalName,responseBody:{type:"json",value:o.jsonExample},description:o.docs}))})}}return r}function aOv({shouldUseExampleName:e,exampleName:t,example:r,irEndpoint:n,irService:i,ir:a}){if(r==null)return;let o=u=>{if(u.valueType.type==="container"&&u.valueType.container.type==="literal")return u.valueType.container.literal._visit({boolean:s=>`${s}`,string:s=>s,_other:()=>{}});if(u.valueType.type==="container"&&u.valueType.container.type==="optional"&&u.valueType.container.optional.type==="container"&&u.valueType.container.optional.container.type==="literal")return u.valueType.container.optional.container.literal._visit({boolean:s=>`${s}`,string:s=>s,_other:()=>{}})},c={};a.headers.forEach(u=>{let s=o(u);s!=null&&(c[u.name.wireValue]=s)}),i.headers.forEach(u=>{let s=o(u);s!=null&&(c[u.name.wireValue]=s)}),n.headers.forEach(u=>{let s=o(u);s!=null&&(c[u.name.wireValue]=s)});let f=r.response?.body!=null?r.response.body.value:void 0;return{name:e?t:void 0,description:"",path:r.request?.endpoint.path??"",pathParameters:r.request?.pathParameters??{},queryParameters:r.request?.queryParameters??{},headers:(()=>{let s={...r.request?.headers??{}};for(let[l,m]of Object.entries(c))(s[l]===null||s[l]===void 0)&&(s[l]=m);return s})(),requestBody:r.request?.requestBody,requestBodyV3:n.requestBody?._visit({inlinedRequestBody:()=>r.request!=null?{type:"json",value:r.request.requestBody}:void 0,reference:()=>r.request!=null?{type:"json",value:r.request.requestBody}:void 0,fileUpload:u=>{if(r.request==null)return;let s={};if(zD(r.request.requestBody)){let l=r.request.requestBody;for(let m of u.properties)m._visit({file:O=>{let P=l[O.key.wireValue];if(O.type==="file")s[O.key.wireValue]={type:"filename",value:typeof P=="string"?P:"<file1>"};else if(O.type==="fileArray"){let C=(Array.isArray(P)?P:[P]).filter(I=>typeof I=="string");s[O.key.wireValue]={type:"filenames",value:C}}},bodyProperty:O=>{if(O.style==="exploded"){let P=l[O.name.wireValue];s[O.name.wireValue]={type:"exploded",value:Array.isArray(P)?P:[P]}}else s[O.name.wireValue]={type:"json",value:l[O.name.wireValue]}},_other:wdt})}return{type:"form",value:s}},bytes:()=>{},_other:()=>{}}),responseStatusCode:r.response?.statusCode??n.response?.statusCode??200,responseBody:f??void 0,responseBodyV3:f!=null?r.response?.body?._visit({json:u=>({type:"json",value:u}),stream:u=>Array.isArray(u)&&u.length>0&&u.every(zYI)?{type:"sse",value:u}:{type:"stream",value:u},error:()=>{},_other:()=>{throw new Error("Unknown ExampleResponseBody: "+r.response?.body?.type)}}):void 0,codeSamples:r.codeSamples?.map(u=>({name:u.name,description:u.docs??void 0,install:void 0,language:u.language,code:u.code})).filter(hj)}}function zYI(e){return typeof e=="object"&&e!==null&&"event"in e&&typeof e?.event=="string"&&"data"in e}function $9f({userSpecifiedExample:e,autogeneratedExample:t,irEndpoint:r,ir:n}){let i=n.headers.map(c=>{let f;if(c.valueType.type==="container"&&c.valueType.container.type==="literal"?f=c.valueType.container.literal._visit({boolean:u=>`${u}`,string:u=>u,_other:()=>{}}):c.valueType.type==="container"&&c.valueType.container.type==="optional"&&c.valueType.container.optional.type==="container"&&c.valueType.container.optional.container.type==="literal"&&(f=c.valueType.container.optional.container.literal._visit({boolean:u=>`${u}`,string:u=>u,_other:()=>{}})),f!=null)return{name:c.name,value:{jsonExample:f,shape:np.ExampleTypeReferenceShape.primitive(np.ExamplePrimitive.string({original:f}))}}}).filter(hj),a=e?.example??t?.example;if(a==null)return;let{codeSamples:o}=e??{codeSamples:[]};return{name:a.name?.originalName,description:a.docs,path:a.url,pathParameters:[...a.rootPathParameters,...a.servicePathParameters,...a.endpointPathParameters].reduce((c,f)=>(c[Xh.PropertyKey(f.name.originalName)]=f.value.jsonExample,c),{}),queryParameters:a.queryParameters.reduce((c,f)=>(c[f.name.wireValue]=f.value.jsonExample,c),{}),headers:[...i,...a.serviceHeaders,...a.endpointHeaders].reduce((c,f)=>(c[f.name.wireValue]=f.value.jsonExample,c),{}),requestBody:a.request?.jsonExample,requestBodyV3:r.requestBody?._visit({inlinedRequestBody:()=>a.request!=null?{type:"json",value:a.request.jsonExample}:void 0,reference:()=>a.request!=null?{type:"json",value:a.request.jsonExample}:void 0,fileUpload:c=>{if(a.request==null)return;let f={};if(zD(a.request.jsonExample)){let u=a.request.jsonExample;for(let s of c.properties)s._visit({file:l=>{let m=u[l.key.wireValue];if(l.type==="file")f[l.key.wireValue]={type:"filename",value:typeof m=="string"?m:"<file1>"};else if(l.type==="fileArray"){let O=(Array.isArray(m)?m:[m]).filter(P=>typeof P=="string");f[l.key.wireValue]={type:"filenames",value:O}}},bodyProperty:l=>{if(l.style==="exploded"){let m=u[l.name.wireValue];f[l.name.wireValue]={type:"exploded",value:Array.isArray(m)?m:[m]}}else f[l.name.wireValue]={type:"json",value:u[l.name.wireValue]}},_other:wdt})}return{type:"form",value:f}},bytes:()=>{},_other:()=>{}}),responseStatusCode:r.response?.statusCode??np.http.ExampleResponse._visit(a.response,{ok:c=>c._visit({body:f=>f!=null?200:204,stream:f=>f.length>0?200:204,sse:f=>f.length>0?200:204,_other:()=>{throw new Error("Unknown ExampleResponseBody: "+c.type)}}),error:({error:c})=>{let f=n.errors[c.errorId];if(f==null)throw new Error("Cannot find error "+c.errorId);return f.statusCode},_other:()=>{throw new Error("Unknown ExampleResponse: "+a.response.type)}}),responseBody:a.response._visit({ok:c=>c._visit({body:f=>f?.jsonExample,stream:()=>{},sse:()=>{},_other:()=>{}}),error:c=>c.body?.jsonExample,_other:()=>{}}),responseBodyV3:a.response._visit({ok:c=>c._visit({body:f=>f!=null?{type:"json",value:f.jsonExample}:void 0,stream:f=>({type:"stream",value:f.map(u=>u.jsonExample)}),sse:f=>({type:"sse",value:f.map(({event:u,data:s})=>({event:u,data:s.jsonExample}))}),_other:()=>{throw new Error("Unknown ExampleResponseBody: "+c.type)}}),error:c=>c.body!=null?{type:"json",value:c.body.jsonExample}:void 0,_other:()=>{throw new Error("Unknown ExampleResponse: "+a.response.type)}}),codeSamples:o?.map(c=>wrt._visit(c,{language:f=>({language:f.language,code:f.code,name:f.name?.originalName,description:f.docs??void 0,install:f.install}),sdk:f=>({language:f.sdk,code:f.code,name:f.name?.originalName,description:f.docs??void 0,install:void 0}),_other:()=>{}})).filter(hj)}}function QYI(e){switch(e.type){case"inlinedPayload":return{type:{type:"object",extends:e.extends.map(t=>Xh.TypeId(t.typeId)),properties:e.properties.map(t=>({description:t.docs??void 0,key:Xh.PropertyKey(t.name.wireValue),valueType:a4(t.valueType),availability:lie(t.availability),propertyAccess:void 0})),extraProperties:void 0},description:void 0};case"reference":return{type:{type:"reference",value:a4(e.payloadType)},description:e.docs};default:ku(e)}}function LYI(e){switch(e.type){case"inlinedBody":return{type:"object",extends:e.extends.map(t=>Xh.TypeId(t.typeId)),properties:e.properties.map(t=>({description:t.docs??void 0,key:Xh.PropertyKey(t.name.wireValue),valueType:a4(t.valueType),availability:lie(t.availability),propertyAccess:void 0})),extraProperties:void 0};case"reference":return{type:"reference",value:a4(e.bodyType)};default:ku(e)}}function UYI(e){let t=e.v2Examples?.userSpecifiedExamples,r=e.v2Examples?.autogeneratedExamples,n=e.examples;return t!=null&&Object.keys(t).length>0?Object.entries(t).map(([i,a])=>({name:i,responseBody:{type:"json",value:a},description:void 0})):r!=null&&Object.keys(r).length>0?Object.entries(r).map(([i,a])=>({name:i,responseBody:{type:"json",value:a},description:void 0})):n.length>0?n.map(i=>({name:i.name?.originalName,responseBody:{type:"json",value:i.jsonExample},description:i.docs})):[]}function LCe({ir:e,snippetsConfig:t,playgroundConfig:r,context:n}){let i={types:{},subpackages:{},rootPackage:Y9f(e.rootPackage,e),auth:Zmv({auth:e.auth,playgroundConfig:r,context:n}),authSchemes:eOv({auth:e.auth,playgroundConfig:r,context:n}),snippetsConfiguration:t,globalHeaders:e.headers.map(a=>({availability:lie(a.availability),description:a.docs??void 0,key:a.name.wireValue,type:a4(a.valueType)})),navigation:void 0};for(let[a,o]of Object.entries(e.types))i.types[Xh.TypeId(a)]={description:o.docs??void 0,name:o.name.name.originalName,shape:rOv(o.shape),availability:lie(o.availability),displayName:o.name.displayName};for(let[a,o]of Object.entries(e.subpackages)){let c=o.service!=null?e.services[o.service]:void 0;i.subpackages[Xh.api.v1.SubpackageId(a)]={subpackageId:Xh.api.v1.SubpackageId(a),displayName:c?.displayName??o.displayName,name:o.name.originalName,description:o.docs??void 0,...Y9f(o,e)}}return i}async function X9f({organization:e,workspace:t,context:r,token:n,audiences:i,snippetsConfig:a,playgroundConfig:o}){let c=xG({workspace:t,audiences:i,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1},readme:void 0,version:void 0,packageName:void 0,context:r,sourceResolver:new FG(r,t)}),f=Ksa({token:n.value}),u=LCe({ir:c,snippetsConfig:a,playgroundConfig:o,context:r}),s=await f.api.v1.register.registerApiDefinition({orgId:Xh.OrgId(e),apiId:Xh.ApiId(c.apiName.originalName),definition:u});if(s.ok)return r.logger.debug(`Registered API Definition ${s.body.apiDefinitionId}`),{id:s.body.apiDefinitionId,ir:c};switch(s.error.error){case"UnauthorizedError":case"UserNotInOrgError":return r.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return r.failAndThrow("Failed to register API",s.error)}}var VYI=new afu({snippetsBySdkId:{},snippetsConfigWithSdkId:{},snippetTemplatesByEndpoint:{},snippetsBySdkIdAndEndpointId:{},snippetTemplatesByEndpointId:{}});function bns({ir:e,apiDefinitionId:t,playgroundConfig:r,context:n}){return ofu(nfu(LCe({ir:e,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},playgroundConfig:r,context:n}),gve.ApiDefinitionId(t),VYI))}var oOv=$i(require("path"),1);async function eyt({iconPath:e,filepaths:t}){e!=null&&typeof e=="string"&&oOv.default.isAbsolute(e)&&t.add(e)}async function sOv({parsedDocsConfig:e}){let t=new Set;return e.logo?.dark!=null&&t.add(e.logo.dark),e.logo?.light!=null&&t.add(e.logo.light),e.favicon!=null&&t.add(e.favicon),e.backgroundImage?.dark!=null&&t.add(e.backgroundImage.dark),e.backgroundImage?.light!=null&&t.add(e.backgroundImage.light),e.metadata?.["og:image"]!=null&&e.metadata["og:image"].type==="filepath"&&t.add(e.metadata["og:image"].value),e.metadata?.["og:logo"]!=null&&e.metadata["og:logo"].type==="filepath"&&t.add(e.metadata["og:logo"].value),e.metadata?.["twitter:image"]!=null&&e.metadata["twitter:image"].type==="filepath"&&t.add(e.metadata["twitter:image"].value),e.typography?.bodyFont!=null&&e.typography.bodyFont.variants.forEach(n=>{t.add(n.absolutePath)}),e.typography?.headingsFont!=null&&e.typography.headingsFont.variants.forEach(n=>{t.add(n.absolutePath)}),e.typography?.codeFont!=null&&e.typography.codeFont.variants.forEach(n=>{t.add(n.absolutePath)}),e.navigation.type==="productgroup"&&e.navigation.products.forEach(n=>{n.image!=null&&t.add(n.image)}),(await Z9f({navigation:e.navigation})).forEach(n=>{t.add(n)}),e.navbarLinks&&await Promise.all(e.navbarLinks.map(async n=>{n.type==="dropdown"&&n.links.map(async i=>{i.icon&&await eyt({iconPath:i.icon,filepaths:t}),i.rightIcon&&await eyt({iconPath:i.rightIcon,filepaths:t})}),n.type!=="github"&&(n.icon&&await eyt({iconPath:n.icon,filepaths:t}),n.rightIcon&&await eyt({iconPath:n.rightIcon,filepaths:t}))})),e.js!=null&&e.js.files.forEach(n=>{t.add(n.absolutePath)}),t}async function Z9f({navigation:e}){let t=new Set;switch(e.type){case"untabbed":await Promise.all(e.items.map(r=>loo({item:r,filepaths:t})));break;case"tabbed":await Promise.all(e.items.map(async r=>{r.icon!=null&&await eyt({iconPath:r.icon,filepaths:t}),r.child.type==="layout"&&r.child.layout!=null?await Promise.all(r.child.layout.map(n=>loo({item:n,filepaths:t}))):r.child.type==="variants"&&r.child.variants!=null&&await Promise.all(r.child.variants.flatMap(n=>{let i=[];return n.icon!=null&&i.push(eyt({iconPath:n.icon,filepaths:t})),i.push(...n.layout.map(a=>loo({item:a,filepaths:t}))),i}))}));break;case"versioned":await Promise.all(e.versions.map(async r=>{r.landingPage!=null&&await loo({item:r.landingPage,filepaths:t}),(await Z9f({navigation:r.navigation})).forEach(i=>t.add(i))}));break;case"productgroup":await Promise.all(e.products.map(async r=>{r.icon!=null&&await eyt({iconPath:r.icon,filepaths:t}),r.type==="internal"&&(r.landingPage!=null&&await loo({item:r.landingPage,filepaths:t}),(await Z9f({navigation:r.navigation})).forEach(i=>t.add(i)))}));break}return t}async function loo({item:e,filepaths:t}){switch(e.type){case"page":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break;case"section":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t}),await Promise.all(e.contents.map(r=>loo({item:r,filepaths:t})));break;case"apiSection":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break;case"link":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break;case"changelog":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break}}async function uOv({navigation:e,apiWorkspaces:t,visitor:r,context:n}){GYI(e)?await Promise.all(e.map(async i=>{HYI(i)?await Promise.all(i.layout.map(async a=>{await G9u({navigationItem:a,visitor:r,apiWorkspaces:t,context:n})})):JYI(i)&&await Promise.all(i.variants.flatMap(a=>a.layout.map(async o=>{await G9u({navigationItem:o,visitor:r,apiWorkspaces:t,context:n})})))})):await Promise.all(e.map(async i=>{await G9u({navigationItem:i,visitor:r,apiWorkspaces:t,context:n})}))}async function G9u({navigationItem:e,visitor:t,apiWorkspaces:r,context:n}){if(await P2r(e,{alphabetized:Tc,api:Tc,apiName:Tc,audiences:Tc,displayErrors:Tc,snippets:Tc,summary:Tc,title:Tc,layout:Tc,collapsed:Tc,icon:Tc,slug:Tc,hidden:Tc,skipSlug:Tc,paginated:Tc,playground:Tc,flattened:Tc,path:Tc,page:Tc,featureFlag:Tc,openrpc:Tc,postman:Tc,contents:async i=>{i!=null&&await Promise.all(i.map(async a=>{await G9u({navigationItem:a,visitor:t,apiWorkspaces:r,context:n})}))},viewers:Tc,orphaned:Tc,availability:Tc}),WYI(e)){let i=r.find(a=>a.workspaceName===e.apiName);i!=null&&await t.apiSection?.({config:e,workspace:i,context:n})}}function WYI(e){return e.api!=null}function GYI(e){return e[0]?.tab!=null}function HYI(e){return"layout"in e&&Array.isArray(e.layout)}function JYI(e){return"variants"in e&&Array.isArray(e.variants)}function Qse(e){return e.startsWith("https://")||e.startsWith("http://")?e:`https://${e}`}lOv.default.extend(fOv.default);var KYI=e=>e.map(t=>({...t,fileId:String(t.relativeFilePath)})),cOv=0,$YI=async({ir:e})=>(cOv++,`${e.apiName.snakeCase.unsafeName}-${cOv}`),Hqr=class{domain;docsWorkspace;ossWorkspaces;apiWorkspaces;taskContext;editThisPage;uploadFiles;registerApi;targetAudiences;constructor({domain:t,docsWorkspace:r,ossWorkspaces:n,apiWorkspaces:i,taskContext:a,editThisPage:o,uploadFiles:c=KYI,registerApi:f=$YI,targetAudiences:u}){this.domain=t,this.docsWorkspace=r,this.ossWorkspaces=n,this.apiWorkspaces=i,this.taskContext=a,this.editThisPage=o,this.uploadFiles=c,this.registerApi=f,this.targetAudiences=u}#e=W9u.init();shouldIncludeByAudience(t){return!t||t.length===0||!this.targetAudiences||this.targetAudiences.length===0?!0:t.some(r=>this.targetAudiences?.includes(r))}applyAudienceFiltering(t){let r=this.filterNavigationByAudience(t.navigation);return{...t,navigation:r}}filterNavigationByAudience(t){return t.type==="untabbed"||t.type==="tabbed"?t:t.type==="versioned"?{...t,versions:t.versions.filter(r=>this.shouldIncludeByAudience(this.getRawVersionAudiences(r.version)))}:t.type==="productgroup"?{...t,products:t.products.filter(r=>{let n=this.getRawProductAudiences(r.product);return this.shouldIncludeByAudience(n)})}:t}getRawProductAudiences(t){let n=this.docsWorkspace.config.products?.find(i=>i.displayName===t);return sHo(n?.audiences)}getRawVersionAudiences(t){let n=this.docsWorkspace.config.versions?.find(i=>i.displayName===t);return sHo(n?.audiences)}_parsedDocsConfig;get parsedDocsConfig(){if(this._parsedDocsConfig==null)throw new Error("parsedDocsConfig is not set");return this._parsedDocsConfig}collectedFileIds=new Map;markdownFilesToFullSlugs=new Map;markdownFilesToNoIndex=new Map;markdownFilesToTags=new Map;rawMarkdownFiles={};async resolve(){this._parsedDocsConfig=await muf({rawDocsConfiguration:this.docsWorkspace.config,context:this.taskContext,absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absoluteFilepathToDocsConfig:this.docsWorkspace.absoluteFilepathToDocsConfig}),this.targetAudiences&&this.targetAudiences.length>0&&(this._parsedDocsConfig=this.applyAudienceFiltering(this._parsedDocsConfig));for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.rawMarkdownFiles[ru.of(l)]=m;let t=this.parsedDocsConfig.experimental?.openapiParserV3,r=t!=null&&!t;this.docsWorkspace.config.navigation!=null&&r&&await uOv({navigation:this.docsWorkspace.config.navigation,visitor:{apiSection:async({workspace:l})=>{(await l.toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,preserveSchemaIds:!0,objectQueryParameters:!0,respectReadonlySchemas:!0})).changelog?.files.forEach(O=>{let P=A3(this.docsWorkspace.absoluteFilePath,O.absoluteFilepath);this.parsedDocsConfig.pages[P]=O.contents,this.rawMarkdownFiles[ru.of(P)]=O.contents})}},apiWorkspaces:this.apiWorkspaces,context:this.taskContext}),this.markdownFilesToFullSlugs=await this.getMarkdownFilesToFullSlugs(this.parsedDocsConfig.pages),this.markdownFilesToNoIndex=await this.getMarkdownFilesToNoIndex(this.parsedDocsConfig.pages),this.markdownFilesToTags=await this.getMarkdownFilesToTags(this.parsedDocsConfig.pages);for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.parsedDocsConfig.pages[ru.of(l)]=await E9f({markdown:m,absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absolutePathToMarkdownFile:this.resolveFilepath(l),context:this.taskContext});for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.parsedDocsConfig.pages[ru.of(l)]=await j9f({markdown:m,absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absolutePathToMarkdownFile:this.resolveFilepath(l),context:this.taskContext});let n=await sOv({parsedDocsConfig:this.parsedDocsConfig});for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))try{let{filepaths:O,markdown:P}=gda(m,{absolutePathToMarkdownFile:this.resolveFilepath(l),absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath});this.parsedDocsConfig.pages[ru.of(l)]=P;for(let C of O)n.add(C)}catch(O){throw this.taskContext.logger.error(`Failed to parse ${l}: ${O instanceof Error?O.message:String(O)}`),O}let i=Array.from(n).map(l=>({absoluteFilePath:l,relativeFilePath:this.toRelativeFilepath(l)}));(await this.uploadFiles(i)).forEach(l=>{this.collectedFileIds.set(l.absoluteFilePath,l.fileId)});let o=await this.toRootNode(),c=await this.getMarkdownFilesToFullyQualifiedPathNames(o);for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.parsedDocsConfig.pages[ru.of(l)]=w9f(m,this.collectedFileIds,c,{absolutePathToMarkdownFile:this.resolveFilepath(l),absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath},this.taskContext);let f={};Object.entries(this.parsedDocsConfig.pages).forEach(([l,m])=>{let O=YYI(this.editThisPage,l),P=this.rawMarkdownFiles[ru.of(l)];f[UDe.PageId(l)]={markdown:m,editThisPageUrl:O?UDe.Url(O):void 0,rawMarkdown:P}});let u=await this.convertDocsConfiguration(o),s={};if(this._parsedDocsConfig.experimental?.mdxComponents!=null){let l=new Set;await Promise.all(this._parsedDocsConfig.experimental.mdxComponents.map(async m=>{let O=p1(this.docsWorkspace.absoluteFilePath,m);(await(0,J9u.stat)(O)).isDirectory()?(await sve(O,"{js,ts,jsx,tsx,md,mdx}")).forEach(I=>{l.add(I)}):O.match(/\.(js|ts|jsx|tsx|md|mdx)$/)!=null&&l.add(O)})),s=Object.fromEntries(await Promise.all([...l].map(async m=>{let O=this.toRelativeFilepath(m),P=(await(0,J9u.readFile)(m)).toString();return[O,P]})))}return{config:u,pages:f,jsFiles:s}}resolveFilepath(t){if(t!=null)return p1(this.docsWorkspace.absoluteFilePath,t)}toRelativeFilepath(t){if(t!=null)return A3(this.docsWorkspace.absoluteFilePath,t)}async getMarkdownFilesToFullSlugs(t){let r=new Map;for(let[n,i]of Object.entries(t)){let o=(0,H9u.default)(i).data.slug;typeof o=="string"&&o.trim().length>0&&r.set(this.resolveFilepath(n),o.trim())}return r}async getMarkdownFilesToNoIndex(t){let r=new Map;for(let[n,i]of Object.entries(t)){let o=(0,H9u.default)(i).data.noindex;typeof o=="boolean"&&r.set(this.resolveFilepath(n),o)}return r}async getMarkdownFilesToTags(t){let r=new Map;for(let[n,i]of Object.entries(t)){let o=(0,H9u.default)(i).data.tags;typeof o=="string"?r.set(this.resolveFilepath(n),o.split(",").map(c=>c.trim()).filter(c=>c.length>0)):Array.isArray(o)&&r.set(this.resolveFilepath(n),o)}return r}async getMarkdownFilesToFullyQualifiedPathNames(t){let r={},n=fl.migrate.FernNavigationV1ToLatest.create().root(t);return fl.NodeCollector.collect(n).slugMap.forEach((a,o)=>{if(a==null||!fl.isPage(a))return;let c=fl.getPageId(a);if(c==null)return;let f=Ql(this.docsWorkspace.absoluteFilePath,ru.of(c));r[f]=o}),r}getDocsBasePath(){return new URL(Qse(this.domain)).pathname}async convertDocsConfiguration(t){return{aiChatConfig:this.parsedDocsConfig.aiChatConfig!=null?{model:this.parsedDocsConfig.aiChatConfig.model,systemPrompt:this.parsedDocsConfig.aiChatConfig.systemPrompt,location:this.parsedDocsConfig.aiChatConfig.location,datasources:this.parsedDocsConfig.aiChatConfig.datasources?.map(n=>({url:n.url,title:n.title}))}:void 0,hideNavLinks:void 0,title:this.parsedDocsConfig.title,logoHeight:this.parsedDocsConfig.logo?.height,logoHref:this.parsedDocsConfig.logo?.href?UDe.Url(this.parsedDocsConfig.logo?.href):void 0,favicon:this.getFileId(this.parsedDocsConfig.favicon),navigation:void 0,root:t,colorsV3:this.convertColorConfigImageReferences(),navbarLinks:this.parsedDocsConfig.navbarLinks?.map(n=>n.type==="dropdown"?{...n,links:n.links?.map(i=>({...i,url:UDe.Url(i.url),icon:this.resolveIconFileId(i.icon),rightIcon:this.resolveIconFileId(i.rightIcon)})),icon:this.resolveIconFileId(n.icon),rightIcon:this.resolveIconFileId(n.rightIcon)}:n.type==="github"?{...n,url:UDe.Url(n.url)}:{...n,url:UDe.Url(n.url),icon:this.resolveIconFileId(n.icon),rightIcon:this.resolveIconFileId(n.rightIcon)}),typographyV2:this.convertDocsTypographyConfiguration(),layout:this.parsedDocsConfig.layout,settings:this.parsedDocsConfig.settings,css:this.parsedDocsConfig.css,js:this.convertJavascriptConfiguration(),metadata:this.convertMetadata(),redirects:this.parsedDocsConfig.redirects,integrations:this.parsedDocsConfig.integrations,footerLinks:this.parsedDocsConfig.footerLinks?.map(n=>({...n,value:UDe.Url(n.value)})),defaultLanguage:this.parsedDocsConfig.defaultLanguage,languages:this.parsedDocsConfig.languages,analyticsConfig:{...this.parsedDocsConfig.analyticsConfig,segment:this.parsedDocsConfig.analyticsConfig?.segment,fullstory:this.parsedDocsConfig.analyticsConfig?.fullstory,intercom:this.parsedDocsConfig.analyticsConfig?.intercom?{appId:this.parsedDocsConfig.analyticsConfig.intercom.appId,apiBase:this.parsedDocsConfig.analyticsConfig.intercom.apiBase}:void 0,posthog:this.parsedDocsConfig.analyticsConfig?.posthog?{apiKey:this.parsedDocsConfig.analyticsConfig.posthog.apiKey,endpoint:this.parsedDocsConfig.analyticsConfig.posthog.endpoint}:void 0,gtm:this.parsedDocsConfig.analyticsConfig?.gtm?{containerId:this.parsedDocsConfig.analyticsConfig.gtm.containerId}:void 0,ga4:this.parsedDocsConfig.analyticsConfig?.ga4?{measurementId:this.parsedDocsConfig.analyticsConfig.ga4.measurementId}:void 0,amplitude:void 0,mixpanel:void 0,hotjar:void 0,koala:void 0,logrocket:void 0,pirsch:void 0,plausible:void 0,fathom:void 0,clearbit:void 0,heap:void 0},announcement:this.parsedDocsConfig.announcement!=null?{text:this.parsedDocsConfig.announcement.message}:void 0,pageActions:this.parsedDocsConfig.pageActions,theme:this.parsedDocsConfig.theme!=null?{sidebar:this.parsedDocsConfig.theme.sidebar,body:this.parsedDocsConfig.theme.body,tabs:this.parsedDocsConfig.theme.tabs,"page-actions":this.parsedDocsConfig.theme.pageActions}:void 0,logo:void 0,logoV2:void 0,colors:void 0,colorsV2:void 0,typography:void 0,backgroundImage:void 0}}getFernWorkspaceForApiSection(t){if(t.apiName!=null){let n=this.apiWorkspaces.find(i=>i.workspaceName===t.apiName);if(n!=null)return n}else if(this.apiWorkspaces.length===1&&this.apiWorkspaces[0]!=null)return this.apiWorkspaces[0];let r=t.apiName?`Failed to load API Definition '${t.apiName}' referenced in docs`:"Failed to load API Definition referenced in docs";throw new Error(r)}getOpenApiWorkspaceForApiSection(t){if(t.apiName!=null){let n=this.ossWorkspaces.find(i=>i.workspaceName===t.apiName);if(n!=null)return n}else if(this.ossWorkspaces.length===1&&this.ossWorkspaces[0]!=null)return this.ossWorkspaces[0];let r=t.apiName?`Failed to load API Definition '${t.apiName}' referenced in docs`:"Failed to load API Definition referenced in docs";throw new Error(r)}async toRootNode(){let t=fl.V1.SlugGenerator.init(fl.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),n=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:n,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(i=>fl.RoleId(i)),featureFlags:void 0}}async toRootChild(t){return pia(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let n=fl.PageId(this.toRelativeFilepath(t.absolutePath)),i=r.apply({urlSlug:t.slug??s$(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(n),title:t.title,slug:i.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:n,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:n}){let i=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,n):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(i,r.items,n):await this.toSidebarRootNode(i,r.items,n);return{type:"unversioned",id:i,landingPage:a,child:o}}async toVersionedNode(t,r){return{id:this.#e.get("versioned"),type:"versioned",children:await Promise.all(t.versions.map((i,a)=>this.toVersionNode(i,r,a===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:n}){let i=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,n):void 0;return{id:i,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,n)))}}async toProductNode(t,r){if(t.type==="internal"){let n=r.setProductSlug(t.slug??s$(t.product)),i;switch(t.navigation.type){case"tabbed":i={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,n)};break;case"untabbed":i={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,n)};break;case"versioned":i=await this.toVersionedNode(t.navigation,n);break;default:ku(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:fl.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:n.get(),child:i,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}else return{type:"productLink",id:this.#e.get(t.product),productId:fl.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:UDe.Url(t.href??""),default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,n){let i=this.#e.get(t.version),a=r.setVersionSlug(t.slug??s$(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(i,t.navigation.items,a):await this.toSidebarRootNode(i,t.navigation.items,a);return{type:"version",id:i,versionId:fl.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:n,availability:t.availability!=null?XYI(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:void 0,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags}}async toSidebarRootNode(t,r,n){let i=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:i,item:c,parentSlug:n}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let f=o.length>0?o[o.length-1]:void 0,u;f?.type==="sidebarGroup"?u=f:(u={id:this.#e.get(`${i}/group`),type:"sidebarGroup",children:[]},o.push(u)),u.children.push(c)}),{type:"sidebarRoot",id:i,children:o}}async toSidebarRootNodeWithVariants(t,r,n){let i=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:i,children:[{type:"varianted",id:i,children:await Promise.all(r.map(a=>this.toVariantNode(a,i,n)))}]}}async toVariantNode(t,r,n){let i=this.#e.get(`${r}/variant/${t.slug??s$(t.title)}`),a=n.apply({urlSlug:t.slug??s$(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,i,a)));return{type:"variant",id:i,variantId:fl.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,n){return pia(t)._visit({page:async i=>this.toPageNode({item:i,parentSlug:n}),apiSection:async i=>this.toApiSectionNode({item:i,parentSlug:n}),section:async i=>this.toSectionNode({prefix:r,item:i,parentSlug:n}),link:async i=>this.toLinkNode(i),changelog:async i=>this.toChangelogNode(i,n)})}async toNavigationChild({prefix:t,item:r,parentSlug:n,hideChildren:i,parentAvailability:a}){return pia(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:n,hideChildren:i,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:n,hideChildren:i,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:n,hideChildren:i,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,n,i)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:n,parentAvailability:i}){let a=Xmv(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),f=this.parsedDocsConfig.experimental?.openapiParserV3;if(f==null||f)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1})}catch{}o==null&&(o=xG({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new FG(this.taskContext,c)}));let s=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),l=bns({ir:o,apiDefinitionId:s,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext});return new V9u(t,l,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,n,i??t.availability).get()}async toChangelogNode(t,r,n){return new Eda(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:n||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:fl.V1.Url(t.url),icon:this.resolveIconFileId(t.icon)}}async toPageNode({item:t,parentSlug:r,hideChildren:n,parentAvailability:i}){let a=fl.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??s$(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{id:this.#e.get(a),type:"page",slug:o.get(),title:t.title,icon:this.resolveIconFileId(t.icon),hidden:n||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:a,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:t.availability??i}}async toSectionNode({prefix:t,item:r,parentSlug:n,hideChildren:i,parentAvailability:a}){let o=this.toRelativeFilepath(r.overviewAbsolutePath),c=o?fl.PageId(o):void 0,f=this.#e.get(c??`${t}/section`),u=n.apply({urlSlug:r.slug??s$(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),s=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,l=i||r.hidden;return{id:f,type:"section",overviewPageId:c,slug:u.get(),title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,hidden:l,viewers:r.viewers,orphaned:r.orphaned,children:await Promise.all(r.contents.map(m=>this.toNavigationChild({prefix:f,item:m,parentSlug:u,hideChildren:l,parentAvailability:r.availability??a}))),authed:void 0,pointsTo:void 0,noindex:s,featureFlags:r.featureFlags,availability:r.availability??a}}async convertTabbedNavigation(t,r,n){let i=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:i,children:await Promise.all(r.map(a=>this.toTabChild(i,a,n)))}}async toTabChild(t,r,n){return pia(r.child)._visit({link:({href:i})=>this.toTabLinkNode(r,i),layout:({layout:i})=>this.toTabNode(t,r,i,n),changelog:({changelog:i})=>this.toTabChangelogNode(r,i,n),variants:({variants:i})=>this.toTabNodeWithVariants(t,r,i,n)})}async toTabChangelogNode(t,r,n){return new Eda(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:n,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r){return{type:"link",id:this.#e.get(r),title:t.title,url:fl.V1.Url(r),icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,n,i){let a=this.#e.get(`${t}/tab`),o=i.apply({urlSlug:r.slug??s$(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNode(a,n,o),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,n,i){let a=this.#e.get(`${t}/tab`),o=i.apply({urlSlug:r.slug??s$(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNodeWithVariants(a,n,o),featureFlags:r.featureFlags}}getFileId(t){if(t==null)return;let r=this.collectedFileIds.get(t);return r==null?this.taskContext.failAndThrow("Failed to locate file after uploading: "+t):UDe.FileId(r)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}convertColorConfigImageReferences(){let{colors:t}=this.parsedDocsConfig;if(t!=null)return t.type==="dark"?{...t,...this.convertLogoAndBackgroundImage({theme:"dark"})}:t.type==="light"?{...t,...this.convertLogoAndBackgroundImage({theme:"light"}),type:"light"}:{...t,dark:{...t.dark,...this.convertLogoAndBackgroundImage({theme:"dark"})},light:{...t.light,...this.convertLogoAndBackgroundImage({theme:"light"})}}}convertLogoAndBackgroundImage({theme:t}){let{logo:r,backgroundImage:n}=this.parsedDocsConfig,i=r?.[t],a=n?.[t];return{logo:this.getFileId(i),backgroundImage:this.getFileId(a)}}convertDocsTypographyConfiguration(){if(this.parsedDocsConfig.typography!=null)return{headingsFont:this.convertFont(this.parsedDocsConfig.typography.headingsFont,"headings"),bodyFont:this.convertFont(this.parsedDocsConfig.typography.bodyFont,"body"),codeFont:this.convertFont(this.parsedDocsConfig.typography.codeFont,"code")}}convertFont(t,r){if(t==null||t.variants[0]==null)return;let n=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${n}`,variants:t.variants.map(i=>({fontFile:this.getFileId(i.absolutePath),weight:i.weight,style:i.style!=null?[i.style]:void 0})),display:t.display,fallback:t.fallback,fontVariationSettings:t.fontVariationSettings}}convertJavascriptConfiguration(){if(this.parsedDocsConfig.js!=null)return{files:this.parsedDocsConfig.js.files.map(({absolutePath:t,strategy:r})=>({fileId:this.getFileId(t),strategy:r})).filter(hj),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:UDe.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":n,...i}=this.parsedDocsConfig.metadata;return{...i,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(n)}}convertFileIdOrUrl(t){if(t!=null)return pia(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:UDe.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function YYI(e,t){if(e?.github==null)return;let{owner:r,repo:n,branch:i="main",host:a="https://github.com"}=e.github;return`${Qse(a)}/${r}/${n}/blob/${i}/fern/${t}?plain=1`}function XYI(e){switch(e){case"beta":return fl.V1.NavigationV1Availability.Beta;case"deprecated":return fl.V1.NavigationV1Availability.Deprecated;case"ga":return fl.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return fl.V1.NavigationV1Availability.Stable;default:ku(e)}}async function dbe(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof E$?t:null))).filter(hj)}async function k9f(e,t,r){if(e instanceof XVr){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof E$))return;let n=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1});return LCe({ir:n,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},playgroundConfig:{oauth:!0},context:t})}var Yj={};yf(Yj,{AlgoliaSearchIndex:()=>dOv,ApiDefinitionId:()=>TOv,ApiId:()=>FOv,Availability:()=>ZOv,DocsConfigId:()=>xOv,EndpointId:()=>QOv,EndpointPathLiteral:()=>YOv,EnvironmentId:()=>zOv,FileId:()=>GOv,HttpMethod:()=>XOv,IndexSegmentId:()=>pOv,JqString:()=>JOv,OrgId:()=>ROv,PageId:()=>WOv,PayloadLocation:()=>jAv,PropertyKey:()=>KOv,PullRequestState:()=>mAv,RoleId:()=>$Ov,TokenId:()=>NOv,TypeId:()=>VOv,Url:()=>HOv,VersionId:()=>qOv,WebSocketId:()=>LOv,WebhookId:()=>UOv,algolia:()=>eUf,api:()=>lUf,commons:()=>fUf,diff:()=>kOv,docs:()=>mUf,generators:()=>AUf,git:()=>PUf,navigation:()=>EUf,sdks:()=>DUf,snippets:()=>PAv,snippetsFactory:()=>wAv,templates:()=>CUf,tokens:()=>EAv});var eUf={};yf(eUf,{AlgoliaSearchIndex:()=>dOv,IndexSegmentId:()=>pOv});function dOv(e){return e}function pOv(e){return e}var lUf={};yf(lUf,{latest:()=>nUf,v1:()=>cUf});var nUf={};yf(nUf,{AuthSchemeId:()=>_Ov,WebhookHttpMethod:()=>bOv,auth:()=>tUf,commons:()=>hOv,endpoint:()=>yOv,type_:()=>vOv,webhook:()=>rUf,websocket:()=>gOv});var tUf={};yf(tUf,{AuthSchemeId:()=>_Ov});function _Ov(e){return e}var hOv={};var yOv={};var vOv={};var rUf={};yf(rUf,{WebhookHttpMethod:()=>bOv});var bOv={Get:"GET",Post:"POST"};var gOv={};var cUf={};yf(cUf,{SubpackageId:()=>COv,WebSocketMessageId:()=>IOv,WebSocketMessageOrigin:()=>MOv,WebhookHttpMethod:()=>BOv,commons:()=>uUf,db:()=>iUf,read:()=>oUf,register:()=>sUf});var iUf={};yf(iUf,{endpoint:()=>mOv});var mOv={};var oUf={};yf(oUf,{SupportedLanguage:()=>OOv,endpoint:()=>aUf,type_:()=>AOv,webhook:()=>POv,websocket:()=>wOv});var aUf={};yf(aUf,{SupportedLanguage:()=>OOv});var OOv={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var AOv={};var POv={};var wOv={};var sUf={};yf(sUf,{SourceId:()=>ZYI,endpoint:()=>jOv,type_:()=>EOv,webhook:()=>SOv,websocket:()=>DOv});var jOv={};var EOv={};var SOv={};var DOv={};function ZYI(e){return e}var uUf={};yf(uUf,{SubpackageId:()=>COv,WebSocketMessageId:()=>IOv,WebSocketMessageOrigin:()=>MOv,WebhookHttpMethod:()=>BOv});function COv(e){return e}function IOv(e){return e}var MOv={Client:"client",Server:"server"};var BOv={Get:"GET",Post:"POST"};var fUf={};yf(fUf,{ApiDefinitionId:()=>TOv,ApiId:()=>FOv,Availability:()=>ZOv,DocsConfigId:()=>xOv,EndpointId:()=>QOv,EndpointPathLiteral:()=>YOv,EnvironmentId:()=>zOv,FileId:()=>GOv,HttpMethod:()=>XOv,JqString:()=>JOv,OrgId:()=>ROv,PageId:()=>WOv,PropertyKey:()=>KOv,RoleId:()=>$Ov,TokenId:()=>NOv,TypeId:()=>VOv,Url:()=>HOv,VersionId:()=>qOv,WebSocketId:()=>LOv,WebhookId:()=>UOv});function TOv(e){return e}function qOv(e){return e}function ROv(e){return e}function NOv(e){return e}function FOv(e){return e}function xOv(e){return e}function zOv(e){return e}function QOv(e){return e}function LOv(e){return e}function UOv(e){return e}function VOv(e){return e}function WOv(e){return e}function GOv(e){return e}function HOv(e){return e}function JOv(e){return e}function KOv(e){return e}function $Ov(e){return e}function YOv(e){return e}var XOv={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var ZOv={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var kOv={};var mUf={};yf(mUf,{latest:()=>_Uf,v1:()=>bUf,v2:()=>gUf});var _Uf={};yf(_Uf,{Layout:()=>tAv,MdxEngine:()=>kYI,TwitterCardSetting:()=>rAv,commons:()=>eAv,frontmatter:()=>dUf,seo:()=>pUf});var kYI={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var eAv={};var dUf={};yf(dUf,{Layout:()=>tAv});var tAv={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var pUf={};yf(pUf,{TwitterCardSetting:()=>rAv});var rAv={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var bUf={};yf(bUf,{commons:()=>vUf,db:()=>nAv,read:()=>iAv,write:()=>hUf});var nAv={};var iAv={};var hUf={};yf(hUf,{DocsRegistrationId:()=>tXI,FilePath:()=>eXI});function eXI(e){return e}function tXI(e){return e}var vUf={};yf(vUf,{ContentAlignment:()=>uAv,FontDisplay:()=>pAv,FontStyle:()=>dAv,HeaderPosition:()=>cAv,JsScriptStrategy:()=>fAv,ProgrammingLanguage:()=>aAv,SearchbarPlacement:()=>oAv,TabsPlacement:()=>sAv,TwitterCardSetting:()=>lAv,commons:()=>yUf});var yUf={};yf(yUf,{ContentAlignment:()=>uAv,FontDisplay:()=>pAv,FontStyle:()=>dAv,HeaderPosition:()=>cAv,JsScriptStrategy:()=>fAv,ProgrammingLanguage:()=>aAv,SearchbarPlacement:()=>oAv,TabsPlacement:()=>sAv,TwitterCardSetting:()=>lAv});var aAv={Typescript:"typescript",Javascript:"javascript",Python:"python",Java:"java",Go:"go",Ruby:"ruby",Csharp:"csharp",Nodets:"nodets",Nodejs:"nodejs",Dotnet:"dotnet",Curl:"curl",Jvm:"jvm",Ts:"ts",Js:"js"};var oAv={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var sAv={Header:"HEADER",Sidebar:"SIDEBAR"};var uAv={Center:"CENTER",Left:"LEFT"};var cAv={Fixed:"FIXED",Absolute:"ABSOLUTE"};var lAv={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var fAv={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var dAv={Normal:"normal",Italic:"italic"};var pAv={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var gUf={};yf(gUf,{read:()=>_Av,write:()=>hAv});var _Av={};var hAv={};var AUf={};yf(AUf,{ChangelogEntryType:()=>vAv,GeneratorId:()=>rXI,GeneratorLanguage:()=>nXI,ReleaseType:()=>bAv,cli:()=>yAv,commons:()=>OUf,versions:()=>gAv});var yAv={};var OUf={};yf(OUf,{ChangelogEntryType:()=>vAv,ReleaseType:()=>bAv});var vAv={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var bAv={Ga:"GA",Rc:"RC"};var gAv={};function rXI(e){return e}var nXI={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var PUf={};yf(PUf,{PullRequestState:()=>mAv});var mAv={Open:"open",Closed:"closed",Merged:"merged"};var EUf={};yf(EUf,{latest:()=>wUf,v1:()=>jUf});var wUf={};yf(wUf,{NodeId:()=>oXI,ProductId:()=>sXI,Slug:()=>iXI,TabId:()=>aXI});function iXI(e){return e}function aXI(e){return e}function oXI(e){return e}function sXI(e){return e}var jUf={};yf(jUf,{NavigationV1Availability:()=>dXI,NodeId:()=>lXI,ProductId:()=>fXI,Slug:()=>uXI,TabId:()=>cXI});function uXI(e){return e}function cXI(e){return e}function lXI(e){return e}function fXI(e){return e}var dXI={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var DUf={};yf(DUf,{Language:()=>OAv,VersionBump:()=>AAv,versions:()=>SUf});var SUf={};yf(SUf,{Language:()=>OAv,VersionBump:()=>AAv});var OAv={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var AAv={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var PAv={};var wAv={};var CUf={};yf(CUf,{PayloadLocation:()=>jAv});var jAv={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var EAv={};var K9u=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function OA(e){return e!=null}var DAv=$i(QLo(),1);var SAv=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function _Wr(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,DAv.default)(e,{special:SAv}).replace(/V\s(\d)/g,"V$1")}function CAv({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(n=>{let i=[];n.namespace?.forEach(a=>{let o=[...i,a],c=Yj.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:_Wr(a)},i.push(a)})}),r}var $9u=class{input;context;constructor(t,r){this.input=t,this.context=r}errors(){return this.context.errors.errors}warnings(){return this.context.errors.warnings}};function IAv(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var UO=class extends $9u{context;accessPath;pathId;constructor({input:t,context:r,accessPath:n,pathId:i}){if(super(t,r),this.context=r,this.accessPath=[...n],this.pathId=i,i!=null){let a=Array.isArray(this.pathId)?this.pathId:[this.pathId];a.every((o,c)=>o===this.accessPath[this.accessPath.length-a.length+c])||this.accessPath.push(...a)}r.logger.debug(`Processing ${IAv(this.accessPath)}`)}safeParse(...t){try{this.parse(...t)}catch{this.context.errors.error({message:"Error converting node. Please contact support if the error persists",path:this.accessPath})}}},Bee=class extends UO{},Kxe=class extends Bee{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var MAv="x-fern-base-path",BAv="x-fern-availability",Y9u="x-fern-sdk-group-name",TAv="x-fern-global-headers",qAv="x-fern-sdk-method-name";var RAv="x-fern-webhook",NAv="x-fern-access-token-locator",FAv="x-fern-basic",xAv="x-fern-username-variable-name",zAv="x-fern-password-variable-name",QAv="x-fern-bearer",LAv="x-fern-token-variable-name",UAv="x-fern-header",VAv="x-fern-header-variable-name",WAv="x-fern-server-name",GAv="x-fern-examples";var X9u=class extends UO{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[WAv]}convert(){if(this.serverName!=null)return this.serverName}};var Z9u=class extends UO{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,n])=>t.replace(`{${r}}`,n.default),this.input.url)??this.input.url,this.serverName=new X9u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.serverName?.convert()??this.url;if(!(this.url==null||t==null))return{id:Yj.EnvironmentId(t),baseUrl:this.url}}};function L8i(e,t,r,n){let i=e??[],a=new Set(i.map(c=>c.url)),o=(t??[]).filter(c=>!a.has(c.url)).map((c,f)=>new Z9u({input:c,context:r,accessPath:n,pathId:["servers",`${f}`]}));return[...i,...o]}function xx(e){return typeof e=="object"&&OA(e)&&"$ref"in e&&typeof e.$ref=="string"}function pbe(e,t,r){let n=e.$ref.substring(2).split("/").map(a=>a.replace(/~1/g,"/")),i=t;for(let a of n){if(typeof i!="object"||i==null)return r;i=i[a]}return i==null?r:(xx(i)&&(i=pbe(i,t,r)),i)}function k9u(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return xx(r)?pbe(r,t,void 0):r}var FPv=$i(AJ());var eUu=class extends UO{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[FAv];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var tUu=class extends UO{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[zAv]}convert(){return this.passwordVariableName}};var rUu=class extends UO{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[xAv]}convert(){return this.usernameVariableName}};var nUu=class extends UO{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[QAv];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var iUu=class extends UO{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[LAv]}convert(){return this.tokenVariableName}};function HAv(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var JAv="x-bearer-format",KAv="x-code-samples",$Av="x-codeSamples";var aUu=class extends UO{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[JAv]}convert(){return this.bearerFormat}};var oUu=class extends UO{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[UAv];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var sUu=class extends UO{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[VAv]}convert(){return this.headerVariableName}};function YAv(e){return e.type==="apiKey"}var foo=class extends UO{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){YAv(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new oUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new sUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new aUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.headerAuthNode?.convert();if(t!=null)return{type:"header",nameOverride:t?.name,headerWireValue:this.headerName??"Authorization",prefix:t?.prefix??this.headerBearerFormatNode?.convert()}}};function uUu(e){return e}function cUu(e){return e==="__proto__"}function lUu(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function fUu(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function dUu(e){let t=[],r=e.length;if(r===0)return t;let n=0,i="",a="",o=!1;for(e.charCodeAt(0)===46&&(t.push(""),n++);n<r;){let c=e[n];a?c==="\\"&&n+1<r?(n++,i+=e[n]):c===a?a="":i+=c:o?c==='"'||c==="'"?a=c:c==="]"?(o=!1,t.push(i),i=""):i+=c:c==="["?(o=!0,i&&(t.push(i),i="")):c==="."?i&&(t.push(i),i=""):i+=c,n++}return i&&t.push(i),t}function gns(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(cUu(t))return r;let n=e[t];return n===void 0?lUu(t)?gns(e,dUu(t),r):r:n}case"number":case"symbol":{typeof t=="number"&&(t=fUu(t));let n=e[t];return n===void 0?r:n}default:{if(Array.isArray(t))return pXI(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),cUu(t))return r;let n=e[t];return n===void 0?r:n}}}function pXI(e,t,r){if(t.length===0)return r;let n=e;for(let i=0;i<t.length;i++){if(n==null||cUu(t[i]))return r;n=n[t[i]]}return n===void 0?r:n}function XAv(e){return function(t){return gns(t,e)}}function ZAv(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function pUu(e){return e==null||typeof e!="object"&&typeof e!="function"}function IUf(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function kAv(e,t,r){return typeof r!="function"?doo(e,t):MUf(e,t,function n(i,a,o,c,f,u){let s=r(i,a,o,c,f,u);return s!==void 0?!!s:MUf(i,a,n,u)},new Map)}function MUf(e,t,r,n){if(t===e)return!0;switch(typeof t){case"object":return _XI(e,t,r,n);case"function":return Object.keys(t).length>0?MUf(e,{...t},r,n):IUf(e,t);default:return ZAv(e)?typeof t=="string"?t==="":!0:IUf(e,t)}}function _XI(e,t,r,n){if(t==null)return!0;if(Array.isArray(t))return ePv(e,t,r,n);if(t instanceof Map)return hXI(e,t,r,n);if(t instanceof Set)return yXI(e,t,r,n);let i=Object.keys(t);if(e==null)return i.length===0;if(i.length===0)return!0;if(n&&n.has(t))return n.get(t)===e;n&&n.set(t,e);try{for(let a=0;a<i.length;a++){let o=i[a];if(!pUu(e)&&!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!r(e[o],t[o],o,e,t,n))return!1}return!0}finally{n&&n.delete(t)}}function hXI(e,t,r,n){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[i,a]of t.entries()){let o=e.get(i);if(r(o,a,i,e,t,n)===!1)return!1}return!0}function ePv(e,t,r,n){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let i=new Set;for(let a=0;a<t.length;a++){let o=t[a],c=!1;for(let f=0;f<e.length;f++){if(i.has(f))continue;let u=e[f],s=!1;if(r(u,o,a,e,t,n)&&(s=!0),s){i.add(f),c=!0;break}}if(!c)return!1}return!0}function yXI(e,t,r,n){return t.size===0?!0:e instanceof Set?ePv([...e],[...t],r,n):!1}function doo(e,t){return kAv(e,t,()=>{})}function tPv(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function _Uu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var rPv="[object RegExp]",hUu="[object String]",yUu="[object Number]",vUu="[object Boolean]",bUu="[object Arguments]",nPv="[object Symbol]",iPv="[object Date]",aPv="[object Map]",oPv="[object Set]",sPv="[object Array]";var uPv="[object ArrayBuffer]",cPv="[object Object]";var lPv="[object DataView]",fPv="[object Uint8Array]",dPv="[object Uint8ClampedArray]",pPv="[object Uint16Array]",_Pv="[object Uint32Array]";var hPv="[object Int8Array]",yPv="[object Int16Array]",vPv="[object Int32Array]";var bPv="[object Float32Array]",gPv="[object Float64Array]";function mPv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function OPv(e,t){return V8i(e,void 0,e,new Map,t)}function V8i(e,t,r,n=new Map,i=void 0){let a=i?.(e,t,r,n);if(a!==void 0)return a;if(pUu(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){let o=new Array(e.length);n.set(e,o);for(let c=0;c<e.length;c++)o[c]=V8i(e[c],c,r,n,i);return Object.hasOwn(e,"index")&&(o.index=e.index),Object.hasOwn(e,"input")&&(o.input=e.input),o}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let o=new RegExp(e.source,e.flags);return o.lastIndex=e.lastIndex,o}if(e instanceof Map){let o=new Map;n.set(e,o);for(let[c,f]of e)o.set(c,V8i(f,c,r,n,i));return o}if(e instanceof Set){let o=new Set;n.set(e,o);for(let c of e)o.add(V8i(c,void 0,r,n,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(mPv(e)){let o=new(Object.getPrototypeOf(e)).constructor(e.length);n.set(e,o);for(let c=0;c<e.length;c++)o[c]=V8i(e[c],c,r,n,i);return o}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let o=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return n.set(e,o),U8i(o,e,r,n,i),o}if(typeof File<"u"&&e instanceof File){let o=new File([e],e.name,{type:e.type});return n.set(e,o),U8i(o,e,r,n,i),o}if(e instanceof Blob){let o=new Blob([e],{type:e.type});return n.set(e,o),U8i(o,e,r,n,i),o}if(e instanceof Error){let o=new e.constructor;return n.set(e,o),o.message=e.message,o.name=e.name,o.stack=e.stack,o.cause=e.cause,U8i(o,e,r,n,i),o}if(typeof e=="object"&&vXI(e)){let o=Object.create(Object.getPrototypeOf(e));return n.set(e,o),U8i(o,e,r,n,i),o}return e}function U8i(e,t,r=e,n,i){let a=[...Object.keys(t),...tPv(t)];for(let o=0;o<a.length;o++){let c=a[o],f=Object.getOwnPropertyDescriptor(e,c);(f==null||f.writable)&&(e[c]=V8i(t[c],c,r,n,i))}}function vXI(e){switch(_Uu(e)){case bUu:case sPv:case uPv:case lPv:case vUu:case iPv:case bPv:case gPv:case hPv:case yPv:case vPv:case aPv:case yUu:case cPv:case rPv:case oPv:case hUu:case nPv:case fPv:case dPv:case pPv:case _Pv:return!0;default:return!1}}function APv(e){return V8i(e,void 0,e,new Map,void 0)}function PPv(e){return e=APv(e),t=>doo(t,e)}function wPv(e,t){return OPv(e,(r,n,i,a)=>{let o=t?.(r,n,i,a);if(o!==void 0)return o;if(typeof e=="object")switch(Object.prototype.toString.call(e)){case yUu:case hUu:case vUu:{let c=new e.constructor(e?.valueOf());return U8i(c,e),c}case bUu:{let c={};return U8i(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function jPv(e){return wPv(e)}var bXI=/^(?:0|[1-9]\d*)$/;function EPv(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return bXI.test(e)}}function SPv(e){return e!==null&&typeof e=="object"&&_Uu(e)==="[object Arguments]"}function DPv(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&lUu(t)&&e?.[t]==null?r=dUu(t):r=[t],r.length===0)return!1;let n=e;for(let i=0;i<r.length;i++){let a=r[i];if((n==null||!Object.hasOwn(n,a))&&!((Array.isArray(n)||SPv(n))&&EPv(a)&&a<n.length))return!1;n=n[a]}return!0}function CPv(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=fUu(e);break}}return t=jPv(t),function(r){let n=gns(r,e);return n===void 0?DPv(r,e):t===void 0?n===void 0:doo(n,t)}}function IPv(e){if(e==null)return uUu;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?CPv(e[0],e[1]):PPv(e);case"string":case"symbol":case"number":return XAv(e)}}function BUf(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(BUf).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function MPv(e,t){let r={},n=Object.keys(e);for(let i=0;i<n.length;i++){let a=n[i],o=e[a];r[a]=t(o,a,e)}return r}function gUu(e,t=uUu){return e==null?{}:MPv(e,IPv(t))}function BPv(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var gXI=/\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;function TPv(e){return Array.from(e.match(gXI)??[])}function qPv(e){let t=TPv(e);if(t.length===0)return"";let[r,...n]=t;return`${r.toLowerCase()}${n.map(i=>BPv(i)).join("")}`}function RPv(e){return typeof e!="string"&&(e=BUf(e)),e.replace(/['\u2019]/g,"")}function Jqr(e){return qPv(RPv(e))}function TQ(e){if(e!=null)return Array.isArray(e)?e:[e]}function mUu({namespace:e,path:t,method:r,sdkMethodName:n,operationId:i,displayName:a,isWebhook:o}){if(t==null)return;let c=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(n==null&&i==null&&a==null&&c==null))return`${mXI(o)}${OXI(e)}.${AXI(n,i,a,c)}`}function mXI(e){return e?"webhook_":"endpoint_"}function OXI(e){return e!=null?TQ(e)?.map(t=>Jqr(t)).join("/"):""}function AXI(e,t,r,n){return e||t||Jqr(r??"")||Jqr(n??"")}function NPv(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var OUu=class extends UO{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[NAv],this.accessTokenLocator!=null&&(NPv(this.accessTokenLocator)||(this.context.errors.error({message:"Invalid access token locator, must be a valid jq path",path:this.accessPath}),this.accessTokenLocator=void 0))}convert(){return this.accessTokenLocator}};var AUu=class extends UO{authorizationUrl;headerAuthNode;accessTokenLocatorNode;constructor(t){super(t),this.safeParse()}parse(){if(this.input.flows.clientCredentials!=null){let t=this.input.flows.clientCredentials;this.authorizationUrl=t.tokenUrl,this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.headerAuthNode=new foo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new OUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.accessTokenLocatorNode?.accessTokenLocator==null&&this.context.errors.error({message:"Expected 'x-fern-access-token-locator' property to be specified",path:this.accessPath})}}convert(){let t=this.accessTokenLocatorNode?.convert();if(t==null||this.authorizationUrl==null)return{type:"bearerAuth",tokenName:void 0};let r=mUu({namespace:void 0,path:this.authorizationUrl,method:"POST",sdkMethodName:void 0,operationId:void 0,displayName:void 0,isWebhook:void 0});if(r!=null)return{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:Yj.EndpointId(r),accessTokenLocator:Yj.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var poo=class extends UO{authScheme;headerAuthNode;bearerTokenNode;bearerTokenVariableNameNode;basicAuthNode;basicUsernameVariableNameNode;basicPasswordVariableNameNode;oauth2Node;constructor(t){super(t),this.safeParse()}parse(){switch(this.input.type){case"http":switch(this.input.scheme){case"basic":{this.authScheme="basic",this.basicAuthNode=new eUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new rUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new tUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),(this.basicAuthNode==null||this.basicAuthNode.username==null&&this.basicUsernameVariableNameNode?.usernameVariableName==null||this.basicAuthNode.password==null&&this.basicPasswordVariableNameNode?.passwordVariableName==null)&&this.context.errors.warning({message:"Basic auth should specify either a username or a username variable name",path:this.accessPath});break}case"bearer":{this.authScheme="bearer",this.bearerTokenNode=new nUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new iUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}default:{this.context.errors.warning({message:`Unsupported HTTP auth scheme: ${this.input.scheme}`,path:this.accessPath});break}}break;case"apiKey":{HAv(this.input)?(this.authScheme="header",this.headerAuthNode=new foo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})):this.context.errors.error({message:`Unsupported API key location: ${this.input.in}`,path:this.accessPath});break}case"oauth2":{this.authScheme="oauth",this.oauth2Node=new AUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}case"openIdConnect":{this.authScheme="bearer";break}}}convert(){switch(this.authScheme){case"basic":{let t=this.basicAuthNode?.convert();return{type:"basicAuth",usernameName:t?.username?.name??this.basicUsernameVariableNameNode?.convert(),passwordName:t?.password?.name??this.basicPasswordVariableNameNode?.convert()}}case"bearer":return{type:"bearerAuth",tokenName:this.bearerTokenNode?.convert()?.tokenVariableName??this.bearerTokenVariableNameNode?.convert()};case"header":return this.headerAuthNode?.convert();case"oauth":return this.oauth2Node?.convert();case void 0:return;default:new FPv.UnreachableCaseError(this.authScheme);return}}};var _oo=class extends UO{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(n=>{let i=k9u(n,this.context.document);if(i==null){this.context.errors.warning({message:`No auth scheme found for ${n}. Inline security schemes are not supported.`,path:this.accessPath});return}let a=new poo({input:i,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});a.convert()!=null?(this.authNodesMap??={},this.authNodesMap[n]=a):this.context.errors.warning({message:`No auth scheme found for ${n}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[t,n]}).filter(OA))}};var PUu=class extends UO{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[MAv],this.basePath!=null?(this.basePath.startsWith("/")&&(this.basePath=this.basePath.slice(1)),this.basePath.endsWith("/")&&(this.basePath=this.basePath.slice(0,-1))):this.basePath=void 0}convert(){return this.basePath}};function xPv(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function zPv(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function hoo(e,t){return e==null?void 0:Object.entries(e).map(([n,i])=>TQ(i.convert())?.map(o=>((t!=null&&!t.includes(n)||t==null&&!xPv(i))&&(o=zPv(o,o.type==="enum"?o.default:void 0)),{key:Yj.PropertyKey(n),valueShape:o,description:i.description,availability:i.availability?.convert()})).filter(OA)).filter(OA).reduce((n,i)=>n.flatMap(a=>i.length>0?i.map(o=>[...a,o]):[[...a]]),[[]])}function wUu(e,t){return xx(e)?pbe(e,t,void 0):e}function W8i(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function QPv(e,t){let r={...e};for(let[n,i]of Object.entries(t??{}))r[n]=[...r[n]??[],...i];return Object.keys(r).length>0?r:void 0}function LPv(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let n of e)for(let i of t)r.push({path:n.path??i.path,responseStatusCode:n.responseStatusCode??i.responseStatusCode,name:n.name??i.name,description:n.description??i.description,pathParameters:n.pathParameters??i.pathParameters,queryParameters:n.queryParameters??i.queryParameters,headers:n.headers??i.headers,requestBody:n.requestBody??i.requestBody,responseBody:n.responseBody??i.responseBody,snippets:{...i.snippets,...n.snippets}});return r}var UPv=$i(AJ());var TUf=["decimal","decimal128","double-int","double","float","sf-decimal"],qUf=["int16","int32","int64","int8","sf-integer","uint8"],RUf=["base64url","binary","byte","char","commonmark","date-time","date","decimal","decimal128","duration","email","hostname","html","http-date","idn-email","idn-hostname","int64","ipv4","ipv6","iri-reference","iri","json-pointer","media-range","password","regex","relative-json-pointer","sf-binary","sf-boolean","sf-string","sf-token","time","uri-reference","uri-template","uri","uuid"],NUf=["beta","pre-release","in-development","generally-available","deprecated"];function Tee(e,t){return xx(e)?pbe(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var tyt=class extends UO{availability;constructor(t){super(t),this.safeParse()}parse(){if(Tee(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[BAv];r!=null&&(NUf.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${NUf.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return Yj.Availability.Beta;case"in-development":return Yj.Availability.InDevelopment;case"generally-available":return Yj.Availability.GenerallyAvailable;case"deprecated":return Yj.Availability.Deprecated;case void 0:return;default:new UPv.UnreachableCaseError(this.availability);return}}};var EUu=$i(AJ());function VPv(e){return typeof e=="object"&&e!=null&&"language"in e}function WPv(e){return typeof e=="object"&&e!=null&&"sdk"in e}function GPv(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function HPv(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function jUu(e){return typeof e=="object"&&e!=null&&"event"in e}function FUf(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(jUu)}function G8i(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function JPv(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var SUu=class extends UO{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,n,i,a){super(t),this.path=r,this.successResponseStatusCode=n,this.requestBodyByContentType=i,this.responseBodies=a,this.safeParse()}parse(){this.examples=this.input[GAv]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([i,a])=>{let o=typeof r=="object"?r[i]:void 0;switch(a.multipartType){case"file":return G8i(o)?[i,{type:"filenameWithData",filename:o.filename,data:Yj.FileId(o.data)}]:o!=null?[i,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>G8i(c)))return[i,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:Yj.FileId(c.data)}))}];if(o.every(c=>typeof c=="string"))return[i,{type:"filenames",value:o}]}return}case"property":return[i,{type:"json",value:o}];case void 0:return;default:new EUu.UnreachableCaseError(a.multipartType);return}}).filter(OA))};case"json":return{type:"json",value:r};case"bytes":return typeof r=="string"?{type:"bytes",value:{type:"base64",value:r}}:void 0;default:return}}convert(){if(this.examples==null)return;this.requestBodyByContentType!=null&&Object.keys(this.requestBodyByContentType).length>1&&this.context.logger.warn(`Multiple request bodies found for #/${[this.accessPath,this.pathId,"x-fern-examples"].join("/")}. Coercing to first request body until supported.`);let t=Object.keys(this.requestBodyByContentType??{})[0];return this.examples.flatMap(r=>(this.responseBodies??[]).map(n=>{let i=t!=null?this.requestBodyByContentType?.[t]:void 0,a;if(i!=null)switch(i.contentType){case"form-data":a=JPv(r.request)?this.convertFormDataExampleRequest(i,r.request):void 0;break;case"json":a=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":a=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new EUu.UnreachableCaseError(i.contentType);break}let o;switch(n.contentType){case"application/json":{GPv(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{FUf(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!FUf(r.response)&&HPv(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new EUu.UnreachableCaseError(n.contentType);break}let c={};r["code-samples"]?.forEach(l=>{VPv(l)?l.language!=null&&(c[l.language]??=[],c[l.language]?.push({name:l.name,language:l.language,install:l.install,code:l.code,generated:!1,description:l.docs})):WPv(l)&&l.sdk!=null&&(c[l.sdk]??=[],c[l.sdk]?.push({name:l.name,language:l.sdk,install:void 0,code:l.code,generated:!1,description:l.docs}))});let f=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([l,m])=>[Yj.PropertyKey(l),m])),u=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,m])=>[Yj.PropertyKey(l),m])),s=Object.fromEntries(Object.entries(r.headers??{}).map(([l,m])=>[Yj.PropertyKey(l),m]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(u).length>0?u:void 0,headers:Object.keys(s).length>0?s:void 0,requestBody:a,responseBody:o,snippets:c}}))}};var mns=class extends UO{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[Y9u]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>Yj.api.v1.SubpackageId(Jqr(r)))}};var DUu=class extends UO{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[qAv]}convert(){return this.sdkMethodName}};var CUu=class extends UO{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[RAv]}convert(){return this.isWebhook}};var IUu=class extends UO{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[KAv]??[],...this.input[$Av]??[]],this.codeSamples.forEach(t=>{[...Object.values(Yj.api.v1.read.SupportedLanguage),"Kotlin","Swift","PHP"].map(r=>r.toLowerCase()).includes(t.lang.toLowerCase())||this.context.errors.warning({message:`Unsupported language: ${t.lang}. This may not render correctly.`,path:this.accessPath})})}convert(){let t={};if(this.codeSamples?.forEach(r=>{t[r.lang.toLowerCase()]??=[],t[r.lang.toLowerCase()]?.push({name:r.label,language:r.lang,code:r.source,install:void 0,generated:!1,description:void 0})}),Object.keys(t).length!==0)return t}};var Sda=$i(AJ());function xUf(e,t){return xx(e)?pbe(e,t,void 0):e}function KPv(e,t){return e.replace(/{(\w+)}/g,(r,n)=>t[n]!=null&&typeof t[n]=="string"||typeof t[n]=="number"||typeof t[n]=="boolean"?`${t[n]}`:r)}var Ade="",hWr=class extends UO{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,n,i,a){super(t),this.path=r,this.responseStatusCode=n,this.name=i,this.shapes=a,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,n])=>{let i=this.resolvedRequestInput?.value[r];switch(n.multipartType){case"file":return t&&(G8i(i)||typeof i=="string");case"files":return t&&Array.isArray(i)&&i.every(a=>G8i(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new Sda.UnreachableCaseError(n.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=xUf(this.input?.requestExample,this.context.document)??(t!=null?{value:t}:void 0);let r=this.shapes.responseBody?.schema?.example({includeOptionals:!1,override:void 0});if(this.resolvedResponseInput=xUf(this.input?.responseExample,this.context.document)??(r!=null?{value:r}:void 0),this.summary=this.input?.requestExample?.summary??this.input?.responseExample?.summary,this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody?.contentType){case"json":{if(typeof this.resolvedRequestInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break}case"bytes":{if(typeof this.resolvedRequestInput.value!="string"){this.context.errors.error({message:"Invalid example, expected string for bytes",path:this.accessPath});return}break}case"form-data":{if(!this.validateFormDataRequestExample()){this.context.errors.error({message:"Invalid example, expected valid form-data",path:this.accessPath});return}break}case void 0:break;default:new Sda.UnreachableCaseError(this.shapes.requestBody?.contentType),this.context.errors.error({message:"Invalid example, unsupported content type",path:this.accessPath});return}if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody?.contentType){case"application/json":if(this.resolvedResponseInput!=null&&typeof this.resolvedResponseInput!="object"||this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break;case"text/event-stream":if(this.resolvedResponseInput.value!=null&&!Array.isArray(this.resolvedResponseInput.value)&&!this.resolvedResponseInput.value.every(jUu)){this.context.errors.error({message:"Invalid example, expected array of SSE events for event-stream",path:this.accessPath});return}break;case"application/octet-stream":if(this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="string"&&!Array.isArray(this.resolvedResponseInput.value)){this.context.errors.error({message:"Invalid example, expected string or array for octet-stream",path:this.accessPath});return}break;case void 0:break;default:new Sda.UnreachableCaseError(this.shapes.responseBody?.contentType);return}}convertFormDataExampleRequest(){if(!(this.resolvedRequestInput==null||this.shapes.requestBody?.fields==null))switch(this.shapes.requestBody?.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(this.shapes.requestBody.fields).map(([r,n])=>{let i=this.resolvedRequestInput?.value?.[r];switch(n.multipartType){case"file":return G8i(i)?[r,{type:"filenameWithData",filename:i.filename,data:Yj.FileId(i.data)}]:[r,{type:"filename",value:i}];case"files":{if(Array.isArray(i)){if(i.every(a=>G8i(a)))return[r,{type:"filenamesWithData",value:i.map(a=>({filename:a.filename,data:Yj.FileId(a.data)}))}];if(i.every(a=>typeof a=="string"))return[r,{type:"filenames",value:i}]}return}case"property":return[r,{type:"json",value:i}];case void 0:return;default:new Sda.UnreachableCaseError(n.multipartType);return}}).filter(OA))};case"json":return{type:"json",value:this.resolvedRequestInput.value};case"bytes":return typeof this.resolvedRequestInput.value=="string"?{type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}}:void 0;default:return}}convertDescription(){if(this.resolvedRequestInput!=null&&this.resolvedResponseInput!=null)return this.resolvedResponseInput.description;if(this.resolvedRequestInput!=null)return this.resolvedRequestInput.description;if(this.resolvedResponseInput!=null)return this.resolvedResponseInput.description}convert(){let t;if(this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody.contentType){case"form-data":t=this.convertFormDataExampleRequest();break;case"json":t={type:"json",value:this.resolvedRequestInput.value};break;case"bytes":t={type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}};break;case void 0:break;default:new Sda.UnreachableCaseError(this.shapes.requestBody?.contentType);break}let r;if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody.contentType){case"application/json":{r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break}case"text/event-stream":r={type:"sse",value:this.resolvedResponseInput?.value};break;case"application/octet-stream":r={type:typeof this.resolvedResponseInput?.value=="string"?"filename":"stream",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;case void 0:r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;default:new Sda.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let n=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([o,c])=>[o,c.example({includeOptionals:!1,override:o})]));n=Object.keys(n).length>0?n:void 0;let i=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(OA));i=Object.keys(i).length>0?i:void 0;let a=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(OA));if(a=Object.keys(a).length>0?a:void 0,!(this.path==null&&t==null&&r==null&&a==null&&i==null&&n==null))return{path:KPv(this.path,n??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?_Wr(this.name):this.summary!=null?_Wr(this.summary):void 0,description:this.convertDescription(),pathParameters:n,queryParameters:i,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function $Pv(e,t){return xx(e)?pbe(e,t,void 0):e}var uwv=$i(AJ());var YPv="#/components/schemas/";function yoo(e){if(e.$ref.startsWith(YPv))return e.$ref.replace(YPv,"")}function Nwi(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function H8i(e){return typeof e.type=="string"&&e.type==="array"}function XPv(e){return e.type==="boolean"}function ZPv(e){return e.type==="integer"}function J8i(e){return!Array.isArray(e.type)&&!H8i(e)}function kPv(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||J8i(t)||H8i(t))}function ewv(e){return"nullable"in e&&typeof e.nullable=="boolean"}function twv(e){return e.type==="null"}function rwv(e){return e.type==="number"}function zUf(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function nwv(e){return e.type==="string"}var MUu=class extends Kxe{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new yU({input:this.input.items,context:this.context,accessPath:this.accessPath,pathId:"items",seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}),this.input.items==null&&this.context.errors.error({message:"Expected 'items' property to be specified",path:this.accessPath})}convert(){return TQ(this.item?.convert())?.map(r=>({type:"alias",value:{type:"list",itemShape:r}}))}example(t){return this.input.example??this.input.examples?.[0]??[this.item?.example(t)]}};var BUu=class extends Bee{constValue;description;availability;constructor(t){super(t),this.safeParse()}parse(){this.input.const!=null&&(typeof this.input.const=="string"||typeof this.input.const=="number"||typeof this.input.const=="boolean")?this.constValue=this.input.const.toString():this.context.errors.warning({message:`Unsupported const type: ${typeof this.input}`,path:this.accessPath}),this.description=this.input.description,this.availability=new tyt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"})}convert(){if(this.constValue!=null)return{type:"enum",default:this.constValue,values:[{value:this.constValue,description:this.description,availability:this.availability?.convert()}]}}example(){return this.input.example??this.input.examples?.[0]??this.constValue}};var TUu=class extends Kxe{typeNodes;nullable;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.parse()}parse(){this.typeNodes=this.input.map(t=>{if(t.type==="null")this.nullable=!0;else return new yU({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(OA)}convert(){if(this.typeNodes==null)return;let n=this.typeNodes.map(i=>TQ(i.convert())?.map(o=>({displayName:i.name,shape:o,description:i.description,availability:i.availability?.convert()}))).filter(OA).reduce((i,a)=>i.flatMap(o=>a.length>0?a.map(c=>[...o,c]):[[...o]]),[[]]).map(i=>({type:"undiscriminatedUnion",variants:i}));return this.nullable?n.map(Nwi).filter(OA):n}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function qUu(e){return e!=null&&e.length>0?e:[void 0]}var voo=class extends Kxe{description;extends=[];properties;extraProperties;requiredProperties;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.extends=[],this.requiredProperties=this.input.required,this.properties=Object.fromEntries(Object.entries(this.input.properties??{}).map(([t,r])=>[t,new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:["properties",t],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})])),this.extraProperties=this.input.additionalProperties!=null?typeof this.input.additionalProperties=="boolean"?this.input.additionalProperties?this.input.title:void 0:new yU({input:this.input.additionalProperties,context:this.context,accessPath:this.accessPath,pathId:["additionalProperties"],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0,this.input.allOf!=null&&(this.extends=this.extends.concat(this.input.allOf.map((t,r)=>{if(xx(t))return yoo(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([n,i])=>[n,new yU({input:i,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",n],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(OA))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return hoo(this.properties,this.requiredProperties)}convertExtraProperties(){return this.extraProperties==null?void 0:typeof this.extraProperties=="string"?[{type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:{type:"alias",value:{type:"unknown",displayName:this.extraProperties}}}]:TQ(this.extraProperties.convert())?.map(r=>({type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:r})).filter(OA)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(n=>qUu(r).map(i=>(this.extends==null||this.extends.length===0)&&n.length===0&&i!=null?{type:"alias",value:i}:{type:"object",extends:this.extends.map(a=>Yj.TypeId(a)),properties:n,extraProperties:i}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(n=>{let i=Tee(n,this.context.document);i!=null&&(r={...r,...Object.fromEntries(Object.entries(i.properties??{}).map(([a,o])=>[a,new yU({input:o,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))})}),this.input.example??this.input.examples?.[0]??(!t&&this.requiredProperties!=null&&this.requiredProperties.length>0?this.requiredProperties?.reduce((n,i)=>{let a=r?.[i];return n[i]=a?.example({includeOptionals:t,override:i}),n},{}):Object.entries(r).reduce((n,[i,a])=>(n[i]=a?.example({includeOptionals:t,override:i}),n),{}))}};var RUu=class extends Kxe{isNullable;discriminated;discriminant;discriminatedMapping;undiscriminatedMapping;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.input.oneOf!=null||this.input.anyOf!=null)if(this.isNullable=(this.input.oneOf??this.input.anyOf)?.some(t=>Tee(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>Tee(t,this.context.document)?.type!=="null"?new yU({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(OA);else{let t=this.input.discriminator.mapping;if(t!=null){this.discriminated=!0,this.discriminant=this.input.discriminator.propertyName,this.discriminatedMapping={};let r=this.discriminatedMapping;Object.entries(t).map(([n,i])=>{let a=Tee({$ref:i},this.context.document);if(a==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${i}`,path:[...this.accessPath,"discriminator","mapping",n]});return}r[n]=new yU({input:a,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",n],pathId:n,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let i=this.undiscriminatedMapping?.flatMap(a=>a.convert()).filter(OA);return this.isNullable&&i!=null?i.map(Nwi).filter(OA):i}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:Yj.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([i,a])=>TQ(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:i,displayName:a.name??_Wr(i),availability:a.availability?.convert(),description:a.description,...c}}).filter(OA)).filter(OA)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(i=>TQ(i.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?_Wr(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:i.name??(o.type==="alias"&&o.value.type==="id"?_Wr(o.value.id):c),shape:o,description:i.description,availability:i.availability?.convert()}}).filter(OA)).filter(OA)}:void 0,n=this.isNullable?Nwi(r):r;return n!=null?[n]:void 0}example(t){return this.input.example??this.input.examples?.[0]??this.undiscriminatedMapping?.[0]?.example(t)??Object.values(this.discriminatedMapping??{})[0]?.example(t)}};var NUu=class extends Bee{default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.input.default!=null&&typeof this.input.default!="boolean"&&this.context.errors.warning({message:`Expected default value to be a boolean. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default}convert(){return{type:"alias",value:{type:"primitive",value:{type:"boolean",default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:!1)}};var K8i=class extends Bee{default;values=[];nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){if(this.input.enum!=null){let t=!0;this.values=this.input.enum.map((r,n)=>{if(t){if(xx(r)){let i=Tee(r,this.context.document);r=typeof i=="string"?i:typeof i?.default=="string"?i?.default:typeof i?.example=="string"?i.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${n}]`]}),t=!1;return}return r}}).filter(OA),this.values=Array.from(new Set(this.values))}this.default=this.input.default}convert(){return{type:"enum",values:this.values.map(t=>({value:t,description:void 0,availability:void 0})),default:this.default}}example(){return this.input.example??this.input.examples?.[0]??this.default??this.values[0]??(this.nullable?null:void 0)}};var iwv=$i(AJ());function PXI(e){return qUf.includes(e)}var FUu=class extends Bee{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be an integer. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(PXI(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${qUf.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="integer";if(this.format!=null)switch(this.format){case"int64":t="long";break;case"int8":case"int16":case"int32":case"uint8":case"sf-integer":case void 0:t="integer";break;default:new iwv.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var xUu=class extends Bee{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return Nwi({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var awv=$i(AJ());function wXI(e){return TUf.includes(e)}var zUu=class extends Bee{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be a number. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(wXI(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${TUf.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="double";if(this.format!=null)switch(this.format){case"decimal":case"decimal128":case"double-int":case"double":case"float":case"sf-decimal":case void 0:t="double";break;default:new awv.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var owv=$i(AJ());function jXI(e){return RUf.includes(e)}var QUu=class extends Bee{format;regex;default;minLength;maxLength;enum;mimeType;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}mapToFdrType(t){switch(t){case"base64url":case"binary":case"byte":case"sf-binary":return"base64";case"date-time":return"datetime";case"int64":return"bigInteger";case"date":return"date";case"uuid":return"uuid";case"char":case"commonmark":case"decimal":case"decimal128":case"duration":case"email":case"hostname":case"html":case"http-date":case"idn-email":case"idn-hostname":case"ipv4":case"ipv6":case"iri-reference":case"iri":case"json-pointer":case"media-range":case"password":case"regex":case"relative-json-pointer":case"sf-boolean":case"sf-string":case"sf-token":case"time":case"uri-reference":case"uri-template":case"uri":case void 0:return"string";default:return new owv.UnreachableCaseError(t),"string"}}parse(){this.regex=this.input.pattern,this.minLength=this.input.minLength,this.maxLength=this.input.maxLength,this.mimeType=this.input.contentMediaType,this.input.default!=null&&typeof this.input.default!="string"&&this.context.errors.warning({message:`Expected default value to be a string. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(jXI(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${RUf.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new K8i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"enum",nullable:this.nullable}))}convert(){if(this.enum!=null)return this.enum.convert();let t="string";return this.format!=null&&(t=this.mapToFdrType(this.format)),{type:"alias",value:{type:"primitive",value:t==="base64"?{type:t,mimeType:this.mimeType,default:this.default}:{type:t,format:t==="string"?this.format:void 0,regex:this.regex,minLength:this.minLength,maxLength:this.maxLength,default:this.default}}}}example({override:t}){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:t??"string")}};var swv=$i(AJ());var LUu=class extends Bee{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,swv.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var Dda=class extends Kxe{description;availability;schemaId;maybeEnumConverterNode;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.description=t.description,this.availability=t.availability,this.safeParse()}parse(){this.schemaId=yoo(this.input);let t=Tee(this.input,this.context.document);t?.enum!=null&&J8i(t)&&(this.maybeEnumConverterNode=new K8i({input:t,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",nullable:this.nullable})),this.schemaId==null&&this.context.errors.error({message:`Unprocessable reference: ${this.input.$ref}`,path:this.accessPath})}convert(){if(this.schemaId!=null)return{type:"alias",value:{type:"id",id:Yj.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=Tee(this.input,this.context.document);if(r!=null)return new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var yU=class e extends Kxe{typeShapeNode;description;name;examples;availability;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.description=this.input.description,this.availability=new tyt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),J8i(this.input)&&ewv(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),xx(this.input)){let t=yoo(this.input);if(t==null){this.context.errors.error({message:"Reference object does not have a valid schema ID",path:this.accessPath});return}if(this.seenSchemas.has(t)){this.context.errors.warning({message:"Circular or deeply nested schema found, terminating",path:this.accessPath});return}this.seenSchemas.add(t),this.typeShapeNode=new Dda({input:this.input,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName,description:this.description,availability:this.availability})}else if(this.name=this.input.title,this.examples=this.input.example,this.input.const!=null)this.typeShapeNode=new BUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(kPv(this.input))this.typeShapeNode=new TUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(J8i(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new RUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(zUf(this.input)&&this.input.allOf!=null)this.typeShapeNode=new voo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(J8i(this.input)&&this.input.enum!=null)this.typeShapeNode=new K8i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable});else if(typeof this.input.type=="string"||Array.isArray(this.input.type)&&this.input.type.length===1){if(this.input.type=Array.isArray(this.input.type)?this.input.type[0]:this.input.type,!Array.isArray(this.input.type))switch(this.input.type){case"object":zUf(this.input)&&(this.typeShapeNode=new voo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":H8i(this.input)&&(this.typeShapeNode=new MUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":XPv(this.input)&&(this.typeShapeNode=new NUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":ZPv(this.input)&&(this.typeShapeNode=new FUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":rwv(this.input)&&(this.typeShapeNode=new zUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":nwv(this.input)&&(this.typeShapeNode=new QUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":twv(this.input)&&(this.typeShapeNode=new xUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new uwv.UnreachableCaseError(this.input.type);break}}else if(Array.isArray(this.input.type)&&this.input.type.includes("null")&&this.input.type.length===2){let t=this.input.type.filter(r=>r!=="null")[0];t!=="array"&&(this.typeShapeNode=new e({input:{...this.input,type:t},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:!0,schemaName:this.schemaName}))}else this.input.properties!=null&&(this.typeShapeNode=new voo({input:{...this.input,type:"object"},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));this.typeShapeNode==null&&(this.typeShapeNode=new LUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!xx(this.input)&&(!H8i(this.input)&&this.input==null||H8i(this.input)&&this.input.items==null)&&this.context.errors.error({message:"Expected type declaration. Received: null",path:this.accessPath}))}convert(){let t=this.typeShapeNode?.convert();if(t==null)return;let r=TQ(t)?.map(n=>this.nullable?Nwi(n):n).filter(OA);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function $8i(e){if(e!=null)return hoo(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(OA))}var yWr=class extends Bee{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;xx(this.input)?r=this.input:this.input.schema!=null?(r=this.input.schema,this.required=this.input.required):(r={type:"string"},this.required=!1),this.availability=new tyt({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let n=$Pv(this.input,this.context.document);this.inputExample=n?.example??Object.values(n?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function cwv(e,t){return xx(e)?pbe(e,t,void 0):e}var QUf=$i(AJ());function UUu(e){let{uniqueId:t,type:r,contextTypes:n,description:i,availability:a}=e;n[Yj.TypeId(t)]={name:t,shape:r,description:i,availability:a}}var lwv=$i(YJl(),1),boo=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,n,i,a,o){this.type=t,this.subtype=r,this.essence=n,this.parameters=i,this.mimeType=a,this.input=o}static APPLICATION_JSON="application/json";static APPLICATION_OCTET_STREAM="application/octet-stream";static MULTIPART_FORM_DATA="multipart/form-data";static parse(t){if(t==null)return null;let r=lwv.default.parse(t);return r==null?null:new e(r.type,r.subtype,r.essence,r.parameters,r,t)}toString(){return this.input}isText(){return this.type==="text"}isImage(){return this.type==="image"}isAudio(){return this.type==="audio"}isVideo(){return this.type==="video"}isFont(){return this.type==="font"}isMultipart(){return this.type==="multipart"}isApplication(){return this.type==="application"}isMessage(){return this.type==="message"}isModel(){return this.type==="model"}isCSS(){return this.isText()&&this.subtype==="css"}isCSV(){return this.isText()&&this.subtype==="csv"}isMarkdown(){return this.isText()&&this.subtype==="markdown"}isPlainText(){return this.isText()&&this.subtype==="plain"}isEventStream(){return this.isText()&&this.subtype==="event-stream"}isMultiPartFormData(){return this.isMultipart()&&this.subtype==="form-data"}isJSON(){return this.isApplication()&&this.subtype==="json"}containsJSON(){return this.isApplication()&&this.subtype.includes("json")}isURLEncoded(){return this.isApplication()&&this.subtype==="x-www-form-urlencoded"}isOctetStream(){return this.isApplication()&&this.subtype==="octet-stream"}isPDF(){return this.isApplication()&&this.subtype==="pdf"}isZip(){return this.isApplication()&&this.subtype==="zip"}isGzip(){return this.isApplication()&&this.subtype==="gzip"}isTar(){return this.isApplication()&&this.subtype==="tar"}isBrotli(){return this.isApplication()&&this.subtype==="br"}isDeflate(){return this.isApplication()&&this.subtype==="deflate"}isProtobuf(){return this.isApplication()&&this.subtype==="protobuf"}isAvif(){return this.isImage()&&this.subtype==="avif"}isWebP(){return this.isImage()&&this.subtype==="webp"}isSVG(){return this.isImage()&&this.subtype==="svg+xml"}isPNG(){return this.isImage()&&this.subtype==="png"}isJPEG(){return this.isImage()&&this.subtype==="jpeg"}isGIF(){return this.isImage()&&this.subtype==="gif"}isMPEG(){return this.isAudio()&&this.subtype==="mpeg"}isWAV(){return this.isAudio()&&this.subtype==="wav"}isHTML(){return this.mimeType.isHTML()}isXML(){return this.mimeType.isXML()}isJavaScript(){return this.mimeType.isJavaScript()}};function EXI(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var VUu=class extends UO{typeSchemas;securitySchemes;constructor(t){super(t),this.safeParse()}parse(){this.input.schemas!=null&&(this.typeSchemas=Object.fromEntries(Object.entries(this.input.schemas).map(([t,r])=>[t,new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),EXI(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],n)=>{let i;if(xx(r)?i=k9u(r.$ref,this.context.document):i=r,i!=null)return[t,new poo({input:i,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${n}`]})]}).filter(OA)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[Yj.api.latest.AuthSchemeId(t),n]}).filter(OA)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let n=r.name??t,i=TQ(r.convert());return i==null?[t,void 0]:[Yj.TypeId(t),{name:n,shape:i[0],description:r.description,availability:void 0}]}).filter(([t,r])=>OA(r))):void 0}}};var WUu=class extends yU{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=Tee(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${xx(this.input)?`Received undefined reference: ${this.input.$ref}`:""}`,path:this.accessPath});return}if(t.type==="string"&&t.format==="binary")this.multipartType="file",this.contentType=t.contentMediaType;else if(t.type==="array"){let r=Tee(t.items,this.context.document);r?.type==="string"&&r?.format==="binary"?(this.multipartType="files",this.contentType=r?.contentMediaType):(this.context.errors.warning({message:"Expected multipart form data files definition with array type with internal string type and binary format.",path:this.accessPath}),this.multipartType=void 0,this.contentType=void 0)}else this.multipartType="property",this.contentType=t.contentMediaType}};var GUu=class extends UO{description;method;path;schema;isOptional;contentType;availability;requiredFields;fields;examples;constructor(t){super(t),this.method=t.method,this.path=t.path,this.safeParse(t)}parse({contentType:t}){if(this.input.schema!=null){let n=Tee(this.input.schema,this.context.document);this.availability=new tyt({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=xx(this.input.schema)?new Dda({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:!1,schemaName:"Request Body",description:this.input.schema.description,availability:this.availability}):void 0;let i=boo.parse(t);i?.containsJSON()?(this.contentType="json",this.schema=this.schema??new yU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):i?.isOctetStream()?(this.contentType="bytes",this.isOptional=n?.required==null):i?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=n?.required,this.fields=Object.fromEntries(Object.entries(n?.properties??{}).map(([a,o])=>{if(o!=null)return[a,new WUu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(OA))):this.context.errors.warning({message:`Expected request body of reference or object with json, streaming or form-data content types. Received: ${t}`,path:this.accessPath})}let r=this.schema?.example({includeOptionals:!0,override:void 0});this.examples={...this.input.example!=null?{[Ade]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[Ade]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:TQ(t)?.map(n=>{let i=n.type;switch(i){case"object":case"alias":return n;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=Jqr([this.method,this.path,this.contentType,"request"].join("_"));return UUu({uniqueId:a,type:n,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Yj.TypeId(a),default:n.type==="enum"&&n.default!=null?{type:"enum",value:n.default}:void 0}}}case void 0:return;default:new QUf.UnreachableCaseError(i);return}}).filter(OA)}convert(){if(this.schema instanceof Dda)return this.schema.convert();switch(this.contentType){case"json":return this.convertJsonLike();case"bytes":return{type:"bytes",isOptional:this.isOptional??!1,contentType:this.contentType};case"form-data":return Object.entries(this.fields??{}).map(([n,i])=>{switch(i.multipartType){case"file":return[{type:i.multipartType,key:Yj.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"files":return[{type:i.multipartType,key:Yj.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"property":{let a=TQ(i.convert()),o=i.multipartType;return a?.map(c=>({type:o,key:Yj.PropertyKey(n),contentType:i.contentType,exploded:void 0,valueShape:c,description:i.description,availability:i.availability?.convert()}))}case void 0:return[];default:return new QUf.UnreachableCaseError(i.multipartType),[]}}).filter(OA).reduce((n,i)=>n.flatMap(a=>i.length>0?i.map(o=>[...a,o]):[[...a]]),[[]]).map(n=>({type:"formData",fields:n,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var HUu=class extends UO{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let n=cwv(this.input,this.context.document);if(n==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(n.content).forEach(([i,a])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[i]=new GUu({input:a,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:i,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>TQ(r.convert())?.map(i=>({description:this.description,contentType:t,body:i}))).filter(OA)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>TQ(t.convert())?.map(n=>{if(!(n.type!=="alias"&&n.type!=="object"))return{description:this.description,shape:n}})).filter(OA)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var fwv={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};function dwv(e,t){if(xx(e)){let r=pbe(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var JUu=$i(AJ());var pwv="application/json";var _wv="application/octet-stream";function hwv(e,t){return e===t||t===Ade||e===Ade}var Ons=class extends UO{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,n,i,a,o,c,f){super(t),this.streamingFormat=n,this.path=i,this.method=a,this.statusCode=o,this.requests=c,this.shapes=f,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,n){for(let i of t)for(let[a,o]of Object.entries(i?.examples??{}))for(let[c,f]of Object.entries(r))for(let u of f)hwv(c,a)&&(n.add(c),this.examples?.push(new hWr({input:{requestExample:o,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,W8i(a,c),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let n=0;for(let i of t){let a=0;for(let[o,c]of r){if(a===n){let[f,u,s]=i??[void 0,void 0,void 0];this.examples?.push(...c.map(l=>new hWr({input:{requestExample:s,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:u!=null&&u!==""?["examples",u]:"examples"},this.path,this.statusCode,W8i(u,o),{requestBody:f,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}a++}n++}if(t.length>r.length)for(let i of t.slice(r.length)){let[a,o]=r[r.length-1]??[void 0,void 0],[c,f,u]=i??[void 0,void 0,void 0];this.examples?.push(...(o??[void 0]).map(s=>new hWr({input:{requestExample:u,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:f!=null&&f!==""?["examples",f]:"examples"},this.path,this.statusCode,W8i(f,a),{requestBody:c,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[i,a,o]=t[t.length-1]??[void 0,void 0,void 0];for(let[c,f]of r.slice(t.length))this.examples?.push(...f.map(u=>new hWr({input:{requestExample:o,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,W8i(a,c),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,n,i){let a=t[Ade];if(a!=null)for(let o of a)this.examples?.push(new hWr({input:{requestExample:i,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:n!=null&&n!==""?["examples",n]:"examples"},this.path,this.statusCode,W8i(n,void 0),{requestBody:r,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders}))}addGlobalFallbackExample(t,r){if(t==null||t.length===0)this.pushResponseExample(r,void 0,void 0,void 0);else for(let n of t)if(Object.keys(n.examples??{}).length===0)this.pushResponseExample(r,n,void 0,void 0);else for(let[i,a]of Object.entries(n.examples??{}))this.pushResponseExample(r,n,i,a)}parse(t){if(t==="empty")this.empty=!0;else{let c=boo.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=pwv,this.input.schema==null?(this.streamingFormat==null||this.streamingFormat==="json")&&this.context.errors.error({message:"Expected schema for JSON response body. Received null",path:this.accessPath}):this.schema=new yU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(c?.isOctetStream())this.contentType=_wv,this.contentSubtype=Tee(this.input.schema,this.context.document)?.contentMediaType;else if(this.unsupportedContentType=t,this.input.schema==null){this.context.errors.error({message:"Expected schema for plain text response body. Received null",path:this.accessPath});return}else this.schema=new yU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"})}let r={};this.input.examples!=null&&(r=gUu(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[Ade]??=[],r[Ade]=[{value:this.input.example}]);let n=Tee(this.input.schema,this.context.document);if(n!=null&&(n.examples!=null&&Object.keys(r).length===0&&(r=gUu(n.examples,c=>[c])),n.example!=null&&Object.keys(r).length===0&&(r[Ade]??=[],r[Ade]?.push({value:n.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[Ade]??=[],r[Ade]?.push(c!=null?{value:c}:void 0)}this.examples??=[];let i=new Set;this.matchRequestResponseExamplesByName(this.requests,r,i);let a=[];for(let c of this.requests)a.push(...Object.entries(c.examples??{}).filter(([f])=>!i.has(f)&&f!==Ade).map(([f,u])=>[c,f,u]));let o=Object.entries(r).filter(([c,f])=>!i.has(c)&&OA(f)&&c!==Ade);Object.keys(r).every(c=>c===Ade)||this.matchExamplesByIndex(a,o),!i.has(Ade)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return TQ(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new JUu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return TQ(this.schema?.convert())?.map(r=>{let n=r.type;switch(n){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let i=Jqr([this.method,this.path,this.statusCode,"response"].join("_"));return UUu({uniqueId:i,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Yj.TypeId(i),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new JUu.UnreachableCaseError(n);return}}).filter(OA)}convert(){if(this.empty)return{type:"empty"};if(this.contentType!=null)switch(this.contentType){case"application/json":return this.streamingFormat==null?this.convertJsonLike():this.convertStreamingFormat();case"application/octet-stream":return{type:"fileDownload",contentType:this.contentSubtype};case"text/event-stream":return this.convertStreamingFormat();case void 0:return;default:new JUu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var Ans=class extends UO{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,n,i,a,o){super(t),this.path=r,this.method=n,this.statusCode=i,this.requests=a,this.shapes=o,this.safeParse()}parse(t){this.description=this.input.description;let r=dwv(this.input,this.context.document);if(r==null){this.context.errors.error({message:xx(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([n,i])=>{this.headers??={},this.headers[n]=new yWr({input:i,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:n})}),r.content==null?(this.responses??=[],this.responses.push(new Ons({input:{},context:this.context,accessPath:this.accessPath,pathId:["content"]},"empty",t,this.path,this.method,this.statusCode,this.requests,this.shapes))):Object.entries(r.content??{}).forEach(([n,i])=>{this.responses??=[],this.responses.push(new Ons({input:i,context:this.context,accessPath:this.accessPath,pathId:["content",n]},n,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(OA)}};var KUu=class extends UO{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,n,i,a){super(t),this.path=r,this.method=n,this.requests=i,this.shapes=a,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,n])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new Ans({input:{...t,...n},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new Ans({input:n,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,parseInt(r),this.requests,this.shapes)))})}convertResponseObjectToHttpResponses(){return Object.entries(this.responsesByStatusCode??{}).flatMap(([t,r])=>{let n=r.convert();if(n!=null)return qUu($8i(r.headers)).flatMap(i=>n?.map(a=>({headers:i,response:{statusCode:parseInt(t),body:a,description:r.description},examples:(r.responses??[]).flatMap(o=>(o.examples??[]).map(c=>c.convert()).filter(OA))})))}).filter(OA)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(n=>{let i=n.schema,a=TQ(i?.convert());if(i!=null)return a?.map(o=>({statusCode:parseInt(t),shape:o,description:r.description??i.description,availability:i.availability?.convert(),name:i.name??fwv[parseInt(t)]??"UNKNOWN ERROR",examples:n.examples?.map(c=>{let f=c.convert();if(f!=null&&f.responseBody?.type==="json")return{name:f.name,description:f.description,responseBody:f.responseBody}}).filter(OA)})).filter(OA)})).filter(OA)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var Y8i=class extends UO{servers;globalAuth;path;method;basePath;isWebhook;endpointIds;description;displayName;operationId;pathParameters;queryParameters;requestHeaders;requests;responses;availability;auth;namespaces;xFernExamplesNode;redocExamplesNode;emptyResponseExamples;constructor(t){super(t),this.servers=t.servers,this.globalAuth=t.globalAuth,this.path=t.path,this.method=t.method,this.basePath=t.basePath,this.isWebhook=t.isWebhook,this.safeParse()}pushEmptyResponseExample(t,r,n){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new hWr({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,W8i(n,void 0),{requestBody:r,pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}))}parse(){if(this.isWebhook&&this.method!=="POST"&&this.method!=="GET"){this.context.errors.error({message:`Webhook method must be POST or GET. Received: ${this.method}`,path:this.accessPath});return}this.description=this.input.description,this.displayName=this.input.summary,this.operationId=this.input.operationId,this.availability=new tyt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=L8i(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new CUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((n,i)=>{if(xx(n)){let a=wUu(n,this.context.document);if(a!=null)n=a;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${n.$ref}`,path:[...this.accessPath,`parameters[${i}]`]});return}}n.in==="path"?n.schema!=null&&(this.pathParameters??={},this.pathParameters[n.name]=new yWr({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="query"?n.schema!=null&&(this.queryParameters??={},this.queryParameters[n.name]=new yWr({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="header"&&n.schema!=null&&(this.requestHeaders??={},this.requestHeaders[n.name]=new yWr({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name}))});for(let n of this.extractPathParameterIds()??[])this.pathParameters?.[n]==null&&this.context.errors.warning({message:`Path parameter not defined: ${n}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new IUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new HUu({input:this.input.requestBody,context:this.context,accessPath:this.accessPath,pathId:"requestBody",method:this.method,path:this.path}):void 0,this.responses=this.input.responses!=null?new KUu({input:this.input.responses,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,Object.values(this.requests?.requestBodiesByContentType??{}),{pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}):void 0,this.responses==null){let n=this.requests?.requestBodiesByContentType;n==null||Object.keys(n).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(n).forEach(i=>{if(Object.keys(i.examples??{}).length===0){let a=i.schema?.example({includeOptionals:!1,override:void 0});a!=null&&this.pushEmptyResponseExample({value:a},i,void 0)}else Object.entries(i.examples??{}).forEach(([a,o])=>{this.pushEmptyResponseExample(o,i,a)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(n=>Number(n)>=200&&Number(n)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new _oo({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new mns({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(n=>n.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((n,i)=>new mns({input:{[Y9u]:n},context:this.context,accessPath:this.accessPath,pathId:["tags",`${i}`]})));let r=new DUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(n=>mUu({namespace:TQ(n?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(OA),this.xFernExamplesNode=new SUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-examples"},this.path,t,this.requests?.requestBodiesByContentType,this.responses?.responsesByStatusCode?.[t]?.responses)}extractPathParameterIds(){if(this.path!=null)return this.path.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}"))return t.slice(1,-1).trim()}).filter(OA)}convertPathToPathParts(){if(this.path===void 0)return;let t=this.path.startsWith("/")?this.path.slice(1):this.path,r=this.basePath?.convert();return(r?[r,...t.split("/")]:t.split("/")).reduce((i,a)=>(i.push({type:"literal",value:"/"}),a.startsWith("{")&&a.endsWith("}")?i.push({type:"pathParameter",value:Yj.PropertyKey(a.slice(1,-1).trim())}):i.push({type:"literal",value:a}),i),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},n=this.emptyResponseExamples?.map(s=>s.convert()).filter(OA),i=LPv(this.xFernExamplesNode?.convert(),[...n??[],...t?.flatMap(s=>s.examples)??[]])?.map(s=>({...s,snippets:QPv(s.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((s,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:Yj.WebhookId(s),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[l]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(m=>m.value.toString())??[],queryParameters:$8i(this.queryParameters)?.flat(),headers:$8i(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(OA)}}).filter(OA);let a=this.servers?.map(s=>s.convert()).filter(OA),o=this.convertPathToPathParts();if(o==null)return;let c,f=this.auth?.convert();f!=null&&(c=Object.keys(f));let u=t?.flatMap(s=>s.headers).filter(OA);return this.endpointIds.map((s,l)=>({id:Yj.EndpointId(s),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(m=>Yj.api.v1.SubpackageId(m)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(m=>Yj.api.latest.AuthSchemeId(m)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:$8i(this.pathParameters)?.flat(),queryParameters:$8i(this.queryParameters)?.flat(),requestHeaders:$8i(this.requestHeaders)?.flat(),responseHeaders:u!=null&&u.length>0?u:void 0,requests:this.requests?.convert(),responses:t?.map(m=>m.response),errors:r,examples:i,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var goo=class extends UO{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n,isWebhook:i}){this.description=this.input.description;let a=L8i(t,this.input.servers,this.context,this.accessPath),o=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new Y8i({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:a,globalAuth:r,path:o,method:"GET",basePath:n,isWebhook:i})),this.input.post!=null&&(this.post=new Y8i({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:a,globalAuth:r,path:o,method:"POST",basePath:n,isWebhook:i})),this.input.put!=null&&(this.put=new Y8i({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:a,globalAuth:r,path:o,method:"PUT",basePath:n,isWebhook:!1})),this.input.patch!=null&&(this.patch=new Y8i({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:a,globalAuth:r,path:o,method:"PATCH",basePath:n,isWebhook:!1})),this.input.delete!=null&&(this.delete=new Y8i({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:a,globalAuth:r,path:o,method:"DELETE",basePath:n,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(OA)}};function $Uu(e){return"payloads"in e}var YUu=class extends UO{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.paths=Object.entries(this.input).map(([i,a])=>{if(a!=null)return new goo({input:a,context:this.context,accessPath:this.accessPath,pathId:i,servers:L8i(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:n,isWebhook:void 0})}).filter(OA)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(n=>{let i=n.convert();i?.forEach(a=>{$Uu(a)?r[Yj.WebhookId(a.id)]=a:t[Yj.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var XUu=class extends UO{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[TAv]?.map(r=>{let{header:n,...i}=r;return(i.optional!=null&&!i.optional||wUu(i,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(n)),[n,new yWr({input:i,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:n})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return hoo(this.globalHeaders,this.requiredProperties)?.flat()}};function ywv(e,t){if(xx(e)){let r=pbe(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var ZUu=class extends UO{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.webhooks=Object.entries(this.input??{}).map(([i,a])=>{let o=ywv(a,this.context.document);if(o!=null)return new goo({input:o,context:this.context,accessPath:this.accessPath,pathId:i,servers:t,globalAuth:r,basePath:n,isWebhook:!0})}).filter(OA)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(n=>{$Uu(n)&&(t[Yj.WebhookId(n.id)]=n)}),t),{})}};var kUu=class extends UO{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=L8i(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new _oo({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new PUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});this.input.paths==null&&this.input.webhooks==null&&this.context.errors.warning({message:"Expected 'paths' or 'webhooks' property to be specified",path:this.accessPath}),this.input.paths!=null&&(this.paths=new YUu({input:this.input.paths,context:this.context,accessPath:this.accessPath,pathId:"paths",basePath:r,servers:t,globalAuth:this.auth})),this.input.webhooks!=null&&(this.webhooks=new ZUu({input:this.input.webhooks,context:this.context,accessPath:this.accessPath,pathId:"webhooks",basePath:r,servers:t,globalAuth:this.auth})),this.input.components!=null&&(this.components=new VUu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new XUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=xrt(),{webhookEndpoints:r,endpoints:n}=this.paths?.convert()??{},i={...this.webhooks?.convert()??{},...r??{}},a=CAv({endpoints:n,webhookEndpoints:i}),{types:o,auths:c}=this.components?.convert()??{};return{id:Yj.ApiDefinitionId(t),endpoints:n??{},websockets:{},webhooks:i,types:{...o,...this.context.generatedTypes},subpackages:a,auths:{...c,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};async function LUf(e,t){if(e instanceof XVr){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof E$))return;let r=new zqr(e.absoluteFilePath),n=await Ght({context:t,specs:e.specs}),i=await r.loadDocuments({context:t,specs:n}),a;for(let o of i){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new K9u,generatedTypes:{}},f=new kUu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=dKl(a,f.convert())}return a}var eqv=$i(WUf(),1),tqv=$i(QVu(),1),rqv=require("fs/promises"),nqv=$i(require("http"),1),iqv=$i(require("path"),1);var yDv=require("events"),GVu=$i(require("fs"),1),xda=$i(require("path"),1);var ZSv=$i(require("os"),1),kSv=300,n2i=20,Hns=1e7,eDv=ZSv.default.platform();var WiM=eDv==="darwin",cWf=eDv==="win32",i2i=WiM||cWf,tDv=3e3,rDv=2e4,lWf=1250;var mWr;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(mWr||(mWr={}));var Fda;(function(e){e.CHANGE="change",e.RENAME="rename"})(Fda||(Fda={}));var Jns;(function(e){e.CHANGE="change",e.ERROR="error"})(Jns||(Jns={}));var QS;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(QS||(QS={}));var WCe;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(WCe||(WCe={}));var GiM=(e,t=1,r)=>{t=Math.max(1,t);let n=r?.leading??!1,i=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,f=0,u=0,s=()=>{let q=Date.now(),V=q-f,$=q-u,re=V>=t||$>=a;return[q,re]},l=q=>{if(u=q,!o)return;let V=o;o=void 0,e.apply(void 0,V)},m=()=>{z(0)},O=()=>{c&&(m(),l(Date.now()))},P=q=>{if(u=q,n)return l(q)},C=q=>{if(i&&o)return l(q);o=void 0},I=()=>{c=void 0;let[q,V]=s();return V?C(q):T(q)},T=q=>{let V=q-f,$=q-u,re=t-V,Y=a-$,k=Math.min(re,Y);return z(k)},z=q=>{c&&clearTimeout(c),!(q<=0)&&(c=setTimeout(I,q))},U=(...q)=>{let[V,$]=s(),re=!!c;if(o=q,f=V,($||!c)&&z(t),$)return re?l(V):P(V)};return U.cancel=m,U.flush=O,U},LVu=GiM;var _Wf=$i(require("fs"),1),VVu=$i(require("path"),1);var $4=$i(require("fs"),1),_be=require("util");var xwi=(e,t)=>function(...n){return e.apply(void 0,n).catch(t)},OWr=(e,t)=>function(...n){try{return e.apply(void 0,n)}catch(i){return t(i)}};var fWf=$i(require("process"),1),nDv=fWf.default.getuid?!fWf.default.getuid():!1,iDv=1e4,Zxe=()=>{};var Kns={isChangeErrorOk:e=>{if(!Kns.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!nDv&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!Kns.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!Kns.isNodeError(e))throw e;if(!Kns.isChangeErrorOk(e))throw e}},qee=Kns;var dWf=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=iDv,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(n),n=()=>t(r);this.add(n)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},aDv=new dWf;var zwi=(e,t)=>function(n){return function i(...a){return aDv.schedule().then(o=>{let c=u=>(o(),u),f=u=>{if(o(),Date.now()>=n)throw u;if(t(u)){let s=Math.round(100*Math.random());return new Promise(m=>setTimeout(m,s)).then(()=>i.apply(void 0,a))}throw u};return e.apply(void 0,a).then(c,f)})}},Qwi=(e,t)=>function(n){return function i(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>n)throw o;if(t(o))return i.apply(void 0,a);throw o}}};var HiM={attempt:{chmod:xwi((0,_be.promisify)($4.default.chmod),qee.onChangeError),chown:xwi((0,_be.promisify)($4.default.chown),qee.onChangeError),close:xwi((0,_be.promisify)($4.default.close),Zxe),fsync:xwi((0,_be.promisify)($4.default.fsync),Zxe),mkdir:xwi((0,_be.promisify)($4.default.mkdir),Zxe),realpath:xwi((0,_be.promisify)($4.default.realpath),Zxe),stat:xwi((0,_be.promisify)($4.default.stat),Zxe),unlink:xwi((0,_be.promisify)($4.default.unlink),Zxe),chmodSync:OWr($4.default.chmodSync,qee.onChangeError),chownSync:OWr($4.default.chownSync,qee.onChangeError),closeSync:OWr($4.default.closeSync,Zxe),existsSync:OWr($4.default.existsSync,Zxe),fsyncSync:OWr($4.default.fsync,Zxe),mkdirSync:OWr($4.default.mkdirSync,Zxe),realpathSync:OWr($4.default.realpathSync,Zxe),statSync:OWr($4.default.statSync,Zxe),unlinkSync:OWr($4.default.unlinkSync,Zxe)},retry:{close:zwi((0,_be.promisify)($4.default.close),qee.isRetriableError),fsync:zwi((0,_be.promisify)($4.default.fsync),qee.isRetriableError),open:zwi((0,_be.promisify)($4.default.open),qee.isRetriableError),readFile:zwi((0,_be.promisify)($4.default.readFile),qee.isRetriableError),rename:zwi((0,_be.promisify)($4.default.rename),qee.isRetriableError),stat:zwi((0,_be.promisify)($4.default.stat),qee.isRetriableError),write:zwi((0,_be.promisify)($4.default.write),qee.isRetriableError),writeFile:zwi((0,_be.promisify)($4.default.writeFile),qee.isRetriableError),closeSync:Qwi($4.default.closeSync,qee.isRetriableError),fsyncSync:Qwi($4.default.fsyncSync,qee.isRetriableError),openSync:Qwi($4.default.openSync,qee.isRetriableError),readFileSync:Qwi($4.default.readFileSync,qee.isRetriableError),renameSync:Qwi($4.default.renameSync,qee.isRetriableError),statSync:Qwi($4.default.statSync,qee.isRetriableError),writeSync:Qwi($4.default.writeSync,qee.isRetriableError),writeFileSync:Qwi($4.default.writeFileSync,qee.isRetriableError)}},oDv=HiM;var UVu=$i(require("fs"),1),$ns=$i(require("path"),1);var pWf=()=>{};var JiM=()=>{let e=pWf,t=pWf,r=!1,n=!1;return{promise:new Promise((f,u)=>{e=s=>(r=!0,f(s)),t=s=>(n=!0,u(s))}),resolve:e,reject:t,isPending:()=>!r&&!n,isResolved:()=>r,isRejected:()=>n}},sDv=JiM;var KiM=()=>{let{promise:e,resolve:t,isPending:r}=sDv(),n=0,i=()=>{n+=1},a=()=>{n-=1,!n&&t()};return(()=>{i(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:i,decrement:a}},uDv=KiM;var cDv={then:e=>{e()}};var lDv=e=>Array.isArray(e)?e:[e],fDv=e=>typeof e=="function";var $iM=(e,t)=>{let r=t?.followSymlinks??!1,n=t?.depth??1/0,i=t?.limit??1/0,a=t?.ignore??[],o=lDv(a).map(xe=>fDv(xe)?xe:Be=>xe.test(Be)),c=xe=>o.some(Be=>Be(xe)),f=t?.signal??{aborted:!1},u=t?.onDirents||(()=>{}),s=[],l=new Set,m={},O=[],P=new Set,C={},I=[],T=new Set,z={},U={},q=new Set,V={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},$={directories:s,directoriesNames:l,directoriesNamesToPaths:m,files:O,filesNames:P,filesNamesToPaths:C,symlinks:I,symlinksNames:T,symlinksNamesToPaths:z,map:U},{promise:re,increment:Y,decrement:k}=uDv(),ne=0,me=(xe,Be,Jt,pt)=>{q.has(Be)||ne>=i||(ne+=1,xe.directories.push(Be),xe.directoriesNames.add(Jt),s.push(Be),l.add(Jt),m.propertyIsEnumerable(Jt)||(m[Jt]=[]),m[Jt].push(Be),q.add(Be),!(pt>=n)&&(ne>=i||Ee(Be,pt+1)))},_e=(xe,Be,Jt)=>{q.has(Be)||ne>=i||(ne+=1,xe.files.push(Be),xe.filesNames.add(Jt),O.push(Be),P.add(Jt),C.propertyIsEnumerable(Jt)||(C[Jt]=[]),C[Jt].push(Be),q.add(Be))},ve=(xe,Be,Jt,pt)=>{q.has(Be)||ne>=i||(ne+=1,xe.symlinks.push(Be),xe.symlinksNames.add(Jt),I.push(Be),T.add(Jt),z.propertyIsEnumerable(Jt)||(z[Jt]=[]),z[Jt].push(Be),q.add(Be),r&&(pt>=n||ne>=i||Ot(Be,pt+1)))},pe=(xe,Be,Jt,pt,vr)=>{f.aborted||c(Be)||(pt.isDirectory()?me(xe,Be,Jt,vr):pt.isFile()?_e(xe,Be,Jt):pt.isSymbolicLink()&&ve(xe,Be,Jt,vr))},De=(xe,Be,Jt,pt)=>{if(f.aborted)return;let vr=Be===$ns.default.sep?"":$ns.default.sep,Gt=Jt.name,Xe=`${Be}${vr}${Gt}`;c(Xe)||(Jt.isDirectory()?me(xe,Xe,Gt,pt):Jt.isFile()?_e(xe,Xe,Gt):Jt.isSymbolicLink()&&ve(xe,Xe,Gt,pt))},Ce=(xe,Be,Jt,pt)=>{for(let vr=0,Gt=Jt.length;vr<Gt;vr++)De(xe,Be,Jt[vr],pt)},Ee=(xe,Be)=>{f.aborted||Be>n||ne>=i||(Y(),UVu.default.readdir(xe,{withFileTypes:!0},(Jt,pt)=>{if(Jt||f.aborted||!pt.length)return k();(u(pt)||cDv).then(()=>{let Gt=U[xe]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};Ce(Gt,xe,pt,Be),k()})}))},Ot=(xe,Be)=>{Y(),UVu.default.realpath(xe,(Jt,pt)=>{if(Jt||f.aborted)return k();UVu.default.stat(pt,(vr,Gt)=>{if(vr||f.aborted)return k();let Xe=$ns.default.basename(pt),dt=U[xe]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};pe(dt,pt,Xe,Gt,Be),k()})})};return(async(xe,Be=1)=>(xe=$ns.default.normalize(xe),q.add(xe),Ee(xe,Be),await re,f.aborted?V:$))(e)},dDv=$iM;var AWr={lang:{debounce:LVu,attempt:e=>{try{return e()}catch(t){return AWr.lang.castError(t)}},castArray:e=>AWr.lang.isArray(e)?e:[e],castError:e=>AWr.lang.isError(e)?e:AWr.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(AWr.lang.isNaN(e))return AWr.lang.isNaN(t);if(AWr.lang.isPrimitive(e)||AWr.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(VVu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?_Wf.default.realpathSync.native(e):_Wf.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===VVu.default.sep&&t.length-e.length>VVu.default.sep.length,poll:(e,t=rDv)=>oDv.retry.stat(t)(e,{bigint:!0}).catch(AWr.lang.noop),readdir:async(e,t,r=1/0,n=1/0,i,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await dDv(e,{depth:r,limit:n,ignore:t,signal:i});return[o.directories,o.files]}}}},gB=AWr;var WVu=$i(require("path"),1);var hWf=class{constructor(t,r,n){this.base=n,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||gB.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=kSv){return(()=>{let r=this.watcher._readyWait,n=[],i=new Set,a=async(c,f)=>{let u=this.options.ignoreInitial?[]:c,s=await this.eventsPopulate([...f]),l=this.eventsDeduplicate([...u,...s]);this.onTargetEvents(l)},o=gB.lang.debounce(()=>{this.watcher.isClosed()||(r=a(n,i),n=[],i=new Set)},t);return async(c,f="",u=!1)=>{u?await this.eventsPopulate([f],n,!0):i.add(f),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((n,i)=>{let[a,o]=i,c=r[o];return a===c||a===QS.CHANGE&&c===QS.ADD||(r[o]=a,n.push(i)),n},[])}async eventsPopulate(t,r=[],n=!1){return await Promise.all(t.map(async i=>{let a=await this.watcher._poller.update(i,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,i]),o===QS.ADD_DIR?await this.eventsPopulateAddDir(t,i,r,n):o===QS.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,i,r,n)}))})),r}async eventsPopulateAddDir(t,r,n=[],i=!1){if(i)return n;let a=this.options.recursive?this.options.depth??n2i:Math.min(1,this.options.depth??n2i),o=this.options.limit??Hns,[c,f]=await gB.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),u=[...c,...f];return await Promise.all(u.map(s=>{if(!this.watcher.isIgnored(s,this.options.ignore)&&!t.includes(s))return this.eventsPopulate([s],n,!0)})),n}async eventsPopulateUnlinkDir(t,r,n=[],i=!1){if(i)return n;for(let a of this.watcher._poller.stats.keys())gB.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],n,!0));return n}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(QS.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!i2i&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(QS.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(QS.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(WVu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(QS.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(WVu.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(QS.UNLINK_DIR,t))}onTargetEvent(t){let[r,n]=t;r===QS.ADD?this.onTargetAdd(n):r===QS.ADD_DIR?this.onTargetAddDir(n):r===QS.CHANGE?this.onTargetChange(n):r===QS.UNLINK?this.onTargetUnlink(n):r===QS.UNLINK_DIR&&this.onTargetUnlinkDir(n)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,n=!1){return this.handlerBatched(t,r,n)}onWatcherChange(t=Fda.CHANGE,r){if(this.watcher.isClosed())return;let n=WVu.default.resolve(this.folderPath,r||"");this.filePath&&n!==this.folderPath&&n!==this.filePath||this.watcher.isIgnored(n,this.options.ignore)||this.onWatcherEvent(t,n)}onWatcherError(t){cWf&&t.code==="EPERM"?this.onWatcherChange(Fda.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(Jns.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(Jns.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(Fda.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&i2i&&this.options.native!==!1?this.options.depth??n2i:Math.min(1,this.options.depth??n2i),n=this.options.limit??Hns,[i,a]=await gB.fs.readdir(this.folderPath,this.options.ignore,r,n,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...i,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(Fda.CHANGE,c,t)}))}}},pDv=hWf;var GCe={interval:100,intervalId:void 0,fns:new Map,init:()=>{GCe.intervalId||(GCe.intervalId=setInterval(GCe.resolve,GCe.interval))},reset:()=>{GCe.intervalId&&(clearInterval(GCe.intervalId),delete GCe.intervalId)},add:(e,t)=>{GCe.fns.set(e,Date.now()+t),GCe.init()},remove:e=>{GCe.fns.delete(e)},resolve:()=>{if(!GCe.fns.size)return GCe.reset();let e=Date.now();for(let[t,r]of GCe.fns)r>=e||(GCe.remove(t),t())}},Yns=GCe;var Xns=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=lWf){let{ino:n,targetPath:i,events:a,locks:o}=t,c=()=>{let l=this._watcher._poller.paths.find(n||-1,m=>m!==i);if(l&&l!==i){if(gB.fs.getRealPath(i,!0)===l)return;this._watcher.event(a.rename,l,i)}else this._watcher.event(a.add,i)};if(!n)return c();let f=()=>{o.add.delete(n),Yns.remove(u)},u=()=>{f(),c()};Yns.add(u,r);let s=()=>{let l=o.unlink.get(n);if(!l)return;f();let m=l();i===m?a.change&&this._watcher._poller.stats.has(i)&&this._watcher.event(a.change,i):this._watcher.event(a.rename,m,i)};o.add.set(n,s),s()}getLockUnlink(t,r=lWf){let{ino:n,targetPath:i,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,i)};if(!n)return c();let f=()=>{o.unlink.delete(n),Yns.remove(u)},u=()=>{f(),c()};Yns.add(u,r);let s=()=>(f(),i);o.unlink.set(n,s),o.add.get(n)?.()}getLockTargetAdd(t,r){let n=this._watcher._poller.getIno(t,QS.ADD,mWr.FILE);return this.getLockAdd({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let n=this._watcher._poller.getIno(t,QS.ADD_DIR,mWr.DIR);return this.getLockAdd({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let n=this._watcher._poller.getIno(t,QS.UNLINK,mWr.FILE);return this.getLockUnlink({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let n=this._watcher._poller.getIno(t,QS.UNLINK_DIR,mWr.DIR);return this.getLockUnlink({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};Xns.DIR_EVENTS={add:QS.ADD_DIR,rename:QS.RENAME_DIR,unlink:QS.UNLINK_DIR};Xns.FILE_EVENTS={add:QS.ADD,change:QS.CHANGE,rename:QS.RENAME,unlink:QS.UNLINK};var _Dv=Xns;var yWf=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(gB.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let n=this.map.get(t);if(gB.lang.isSet(n)){let i=n.delete(r);return n.size||this.map.delete(t),i}else if(n===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let n=this.map.get(t);if(gB.lang.isSet(n))return Array.from(n).find(r);if(r(n))return n}}get(t){return this.map.get(t)}has(t,r){if(gB.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let n=this.map.get(t);return gB.lang.isSet(n)?n.has(r):n===r}return!1}set(t,r){if(this.map.has(t)){let n=this.map.get(t);gB.lang.isSet(n)?n.add(r):n!==r&&this.map.set(t,new Set([n,r]))}else this.map.set(t,r);return this}},vWf=yWf;var bWf=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},hDv=bWf;var gWf=class{constructor(){this.inos={},this.paths=new vWf,this.stats=new Map}getIno(t,r,n){let i=this.inos[r];if(!i)return;let a=i[t];if(a&&!(n&&a[1]!==n))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let n=await gB.fs.poll(t,r);if(!(!n||!(n.isFile()||n.isDirectory())))return new hDv(n)}reset(){this.inos={},this.paths=new vWf,this.stats=new Map}async update(t,r){let n=this.getStats(t),i=await this.poll(t,r);if(this.updateStats(t,i),!n&&i){if(i.isFile())return this.updateIno(t,QS.ADD,i),[QS.ADD];if(i.isDirectory())return this.updateIno(t,QS.ADD_DIR,i),[QS.ADD_DIR]}else if(n&&!i){if(n.isFile())return this.updateIno(t,QS.UNLINK,n),[QS.UNLINK];if(n.isDirectory())return this.updateIno(t,QS.UNLINK_DIR,n),[QS.UNLINK_DIR]}else if(n&&i){if(n.isFile()){if(i.isFile())return n.ino===i.ino&&!n.size&&!i.size?[]:(this.updateIno(t,QS.CHANGE,i),[QS.CHANGE]);if(i.isDirectory())return this.updateIno(t,QS.UNLINK,n),this.updateIno(t,QS.ADD_DIR,i),[QS.UNLINK,QS.ADD_DIR]}else if(n.isDirectory()){if(i.isFile())return this.updateIno(t,QS.UNLINK_DIR,n),this.updateIno(t,QS.ADD,i),[QS.UNLINK_DIR,QS.ADD];if(i.isDirectory())return n.ino===i.ino?[]:(this.updateIno(t,QS.UNLINK_DIR,n),this.updateIno(t,QS.ADD_DIR,i),[QS.UNLINK_DIR,QS.ADD_DIR])}}return[]}updateIno(t,r,n){let i=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=n.isFile()?mWr.FILE:mWr.DIR;i[t]=[n.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let n=this.stats.get(t)?.ino||-1;this.paths.delete(n,t),this.stats.delete(t)}}},mWf=gWf;var OWf=class e extends yDv.EventEmitter{constructor(t,r,n){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(WCe.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(i=>this.on(WCe.CLOSE,i)),this._readyWait=new Promise(i=>this.on(WCe.READY,i)),this._locker=new _Dv(this),this._roots=new Set,this._poller=new mWf,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,n)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(gB.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(WCe.CLOSE))}error(t){if(this.isClosed())return!1;let r=gB.lang.castError(t);return this.emit(WCe.ERROR,r)}event(t,r,n){return this.isClosed()?!1:(this.emit(WCe.ALL,t,r,n),this.emit(t,r,n))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(WCe.READY))}pollerExists(t,r){for(let n of this._pollers)if(n.targetPath===t&&gB.lang.isShallowEqual(n.options,r))return!0;return!1}subwatcherExists(t,r){for(let n of this._subwatchers)if(n.targetPath===t&&gB.lang.isShallowEqual(n.options,r))return!0;return!1}watchersClose(t,r,n=!0){if(t){let i=this._watchers[t];if(i)for(let a of[...i])r&&a.filePath!==r||this.watcherClose(a);if(n)for(let a in this._watchers)gB.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let i in this._watchers)this.watchersClose(i,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,n]of t)this.watchPath(r,n.options,n.handler)}async watcherAdd(t,r){let{folderPath:n}=t;(this._watchers[n]=this._watchers[n]||[]).push(t);let a=new pDv(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let n=t.filePath||t.folderPath;this._roots.has(n)&&(this._watchersRestorable[n]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=gB.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,n,i){if(this._watchers[t]?.find(c=>c.handler===n&&(!c.filePath||c.filePath===i)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=xda.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(s=>(c===1||s.options.recursive&&c<=(s.options.depth??n2i))&&s.handler===n&&(!s.filePath||s.filePath===i)&&s.options.ignore===r.ignore&&!!s.options.native==!!r.native&&(!r.recursive||s.options.recursive&&i2i&&s.options.native!==!1)))return!0;if(!i2i)break;let u=xda.default.dirname(t);if(o===u)break;o=u}return!1}async watchDirectories(t,r,n,i,a){if(this.isClosed())return;t=gB.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,n,i))try{let f=!r.recursive||i2i&&r.native!==!1?r:{...r,recursive:!1},s={watcher:GVu.default.watch(c,f),handler:n,options:r,folderPath:c,filePath:i},l=o=await this.watcherAdd(s,a);if(this._roots.has(i||c)){let O={...r,ignoreInitial:!0,recursive:!1},P=xda.default.dirname(c),C=c;await this.watchDirectories([P],O,n,C,l)}}catch(f){this.error(f)}return o}async watchDirectory(t,r,n,i,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||i2i&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,n,i,a));{r={...r,recursive:!0};let o=r.depth??n2i,c=r.limit??Hns,[f]=await gB.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let u=await this.watchDirectories([t],r,n,i,a);if(f.length){let s=gB.fs.getDepth(t);for(let l of f){let m=gB.fs.getDepth(l),O=Math.max(0,o-(m-s)),P={...r,depth:O};await this.watchDirectories([l],P,n,i,a||u)}}})}}}async watchFileOnce(t,r,n){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let i={targetPath:t,options:r},a=(u,s)=>{s===t&&(f(),n())},o=new e(a),c=()=>{this._subwatchers.add(i),this.on(WCe.CLOSE,f),o.watchFile(t,r,a)},f=()=>{this._subwatchers.delete(i),this.removeListener(WCe.CLOSE,f),o.close()};return c()}async watchFile(t,r,n){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let i=xda.default.dirname(t);return this.watchDirectory(i,r,n,t)}async watchPollingOnce(t,r,n){if(this.isClosed())return;let i=!1,a=new mWf,o=await this.watchPolling(t,r,async()=>{i||!(await a.update(t,r.pollingTimeout)).length||i||(i=!0,o(),n())})}async watchPolling(t,r,n){if(this.isClosed())return gB.lang.noop;if(this.pollerExists(t,r))return gB.lang.noop;let i={...r,interval:r.pollingInterval??tDv},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(WCe.CLOSE,c),GVu.default.watchFile(t,i,n)},c=()=>{this._pollers.delete(a),this.removeListener(WCe.CLOSE,c),GVu.default.unwatchFile(t,n)};return gB.lang.attempt(o),()=>gB.lang.attempt(c)}async watchUnknownChild(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchFileOnce(t,r,i)}async watchUnknownTarget(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchPollingOnce(t,r,i)}async watchPaths(t,r,n){if(this.isClosed())return;if(t=gB.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,f)=>f===o||!gB.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,n)));else for(let a of t)await this.watchPath(a,r,n)}async watchPath(t,r,n){if(this.isClosed()||(t=xda.default.resolve(t),this.isIgnored(t,r.ignore)))return;let i=await gB.fs.poll(t,r.pollingTimeout);if(i){if(i.isFile())return this.watchFile(t,r,n);if(i.isDirectory())return this.watchDirectory(t,r,n);this.error(`"${t}" is not supported`)}else{let a=xda.default.dirname(t);return(await gB.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,n):this.watchUnknownTarget(t,r,n)}}async watch(t,r,n=gB.lang.noop){if(gB.lang.isFunction(t))return this.watch([],{},t);if(gB.lang.isUndefined(t))return this.watch([],r,n);if(gB.lang.isFunction(r))return this.watch(t,{},r);if(gB.lang.isUndefined(r))return this.watch(t,{},n);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let i=gB.lang.castArray(t);i.forEach(a=>this._roots.add(a)),await this.watchPaths(i,r,n),!this.isClosed()&&(n!==gB.lang.noop&&this.on(WCe.ALL,n),r.readdirMap=void 0,this.ready())}},HVu=OWf;kTu();var NTv=$i(NWu(),1),kxe=require("fs/promises"),FTv=require("os"),xTv=$i(RDe(),1),zTv=$i(RTv(),1),kWu=process.platform==="win32",GuM="etag",HuM="preview",JuM="app-preview",KuM="bundle",$uM=".next",YuM="standalone",XuM=".fern",ZuM="packages/fern-docs/bundle/.next/server/instrumentation.js",kuM=".npmrc",ecM=".pnpmfile.cjs",tcM="pnpm-workspace.yaml",rcM='Cannot find matching keyid: {"signatures":';function ncM(){return Ql(F_.of((0,FTv.homedir)()),ru.of(XuM))}function eGu({app:e=!1}){return Ql(ncM(),ru.of(e?JuM:HuM))}function p2i({app:e=!1}){return Ql(eGu({app:e}),ru.of(e?$uM:KuM))}function Ois({app:e=!1}){return Ql(p2i({app:e}),ru.of(YuM))}function icM({app:e=!1}){return Ql(Ois({app:e}),ru.of(ZuM))}function acM({app:e=!1}){return Ql(Ois({app:e}),ru.of(tcM))}function ocM({app:e=!1}){return Ql(Ois({app:e}),ru.of(ecM))}function scM({app:e=!1}){return Ql(Ois({app:e}),ru.of(kuM))}function Wda(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function ucM({app:e=!1}){return Ql(eGu({app:e}),ru.of(GuM))}var ccM=`module.exports = {
|
|
3032
|
+
]`;case 1:return`${i} Did you mean ${r[0]}?`;case 2:return`${i} Did you mean ${r[0]} or ${r[1]}?`;default:return`${i} Did you mean ${r[0]}, ${r[1]}, or ${r[2]}?`}}function L9u(e){return`API section ${e} is specified multiple times, however will be only rendered once.`}function wYI(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function U9u({children:e,findEndpointById:t,stringifyEndpointPathParts:r,disableEndpointPairs:n,apiDefinitionId:i}){if(n)return e;let a=[],o=new Map;return e.forEach(c=>{if(c.type!=="endpoint"){a.push(c);return}let f=t(c.endpointId);if(f==null)throw new Error(`Endpoint ${c.endpointId} not found`);let u=`${f.method} ${r(f)}`,s=o.get(u);if(o.set(u,c),s==null||s.isResponseStream===c.isResponseStream){a.push(c);return}let l=a.indexOf(s),m=c.isResponseStream?c:s,O=c.isResponseStream?s:c,P={id:fl.V1.NodeId(`${i}:${O.endpointId}+${m.endpointId}`),type:"endpointPair",stream:m,nonStream:O};a[l]=P}),a}function Jmv({left:e,right:t,findEndpointById:r,stringifyEndpointPathParts:n,disableEndpointPairs:i,apiDefinitionId:a}){return U9u({children:[...e,...t],findEndpointById:r,stringifyEndpointPathParts:n,disableEndpointPairs:i,apiDefinitionId:a}).filter(o=>o.type==="apiPackage"?o.children.length>0:!0)}function uoo(e,t){if(t!=null)return A3(e.absoluteFilePath,t)}function Kmv({docsWorkspace:e,page:t,parentSlug:r,idgen:n,markdownFilesToFullSlugs:i,markdownFilesToNoIndex:a,hideChildren:o,resolveIconFileId:c}){let f=fl.V1.PageId(uoo(e,t.absolutePath)),u=r.apply({fullSlug:i.get(t.absolutePath)?.split("/"),urlSlug:t.slug??s$(t.title)});return{id:n.get(f),type:"page",pageId:f,title:t.title,slug:u.get(),icon:c?c(t.icon):t.icon,hidden:o||t.hidden,noindex:t.noindex||a.get(t.absolutePath),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,availability:t.availability}}var V9u=class{apiSection;docsWorkspace;taskContext;markdownFilesToFullSlugs;markdownFilesToNoIndex;markdownFilesToTags;workspace;hideChildren;parentAvailability;apiDefinitionId;#e;#t=new Set;#r=new Set;#n=new Set;#i=new Set;#a=new Set;#o=new Map;#u=[];#s;#c;#f;disableEndpointPairs;collectedFileIds=new Map;constructor(t,r,n,i,a,o,c,f,u,s,l,m,O){this.apiSection=t,this.docsWorkspace=i,this.taskContext=a,this.markdownFilesToFullSlugs=o,this.markdownFilesToNoIndex=c,this.markdownFilesToTags=f,this.workspace=l,this.hideChildren=m,this.parentAvailability=O,this.disableEndpointPairs=i.config.experimental?.disableStreamToggle??!1,this.apiDefinitionId=fl.V1.ApiDefinitionId(r.id),this.#e=Q8i.create(r,a),this.collectedFileIds=s,this.#f=u,this.#s=this.apiSection.overviewAbsolutePath!=null?fl.V1.PageId(uoo(this.docsWorkspace,this.apiSection.overviewAbsolutePath)):void 0;let P=this.apiSection.overviewAbsolutePath!=null?this.markdownFilesToFullSlugs.get(this.apiSection.overviewAbsolutePath):void 0;this.#c=n.apply({fullSlug:P?.split("/"),skipUrlSlug:this.apiSection.skipUrlSlug,urlSlug:this.apiSection.slug??s$(this.apiSection.title)});let C=this.apiSection.availability??this.parentAvailability;this.apiSection.navigation!=null&&(this.#u=this.#d(this.apiSection.navigation,this.#e.api.rootPackage,this.#c,C)),this.#u=this.#g(this.#u.map(I=>this.#m(I,C)),this.#O(this.#e.api.rootPackage,this.#c,C))}get(){let t=fl.V1.followRedirects(this.#u),r=new Eda(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.workspace?.changelog?.files.map(n=>n.absoluteFilepath),this.docsWorkspace,this.#f).orUndefined();return{id:this.#f.get(this.apiDefinitionId),type:"apiReference",title:this.apiSection.title,apiDefinitionId:this.apiDefinitionId,overviewPageId:this.#s,paginated:this.apiSection.paginated,slug:this.#c.get(),icon:this.resolveIconFileId(this.apiSection.icon),hidden:this.hideChildren||this.apiSection.hidden,hideTitle:this.apiSection.flattened,showErrors:this.apiSection.showErrors,changelog:r?.toChangelogNode({parentSlug:this.#c,viewers:void 0,hidden:this.hideChildren}),children:this.#u,availability:this.apiSection.availability??this.parentAvailability,pointsTo:t,noindex:void 0,playground:this.#v(this.apiSection.playground),postmanCollectionUrl:this.apiSection.postman,authed:void 0,viewers:this.apiSection.viewers,orphaned:this.apiSection.orphaned,featureFlags:this.apiSection.featureFlags}}#d(t,r,n,i){r=this.#e.resolveSubpackage(r);let a=r!=null?Q8i.getSubpackageId(r):void 0;return t.map(o=>W9f(o)._visit({link:c=>({id:this.#f.get(c.url),type:"link",title:c.text,icon:this.resolveIconFileId(c.icon),url:fl.Url(c.url)}),page:c=>this.#p(c,n,i),package:c=>this.#l(c,n,i),section:c=>this.#_(c,n,i),item:({value:c})=>this.#y(c,a,n,i),endpoint:c=>this.#h(c,a,n,i)})).filter(hj)}#p(t,r,n){return Kmv({page:{...t,availability:t.availability??n},parentSlug:r,docsWorkspace:this.docsWorkspace,markdownFilesToFullSlugs:this.markdownFilesToFullSlugs,markdownFilesToNoIndex:this.markdownFilesToNoIndex,idgen:this.#f,hideChildren:this.hideChildren,resolveIconFileId:this.resolveIconFileId.bind(this)})}#l(t,r,n){let i=t.overviewAbsolutePath!=null?fl.V1.PageId(uoo(this.docsWorkspace,t.overviewAbsolutePath)):void 0,a=t.overviewAbsolutePath!=null?this.markdownFilesToFullSlugs.get(t.overviewAbsolutePath):void 0,o=t.availability??n,c=this.#e.getSubpackageByIdOrLocator(t.package);if(c!=null){let f=Q8i.getSubpackageId(c),u=this.#f.get(i??`${this.apiDefinitionId}:${f}`);this.#a.has(f)&&this.taskContext.logger.warn(L9u(t.package)),this.#a.add(f),this.#o.set(u,[f]);let s=t.slug??(pWr(c)?c.urlSlug:this.apiSection.slug??s$(this.apiSection.title)),l=r.apply({fullSlug:a?.split("/"),skipUrlSlug:t.skipUrlSlug,urlSlug:s}),m=this.#d(t.contents,c,l,o);return{id:u,type:"apiPackage",children:m,title:t.title??(pWr(c)?c.displayName??ooo(c.name):this.apiSection.title),slug:l.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,overviewPageId:i,availability:o,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}else{this.taskContext.logger.warn(Q9u(t.package,this.#e.subpackageLocators));let f=t.slug??s$(t.package),u=r.apply({fullSlug:a?.split("/"),skipUrlSlug:t.skipUrlSlug,urlSlug:f}),s=this.#d(t.contents,void 0,u,o);return{id:this.#f.get(i??`${this.apiDefinitionId}:${s$(t.package)}`),type:"apiPackage",children:s,title:t.title??t.package,slug:u.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,overviewPageId:i,availability:o,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}}#_(t,r,n){let i=t.overviewAbsolutePath!=null?fl.V1.PageId(uoo(this.docsWorkspace,t.overviewAbsolutePath)):void 0,a=t.overviewAbsolutePath!=null?this.markdownFilesToFullSlugs.get(t.overviewAbsolutePath):void 0,o=t.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(t.overviewAbsolutePath):void 0,c=this.#f.get(i??a??r.get()),f=t.referencedSubpackages.map(O=>{let P=this.#e.getSubpackageByIdOrLocator(O),C=P!=null?Q8i.getSubpackageId(P):void 0;if(C===void 0){this.taskContext.logger.error(Q9u(O,this.#e.subpackageLocators));return}return{subpackageId:C,locator:O}}).filter(O=>O!=null).filter(hj);this.#o.set(c,f.map(O=>O.subpackageId)),f.forEach(O=>{this.#a.has(O.subpackageId)&&this.taskContext.logger.error(L9u(O.locator)),this.#a.add(O.subpackageId)});let u=t.slug??s$(t.title),s=r.apply({fullSlug:a?.split("/"),skipUrlSlug:t.skipUrlSlug,urlSlug:u}),l=t.availability??n,m=this.#d(t.contents,void 0,s,l);return{id:c,type:"apiPackage",children:m,title:t.title,slug:s.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,overviewPageId:i,availability:l,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:o,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}#y(t,r,n,i){t=t.trim();let a=this.#e.getSubpackageByIdOrLocator(t)??this.#e.getSubpackageByIdOrLocator(YA(t));if(a!=null){let o=Q8i.getSubpackageId(a),c=this.#f.get(`${this.apiDefinitionId}:${o}`);this.#a.has(o)&&this.taskContext.logger.error(L9u(t)),this.#a.add(o),this.#o.set(c,[o]);let f=pWr(a)?a.urlSlug:"",u=n.apply({urlSlug:f});return{id:c,type:"apiPackage",children:[],title:pWr(a)?a.displayName??ooo(a.name):this.apiSection.title,slug:u.get(),icon:void 0,hidden:this.hideChildren,overviewPageId:void 0,availability:i,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}return this.#h({type:"endpoint",endpoint:t,title:void 0,icon:void 0,slug:void 0,hidden:void 0,availability:void 0,playground:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0},r,n,i)}#h(t,r,n,i){let a=(r!=null?this.#e.subpackages.get(gve.SubpackageId(r))?.endpoints.get(gve.EndpointId(t.endpoint)):void 0)??this.#e.endpointsByLocator.get(t.endpoint);if(a!=null){let f=this.#e.getEndpointId(a);if(f==null)this.taskContext.logger.debug(`Expected Endpoint ID for ${a.id} at path: ${z9u(a.method,a.path.parts)}. Got undefined.`);else{this.#t.has(f)&&this.taskContext.logger.error(`Duplicate endpoint found in the API Reference layout: ${f}`),this.#t.add(f);let u=t.slug!=null?n.append(t.slug):n.apply(a);return{id:this.#f.get(`${this.apiDefinitionId}:${f}`),type:"endpoint",method:a.method,endpointId:f,apiDefinitionId:this.apiDefinitionId,availability:t.availability??fl.V1.convertAvailability(a.availability)??i,isResponseStream:a.response?.type.type==="stream",title:t.title??a.name??VPe(a.path.parts),slug:u.get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}}let o=(r!=null?this.#e.subpackages.get(gve.SubpackageId(r))?.webSockets.get(gve.WebSocketId(t.endpoint)):void 0)??this.#e.webSocketsByLocator.get(t.endpoint);if(o!=null){let f=this.#e.getWebSocketId(o);if(f==null)this.taskContext.logger.error(`Expected WebSocket ID for ${o.id}. Got undefined.`);else return this.#r.has(f)&&this.taskContext.logger.error(`Duplicate web socket found in the API Reference layout: ${f}`),this.#r.add(f),{id:this.#f.get(`${this.apiDefinitionId}:${f}`),type:"webSocket",webSocketId:f,title:t.title??o.name??VPe(o.path.parts),slug:(t.slug!=null?n.append(t.slug):n.apply(o)).get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,apiDefinitionId:this.apiDefinitionId,availability:fl.V1.convertAvailability(o.availability)??i,playground:this.#v(t.playground),authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}let c=(r!=null?this.#e.subpackages.get(gve.SubpackageId(r))?.webhooks.get(gve.WebhookId(t.endpoint)):void 0)??this.#e.webhooks.get(fl.V1.WebhookId(t.endpoint));if(c!=null){let f=this.#e.getWebhookId(c);if(f==null)this.taskContext.logger.error(`Expected Webhook ID for ${c.id}. Got undefined.`);else return this.#n.has(f)&&this.taskContext.logger.error(`Duplicate webhook found in the API Reference layout: ${f}`),this.#n.add(f),{id:this.#f.get(`${this.apiDefinitionId}:${f}`),type:"webhook",webhookId:f,method:c.method,title:t.title??c.name??(0,$mv.default)("/",...c.path),slug:(t.slug!=null?n.append(t.slug):n.apply(c)).get(),icon:this.resolveIconFileId(t.icon),hidden:this.hideChildren||t.hidden,apiDefinitionId:this.apiDefinitionId,availability:i,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}this.taskContext.logger.error("Unknown identifier in the API Reference layout: ",t.endpoint)}#g(t,r){return Jmv({left:t,right:r,findEndpointById:n=>this.#e.endpoints.get(n),stringifyEndpointPathParts:n=>VPe(n.path.parts),disableEndpointPairs:this.disableEndpointPairs,apiDefinitionId:this.apiDefinitionId})}#m(t,r){return J9f({child:t,nodeIdToSubpackageId:this.#o,convertApiDefinitionPackageId:(n,i,a)=>this.#A(n,i,a),mergeAndFilterChildren:this.#g.bind(this)})}#O(t,r,n){let i=[];return t.endpoints.forEach(a=>{if(a.protocol?.type==="grpc"){let o=this.#e.getGrpcId(a);if(o==null){this.taskContext.logger.error(`Expected Grpc ID for ${a.id} at path: ${z9u(a.method,a.path.parts)}. Got undefined.`);return}if(this.#i.has(o))return;let c=r.apply(a);i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"grpc",grpcId:o,title:a.name??VPe(a.path.parts),method:a.protocol?.methodType??"UNARY",apiDefinitionId:this.apiDefinitionId,availability:n,slug:c.get(),icon:void 0,hidden:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}else{let o=this.#e.getEndpointId(a);if(o==null){this.taskContext.logger.debug(`Expected Endpoint ID for ${a.id} at path: ${z9u(a.method,a.path.parts)}. Got undefined.`);return}if(this.#t.has(o))return;let c=r.apply(a);i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"endpoint",method:a.method,endpointId:o,apiDefinitionId:this.apiDefinitionId,availability:fl.V1.convertAvailability(a.availability)??n,isResponseStream:a.response?.type.type==="stream",title:a.name??VPe(a.path.parts),slug:c.get(),icon:void 0,hidden:this.hideChildren,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}}),t.websockets.forEach(a=>{let o=this.#e.getWebSocketId(a);if(o==null){this.taskContext.logger.error(`Expected WebSocket ID for ${a.id}. Got undefined.`);return}this.#r.has(o)||i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"webSocket",webSocketId:o,title:a.name??VPe(a.path.parts),slug:r.apply(a).get(),icon:void 0,hidden:this.hideChildren,apiDefinitionId:this.apiDefinitionId,availability:fl.V1.convertAvailability(a.availability)??n,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}),t.webhooks.forEach(a=>{let o=this.#e.getWebhookId(a);if(o==null){this.taskContext.logger.error(`Expected Webhook ID for ${a.id}. Got undefined.`);return}this.#n.has(o)||i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${o}`),type:"webhook",webhookId:o,method:a.method,title:a.name??ooo(a.id),slug:r.apply(a).get(),icon:void 0,hidden:this.hideChildren,apiDefinitionId:this.apiDefinitionId,availability:n,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}),t.subpackages.forEach(a=>{if(this.#a.has(a))return;let o=this.#e.getSubpackageByIdOrLocator(a);if(o==null){this.taskContext.logger.error(`Subpackage ${a} not found in ${this.apiDefinitionId}`);return}let c=pWr(o)?r.apply(o):r,f=this.#A(a,c,n);f.length>0&&i.push({id:fl.V1.NodeId(`${this.apiDefinitionId}:${a}`),type:"apiPackage",children:f,title:pWr(o)?o.displayName??ooo(o.name):this.apiSection.title,slug:c.get(),icon:void 0,hidden:this.hideChildren,overviewPageId:void 0,availability:n,apiDefinitionId:this.apiDefinitionId,pointsTo:void 0,noindex:void 0,playground:void 0,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}),i=this.mergeEndpointPairs(i),this.apiSection.alphabetized&&(i=i.sort((a,o)=>{let c=a.type==="endpointPair"?a.nonStream.title:a.title,f=o.type==="endpointPair"?o.nonStream.title:o.title;return c.localeCompare(f)})),i}#A(t,r,n){let i=t!=null?this.#e.resolveSubpackage(this.#e.getSubpackageByIdOrLocator(t)):void 0;return i==null?(this.taskContext.logger.debug(Q9u(t||"unknown",[])),[]):this.#O(i,r,n)}#v(t){return xmv(t)}mergeEndpointPairs(t){return U9u({children:t,findEndpointById:r=>this.#e.endpoints.get(r),stringifyEndpointPathParts:r=>VPe(r.path.parts),disableEndpointPairs:this.disableEndpointPairs,apiDefinitionId:this.apiDefinitionId})}getFileId(t){let r=this.collectedFileIds.get(t);return r??this.taskContext.failAndThrow("Failed to locate file after uploading: "+t)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}};var Ymv=$i(require("crypto"),1);function jYI(e){return Ymv.default.createHash("sha256").update(e).digest("hex")}var W9u=class e{static init(){return new e}constructor(){}#e=new Map;#t=new Set;#r(t){let r=this.#e.get(t)??0;return this.#e.set(t,r+1),jYI(r===0?t:`${t}-${r}`)}#n(t){let r=this.#r(t),n=0;for(;this.#t.has(r);)if(r=this.#r(t),n++,n>100)throw new Error(`Infinite loop detected for id: ${t}`);return r}get(t){return fl.V1.NodeId(this.#n(t))}};function Xmv(e){return e==null?{}:{pythonSdk:e.python!=null?{package:typeof e.python=="string"?e.python:e.python.package,version:typeof e.python=="string"?void 0:e.python.version}:void 0,typescriptSdk:e.typescript!=null?{package:typeof e.typescript=="string"?e.typescript:e.typescript.package,version:typeof e.typescript=="string"?void 0:e.typescript.version}:void 0,goSdk:e.go!=null?{githubRepo:typeof e.go=="string"?e.go:e.go.package,version:typeof e.go=="string"?void 0:e.go.version}:void 0,javaSdk:e.java!=null?{coordinate:typeof e.java=="string"?e.java:e.java.package,version:typeof e.java=="string"?void 0:e.java.version}:void 0,rubySdk:e.ruby!=null?{gem:typeof e.ruby=="string"?e.ruby:e.ruby.package,version:typeof e.ruby=="string"?void 0:e.ruby.version}:void 0,csharpSdk:e.csharp!=null?{package:typeof e.csharp=="string"?e.csharp:e.csharp.package,version:typeof e.csharp=="string"?void 0:e.csharp.version}:void 0,phpSdk:e.php!=null?{package:typeof e.php=="string"?e.php:e.php.package,version:typeof e.php=="string"?void 0:e.php.version}:void 0,swiftSdk:e.swift!=null?{package:typeof e.swift=="string"?e.swift:e.swift.package,version:typeof e.swift=="string"?void 0:e.swift.version}:void 0,rustSdk:e.rust!=null?{package:typeof e.rust=="string"?e.rust:e.rust.package,version:typeof e.rust=="string"?void 0:e.rust.version}:void 0}}function Zmv({auth:e,playgroundConfig:t,context:r}){if(e.schemes.length>0&&e.schemes[0]!=null){let n=e.schemes[0];return kmv({scheme:n,playgroundConfig:t,context:r})}}function kmv({scheme:e,playgroundConfig:t,context:r}){switch(e.type){case"basic":return{type:"basicAuth",passwordName:e.password.originalName,usernameName:e.username.originalName,description:e.docs};case"bearer":return{type:"bearerAuth",tokenName:e.token.originalName,description:e.docs};case"header":return{type:"header",headerWireValue:e.name.wireValue,nameOverride:e.name.name.originalName,prefix:e.prefix,description:e.docs};case"oauth":{let n=e.configuration.tokenEndpoint.responseProperties.accessToken.propertyPath?.map(i=>i.name.originalName).join(".")||"$.body.access_token";return t?.oauth?{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:Xh.EndpointId(e.configuration.tokenEndpoint.endpointReference.endpointId),accessTokenLocator:Xh.JqString(n),headerName:e.configuration.tokenHeader,tokenPrefix:e.configuration.tokenPrefix,description:e.docs}}}:{type:"bearerAuth",tokenName:"token",description:e.docs}}case"inferred":{e.tokenEndpoint.authenticatedRequestHeaders.length>1&&r.logger.warn("Inferred auth scheme has multiple authenticated request headers. Only the `Authentication` or first header will be pushed to FDR.");let n=e.tokenEndpoint.authenticatedRequestHeaders.find(a=>a.headerName.toLowerCase()==="authorization");if(n)return n.responseProperty.propertyPath!=null&&n.responseProperty.propertyPath.length>0&&r.logger.warn("Inferred Authentication header has a property path. The property wirevalue will be pushed to FDR without property path."),{type:"bearerAuth",tokenName:n.responseProperty.property.name.wireValue,description:e.docs};let i=e.tokenEndpoint.authenticatedRequestHeaders[0];return i?{type:"header",headerWireValue:i.headerName,prefix:i.valuePrefix,nameOverride:void 0,description:e.docs}:{type:"bearerAuth",tokenName:"token",description:e.docs}}default:ku(e)}}function eOv({auth:e,playgroundConfig:t,context:r}){let n={};for(let i of e.schemes){let a=kmv({scheme:i,playgroundConfig:t,context:r});a!=null&&(n[Xh.AuthSchemeId(i.key)]=a)}return n}function rOv(e){return e._visit({alias:t=>({type:"alias",value:a4(t.aliasOf)}),enum:t=>({type:"enum",default:t.default!=null?t.default.name.wireValue:void 0,values:t.values.map(r=>({description:r.docs??void 0,value:r.name.wireValue,availability:lie(r.availability)}))}),object:t=>({type:"object",extends:t.extends.map(r=>Xh.TypeId(r.typeId)),properties:t.properties.map(r=>({description:r.docs??void 0,key:Xh.PropertyKey(r.name.wireValue),valueType:a4(r.valueType),availability:lie(r.availability),propertyAccess:r.propertyAccess})),extraProperties:DYI(t.extraProperties)}),union:t=>{let r=t.baseProperties.map(n=>({key:Xh.PropertyKey(n.name.wireValue),valueType:a4(n.valueType),availability:lie(n.availability),description:n.docs,propertyAccess:n.propertyAccess}));return{type:"discriminatedUnion",discriminant:t.discriminant.wireValue,variants:t.types.map(n=>({description:n.docs??void 0,discriminantValue:n.discriminantValue.wireValue,displayName:n.displayName,availability:n.availability!=null?lie(n.availability):void 0,additionalProperties:np.types.SingleUnionTypeProperties._visit(n.shape,{samePropertiesAsObject:i=>({extends:[Xh.TypeId(i.typeId)],properties:r,extraProperties:void 0}),singleProperty:i=>({extends:[],properties:[{key:Xh.PropertyKey(i.name.wireValue),valueType:a4(i.type),description:void 0,availability:void 0,propertyAccess:void 0},...r],extraProperties:void 0}),noProperties:()=>({extends:[],properties:r,extraProperties:void 0}),_other:()=>{throw new Error("Unknown SingleUnionTypeProperties: "+n.shape.propertiesType)}})}))}},undiscriminatedUnion:t=>({type:"undiscriminatedUnion",variants:t.members.map(r=>({typeName:r.type.type==="named"?r.type.name.originalName:void 0,description:r.docs??void 0,type:a4(r.type),availability:void 0,displayName:r.type.type==="named"?r.type.displayName:void 0}))}),_other:()=>{throw new Error("Unknown Type shape: "+e.type)}})}function a4(e){return e._visit({container:t=>np.types.ContainerType._visit(t,{list:r=>({type:"list",itemType:a4(r)}),map:({keyType:r,valueType:n})=>({type:"map",keyType:a4(r),valueType:a4(n)}),optional:r=>({type:"optional",itemType:a4(r),defaultValue:void 0}),nullable:r=>({type:"nullable",itemType:a4(r)}),set:r=>({type:"set",itemType:a4(r)}),literal:r=>np.types.Literal._visit(r,{boolean:n=>({type:"literal",value:{type:"booleanLiteral",value:n}}),string:n=>({type:"literal",value:{type:"stringLiteral",value:n}}),_other:()=>{throw new Error("Unknown literal type: "+r.type)}}),_other:()=>{throw new Error("Unknown container reference: "+t.type)}}),named:t=>({type:"id",value:Xh.TypeId(t.typeId),default:void 0}),primitive:t=>({type:"primitive",value:np.types.PrimitiveTypeV1._visit(t.v1,{integer:()=>SYI(t.v2),float:()=>tOv(t.v2),double:()=>tOv(t.v2),string:()=>EYI(t.v2),long:()=>({type:"long",default:t.v2?.type==="long"?t.v2.default:void 0,minimum:void 0,maximum:void 0}),boolean:()=>({type:"boolean",default:t.v2?.type==="boolean"?t.v2.default:void 0}),dateTime:()=>({type:"datetime",default:void 0}),date:()=>({type:"date",default:void 0}),uuid:()=>({type:"uuid",default:void 0}),base64:()=>({type:"base64",mimeType:void 0,default:void 0}),bigInteger:()=>({type:"bigInteger",default:t.v2?.type==="bigInteger"?t.v2.default:void 0}),uint:()=>({type:"uint"}),uint64:()=>({type:"uint64"}),_other:()=>{throw new Error("Unknown primitive: "+t.v1)}})}),unknown:()=>({type:"unknown"}),_other:()=>{throw new Error("Unknown Type reference: "+e.type)}})}function EYI(e){let t=e!=null&&e.type==="string"?e.validation:void 0;return{type:"string",format:t?.format,regex:t?.pattern,minLength:t?.minLength,maxLength:t?.maxLength,default:e!=null&&e.type==="string"?e.default:void 0}}function SYI(e){let t=e!=null&&e.type==="integer"?e.validation:void 0;return{type:"integer",minimum:t?.min,maximum:t?.max,default:e!=null&&e.type==="integer"?e.default:void 0}}function tOv(e){let t=e!=null&&e.type==="double"?e.validation:void 0;return{type:"double",minimum:t?.min,maximum:t?.max,default:e!=null&&e.type==="double"?e.default:void 0}}function DYI(e){return typeof e=="boolean"?e?Bh.unknown():void 0:typeof e=="string"?{type:"id",value:Xh.TypeId(e),default:void 0}:a4(e)}function Y9f(e,t){let r=e.service!=null?t.services[e.service]:void 0,n=e.webhooks!=null?t.webhookGroups[e.webhooks]:void 0,i=e.websocket!=null&&t.websocketChannels!=null?t.websocketChannels[e.websocket]:void 0;return{endpoints:r!=null?IYI(r,t):[],webhooks:n!=null?CYI(n):[],websockets:i!=null?[MYI(i,t)]:[],types:e.types.map(a=>Xh.TypeId(a)),subpackages:e.subpackages.map(a=>Xh.api.v1.SubpackageId(a)),pointsTo:e.navigationConfig!=null?Xh.api.v1.SubpackageId(e.navigationConfig.pointsTo):void 0}}function CYI(e){return e.map(t=>{let r=[];return t.v2Examples!=null?(r.push(...Object.values(t.v2Examples.userSpecifiedExamples)),r.push(...Object.values(t.v2Examples.autogeneratedExamples))):r.push(...t.examples?.map(n=>({payload:n.payload.jsonExample}))??[]),{description:t.docs??void 0,id:Xh.WebhookId(t.name.originalName),path:[],method:t.method,name:t.displayName??tia(t.name.originalName),headers:t.headers.map(n=>({description:n.docs??void 0,key:n.name.wireValue,type:a4(n.valueType),availability:lie(n.availability)})),payload:QYI(t.payload),examples:r}})}function IYI(e,t){let r=[];for(let n of e.endpoints){let i=n.autogeneratedExamples[0],a=[];if(n.v2Examples!=null){let c,f=n.v2Examples.userSpecifiedExamples,u=n.v2Examples.autogeneratedExamples,s=Object.values(f).map(m=>m.response?.statusCode).filter((m,O,P)=>P.indexOf(m)!==O).length>0;for(let[m,O]of Object.entries(f))c=aOv({shouldUseExampleName:s,exampleName:O.displayName??m,example:O,irEndpoint:n,irService:e,ir:t}),c!=null&&a.push(c);let l=Object.values(u).map(m=>m.response?.statusCode).filter((m,O,P)=>P.indexOf(m)!==O).length>0;for(let[m,O]of Object.entries(u))c=aOv({shouldUseExampleName:l,exampleName:O.displayName??m,example:O,irEndpoint:n,irService:e,ir:t}),c!=null&&a.push(c)}else if(n.userSpecifiedExamples.length>0)a.push(...n.userSpecifiedExamples.map(c=>$9f({userSpecifiedExample:c,...i!=null&&{autogeneratedExample:i},irEndpoint:n,ir:t})).filter(hj));else if(i!=null){let c=$9f({autogeneratedExample:i,irEndpoint:n,ir:t});c!=null&&a.push(c)}else if(n.response?.body?.type==="fileDownload"){let c=hro({ir:t,service:e,endpoint:{...n,response:void 0},typeDeclarations:t.types,skipOptionalRequestProperties:!0,generationResponse:{type:"success"}});if(c.type==="success"){let f=$9f({autogeneratedExample:c,irEndpoint:n,ir:t});if(f!=null){let u={...f,responseBodyV3:{type:"filename",value:"<bytes>"}};a.push(u)}}}let o={slug:void 0,availability:lie(n.availability??e.availability),auth:n.auth,authV2:BYI(n.security),multiAuth:TYI(n.security),description:n.docs??void 0,method:FYI(n.method),defaultEnvironment:t.environments?.defaultEnvironment!=null?Xh.EnvironmentId(t.environments.defaultEnvironment):void 0,environments:t.environments!=null?qYI({environmentsConfig:t.environments,endpoint:n}):void 0,id:Xh.EndpointId(n.name.originalName),originalEndpointId:n.id,name:n.displayName??tia(n.name.originalName),path:n.basePath!=null?{pathParameters:n.pathParameters.map(c=>({description:c.docs??void 0,key:Xh.PropertyKey(c.name.originalName),type:a4(c.valueType),availability:void 0,explode:void 0})),parts:[...coo(n.basePath),...coo(n.path)]}:{pathParameters:[...t.pathParameters,...e.pathParameters,...n.pathParameters].map(c=>({description:c.docs??void 0,key:Xh.PropertyKey(c.name.originalName),type:a4(c.valueType),availability:void 0,explode:void 0})),parts:[...t.basePath!=null?coo(t.basePath):[],...coo(e.basePath),...coo(n.path)]},queryParameters:n.queryParameters.map(c=>({description:c.docs??void 0,key:c.name.wireValue,type:a4(c.valueType),availability:lie(c.availability),explode:void 0})),headers:[...e.headers,...n.headers].map(c=>({description:c.docs??void 0,key:c.name.wireValue,type:a4(c.valueType),availability:lie(c.availability)})),request:n.requestBody!=null?nOv(n.requestBody):void 0,requestsV2:{requests:n.v2RequestBodies?.requestBodies?.map(nOv).filter(hj)},response:n.response!=null?iOv(n.response):void 0,responsesV2:{responses:n.v2Responses?.responses?.map(iOv).filter(hj)},errors:void 0,errorsV2:xYI(n.errors,t),examples:a,protocol:n.source?._visit({openapi:()=>({type:"rest"}),openrpc:()=>({type:"openrpc",methodName:n.id}),proto:c=>({type:"grpc",methodName:n.id,methodType:c.methodType}),_other:()=>{}}),includeInApiExplorer:void 0};r.push(o)}return r}function MYI(e,t){let r=[];if(e.v2Examples!=null&&(Object.keys(e.v2Examples.userSpecifiedExamples).length>0||Object.keys(e.v2Examples.autogeneratedExamples).length>0)){let n=Object.values(e.v2Examples.userSpecifiedExamples),i=Object.values(e.v2Examples.autogeneratedExamples),a=n.length>0?n[0]:i[0];a!=null&&r.push({name:"",description:"",path:a.baseUrl??"",pathParameters:a.pathParameters??{},queryParameters:a.queryParameters??{},headers:a.headers??{},messages:a.messages?.map(o=>({type:Xh.api.v1.WebSocketMessageId(o.type),body:o.body}))??[]})}else r=e.examples.map(n=>({name:n.name?.originalName,description:n.docs,path:n.url,pathParameters:n.pathParameters.reduce((i,a)=>(i[Xh.PropertyKey(a.name.originalName)]=a.value.jsonExample,i),{}),queryParameters:n.queryParameters.reduce((i,a)=>(i[a.name.wireValue]=a.value.jsonExample,i),{}),headers:n.headers.reduce((i,a)=>(i[a.name.wireValue]=a.value.jsonExample,i),{}),messages:n.messages.map(i=>({type:Xh.api.v1.WebSocketMessageId(i.type),body:i.body.jsonExample}))}));return{auth:e.auth,availability:lie(e.availability),description:e.docs??void 0,defaultEnvironment:t.environments?.defaultEnvironment!=null?Xh.EnvironmentId(t.environments.defaultEnvironment):void 0,environments:t.environments!=null?RYI({environmentsConfig:t.environments,channel:e}):[],id:Xh.WebSocketId(e.name.originalName),name:e.displayName??tia(e.name.originalName),path:{pathParameters:e.pathParameters.map(n=>({description:n.docs??void 0,key:Xh.PropertyKey(n.name.originalName),type:a4(n.valueType),availability:void 0,explode:void 0})),parts:coo(e.path)},headers:e.headers.map(n=>({key:n.name.wireValue,type:a4(n.valueType),description:n.docs,availability:lie(n.availability)})),queryParameters:e.queryParameters.map(n=>({description:n.docs??void 0,key:n.name.wireValue,type:a4(n.valueType),availability:lie(n.availability),explode:void 0})),messages:e.messages.map(n=>({type:Xh.api.v1.WebSocketMessageId(n.type),displayName:n.displayName,origin:n.origin,body:LYI(n.body),description:n.docs,availability:lie(n.availability)})),examples:r}}function BYI(e){if(e==null)return;if(e.length===0)return[];let t=new Set(e.flatMap(r=>Object.keys(r)));return Array.from(t).map(r=>Xh.AuthSchemeId(r))}function TYI(e){if(e!=null)return e.length===0?[]:e.map(t=>({schemes:Object.keys(t).map(r=>Xh.AuthSchemeId(r))}))}function lie(e){if(e!=null)switch(e.status){case"DEPRECATED":return Xh.Availability.Deprecated;case"PRE_RELEASE":return Xh.Availability.Beta;case"GENERAL_AVAILABILITY":return Xh.Availability.GenerallyAvailable;case"IN_DEVELOPMENT":return Xh.Availability.Beta;default:ku(e.status)}}function qYI({environmentsConfig:e,endpoint:t}){let r=e.environments,n=t.baseUrl,i=t.v2BaseUrls;switch(r.type){case"singleBaseUrl":return r.environments.map(a=>({id:Xh.EnvironmentId(a.id),baseUrl:a.url}));case"multipleBaseUrls":if(i!=null)return i.flatMap(o=>r.environments.map(c=>{let f=c.urls[o];if(f==null)throw new Error(`Encountered undefined server name "${o}" at endpoint ${t.method.toUpperCase()} ${t.path}. Expected environment ${c.id} to contain url for ${o}`);return{id:Xh.EnvironmentId(o),baseUrl:f}})).filter((o,c,f)=>c===f.findIndex(u=>u.id===o.id&&u.baseUrl===o.baseUrl));if(n==null)throw new Error(`Expected endpoint ${t.name.originalName} to have base url.`);return r.environments.map(a=>{let o=a.urls[n];if(o==null)throw new Error(`Encountered undefined server name "${n}" at endpoint ${t.method.toUpperCase()} ${t.path.head}. Expected environment ${a.id} to contain url for ${n}`);return{id:Xh.EnvironmentId(a.id),baseUrl:o}});default:ku(r)}}function RYI({environmentsConfig:e,channel:t}){let r=e.environments,n=t.baseUrl;switch(r.type){case"singleBaseUrl":return r.environments.map(i=>({id:Xh.EnvironmentId(i.id),baseUrl:NYI(i.url,"wss")}));case"multipleBaseUrls":if(n==null)throw new Error(`Expected channel ${t.name.originalName} to have base url.`);return r.environments.map(i=>{let a=i.urls[n];if(a==null)throw new Error(`Encountered undefined server name ${a} at channel ${t.name.originalName} ${t.path.head}. Expected environment ${i.id} to contain url for ${n}`);return{id:Xh.EnvironmentId(i.id),baseUrl:a}});default:ku(r)}}function NYI(e,t){return e.replace(/^[^:]+/,t)}function FYI(e){return np.http.HttpMethod._visit(e,{get:()=>Xh.HttpMethod.Get,post:()=>Xh.HttpMethod.Post,put:()=>Xh.HttpMethod.Put,patch:()=>Xh.HttpMethod.Patch,delete:()=>Xh.HttpMethod.Delete,head:()=>Xh.HttpMethod.Head,_other:()=>{throw new Error("Unknown http method: "+e)}})}function coo(e){let t=e.parts.flatMap(r=>[{type:"pathParameter",value:Xh.PropertyKey(r.pathParameter)},{type:"literal",value:r.tail}]);return[{type:"literal",value:e.head},...t]}function nOv(e){let t=np.http.HttpRequestBody._visit(e,{inlinedRequestBody:r=>({type:"json",contentType:r.contentType??T8.APPLICATION_JSON,shape:{type:"object",extends:r.extends.map(n=>Xh.TypeId(n.typeId)),properties:r.properties.map(n=>({description:n.docs??void 0,key:Xh.PropertyKey(n.name.wireValue),valueType:a4(n.valueType),availability:lie(n.availability),propertyAccess:n.propertyAccess})),extraProperties:r.extraProperties?{type:"unknown"}:void 0}}),reference:r=>({type:"json",contentType:r.contentType??T8.APPLICATION_JSON,shape:{type:"reference",value:a4(r.requestBodyType)},description:r.docs??void 0}),fileUpload:r=>({type:"fileUpload",value:{name:r.name.originalName,description:void 0,availability:void 0,properties:r.properties.map(n=>n._visit({file:i=>{let a=i._visit({file:o=>({type:"file",key:Xh.PropertyKey(o.key.wireValue),isOptional:o.isOptional,contentType:o.contentType,description:o.docs??void 0,availability:void 0}),fileArray:o=>({type:"fileArray",key:Xh.PropertyKey(o.key.wireValue),isOptional:o.isOptional,contentType:o.contentType,description:o.docs??void 0,availability:void 0}),_other:()=>{}});if(a!=null)return{type:"file",value:a}},bodyProperty:i=>({type:"bodyProperty",key:Xh.PropertyKey(i.name.wireValue),valueType:a4(i.valueType),contentType:i.contentType,description:i.docs??void 0,availability:lie(i.availability),exploded:i.style==="exploded",propertyAccess:void 0}),_other:()=>{}})).filter(hj)},contentType:r.contentType,description:r.docs??void 0}),bytes:r=>({type:"bytes",description:r.docs??void 0,availability:void 0,isOptional:r.isOptional,contentType:r.contentType}),_other:()=>{throw new Error("Unknown HttpRequestBody: "+e.type)}});return t!=null?{type:t,description:e.docs}:void 0}function iOv(e){if(e.body==null)return;let t,r=np.http.HttpResponseBody._visit(e.body,{fileDownload:n=>(t=n.docs,{type:"fileDownload",contentType:void 0}),json:n=>(t=n.docs,{type:"reference",value:a4(n.responseBodyType)}),text:()=>{},bytes:()=>{},streamParameter:()=>{},streaming:n=>{if(n.type==="text")return t=n.docs,{type:"streamingText"};if(n.type==="json")return t=n.docs,{type:"stream",shape:{type:"reference",value:a4(n.payload)},terminator:n.terminator};if(n.type==="sse")return t=n.docs,{type:"stream",shape:{type:"reference",value:a4(n.payload)},terminator:n.terminator}},_other:()=>{throw new Error("Unknown HttpResponse: "+e.body)}});return r!=null?{type:r,statusCode:e.statusCode,description:t}:e.statusCode!=null?{statusCode:e.statusCode,description:t,type:{type:"object",extends:[],properties:[],extraProperties:void 0}}:void 0}function xYI(e,t){let r=[];if(t.errorDiscriminationStrategy.type==="statusCode")for(let n of e){let i=t.errors[n.error.errorId];i&&r.push({type:i.type==null?void 0:{type:"alias",value:a4(i.type)},statusCode:i.statusCode,description:i.docs??void 0,name:i.displayName??i.name.name.originalName,availability:void 0,examples:UYI(i)})}else for(let n of e){let i=t.errors[n.error.errorId];if(i){let a=[{key:Xh.PropertyKey(t.errorDiscriminationStrategy.discriminant.wireValue),valueType:{type:"literal",value:{type:"stringLiteral",value:i.discriminantValue.name.originalName}},description:i.docs,availability:void 0,propertyAccess:void 0}];i.type!=null&&a.push({key:Xh.PropertyKey(t.errorDiscriminationStrategy.contentProperty.wireValue),valueType:a4(i.type),description:i.docs,availability:void 0,propertyAccess:void 0}),r.push({type:i.type==null?void 0:{type:"object",extends:[],properties:a,extraProperties:void 0},statusCode:i.statusCode,description:i.docs??void 0,availability:void 0,name:i.displayName??i.name.name.originalName,examples:i.examples.map(o=>({name:o.name?.originalName,responseBody:{type:"json",value:o.jsonExample},description:o.docs}))})}}return r}function aOv({shouldUseExampleName:e,exampleName:t,example:r,irEndpoint:n,irService:i,ir:a}){if(r==null)return;let o=u=>{if(u.valueType.type==="container"&&u.valueType.container.type==="literal")return u.valueType.container.literal._visit({boolean:s=>`${s}`,string:s=>s,_other:()=>{}});if(u.valueType.type==="container"&&u.valueType.container.type==="optional"&&u.valueType.container.optional.type==="container"&&u.valueType.container.optional.container.type==="literal")return u.valueType.container.optional.container.literal._visit({boolean:s=>`${s}`,string:s=>s,_other:()=>{}})},c={};a.headers.forEach(u=>{let s=o(u);s!=null&&(c[u.name.wireValue]=s)}),i.headers.forEach(u=>{let s=o(u);s!=null&&(c[u.name.wireValue]=s)}),n.headers.forEach(u=>{let s=o(u);s!=null&&(c[u.name.wireValue]=s)});let f=r.response?.body!=null?r.response.body.value:void 0;return{name:e?t:void 0,description:"",path:r.request?.endpoint.path??"",pathParameters:r.request?.pathParameters??{},queryParameters:r.request?.queryParameters??{},headers:(()=>{let s={...r.request?.headers??{}};for(let[l,m]of Object.entries(c))(s[l]===null||s[l]===void 0)&&(s[l]=m);return s})(),requestBody:r.request?.requestBody,requestBodyV3:n.requestBody?._visit({inlinedRequestBody:()=>r.request!=null?{type:"json",value:r.request.requestBody}:void 0,reference:()=>r.request!=null?{type:"json",value:r.request.requestBody}:void 0,fileUpload:u=>{if(r.request==null)return;let s={};if(zD(r.request.requestBody)){let l=r.request.requestBody;for(let m of u.properties)m._visit({file:O=>{let P=l[O.key.wireValue];if(O.type==="file")s[O.key.wireValue]={type:"filename",value:typeof P=="string"?P:"<file1>"};else if(O.type==="fileArray"){let C=(Array.isArray(P)?P:[P]).filter(I=>typeof I=="string");s[O.key.wireValue]={type:"filenames",value:C}}},bodyProperty:O=>{if(O.style==="exploded"){let P=l[O.name.wireValue];s[O.name.wireValue]={type:"exploded",value:Array.isArray(P)?P:[P]}}else s[O.name.wireValue]={type:"json",value:l[O.name.wireValue]}},_other:wdt})}return{type:"form",value:s}},bytes:()=>{},_other:()=>{}}),responseStatusCode:r.response?.statusCode??n.response?.statusCode??200,responseBody:f??void 0,responseBodyV3:f!=null?r.response?.body?._visit({json:u=>({type:"json",value:u}),stream:u=>Array.isArray(u)&&u.length>0&&u.every(zYI)?{type:"sse",value:u}:{type:"stream",value:u},error:()=>{},_other:()=>{throw new Error("Unknown ExampleResponseBody: "+r.response?.body?.type)}}):void 0,codeSamples:r.codeSamples?.map(u=>({name:u.name,description:u.docs??void 0,install:void 0,language:u.language,code:u.code})).filter(hj)}}function zYI(e){return typeof e=="object"&&e!==null&&"event"in e&&typeof e?.event=="string"&&"data"in e}function $9f({userSpecifiedExample:e,autogeneratedExample:t,irEndpoint:r,ir:n}){let i=n.headers.map(c=>{let f;if(c.valueType.type==="container"&&c.valueType.container.type==="literal"?f=c.valueType.container.literal._visit({boolean:u=>`${u}`,string:u=>u,_other:()=>{}}):c.valueType.type==="container"&&c.valueType.container.type==="optional"&&c.valueType.container.optional.type==="container"&&c.valueType.container.optional.container.type==="literal"&&(f=c.valueType.container.optional.container.literal._visit({boolean:u=>`${u}`,string:u=>u,_other:()=>{}})),f!=null)return{name:c.name,value:{jsonExample:f,shape:np.ExampleTypeReferenceShape.primitive(np.ExamplePrimitive.string({original:f}))}}}).filter(hj),a=e?.example??t?.example;if(a==null)return;let{codeSamples:o}=e??{codeSamples:[]};return{name:a.name?.originalName,description:a.docs,path:a.url,pathParameters:[...a.rootPathParameters,...a.servicePathParameters,...a.endpointPathParameters].reduce((c,f)=>(c[Xh.PropertyKey(f.name.originalName)]=f.value.jsonExample,c),{}),queryParameters:a.queryParameters.reduce((c,f)=>(c[f.name.wireValue]=f.value.jsonExample,c),{}),headers:[...i,...a.serviceHeaders,...a.endpointHeaders].reduce((c,f)=>(c[f.name.wireValue]=f.value.jsonExample,c),{}),requestBody:a.request?.jsonExample,requestBodyV3:r.requestBody?._visit({inlinedRequestBody:()=>a.request!=null?{type:"json",value:a.request.jsonExample}:void 0,reference:()=>a.request!=null?{type:"json",value:a.request.jsonExample}:void 0,fileUpload:c=>{if(a.request==null)return;let f={};if(zD(a.request.jsonExample)){let u=a.request.jsonExample;for(let s of c.properties)s._visit({file:l=>{let m=u[l.key.wireValue];if(l.type==="file")f[l.key.wireValue]={type:"filename",value:typeof m=="string"?m:"<file1>"};else if(l.type==="fileArray"){let O=(Array.isArray(m)?m:[m]).filter(P=>typeof P=="string");f[l.key.wireValue]={type:"filenames",value:O}}},bodyProperty:l=>{if(l.style==="exploded"){let m=u[l.name.wireValue];f[l.name.wireValue]={type:"exploded",value:Array.isArray(m)?m:[m]}}else f[l.name.wireValue]={type:"json",value:u[l.name.wireValue]}},_other:wdt})}return{type:"form",value:f}},bytes:()=>{},_other:()=>{}}),responseStatusCode:r.response?.statusCode??np.http.ExampleResponse._visit(a.response,{ok:c=>c._visit({body:f=>f!=null?200:204,stream:f=>f.length>0?200:204,sse:f=>f.length>0?200:204,_other:()=>{throw new Error("Unknown ExampleResponseBody: "+c.type)}}),error:({error:c})=>{let f=n.errors[c.errorId];if(f==null)throw new Error("Cannot find error "+c.errorId);return f.statusCode},_other:()=>{throw new Error("Unknown ExampleResponse: "+a.response.type)}}),responseBody:a.response._visit({ok:c=>c._visit({body:f=>f?.jsonExample,stream:()=>{},sse:()=>{},_other:()=>{}}),error:c=>c.body?.jsonExample,_other:()=>{}}),responseBodyV3:a.response._visit({ok:c=>c._visit({body:f=>f!=null?{type:"json",value:f.jsonExample}:void 0,stream:f=>({type:"stream",value:f.map(u=>u.jsonExample)}),sse:f=>({type:"sse",value:f.map(({event:u,data:s})=>({event:u,data:s.jsonExample}))}),_other:()=>{throw new Error("Unknown ExampleResponseBody: "+c.type)}}),error:c=>c.body!=null?{type:"json",value:c.body.jsonExample}:void 0,_other:()=>{throw new Error("Unknown ExampleResponse: "+a.response.type)}}),codeSamples:o?.map(c=>wrt._visit(c,{language:f=>({language:f.language,code:f.code,name:f.name?.originalName,description:f.docs??void 0,install:f.install}),sdk:f=>({language:f.sdk,code:f.code,name:f.name?.originalName,description:f.docs??void 0,install:void 0}),_other:()=>{}})).filter(hj)}}function QYI(e){switch(e.type){case"inlinedPayload":return{type:{type:"object",extends:e.extends.map(t=>Xh.TypeId(t.typeId)),properties:e.properties.map(t=>({description:t.docs??void 0,key:Xh.PropertyKey(t.name.wireValue),valueType:a4(t.valueType),availability:lie(t.availability),propertyAccess:void 0})),extraProperties:void 0},description:void 0};case"reference":return{type:{type:"reference",value:a4(e.payloadType)},description:e.docs};default:ku(e)}}function LYI(e){switch(e.type){case"inlinedBody":return{type:"object",extends:e.extends.map(t=>Xh.TypeId(t.typeId)),properties:e.properties.map(t=>({description:t.docs??void 0,key:Xh.PropertyKey(t.name.wireValue),valueType:a4(t.valueType),availability:lie(t.availability),propertyAccess:void 0})),extraProperties:void 0};case"reference":return{type:"reference",value:a4(e.bodyType)};default:ku(e)}}function UYI(e){let t=e.v2Examples?.userSpecifiedExamples,r=e.v2Examples?.autogeneratedExamples,n=e.examples;return t!=null&&Object.keys(t).length>0?Object.entries(t).map(([i,a])=>({name:i,responseBody:{type:"json",value:a},description:void 0})):r!=null&&Object.keys(r).length>0?Object.entries(r).map(([i,a])=>({name:i,responseBody:{type:"json",value:a},description:void 0})):n.length>0?n.map(i=>({name:i.name?.originalName,responseBody:{type:"json",value:i.jsonExample},description:i.docs})):[]}function LCe({ir:e,snippetsConfig:t,playgroundConfig:r,context:n}){let i={types:{},subpackages:{},rootPackage:Y9f(e.rootPackage,e),auth:Zmv({auth:e.auth,playgroundConfig:r,context:n}),authSchemes:eOv({auth:e.auth,playgroundConfig:r,context:n}),snippetsConfiguration:t,globalHeaders:e.headers.map(a=>({availability:lie(a.availability),description:a.docs??void 0,key:a.name.wireValue,type:a4(a.valueType)})),navigation:void 0};for(let[a,o]of Object.entries(e.types))i.types[Xh.TypeId(a)]={description:o.docs??void 0,name:o.name.name.originalName,shape:rOv(o.shape),availability:lie(o.availability),displayName:o.name.displayName};for(let[a,o]of Object.entries(e.subpackages)){let c=o.service!=null?e.services[o.service]:void 0;i.subpackages[Xh.api.v1.SubpackageId(a)]={subpackageId:Xh.api.v1.SubpackageId(a),displayName:c?.displayName??o.displayName,name:o.name.originalName,description:o.docs??void 0,...Y9f(o,e)}}return i}async function X9f({organization:e,workspace:t,context:r,token:n,audiences:i,snippetsConfig:a,playgroundConfig:o}){let c=xG({workspace:t,audiences:i,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1},readme:void 0,version:void 0,packageName:void 0,context:r,sourceResolver:new FG(r,t)}),f=Ksa({token:n.value}),u=LCe({ir:c,snippetsConfig:a,playgroundConfig:o,context:r}),s=await f.api.v1.register.registerApiDefinition({orgId:Xh.OrgId(e),apiId:Xh.ApiId(c.apiName.originalName),definition:u});if(s.ok)return r.logger.debug(`Registered API Definition ${s.body.apiDefinitionId}`),{id:s.body.apiDefinitionId,ir:c};switch(s.error.error){case"UnauthorizedError":case"UserNotInOrgError":return r.failAndThrow("You do not have permissions to register the docs. Reach out to support@buildwithfern.com");default:return r.failAndThrow("Failed to register API",s.error)}}var VYI=new afu({snippetsBySdkId:{},snippetsConfigWithSdkId:{},snippetTemplatesByEndpoint:{},snippetsBySdkIdAndEndpointId:{},snippetTemplatesByEndpointId:{}});function bns({ir:e,apiDefinitionId:t,playgroundConfig:r,context:n}){return ofu(nfu(LCe({ir:e,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},playgroundConfig:r,context:n}),gve.ApiDefinitionId(t),VYI))}var oOv=$i(require("path"),1);async function eyt({iconPath:e,filepaths:t}){e!=null&&typeof e=="string"&&oOv.default.isAbsolute(e)&&t.add(e)}async function sOv({parsedDocsConfig:e}){let t=new Set;return e.logo?.dark!=null&&t.add(e.logo.dark),e.logo?.light!=null&&t.add(e.logo.light),e.favicon!=null&&t.add(e.favicon),e.backgroundImage?.dark!=null&&t.add(e.backgroundImage.dark),e.backgroundImage?.light!=null&&t.add(e.backgroundImage.light),e.metadata?.["og:image"]!=null&&e.metadata["og:image"].type==="filepath"&&t.add(e.metadata["og:image"].value),e.metadata?.["og:logo"]!=null&&e.metadata["og:logo"].type==="filepath"&&t.add(e.metadata["og:logo"].value),e.metadata?.["twitter:image"]!=null&&e.metadata["twitter:image"].type==="filepath"&&t.add(e.metadata["twitter:image"].value),e.typography?.bodyFont!=null&&e.typography.bodyFont.variants.forEach(n=>{t.add(n.absolutePath)}),e.typography?.headingsFont!=null&&e.typography.headingsFont.variants.forEach(n=>{t.add(n.absolutePath)}),e.typography?.codeFont!=null&&e.typography.codeFont.variants.forEach(n=>{t.add(n.absolutePath)}),e.navigation.type==="productgroup"&&e.navigation.products.forEach(n=>{n.image!=null&&t.add(n.image)}),(await Z9f({navigation:e.navigation})).forEach(n=>{t.add(n)}),e.navbarLinks&&await Promise.all(e.navbarLinks.map(async n=>{n.type==="dropdown"&&n.links.map(async i=>{i.icon&&await eyt({iconPath:i.icon,filepaths:t}),i.rightIcon&&await eyt({iconPath:i.rightIcon,filepaths:t})}),n.type!=="github"&&(n.icon&&await eyt({iconPath:n.icon,filepaths:t}),n.rightIcon&&await eyt({iconPath:n.rightIcon,filepaths:t}))})),e.js!=null&&e.js.files.forEach(n=>{t.add(n.absolutePath)}),t}async function Z9f({navigation:e}){let t=new Set;switch(e.type){case"untabbed":await Promise.all(e.items.map(r=>loo({item:r,filepaths:t})));break;case"tabbed":await Promise.all(e.items.map(async r=>{r.icon!=null&&await eyt({iconPath:r.icon,filepaths:t}),r.child.type==="layout"&&r.child.layout!=null?await Promise.all(r.child.layout.map(n=>loo({item:n,filepaths:t}))):r.child.type==="variants"&&r.child.variants!=null&&await Promise.all(r.child.variants.flatMap(n=>{let i=[];return n.icon!=null&&i.push(eyt({iconPath:n.icon,filepaths:t})),i.push(...n.layout.map(a=>loo({item:a,filepaths:t}))),i}))}));break;case"versioned":await Promise.all(e.versions.map(async r=>{r.landingPage!=null&&await loo({item:r.landingPage,filepaths:t}),(await Z9f({navigation:r.navigation})).forEach(i=>t.add(i))}));break;case"productgroup":await Promise.all(e.products.map(async r=>{r.icon!=null&&await eyt({iconPath:r.icon,filepaths:t}),r.type==="internal"&&(r.landingPage!=null&&await loo({item:r.landingPage,filepaths:t}),(await Z9f({navigation:r.navigation})).forEach(i=>t.add(i)))}));break}return t}async function loo({item:e,filepaths:t}){switch(e.type){case"page":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break;case"section":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t}),await Promise.all(e.contents.map(r=>loo({item:r,filepaths:t})));break;case"apiSection":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break;case"link":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break;case"changelog":e.icon!=null&&await eyt({iconPath:e.icon,filepaths:t});break}}async function uOv({navigation:e,apiWorkspaces:t,visitor:r,context:n}){GYI(e)?await Promise.all(e.map(async i=>{HYI(i)?await Promise.all(i.layout.map(async a=>{await G9u({navigationItem:a,visitor:r,apiWorkspaces:t,context:n})})):JYI(i)&&await Promise.all(i.variants.flatMap(a=>a.layout.map(async o=>{await G9u({navigationItem:o,visitor:r,apiWorkspaces:t,context:n})})))})):await Promise.all(e.map(async i=>{await G9u({navigationItem:i,visitor:r,apiWorkspaces:t,context:n})}))}async function G9u({navigationItem:e,visitor:t,apiWorkspaces:r,context:n}){if(await P2r(e,{alphabetized:Tc,api:Tc,apiName:Tc,audiences:Tc,displayErrors:Tc,snippets:Tc,summary:Tc,title:Tc,layout:Tc,collapsed:Tc,icon:Tc,slug:Tc,hidden:Tc,skipSlug:Tc,paginated:Tc,playground:Tc,flattened:Tc,path:Tc,page:Tc,featureFlag:Tc,openrpc:Tc,postman:Tc,contents:async i=>{i!=null&&await Promise.all(i.map(async a=>{await G9u({navigationItem:a,visitor:t,apiWorkspaces:r,context:n})}))},viewers:Tc,orphaned:Tc,availability:Tc}),WYI(e)){let i=r.find(a=>a.workspaceName===e.apiName);i!=null&&await t.apiSection?.({config:e,workspace:i,context:n})}}function WYI(e){return e.api!=null}function GYI(e){return e[0]?.tab!=null}function HYI(e){return"layout"in e&&Array.isArray(e.layout)}function JYI(e){return"variants"in e&&Array.isArray(e.variants)}function Qse(e){return e.startsWith("https://")||e.startsWith("http://")?e:`https://${e}`}lOv.default.extend(fOv.default);var KYI=e=>e.map(t=>({...t,fileId:String(t.relativeFilePath)})),cOv=0,$YI=async({ir:e})=>(cOv++,`${e.apiName.snakeCase.unsafeName}-${cOv}`),Hqr=class{domain;docsWorkspace;ossWorkspaces;apiWorkspaces;taskContext;editThisPage;uploadFiles;registerApi;targetAudiences;constructor({domain:t,docsWorkspace:r,ossWorkspaces:n,apiWorkspaces:i,taskContext:a,editThisPage:o,uploadFiles:c=KYI,registerApi:f=$YI,targetAudiences:u}){this.domain=t,this.docsWorkspace=r,this.ossWorkspaces=n,this.apiWorkspaces=i,this.taskContext=a,this.editThisPage=o,this.uploadFiles=c,this.registerApi=f,this.targetAudiences=u}#e=W9u.init();shouldIncludeByAudience(t){return!t||t.length===0||!this.targetAudiences||this.targetAudiences.length===0?!0:t.some(r=>this.targetAudiences?.includes(r))}applyAudienceFiltering(t){let r=this.filterNavigationByAudience(t.navigation);return{...t,navigation:r}}filterNavigationByAudience(t){return t.type==="untabbed"||t.type==="tabbed"?t:t.type==="versioned"?{...t,versions:t.versions.filter(r=>this.shouldIncludeByAudience(this.getRawVersionAudiences(r.version)))}:t.type==="productgroup"?{...t,products:t.products.filter(r=>{let n=this.getRawProductAudiences(r.product);return this.shouldIncludeByAudience(n)})}:t}getRawProductAudiences(t){let n=this.docsWorkspace.config.products?.find(i=>i.displayName===t);return sHo(n?.audiences)}getRawVersionAudiences(t){let n=this.docsWorkspace.config.versions?.find(i=>i.displayName===t);return sHo(n?.audiences)}_parsedDocsConfig;get parsedDocsConfig(){if(this._parsedDocsConfig==null)throw new Error("parsedDocsConfig is not set");return this._parsedDocsConfig}collectedFileIds=new Map;markdownFilesToFullSlugs=new Map;markdownFilesToNoIndex=new Map;markdownFilesToTags=new Map;rawMarkdownFiles={};async resolve(){this._parsedDocsConfig=await muf({rawDocsConfiguration:this.docsWorkspace.config,context:this.taskContext,absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absoluteFilepathToDocsConfig:this.docsWorkspace.absoluteFilepathToDocsConfig}),this.targetAudiences&&this.targetAudiences.length>0&&(this._parsedDocsConfig=this.applyAudienceFiltering(this._parsedDocsConfig));for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.rawMarkdownFiles[ru.of(l)]=m;let t=this.parsedDocsConfig.experimental?.openapiParserV3,r=t!=null&&!t;this.docsWorkspace.config.navigation!=null&&r&&await uOv({navigation:this.docsWorkspace.config.navigation,visitor:{apiSection:async({workspace:l})=>{(await l.toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,preserveSchemaIds:!0,objectQueryParameters:!0,respectReadonlySchemas:!0})).changelog?.files.forEach(O=>{let P=A3(this.docsWorkspace.absoluteFilePath,O.absoluteFilepath);this.parsedDocsConfig.pages[P]=O.contents,this.rawMarkdownFiles[ru.of(P)]=O.contents})}},apiWorkspaces:this.apiWorkspaces,context:this.taskContext}),this.markdownFilesToFullSlugs=await this.getMarkdownFilesToFullSlugs(this.parsedDocsConfig.pages),this.markdownFilesToNoIndex=await this.getMarkdownFilesToNoIndex(this.parsedDocsConfig.pages),this.markdownFilesToTags=await this.getMarkdownFilesToTags(this.parsedDocsConfig.pages);for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.parsedDocsConfig.pages[ru.of(l)]=await E9f({markdown:m,absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absolutePathToMarkdownFile:this.resolveFilepath(l),context:this.taskContext});for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.parsedDocsConfig.pages[ru.of(l)]=await j9f({markdown:m,absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath,absolutePathToMarkdownFile:this.resolveFilepath(l),context:this.taskContext});let n=await sOv({parsedDocsConfig:this.parsedDocsConfig});for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))try{let{filepaths:O,markdown:P}=gda(m,{absolutePathToMarkdownFile:this.resolveFilepath(l),absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath});this.parsedDocsConfig.pages[ru.of(l)]=P;for(let C of O)n.add(C)}catch(O){throw this.taskContext.logger.error(`Failed to parse ${l}: ${O instanceof Error?O.message:String(O)}`),O}let i=Array.from(n).map(l=>({absoluteFilePath:l,relativeFilePath:this.toRelativeFilepath(l)}));(await this.uploadFiles(i)).forEach(l=>{this.collectedFileIds.set(l.absoluteFilePath,l.fileId)});let o=await this.toRootNode(),c=await this.getMarkdownFilesToFullyQualifiedPathNames(o);for(let[l,m]of Object.entries(this.parsedDocsConfig.pages))this.parsedDocsConfig.pages[ru.of(l)]=w9f(m,this.collectedFileIds,c,{absolutePathToMarkdownFile:this.resolveFilepath(l),absolutePathToFernFolder:this.docsWorkspace.absoluteFilePath},this.taskContext);let f={};Object.entries(this.parsedDocsConfig.pages).forEach(([l,m])=>{let O=YYI(this.editThisPage,l),P=this.rawMarkdownFiles[ru.of(l)];f[UDe.PageId(l)]={markdown:m,editThisPageUrl:O?UDe.Url(O):void 0,rawMarkdown:P}});let u=await this.convertDocsConfiguration(o),s={};if(this._parsedDocsConfig.experimental?.mdxComponents!=null){let l=new Set;await Promise.all(this._parsedDocsConfig.experimental.mdxComponents.map(async m=>{let O=p1(this.docsWorkspace.absoluteFilePath,m);(await(0,J9u.stat)(O)).isDirectory()?(await sve(O,"{js,ts,jsx,tsx,md,mdx}")).forEach(I=>{l.add(I)}):O.match(/\.(js|ts|jsx|tsx|md|mdx)$/)!=null&&l.add(O)})),s=Object.fromEntries(await Promise.all([...l].map(async m=>{let O=this.toRelativeFilepath(m),P=(await(0,J9u.readFile)(m)).toString();return[O,P]})))}return{config:u,pages:f,jsFiles:s}}resolveFilepath(t){if(t!=null)return p1(this.docsWorkspace.absoluteFilePath,t)}toRelativeFilepath(t){if(t!=null)return A3(this.docsWorkspace.absoluteFilePath,t)}async getMarkdownFilesToFullSlugs(t){let r=new Map;for(let[n,i]of Object.entries(t)){let o=(0,H9u.default)(i).data.slug;typeof o=="string"&&o.trim().length>0&&r.set(this.resolveFilepath(n),o.trim())}return r}async getMarkdownFilesToNoIndex(t){let r=new Map;for(let[n,i]of Object.entries(t)){let o=(0,H9u.default)(i).data.noindex;typeof o=="boolean"&&r.set(this.resolveFilepath(n),o)}return r}async getMarkdownFilesToTags(t){let r=new Map;for(let[n,i]of Object.entries(t)){let o=(0,H9u.default)(i).data.tags;typeof o=="string"?r.set(this.resolveFilepath(n),o.split(",").map(c=>c.trim()).filter(c=>c.length>0)):Array.isArray(o)&&r.set(this.resolveFilepath(n),o)}return r}async getMarkdownFilesToFullyQualifiedPathNames(t){let r={},n=fl.migrate.FernNavigationV1ToLatest.create().root(t);return fl.NodeCollector.collect(n).slugMap.forEach((a,o)=>{if(a==null||!fl.isPage(a))return;let c=fl.getPageId(a);if(c==null)return;let f=Ql(this.docsWorkspace.absoluteFilePath,ru.of(c));r[f]=o}),r}getDocsBasePath(){return new URL(Qse(this.domain)).pathname}async convertDocsConfiguration(t){return{aiChatConfig:this.parsedDocsConfig.aiChatConfig!=null?{model:this.parsedDocsConfig.aiChatConfig.model,systemPrompt:this.parsedDocsConfig.aiChatConfig.systemPrompt,location:this.parsedDocsConfig.aiChatConfig.location,datasources:this.parsedDocsConfig.aiChatConfig.datasources?.map(n=>({url:n.url,title:n.title}))}:void 0,hideNavLinks:void 0,title:this.parsedDocsConfig.title,logoHeight:this.parsedDocsConfig.logo?.height,logoHref:this.parsedDocsConfig.logo?.href?UDe.Url(this.parsedDocsConfig.logo?.href):void 0,favicon:this.getFileId(this.parsedDocsConfig.favicon),navigation:void 0,root:t,colorsV3:this.convertColorConfigImageReferences(),navbarLinks:this.parsedDocsConfig.navbarLinks?.map(n=>n.type==="dropdown"?{...n,links:n.links?.map(i=>({...i,url:UDe.Url(i.url),icon:this.resolveIconFileId(i.icon),rightIcon:this.resolveIconFileId(i.rightIcon)})),icon:this.resolveIconFileId(n.icon),rightIcon:this.resolveIconFileId(n.rightIcon)}:n.type==="github"?{...n,url:UDe.Url(n.url)}:{...n,url:UDe.Url(n.url),icon:this.resolveIconFileId(n.icon),rightIcon:this.resolveIconFileId(n.rightIcon)}),typographyV2:this.convertDocsTypographyConfiguration(),layout:this.parsedDocsConfig.layout,settings:this.parsedDocsConfig.settings,css:this.parsedDocsConfig.css,js:this.convertJavascriptConfiguration(),metadata:this.convertMetadata(),redirects:this.parsedDocsConfig.redirects,integrations:this.parsedDocsConfig.integrations,footerLinks:this.parsedDocsConfig.footerLinks?.map(n=>({...n,value:UDe.Url(n.value)})),defaultLanguage:this.parsedDocsConfig.defaultLanguage,languages:this.parsedDocsConfig.languages,analyticsConfig:{...this.parsedDocsConfig.analyticsConfig,segment:this.parsedDocsConfig.analyticsConfig?.segment,fullstory:this.parsedDocsConfig.analyticsConfig?.fullstory,intercom:this.parsedDocsConfig.analyticsConfig?.intercom?{appId:this.parsedDocsConfig.analyticsConfig.intercom.appId,apiBase:this.parsedDocsConfig.analyticsConfig.intercom.apiBase}:void 0,posthog:this.parsedDocsConfig.analyticsConfig?.posthog?{apiKey:this.parsedDocsConfig.analyticsConfig.posthog.apiKey,endpoint:this.parsedDocsConfig.analyticsConfig.posthog.endpoint}:void 0,gtm:this.parsedDocsConfig.analyticsConfig?.gtm?{containerId:this.parsedDocsConfig.analyticsConfig.gtm.containerId}:void 0,ga4:this.parsedDocsConfig.analyticsConfig?.ga4?{measurementId:this.parsedDocsConfig.analyticsConfig.ga4.measurementId}:void 0,amplitude:void 0,mixpanel:void 0,hotjar:void 0,koala:void 0,logrocket:void 0,pirsch:void 0,plausible:void 0,fathom:void 0,clearbit:void 0,heap:void 0},announcement:this.parsedDocsConfig.announcement!=null?{text:this.parsedDocsConfig.announcement.message}:void 0,pageActions:this.parsedDocsConfig.pageActions,theme:this.parsedDocsConfig.theme!=null?{sidebar:this.parsedDocsConfig.theme.sidebar,body:this.parsedDocsConfig.theme.body,tabs:this.parsedDocsConfig.theme.tabs,"page-actions":this.parsedDocsConfig.theme.pageActions}:void 0,logo:void 0,logoV2:void 0,colors:void 0,colorsV2:void 0,typography:void 0,backgroundImage:void 0}}getFernWorkspaceForApiSection(t){if(t.apiName!=null){let n=this.apiWorkspaces.find(i=>i.workspaceName===t.apiName);if(n!=null)return n}else if(this.apiWorkspaces.length===1&&this.apiWorkspaces[0]!=null)return this.apiWorkspaces[0];let r=t.apiName?`Failed to load API Definition '${t.apiName}' referenced in docs.
|
|
3033
|
+
A valid API configuration was not found at the path: fern/apis/${t.apiName}.
|
|
3034
|
+
Learn more about project structure:
|
|
3035
|
+
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`:`Failed to load API Definition referenced in docs.
|
|
3036
|
+
Learn more about project structure:
|
|
3037
|
+
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}getOpenApiWorkspaceForApiSection(t){if(t.apiName!=null){let n=this.ossWorkspaces.find(i=>i.workspaceName===t.apiName);if(n!=null)return n}else if(this.ossWorkspaces.length===1&&this.ossWorkspaces[0]!=null)return this.ossWorkspaces[0];let r=t.apiName?`Failed to load API Definition '${t.apiName}' referenced in docs.
|
|
3038
|
+
A valid API configuration was not found at the path: fern/apis/${t.apiName}.
|
|
3039
|
+
Learn more about project structure:
|
|
3040
|
+
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`:`Failed to load API Definition referenced in docs.
|
|
3041
|
+
Learn more about project structure:
|
|
3042
|
+
https://buildwithfern.com/learn/docs/getting-started/project-structure#api-definitions`;throw new Error(r)}async toRootNode(){let t=fl.V1.SlugGenerator.init(fl.slugjoin(this.getDocsBasePath())),r=this.#e.get("root"),n=await this.toRootChild(t);return{type:"root",version:"v1",id:r,child:n,slug:t.get(),title:this.parsedDocsConfig.title??"Documentation",hidden:!1,icon:void 0,pointsTo:void 0,authed:void 0,viewers:void 0,orphaned:void 0,roles:this.parsedDocsConfig.roles?.map(i=>fl.RoleId(i)),featureFlags:void 0}}async toRootChild(t){return pia(this.parsedDocsConfig.navigation)._visit({untabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),tabbed:r=>this.toUnversionedNode({landingPage:this.parsedDocsConfig.landingPage,navigationConfig:r,parentSlug:t}),versioned:r=>this.toVersionedNode(r,t),productgroup:r=>this.toProductGroupNode({landingPageConfig:this.parsedDocsConfig.landingPage,productGroup:r,parentSlug:t})})}toLandingPageNode(t,r){let n=fl.PageId(this.toRelativeFilepath(t.absolutePath)),i=r.apply({urlSlug:t.slug??s$(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{type:"landingPage",id:this.#e.get(n),title:t.title,slug:i.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:n,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags}}async toUnversionedNode({landingPage:t,navigationConfig:r,parentSlug:n}){let i=this.#e.get("unversioned"),a=t!=null?this.toLandingPageNode(t,n):void 0,o=r.type==="tabbed"?await this.convertTabbedNavigation(i,r.items,n):await this.toSidebarRootNode(i,r.items,n);return{type:"unversioned",id:i,landingPage:a,child:o}}async toVersionedNode(t,r){return{id:this.#e.get("versioned"),type:"versioned",children:await Promise.all(t.versions.map((i,a)=>this.toVersionNode(i,r,a===0)))}}async toProductGroupNode({productGroup:t,landingPageConfig:r,parentSlug:n}){let i=this.#e.get("productgroup"),a=r!=null?this.toLandingPageNode(r,n):void 0;return{id:i,type:"productgroup",landingPage:a,children:await Promise.all(t.products.map(o=>this.toProductNode(o,n)))}}async toProductNode(t,r){if(t.type==="internal"){let n=r.setProductSlug(t.slug??s$(t.product)),i;switch(t.navigation.type){case"tabbed":i={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.convertTabbedNavigation(this.#e.get(t.product),t.navigation.items,n)};break;case"untabbed":i={type:"unversioned",id:this.#e.get(t.product),landingPage:void 0,child:await this.toSidebarRootNode(this.#e.get(t.product),t.navigation.items,n)};break;case"versioned":i=await this.toVersionedNode(t.navigation,n);break;default:ku(t.navigation)}return{type:"product",id:this.#e.get(t.product),productId:fl.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",slug:n.get(),child:i,default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,pointsTo:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags}}else return{type:"productLink",id:this.#e.get(t.product),productId:fl.V1.ProductId(t.product),title:t.product,subtitle:t.subtitle??"",href:UDe.Url(t.href??""),default:!1,hidden:void 0,authed:void 0,icon:this.resolveIconFileId(t.icon),image:t.image!=null?this.getFileId(t.image):void 0,viewers:t.viewers,orphaned:t.orphaned}}async toVersionNode(t,r,n){let i=this.#e.get(t.version),a=r.setVersionSlug(t.slug??s$(t.version)),o=t.navigation.type==="tabbed"?await this.convertTabbedNavigation(i,t.navigation.items,a):await this.toSidebarRootNode(i,t.navigation.items,a);return{type:"version",id:i,versionId:fl.VersionId(t.version),title:t.version,slug:a.get(),child:o,default:n,availability:t.availability!=null?XYI(t.availability):void 0,landingPage:t.landingPage?this.toLandingPageNode(t.landingPage,a):void 0,hidden:void 0,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,icon:void 0,pointsTo:void 0,featureFlags:t.featureFlags}}async toSidebarRootNode(t,r,n){let i=this.#e.get(`${t}/root`),a=await Promise.all(r.map(c=>this.toNavigationChild({prefix:i,item:c,parentSlug:n}))),o=[];return a.forEach(c=>{if(c.type==="apiReference"){o.push(c);return}if(c.type==="section"&&!c.collapsed){o.push(c);return}let f=o.length>0?o[o.length-1]:void 0,u;f?.type==="sidebarGroup"?u=f:(u={id:this.#e.get(`${i}/group`),type:"sidebarGroup",children:[]},o.push(u)),u.children.push(c)}),{type:"sidebarRoot",id:i,children:o}}async toSidebarRootNodeWithVariants(t,r,n){let i=this.#e.get(`${t}/root`);return{type:"sidebarRoot",id:i,children:[{type:"varianted",id:i,children:await Promise.all(r.map(a=>this.toVariantNode(a,i,n)))}]}}async toVariantNode(t,r,n){let i=this.#e.get(`${r}/variant/${t.slug??s$(t.title)}`),a=n.apply({urlSlug:t.slug??s$(t.title),skipUrlSlug:t.skipUrlSlug}),o=await Promise.all(t.layout.map(c=>this.toVariantChild(c,i,a)));return{type:"variant",id:i,variantId:fl.V1.VariantId(t.title),subtitle:t.subtitle??"",default:t.default??!1,image:void 0,children:o,title:t.title,slug:a.get(),icon:this.resolveIconFileId(t.icon),hidden:t.hidden,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:t.featureFlags,pointsTo:void 0}}async toVariantChild(t,r,n){return pia(t)._visit({page:async i=>this.toPageNode({item:i,parentSlug:n}),apiSection:async i=>this.toApiSectionNode({item:i,parentSlug:n}),section:async i=>this.toSectionNode({prefix:r,item:i,parentSlug:n}),link:async i=>this.toLinkNode(i),changelog:async i=>this.toChangelogNode(i,n)})}async toNavigationChild({prefix:t,item:r,parentSlug:n,hideChildren:i,parentAvailability:a}){return pia(r)._visit({page:async o=>this.toPageNode({item:o,parentSlug:n,hideChildren:i,parentAvailability:a}),apiSection:async o=>this.toApiSectionNode({item:o,parentSlug:n,hideChildren:i,parentAvailability:a}),section:async o=>this.toSectionNode({prefix:t,item:o,parentSlug:n,hideChildren:i,parentAvailability:a}),link:async o=>this.toLinkNode(o),changelog:async o=>this.toChangelogNode(o,n,i)})}async toApiSectionNode({item:t,parentSlug:r,hideChildren:n,parentAvailability:i}){let a=Xmv(t.snippetsConfiguration),o,c=await this.getFernWorkspaceForApiSection(t).toFernWorkspace({context:this.taskContext},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,objectQueryParameters:!0,preserveSchemaIds:!0}),f=this.parsedDocsConfig.experimental?.openapiParserV3;if(f==null||f)try{o=await this.getOpenApiWorkspaceForApiSection(t).getIntermediateRepresentation({context:this.taskContext,audiences:t.audiences,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1})}catch{}o==null&&(o=xG({workspace:c,audiences:t.audiences,generationLanguage:void 0,keywords:void 0,smartCasing:!1,exampleGeneration:{disabled:!1,skipAutogenerationIfManualExamplesExist:!0,skipErrorAutogenerationIfManualErrorExamplesExist:!0},readme:void 0,version:void 0,packageName:void 0,context:this.taskContext,sourceResolver:new FG(this.taskContext,c)}));let s=await this.registerApi({ir:o,snippetsConfig:a,playgroundConfig:{oauth:t.playground?.oauth},apiName:t.apiName,workspace:c}),l=bns({ir:o,apiDefinitionId:s,playgroundConfig:{oauth:t.playground?.oauth},context:this.taskContext});return new V9u(t,l,r,this.docsWorkspace,this.taskContext,this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,this.#e,this.collectedFileIds,c,n,i??t.availability).get()}async toChangelogNode(t,r,n){return new Eda(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,t.changelog,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:r,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:n||t.hidden,slug:t.slug})}async toLinkNode(t){return{type:"link",id:this.#e.get(t.url),title:t.text,url:fl.V1.Url(t.url),icon:this.resolveIconFileId(t.icon)}}async toPageNode({item:t,parentSlug:r,hideChildren:n,parentAvailability:i}){let a=fl.PageId(this.toRelativeFilepath(t.absolutePath)),o=r.apply({urlSlug:t.slug??s$(t.title),fullSlug:this.markdownFilesToFullSlugs.get(t.absolutePath)?.split("/")});return{id:this.#e.get(a),type:"page",slug:o.get(),title:t.title,icon:this.resolveIconFileId(t.icon),hidden:n||t.hidden,viewers:t.viewers,orphaned:t.orphaned,pageId:a,authed:void 0,noindex:t.noindex||this.markdownFilesToNoIndex.get(t.absolutePath),featureFlags:t.featureFlags,availability:t.availability??i}}async toSectionNode({prefix:t,item:r,parentSlug:n,hideChildren:i,parentAvailability:a}){let o=this.toRelativeFilepath(r.overviewAbsolutePath),c=o?fl.PageId(o):void 0,f=this.#e.get(c??`${t}/section`),u=n.apply({urlSlug:r.slug??s$(r.title),fullSlug:r.overviewAbsolutePath?this.markdownFilesToFullSlugs.get(r.overviewAbsolutePath)?.split("/"):void 0,skipUrlSlug:r.skipUrlSlug}),s=r.overviewAbsolutePath!=null?this.markdownFilesToNoIndex.get(r.overviewAbsolutePath):void 0,l=i||r.hidden;return{id:f,type:"section",overviewPageId:c,slug:u.get(),title:r.title,icon:this.resolveIconFileId(r.icon),collapsed:r.collapsed,hidden:l,viewers:r.viewers,orphaned:r.orphaned,children:await Promise.all(r.contents.map(m=>this.toNavigationChild({prefix:f,item:m,parentSlug:u,hideChildren:l,parentAvailability:r.availability??a}))),authed:void 0,pointsTo:void 0,noindex:s,featureFlags:r.featureFlags,availability:r.availability??a}}async convertTabbedNavigation(t,r,n){let i=this.#e.get(`${t}/tabbed`);return{type:"tabbed",id:i,children:await Promise.all(r.map(a=>this.toTabChild(i,a,n)))}}async toTabChild(t,r,n){return pia(r.child)._visit({link:({href:i})=>this.toTabLinkNode(r,i),layout:({layout:i})=>this.toTabNode(t,r,i,n),changelog:({changelog:i})=>this.toTabChangelogNode(r,i,n),variants:({variants:i})=>this.toTabNodeWithVariants(t,r,i,n)})}async toTabChangelogNode(t,r,n){return new Eda(this.markdownFilesToFullSlugs,this.markdownFilesToNoIndex,this.markdownFilesToTags,r,this.docsWorkspace,this.#e).toChangelogNode({parentSlug:n,title:t.title,icon:this.resolveIconFileId(t.icon),viewers:t.viewers,hidden:t.hidden,slug:t.slug})}async toTabLinkNode(t,r){return{type:"link",id:this.#e.get(r),title:t.title,url:fl.V1.Url(r),icon:this.resolveIconFileId(t.icon)}}async toTabNode(t,r,n,i){let a=this.#e.get(`${t}/tab`),o=i.apply({urlSlug:r.slug??s$(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNode(a,n,o),featureFlags:r.featureFlags}}async toTabNodeWithVariants(t,r,n,i){let a=this.#e.get(`${t}/tab`),o=i.apply({urlSlug:r.slug??s$(r.title),skipUrlSlug:r.skipUrlSlug});return{type:"tab",id:a,title:r.title,slug:o.get(),icon:this.resolveIconFileId(r.icon),hidden:r.hidden,authed:void 0,viewers:r.viewers,orphaned:r.orphaned,pointsTo:void 0,child:await this.toSidebarRootNodeWithVariants(a,n,o),featureFlags:r.featureFlags}}getFileId(t){if(t==null)return;let r=this.collectedFileIds.get(t);return r==null?this.taskContext.failAndThrow("Failed to locate file after uploading: "+t):UDe.FileId(r)}resolveIconFileId(t){if(t!=null)return this.collectedFileIds.has(t)?`file:${this.getFileId(t)}`:t}convertColorConfigImageReferences(){let{colors:t}=this.parsedDocsConfig;if(t!=null)return t.type==="dark"?{...t,...this.convertLogoAndBackgroundImage({theme:"dark"})}:t.type==="light"?{...t,...this.convertLogoAndBackgroundImage({theme:"light"}),type:"light"}:{...t,dark:{...t.dark,...this.convertLogoAndBackgroundImage({theme:"dark"})},light:{...t.light,...this.convertLogoAndBackgroundImage({theme:"light"})}}}convertLogoAndBackgroundImage({theme:t}){let{logo:r,backgroundImage:n}=this.parsedDocsConfig,i=r?.[t],a=n?.[t];return{logo:this.getFileId(i),backgroundImage:this.getFileId(a)}}convertDocsTypographyConfiguration(){if(this.parsedDocsConfig.typography!=null)return{headingsFont:this.convertFont(this.parsedDocsConfig.typography.headingsFont,"headings"),bodyFont:this.convertFont(this.parsedDocsConfig.typography.bodyFont,"body"),codeFont:this.convertFont(this.parsedDocsConfig.typography.codeFont,"code")}}convertFont(t,r){if(t==null||t.variants[0]==null)return;let n=this.getFileId(t.variants[0].absolutePath);return{type:"custom",name:t.name??`font:${r}:${n}`,variants:t.variants.map(i=>({fontFile:this.getFileId(i.absolutePath),weight:i.weight,style:i.style!=null?[i.style]:void 0})),display:t.display,fallback:t.fallback,fontVariationSettings:t.fontVariationSettings}}convertJavascriptConfiguration(){if(this.parsedDocsConfig.js!=null)return{files:this.parsedDocsConfig.js.files.map(({absolutePath:t,strategy:r})=>({fileId:this.getFileId(t),strategy:r})).filter(hj),remote:this.parsedDocsConfig.js.remote?.map(t=>({...t,url:UDe.Url(t.url)})),inline:void 0}}convertMetadata(){if(this.parsedDocsConfig.metadata==null)return;let{"og:image":t,"og:logo":r,"twitter:image":n,...i}=this.parsedDocsConfig.metadata;return{...i,"og:image":this.convertFileIdOrUrl(t),"og:logo":this.convertFileIdOrUrl(r),"twitter:image":this.convertFileIdOrUrl(n)}}convertFileIdOrUrl(t){if(t!=null)return pia(t,"type")._visit({filepath:({value:r})=>({type:"fileId",value:this.getFileId(r)}),url:({value:r})=>({type:"url",value:UDe.Url(r)}),_other:()=>this.taskContext.failAndThrow("Invalid metadata configuration")})}};function YYI(e,t){if(e?.github==null)return;let{owner:r,repo:n,branch:i="main",host:a="https://github.com"}=e.github;return`${Qse(a)}/${r}/${n}/blob/${i}/fern/${t}?plain=1`}function XYI(e){switch(e){case"beta":return fl.V1.NavigationV1Availability.Beta;case"deprecated":return fl.V1.NavigationV1Availability.Deprecated;case"ga":return fl.V1.NavigationV1Availability.GenerallyAvailable;case"stable":return fl.V1.NavigationV1Availability.Stable;default:ku(e)}}async function dbe(e){return(await Promise.all(e.apiWorkspaces.map(async t=>t instanceof E$?t:null))).filter(hj)}async function k9f(e,t,r){if(e instanceof XVr){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof E$))return;let n=await e.getIntermediateRepresentation({context:t,audiences:r,enableUniqueErrorsPerEndpoint:!0,generateV1Examples:!1});return LCe({ir:n,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},playgroundConfig:{oauth:!0},context:t})}var Yj={};yf(Yj,{AlgoliaSearchIndex:()=>dOv,ApiDefinitionId:()=>TOv,ApiId:()=>FOv,Availability:()=>ZOv,DocsConfigId:()=>xOv,EndpointId:()=>QOv,EndpointPathLiteral:()=>YOv,EnvironmentId:()=>zOv,FileId:()=>GOv,HttpMethod:()=>XOv,IndexSegmentId:()=>pOv,JqString:()=>JOv,OrgId:()=>ROv,PageId:()=>WOv,PayloadLocation:()=>jAv,PropertyKey:()=>KOv,PullRequestState:()=>mAv,RoleId:()=>$Ov,TokenId:()=>NOv,TypeId:()=>VOv,Url:()=>HOv,VersionId:()=>qOv,WebSocketId:()=>LOv,WebhookId:()=>UOv,algolia:()=>eUf,api:()=>lUf,commons:()=>fUf,diff:()=>kOv,docs:()=>mUf,generators:()=>AUf,git:()=>PUf,navigation:()=>EUf,sdks:()=>DUf,snippets:()=>PAv,snippetsFactory:()=>wAv,templates:()=>CUf,tokens:()=>EAv});var eUf={};yf(eUf,{AlgoliaSearchIndex:()=>dOv,IndexSegmentId:()=>pOv});function dOv(e){return e}function pOv(e){return e}var lUf={};yf(lUf,{latest:()=>nUf,v1:()=>cUf});var nUf={};yf(nUf,{AuthSchemeId:()=>_Ov,WebhookHttpMethod:()=>bOv,auth:()=>tUf,commons:()=>hOv,endpoint:()=>yOv,type_:()=>vOv,webhook:()=>rUf,websocket:()=>gOv});var tUf={};yf(tUf,{AuthSchemeId:()=>_Ov});function _Ov(e){return e}var hOv={};var yOv={};var vOv={};var rUf={};yf(rUf,{WebhookHttpMethod:()=>bOv});var bOv={Get:"GET",Post:"POST"};var gOv={};var cUf={};yf(cUf,{SubpackageId:()=>COv,WebSocketMessageId:()=>IOv,WebSocketMessageOrigin:()=>MOv,WebhookHttpMethod:()=>BOv,commons:()=>uUf,db:()=>iUf,read:()=>oUf,register:()=>sUf});var iUf={};yf(iUf,{endpoint:()=>mOv});var mOv={};var oUf={};yf(oUf,{SupportedLanguage:()=>OOv,endpoint:()=>aUf,type_:()=>AOv,webhook:()=>POv,websocket:()=>wOv});var aUf={};yf(aUf,{SupportedLanguage:()=>OOv});var OOv={Curl:"curl",Python:"python",Javascript:"javascript",Js:"js",Node:"node",Typescript:"typescript",Ts:"ts",Go:"go",Ruby:"ruby",Csharp:"csharp"};var AOv={};var POv={};var wOv={};var sUf={};yf(sUf,{SourceId:()=>ZYI,endpoint:()=>jOv,type_:()=>EOv,webhook:()=>SOv,websocket:()=>DOv});var jOv={};var EOv={};var SOv={};var DOv={};function ZYI(e){return e}var uUf={};yf(uUf,{SubpackageId:()=>COv,WebSocketMessageId:()=>IOv,WebSocketMessageOrigin:()=>MOv,WebhookHttpMethod:()=>BOv});function COv(e){return e}function IOv(e){return e}var MOv={Client:"client",Server:"server"};var BOv={Get:"GET",Post:"POST"};var fUf={};yf(fUf,{ApiDefinitionId:()=>TOv,ApiId:()=>FOv,Availability:()=>ZOv,DocsConfigId:()=>xOv,EndpointId:()=>QOv,EndpointPathLiteral:()=>YOv,EnvironmentId:()=>zOv,FileId:()=>GOv,HttpMethod:()=>XOv,JqString:()=>JOv,OrgId:()=>ROv,PageId:()=>WOv,PropertyKey:()=>KOv,RoleId:()=>$Ov,TokenId:()=>NOv,TypeId:()=>VOv,Url:()=>HOv,VersionId:()=>qOv,WebSocketId:()=>LOv,WebhookId:()=>UOv});function TOv(e){return e}function qOv(e){return e}function ROv(e){return e}function NOv(e){return e}function FOv(e){return e}function xOv(e){return e}function zOv(e){return e}function QOv(e){return e}function LOv(e){return e}function UOv(e){return e}function VOv(e){return e}function WOv(e){return e}function GOv(e){return e}function HOv(e){return e}function JOv(e){return e}function KOv(e){return e}function $Ov(e){return e}function YOv(e){return e}var XOv={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE"};var ZOv={Stable:"Stable",GenerallyAvailable:"GenerallyAvailable",InDevelopment:"InDevelopment",PreRelease:"PreRelease",Deprecated:"Deprecated",Beta:"Beta"};var kOv={};var mUf={};yf(mUf,{latest:()=>_Uf,v1:()=>bUf,v2:()=>gUf});var _Uf={};yf(_Uf,{Layout:()=>tAv,MdxEngine:()=>kYI,TwitterCardSetting:()=>rAv,commons:()=>eAv,frontmatter:()=>dUf,seo:()=>pUf});var kYI={NextMdxRemote:"next-mdx-remote",MdxBundler:"mdx-bundler"};var eAv={};var dUf={};yf(dUf,{Layout:()=>tAv});var tAv={Guide:"guide",Overview:"overview",Reference:"reference",Page:"page",Custom:"custom"};var pUf={};yf(pUf,{TwitterCardSetting:()=>rAv});var rAv={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var bUf={};yf(bUf,{commons:()=>vUf,db:()=>nAv,read:()=>iAv,write:()=>hUf});var nAv={};var iAv={};var hUf={};yf(hUf,{DocsRegistrationId:()=>tXI,FilePath:()=>eXI});function eXI(e){return e}function tXI(e){return e}var vUf={};yf(vUf,{ContentAlignment:()=>uAv,FontDisplay:()=>pAv,FontStyle:()=>dAv,HeaderPosition:()=>cAv,JsScriptStrategy:()=>fAv,ProgrammingLanguage:()=>aAv,SearchbarPlacement:()=>oAv,TabsPlacement:()=>sAv,TwitterCardSetting:()=>lAv,commons:()=>yUf});var yUf={};yf(yUf,{ContentAlignment:()=>uAv,FontDisplay:()=>pAv,FontStyle:()=>dAv,HeaderPosition:()=>cAv,JsScriptStrategy:()=>fAv,ProgrammingLanguage:()=>aAv,SearchbarPlacement:()=>oAv,TabsPlacement:()=>sAv,TwitterCardSetting:()=>lAv});var aAv={Typescript:"typescript",Javascript:"javascript",Python:"python",Java:"java",Go:"go",Ruby:"ruby",Csharp:"csharp",Nodets:"nodets",Nodejs:"nodejs",Dotnet:"dotnet",Curl:"curl",Jvm:"jvm",Ts:"ts",Js:"js"};var oAv={Header:"HEADER",HeaderTabs:"HEADER_TABS",Sidebar:"SIDEBAR"};var sAv={Header:"HEADER",Sidebar:"SIDEBAR"};var uAv={Center:"CENTER",Left:"LEFT"};var cAv={Fixed:"FIXED",Absolute:"ABSOLUTE"};var lAv={Summary:"summary",SummaryLargeImage:"summary_large_image",App:"app",Player:"player"};var fAv={BeforeInteractive:"beforeInteractive",AfterInteractive:"afterInteractive",LazyOnload:"lazyOnload"};var dAv={Normal:"normal",Italic:"italic"};var pAv={Auto:"auto",Block:"block",Swap:"swap",Fallback:"fallback",Optional:"optional"};var gUf={};yf(gUf,{read:()=>_Av,write:()=>hAv});var _Av={};var hAv={};var AUf={};yf(AUf,{ChangelogEntryType:()=>vAv,GeneratorId:()=>rXI,GeneratorLanguage:()=>nXI,ReleaseType:()=>bAv,cli:()=>yAv,commons:()=>OUf,versions:()=>gAv});var yAv={};var OUf={};yf(OUf,{ChangelogEntryType:()=>vAv,ReleaseType:()=>bAv});var vAv={Fix:"fix",Feat:"feat",Chore:"chore",Break:"break",Internal:"internal"};var bAv={Ga:"GA",Rc:"RC"};var gAv={};function rXI(e){return e}var nXI={Python:"python",Go:"go",Java:"java",Typescript:"typescript",Ruby:"ruby",Csharp:"csharp",Php:"php",Swift:"swift",Rust:"rust"};var PUf={};yf(PUf,{PullRequestState:()=>mAv});var mAv={Open:"open",Closed:"closed",Merged:"merged"};var EUf={};yf(EUf,{latest:()=>wUf,v1:()=>jUf});var wUf={};yf(wUf,{NodeId:()=>oXI,ProductId:()=>sXI,Slug:()=>iXI,TabId:()=>aXI});function iXI(e){return e}function aXI(e){return e}function oXI(e){return e}function sXI(e){return e}var jUf={};yf(jUf,{NavigationV1Availability:()=>dXI,NodeId:()=>lXI,ProductId:()=>fXI,Slug:()=>uXI,TabId:()=>cXI});function uXI(e){return e}function cXI(e){return e}function lXI(e){return e}function fXI(e){return e}var dXI={Stable:"stable",GenerallyAvailable:"generally-available",InDevelopment:"in-development",PreRelease:"pre-release",Beta:"beta",Deprecated:"deprecated"};var DUf={};yf(DUf,{Language:()=>OAv,VersionBump:()=>AAv,versions:()=>SUf});var SUf={};yf(SUf,{Language:()=>OAv,VersionBump:()=>AAv});var OAv={Go:"Go",TypeScript:"TypeScript",Java:"Java",Python:"Python",Csharp:"Csharp",Ruby:"Ruby"};var AAv={Major:"MAJOR",Minor:"MINOR",Patch:"PATCH"};var PAv={};var wAv={};var CUf={};yf(CUf,{PayloadLocation:()=>jAv});var jAv={Body:"BODY",Query:"QUERY",Path:"PATH",Headers:"HEADERS",Relative:"RELATIVE",Auth:"AUTH"};var EAv={};var K9u=class{warnings=[];errors=[];error(t){this.errors.push(t)}warning(t){this.warnings.push(t)}};function OA(e){return e!=null}var DAv=$i(QLo(),1);var SAv=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function _Wr(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,DAv.default)(e,{special:SAv}).replace(/V\s(\d)/g,"V$1")}function CAv({endpoints:e,webhookEndpoints:t}){let r={};return Object.values({...e,...t}).forEach(n=>{let i=[];n.namespace?.forEach(a=>{let o=[...i,a],c=Yj.api.v1.SubpackageId(o.join("."));r[c]={id:c,name:a,displayName:_Wr(a)},i.push(a)})}),r}var $9u=class{input;context;constructor(t,r){this.input=t,this.context=r}errors(){return this.context.errors.errors}warnings(){return this.context.errors.warnings}};function IAv(e){return`#/${e.map(t=>t.replaceAll(/~/g,"~0").replaceAll(/\//g,"~1")).join("/")}`}var UO=class extends $9u{context;accessPath;pathId;constructor({input:t,context:r,accessPath:n,pathId:i}){if(super(t,r),this.context=r,this.accessPath=[...n],this.pathId=i,i!=null){let a=Array.isArray(this.pathId)?this.pathId:[this.pathId];a.every((o,c)=>o===this.accessPath[this.accessPath.length-a.length+c])||this.accessPath.push(...a)}r.logger.debug(`Processing ${IAv(this.accessPath)}`)}safeParse(...t){try{this.parse(...t)}catch{this.context.errors.error({message:"Error converting node. Please contact support if the error persists",path:this.accessPath})}}},Bee=class extends UO{},Kxe=class extends Bee{seenSchemas;constructor(t){super(t),this.seenSchemas=new Set(t.seenSchemas)}};var MAv="x-fern-base-path",BAv="x-fern-availability",Y9u="x-fern-sdk-group-name",TAv="x-fern-global-headers",qAv="x-fern-sdk-method-name";var RAv="x-fern-webhook",NAv="x-fern-access-token-locator",FAv="x-fern-basic",xAv="x-fern-username-variable-name",zAv="x-fern-password-variable-name",QAv="x-fern-bearer",LAv="x-fern-token-variable-name",UAv="x-fern-header",VAv="x-fern-header-variable-name",WAv="x-fern-server-name",GAv="x-fern-examples";var X9u=class extends UO{serverName;constructor(t){super(t),this.safeParse()}parse(){this.serverName=this.input[WAv]}convert(){if(this.serverName!=null)return this.serverName}};var Z9u=class extends UO{url;serverName;constructor(t){super(t),this.safeParse()}parse(){this.url=Object.entries(this.input.variables??{}).reduce((t,[r,n])=>t.replace(`{${r}}`,n.default),this.input.url)??this.input.url,this.serverName=new X9u({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.serverName?.convert()??this.url;if(!(this.url==null||t==null))return{id:Yj.EnvironmentId(t),baseUrl:this.url}}};function L8i(e,t,r,n){let i=e??[],a=new Set(i.map(c=>c.url)),o=(t??[]).filter(c=>!a.has(c.url)).map((c,f)=>new Z9u({input:c,context:r,accessPath:n,pathId:["servers",`${f}`]}));return[...i,...o]}function xx(e){return typeof e=="object"&&OA(e)&&"$ref"in e&&typeof e.$ref=="string"}function pbe(e,t,r){let n=e.$ref.substring(2).split("/").map(a=>a.replace(/~1/g,"/")),i=t;for(let a of n){if(typeof i!="object"||i==null)return r;i=i[a]}return i==null?r:(xx(i)&&(i=pbe(i,t,r)),i)}function k9u(e,t){let r=t.components?.securitySchemes?.[e];if(r!=null)return xx(r)?pbe(r,t,void 0):r}var FPv=$i(AJ());var eUu=class extends UO{username;password;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[FAv];this.username=t?.username,this.password=t?.password}convert(){return{username:this.username,password:this.password}}};var tUu=class extends UO{passwordVariableName;constructor(t){super(t),this.safeParse()}parse(){this.passwordVariableName=this.input[zAv]}convert(){return this.passwordVariableName}};var rUu=class extends UO{usernameVariableName;constructor(t){super(t),this.safeParse()}parse(){this.usernameVariableName=this.input[xAv]}convert(){return this.usernameVariableName}};var nUu=class extends UO{bearerTokenVariableName;bearerTokenEnvVar;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[QAv];this.bearerTokenVariableName=t?.name,this.bearerTokenEnvVar=t?.env}convert(){return{tokenVariableName:this.bearerTokenVariableName,tokenEnvVar:this.bearerTokenEnvVar}}};var iUu=class extends UO{tokenVariableName;constructor(t){super(t),this.safeParse()}parse(){this.tokenVariableName=this.input[LAv]}convert(){return this.tokenVariableName}};function HAv(e){return typeof e=="object"&&e!=null&&"in"in e&&e.in==="header"}var JAv="x-bearer-format",KAv="x-code-samples",$Av="x-codeSamples";var aUu=class extends UO{bearerFormat;constructor(t){super(t),this.safeParse()}parse(){this.bearerFormat=this.input[JAv]}convert(){return this.bearerFormat}};var oUu=class extends UO{headerVariableName;headerEnvVar;headerPrefix;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[UAv];this.headerVariableName=t?.name,this.headerEnvVar=t?.env,this.headerPrefix=t?.prefix}convert(){return{name:this.headerVariableName,env:this.headerEnvVar,prefix:this.headerPrefix}}};var sUu=class extends UO{headerVariableName;constructor(t){super(t),this.safeParse()}parse(){this.headerVariableName=this.input[VAv]}convert(){return this.headerVariableName}};function YAv(e){return e.type==="apiKey"}var foo=class extends UO{headerName;headerBearerFormatNode;headerAuthNode;headerVariableNameNode;constructor(t){super(t),this.safeParse()}parse(){YAv(this.input)&&(this.headerName=this.input.name),this.headerAuthNode=new oUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerVariableNameNode=new sUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.headerBearerFormatNode=new aUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})}convert(){let t=this.headerAuthNode?.convert();if(t!=null)return{type:"header",nameOverride:t?.name,headerWireValue:this.headerName??"Authorization",prefix:t?.prefix??this.headerBearerFormatNode?.convert()}}};function uUu(e){return e}function cUu(e){return e==="__proto__"}function lUu(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function fUu(e){return typeof e=="string"||typeof e=="symbol"?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function dUu(e){let t=[],r=e.length;if(r===0)return t;let n=0,i="",a="",o=!1;for(e.charCodeAt(0)===46&&(t.push(""),n++);n<r;){let c=e[n];a?c==="\\"&&n+1<r?(n++,i+=e[n]):c===a?a="":i+=c:o?c==='"'||c==="'"?a=c:c==="]"?(o=!1,t.push(i),i=""):i+=c:c==="["?(o=!0,i&&(t.push(i),i="")):c==="."?i&&(t.push(i),i=""):i+=c,n++}return i&&t.push(i),t}function gns(e,t,r){if(e==null)return r;switch(typeof t){case"string":{if(cUu(t))return r;let n=e[t];return n===void 0?lUu(t)?gns(e,dUu(t),r):r:n}case"number":case"symbol":{typeof t=="number"&&(t=fUu(t));let n=e[t];return n===void 0?r:n}default:{if(Array.isArray(t))return pXI(e,t,r);if(Object.is(t?.valueOf(),-0)?t="-0":t=String(t),cUu(t))return r;let n=e[t];return n===void 0?r:n}}}function pXI(e,t,r){if(t.length===0)return r;let n=e;for(let i=0;i<t.length;i++){if(n==null||cUu(t[i]))return r;n=n[t[i]]}return n===void 0?r:n}function XAv(e){return function(t){return gns(t,e)}}function ZAv(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function pUu(e){return e==null||typeof e!="object"&&typeof e!="function"}function IUf(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function kAv(e,t,r){return typeof r!="function"?doo(e,t):MUf(e,t,function n(i,a,o,c,f,u){let s=r(i,a,o,c,f,u);return s!==void 0?!!s:MUf(i,a,n,u)},new Map)}function MUf(e,t,r,n){if(t===e)return!0;switch(typeof t){case"object":return _XI(e,t,r,n);case"function":return Object.keys(t).length>0?MUf(e,{...t},r,n):IUf(e,t);default:return ZAv(e)?typeof t=="string"?t==="":!0:IUf(e,t)}}function _XI(e,t,r,n){if(t==null)return!0;if(Array.isArray(t))return ePv(e,t,r,n);if(t instanceof Map)return hXI(e,t,r,n);if(t instanceof Set)return yXI(e,t,r,n);let i=Object.keys(t);if(e==null)return i.length===0;if(i.length===0)return!0;if(n&&n.has(t))return n.get(t)===e;n&&n.set(t,e);try{for(let a=0;a<i.length;a++){let o=i[a];if(!pUu(e)&&!(o in e)||t[o]===void 0&&e[o]!==void 0||t[o]===null&&e[o]!==null||!r(e[o],t[o],o,e,t,n))return!1}return!0}finally{n&&n.delete(t)}}function hXI(e,t,r,n){if(t.size===0)return!0;if(!(e instanceof Map))return!1;for(let[i,a]of t.entries()){let o=e.get(i);if(r(o,a,i,e,t,n)===!1)return!1}return!0}function ePv(e,t,r,n){if(t.length===0)return!0;if(!Array.isArray(e))return!1;let i=new Set;for(let a=0;a<t.length;a++){let o=t[a],c=!1;for(let f=0;f<e.length;f++){if(i.has(f))continue;let u=e[f],s=!1;if(r(u,o,a,e,t,n)&&(s=!0),s){i.add(f),c=!0;break}}if(!c)return!1}return!0}function yXI(e,t,r,n){return t.size===0?!0:e instanceof Set?ePv([...e],[...t],r,n):!1}function doo(e,t){return kAv(e,t,()=>{})}function tPv(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function _Uu(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}var rPv="[object RegExp]",hUu="[object String]",yUu="[object Number]",vUu="[object Boolean]",bUu="[object Arguments]",nPv="[object Symbol]",iPv="[object Date]",aPv="[object Map]",oPv="[object Set]",sPv="[object Array]";var uPv="[object ArrayBuffer]",cPv="[object Object]";var lPv="[object DataView]",fPv="[object Uint8Array]",dPv="[object Uint8ClampedArray]",pPv="[object Uint16Array]",_Pv="[object Uint32Array]";var hPv="[object Int8Array]",yPv="[object Int16Array]",vPv="[object Int32Array]";var bPv="[object Float32Array]",gPv="[object Float64Array]";function mPv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function OPv(e,t){return V8i(e,void 0,e,new Map,t)}function V8i(e,t,r,n=new Map,i=void 0){let a=i?.(e,t,r,n);if(a!==void 0)return a;if(pUu(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){let o=new Array(e.length);n.set(e,o);for(let c=0;c<e.length;c++)o[c]=V8i(e[c],c,r,n,i);return Object.hasOwn(e,"index")&&(o.index=e.index),Object.hasOwn(e,"input")&&(o.input=e.input),o}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let o=new RegExp(e.source,e.flags);return o.lastIndex=e.lastIndex,o}if(e instanceof Map){let o=new Map;n.set(e,o);for(let[c,f]of e)o.set(c,V8i(f,c,r,n,i));return o}if(e instanceof Set){let o=new Set;n.set(e,o);for(let c of e)o.add(V8i(c,void 0,r,n,i));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(mPv(e)){let o=new(Object.getPrototypeOf(e)).constructor(e.length);n.set(e,o);for(let c=0;c<e.length;c++)o[c]=V8i(e[c],c,r,n,i);return o}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){let o=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return n.set(e,o),U8i(o,e,r,n,i),o}if(typeof File<"u"&&e instanceof File){let o=new File([e],e.name,{type:e.type});return n.set(e,o),U8i(o,e,r,n,i),o}if(e instanceof Blob){let o=new Blob([e],{type:e.type});return n.set(e,o),U8i(o,e,r,n,i),o}if(e instanceof Error){let o=new e.constructor;return n.set(e,o),o.message=e.message,o.name=e.name,o.stack=e.stack,o.cause=e.cause,U8i(o,e,r,n,i),o}if(typeof e=="object"&&vXI(e)){let o=Object.create(Object.getPrototypeOf(e));return n.set(e,o),U8i(o,e,r,n,i),o}return e}function U8i(e,t,r=e,n,i){let a=[...Object.keys(t),...tPv(t)];for(let o=0;o<a.length;o++){let c=a[o],f=Object.getOwnPropertyDescriptor(e,c);(f==null||f.writable)&&(e[c]=V8i(t[c],c,r,n,i))}}function vXI(e){switch(_Uu(e)){case bUu:case sPv:case uPv:case lPv:case vUu:case iPv:case bPv:case gPv:case hPv:case yPv:case vPv:case aPv:case yUu:case cPv:case rPv:case oPv:case hUu:case nPv:case fPv:case dPv:case pPv:case _Pv:return!0;default:return!1}}function APv(e){return V8i(e,void 0,e,new Map,void 0)}function PPv(e){return e=APv(e),t=>doo(t,e)}function wPv(e,t){return OPv(e,(r,n,i,a)=>{let o=t?.(r,n,i,a);if(o!==void 0)return o;if(typeof e=="object")switch(Object.prototype.toString.call(e)){case yUu:case hUu:case vUu:{let c=new e.constructor(e?.valueOf());return U8i(c,e),c}case bUu:{let c={};return U8i(c,e),c.length=e.length,c[Symbol.iterator]=e[Symbol.iterator],c}default:return}})}function jPv(e){return wPv(e)}var bXI=/^(?:0|[1-9]\d*)$/;function EPv(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return bXI.test(e)}}function SPv(e){return e!==null&&typeof e=="object"&&_Uu(e)==="[object Arguments]"}function DPv(e,t){let r;if(Array.isArray(t)?r=t:typeof t=="string"&&lUu(t)&&e?.[t]==null?r=dUu(t):r=[t],r.length===0)return!1;let n=e;for(let i=0;i<r.length;i++){let a=r[i];if((n==null||!Object.hasOwn(n,a))&&!((Array.isArray(n)||SPv(n))&&EPv(a)&&a<n.length))return!1;n=n[a]}return!0}function CPv(e,t){switch(typeof e){case"object":{Object.is(e?.valueOf(),-0)&&(e="-0");break}case"number":{e=fUu(e);break}}return t=jPv(t),function(r){let n=gns(r,e);return n===void 0?DPv(r,e):t===void 0?n===void 0:doo(n,t)}}function IPv(e){if(e==null)return uUu;switch(typeof e){case"function":return e;case"object":return Array.isArray(e)&&e.length===2?CPv(e[0],e[1]):PPv(e);case"string":case"symbol":case"number":return XAv(e)}}function BUf(e){if(e==null)return"";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(BUf).join(",");let t=String(e);return t==="0"&&Object.is(Number(e),-0)?"-0":t}function MPv(e,t){let r={},n=Object.keys(e);for(let i=0;i<n.length;i++){let a=n[i],o=e[a];r[a]=t(o,a,e)}return r}function gUu(e,t=uUu){return e==null?{}:MPv(e,IPv(t))}function BPv(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}var gXI=/\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;function TPv(e){return Array.from(e.match(gXI)??[])}function qPv(e){let t=TPv(e);if(t.length===0)return"";let[r,...n]=t;return`${r.toLowerCase()}${n.map(i=>BPv(i)).join("")}`}function RPv(e){return typeof e!="string"&&(e=BUf(e)),e.replace(/['\u2019]/g,"")}function Jqr(e){return qPv(RPv(e))}function TQ(e){if(e!=null)return Array.isArray(e)?e:[e]}function mUu({namespace:e,path:t,method:r,sdkMethodName:n,operationId:i,displayName:a,isWebhook:o}){if(t==null)return;let c=r!=null&&t!=null?`${r}_${t.split("/").join("_")}`:r??t.split("/").join("_");if(!(n==null&&i==null&&a==null&&c==null))return`${mXI(o)}${OXI(e)}.${AXI(n,i,a,c)}`}function mXI(e){return e?"webhook_":"endpoint_"}function OXI(e){return e!=null?TQ(e)?.map(t=>Jqr(t)).join("/"):""}function AXI(e,t,r,n){return e||t||Jqr(r??"")||Jqr(n??"")}function NPv(e){return e.length===0?!1:/^\$?(\.[\w*]+|\[['"][\w*]+['"]?\]|\[['"]?[\d*]+['"]?\]|\[[\d:]+\])*$/.test(e)}var OUu=class extends UO{accessTokenLocator;constructor(t){super(t),this.safeParse()}parse(){this.accessTokenLocator=this.input[NAv],this.accessTokenLocator!=null&&(NPv(this.accessTokenLocator)||(this.context.errors.error({message:"Invalid access token locator, must be a valid jq path",path:this.accessPath}),this.accessTokenLocator=void 0))}convert(){return this.accessTokenLocator}};var AUu=class extends UO{authorizationUrl;headerAuthNode;accessTokenLocatorNode;constructor(t){super(t),this.safeParse()}parse(){if(this.input.flows.clientCredentials!=null){let t=this.input.flows.clientCredentials;this.authorizationUrl=t.tokenUrl,this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.headerAuthNode=new foo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.accessTokenLocatorNode=new OUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.authorizationUrl==null&&this.context.errors.error({message:"Expected 'tokenUrl' property to be specified",path:this.accessPath}),this.accessTokenLocatorNode?.accessTokenLocator==null&&this.context.errors.error({message:"Expected 'x-fern-access-token-locator' property to be specified",path:this.accessPath})}}convert(){let t=this.accessTokenLocatorNode?.convert();if(t==null||this.authorizationUrl==null)return{type:"bearerAuth",tokenName:void 0};let r=mUu({namespace:void 0,path:this.authorizationUrl,method:"POST",sdkMethodName:void 0,operationId:void 0,displayName:void 0,isWebhook:void 0});if(r!=null)return{type:"oAuth",value:{type:"clientCredentials",value:{type:"referencedEndpoint",endpointId:Yj.EndpointId(r),accessTokenLocator:Yj.JqString(t),headerName:this.headerAuthNode?.convert()?.headerWireValue,tokenPrefix:this.headerAuthNode?.convert()?.prefix}}}}};var poo=class extends UO{authScheme;headerAuthNode;bearerTokenNode;bearerTokenVariableNameNode;basicAuthNode;basicUsernameVariableNameNode;basicPasswordVariableNameNode;oauth2Node;constructor(t){super(t),this.safeParse()}parse(){switch(this.input.type){case"http":switch(this.input.scheme){case"basic":{this.authScheme="basic",this.basicAuthNode=new eUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicUsernameVariableNameNode=new rUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.basicPasswordVariableNameNode=new tUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),(this.basicAuthNode==null||this.basicAuthNode.username==null&&this.basicUsernameVariableNameNode?.usernameVariableName==null||this.basicAuthNode.password==null&&this.basicPasswordVariableNameNode?.passwordVariableName==null)&&this.context.errors.warning({message:"Basic auth should specify either a username or a username variable name",path:this.accessPath});break}case"bearer":{this.authScheme="bearer",this.bearerTokenNode=new nUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),this.bearerTokenVariableNameNode=new iUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}default:{this.context.errors.warning({message:`Unsupported HTTP auth scheme: ${this.input.scheme}`,path:this.accessPath});break}}break;case"apiKey":{HAv(this.input)?(this.authScheme="header",this.headerAuthNode=new foo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId})):this.context.errors.error({message:`Unsupported API key location: ${this.input.in}`,path:this.accessPath});break}case"oauth2":{this.authScheme="oauth",this.oauth2Node=new AUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});break}case"openIdConnect":{this.authScheme="bearer";break}}}convert(){switch(this.authScheme){case"basic":{let t=this.basicAuthNode?.convert();return{type:"basicAuth",usernameName:t?.username?.name??this.basicUsernameVariableNameNode?.convert(),passwordName:t?.password?.name??this.basicPasswordVariableNameNode?.convert()}}case"bearer":return{type:"bearerAuth",tokenName:this.bearerTokenNode?.convert()?.tokenVariableName??this.bearerTokenVariableNameNode?.convert()};case"header":return this.headerAuthNode?.convert();case"oauth":return this.oauth2Node?.convert();case void 0:return;default:new FPv.UnreachableCaseError(this.authScheme);return}}};var _oo=class extends UO{authNodesMap;constructor(t){super(t),this.safeParse()}parse(){this.input.map((t,r)=>Object.keys(t).map(n=>{let i=k9u(n,this.context.document);if(i==null){this.context.errors.warning({message:`No auth scheme found for ${n}. Inline security schemes are not supported.`,path:this.accessPath});return}let a=new poo({input:i,context:this.context,accessPath:this.accessPath,pathId:["security",`${r}`]});a.convert()!=null?(this.authNodesMap??={},this.authNodesMap[n]=a):this.context.errors.warning({message:`No auth scheme found for ${n}`,path:this.accessPath})}))}convert(){return Object.fromEntries(Object.entries(this.authNodesMap??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[t,n]}).filter(OA))}};var PUu=class extends UO{basePath;constructor(t){super(t),this.safeParse()}parse(){this.basePath=this.input[MAv],this.basePath!=null?(this.basePath.startsWith("/")&&(this.basePath=this.basePath.slice(1)),this.basePath.endsWith("/")&&(this.basePath=this.basePath.slice(0,-1))):this.basePath=void 0}convert(){return this.basePath}};function xPv(e){return"required"in e&&typeof e.required=="boolean"?e.required:!1}function zPv(e,t){return{type:"alias",value:{type:"optional",shape:e,default:t}}}function hoo(e,t){return e==null?void 0:Object.entries(e).map(([n,i])=>TQ(i.convert())?.map(o=>((t!=null&&!t.includes(n)||t==null&&!xPv(i))&&(o=zPv(o,o.type==="enum"?o.default:void 0)),{key:Yj.PropertyKey(n),valueShape:o,description:i.description,availability:i.availability?.convert()})).filter(OA)).filter(OA).reduce((n,i)=>n.flatMap(a=>i.length>0?i.map(o=>[...a,o]):[[...a]]),[[]])}function wUu(e,t){return xx(e)?pbe(e,t,void 0):e}function W8i(e,t){return e!=null&&e!==""?e:t!=null&&t!==""?t:void 0}function QPv(e,t){let r={...e};for(let[n,i]of Object.entries(t??{}))r[n]=[...r[n]??[],...i];return Object.keys(r).length>0?r:void 0}function LPv(e,t){if(e==null)return t;if(t==null)return e;let r=[];for(let n of e)for(let i of t)r.push({path:n.path??i.path,responseStatusCode:n.responseStatusCode??i.responseStatusCode,name:n.name??i.name,description:n.description??i.description,pathParameters:n.pathParameters??i.pathParameters,queryParameters:n.queryParameters??i.queryParameters,headers:n.headers??i.headers,requestBody:n.requestBody??i.requestBody,responseBody:n.responseBody??i.responseBody,snippets:{...i.snippets,...n.snippets}});return r}var UPv=$i(AJ());var TUf=["decimal","decimal128","double-int","double","float","sf-decimal"],qUf=["int16","int32","int64","int8","sf-integer","uint8"],RUf=["base64url","binary","byte","char","commonmark","date-time","date","decimal","decimal128","duration","email","hostname","html","http-date","idn-email","idn-hostname","int64","ipv4","ipv6","iri-reference","iri","json-pointer","media-range","password","regex","relative-json-pointer","sf-binary","sf-boolean","sf-string","sf-token","time","uri-reference","uri-template","uri","uuid"],NUf=["beta","pre-release","in-development","generally-available","deprecated"];function Tee(e,t){return xx(e)?pbe(e,t,{type:"unknown","x-fern-type":"unknown",additionalProperties:!1}):e}var tyt=class extends UO{availability;constructor(t){super(t),this.safeParse()}parse(){if(Tee(this.input,this.context.document)?.deprecated)this.availability="deprecated";else{let r=this.input[BAv];r!=null&&(NUf.includes(r)?this.availability=r:(this.context.errors.warning({message:`Expected one of: ${NUf.join(", ")}. Received: ${r}`,path:this.accessPath}),this.availability=void 0))}}convert(){switch(this.availability){case"beta":case"pre-release":return Yj.Availability.Beta;case"in-development":return Yj.Availability.InDevelopment;case"generally-available":return Yj.Availability.GenerallyAvailable;case"deprecated":return Yj.Availability.Deprecated;case void 0:return;default:new UPv.UnreachableCaseError(this.availability);return}}};var EUu=$i(AJ());function VPv(e){return typeof e=="object"&&e!=null&&"language"in e}function WPv(e){return typeof e=="object"&&e!=null&&"sdk"in e}function GPv(e){return typeof e=="object"&&e!=null&&("error"in e||"body"in e)}function HPv(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)}function jUu(e){return typeof e=="object"&&e!=null&&"event"in e}function FUf(e){return typeof e=="object"&&e!=null&&"stream"in e&&Array.isArray(e.stream)&&e.stream.every(jUu)}function G8i(e){return typeof e=="object"&&e!=null&&"filename"in e&&"data"in e&&typeof e.filename=="string"&&typeof e.data=="string"}function JPv(e){return typeof e=="object"&&e!=null&&!Array.isArray(e)}var SUu=class extends UO{path;successResponseStatusCode;requestBodyByContentType;responseBodies;examples;constructor(t,r,n,i,a){super(t),this.path=r,this.successResponseStatusCode=n,this.requestBodyByContentType=i,this.responseBodies=a,this.safeParse()}parse(){this.examples=this.input[GAv]}convertFormDataExampleRequest(t,r){if(t.fields!=null)switch(t.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(t.fields).map(([i,a])=>{let o=typeof r=="object"?r[i]:void 0;switch(a.multipartType){case"file":return G8i(o)?[i,{type:"filenameWithData",filename:o.filename,data:Yj.FileId(o.data)}]:o!=null?[i,{type:"filename",value:o}]:void 0;case"files":{if(Array.isArray(o)){if(o.every(c=>G8i(c)))return[i,{type:"filenamesWithData",value:o.map(c=>({filename:c.filename,data:Yj.FileId(c.data)}))}];if(o.every(c=>typeof c=="string"))return[i,{type:"filenames",value:o}]}return}case"property":return[i,{type:"json",value:o}];case void 0:return;default:new EUu.UnreachableCaseError(a.multipartType);return}}).filter(OA))};case"json":return{type:"json",value:r};case"bytes":return typeof r=="string"?{type:"bytes",value:{type:"base64",value:r}}:void 0;default:return}}convert(){if(this.examples==null)return;this.requestBodyByContentType!=null&&Object.keys(this.requestBodyByContentType).length>1&&this.context.logger.warn(`Multiple request bodies found for #/${[this.accessPath,this.pathId,"x-fern-examples"].join("/")}. Coercing to first request body until supported.`);let t=Object.keys(this.requestBodyByContentType??{})[0];return this.examples.flatMap(r=>(this.responseBodies??[]).map(n=>{let i=t!=null?this.requestBodyByContentType?.[t]:void 0,a;if(i!=null)switch(i.contentType){case"form-data":a=JPv(r.request)?this.convertFormDataExampleRequest(i,r.request):void 0;break;case"json":a=r.request!=null?{type:"json",value:r.request}:void 0;break;case"bytes":a=typeof r.request=="string"&&r.request!=null?{type:"bytes",value:{type:"base64",value:r.request}}:void 0;break;case void 0:break;default:new EUu.UnreachableCaseError(i.contentType);break}let o;switch(n.contentType){case"application/json":{GPv(r.response)&&(o={type:"json",value:r.response.body});break}case"text/event-stream":{FUf(r.response)&&(o={type:"sse",value:r.response.stream.map(l=>({event:l.event,data:l.data}))});break}case"application/octet-stream":!FUf(r.response)&&HPv(r.response)&&(o={type:"stream",value:r.response.stream});break;case void 0:break;default:new EUu.UnreachableCaseError(n.contentType);break}let c={};r["code-samples"]?.forEach(l=>{VPv(l)?l.language!=null&&(c[l.language]??=[],c[l.language]?.push({name:l.name,language:l.language,install:l.install,code:l.code,generated:!1,description:l.docs})):WPv(l)&&l.sdk!=null&&(c[l.sdk]??=[],c[l.sdk]?.push({name:l.name,language:l.sdk,install:void 0,code:l.code,generated:!1,description:l.docs}))});let f=Object.fromEntries(Object.entries(r["path-parameters"]??{}).map(([l,m])=>[Yj.PropertyKey(l),m])),u=Object.fromEntries(Object.entries(r["query-parameters"]??{}).map(([l,m])=>[Yj.PropertyKey(l),m])),s=Object.fromEntries(Object.entries(r.headers??{}).map(([l,m])=>[Yj.PropertyKey(l),m]));return{path:this.path,responseStatusCode:this.successResponseStatusCode,name:r.name,description:r.docs,pathParameters:Object.keys(f).length>0?f:void 0,queryParameters:Object.keys(u).length>0?u:void 0,headers:Object.keys(s).length>0?s:void 0,requestBody:a,responseBody:o,snippets:c}}))}};var mns=class extends UO{groupName;constructor(t){super(t),this.safeParse()}parse(){this.groupName=this.input[Y9u]}convert(){if(this.groupName==null)return;let t;return Array.isArray(this.groupName)?t=this.groupName:t=[this.groupName],t.map(r=>Yj.api.v1.SubpackageId(Jqr(r)))}};var DUu=class extends UO{sdkMethodName;constructor(t){super(t),this.safeParse()}parse(){this.sdkMethodName=this.input[qAv]}convert(){return this.sdkMethodName}};var CUu=class extends UO{isWebhook;constructor(t){super(t),this.safeParse()}parse(){this.isWebhook=this.input[RAv]}convert(){return this.isWebhook}};var IUu=class extends UO{codeSamples;constructor(t){super(t),this.safeParse()}parse(){this.codeSamples=[...this.input[KAv]??[],...this.input[$Av]??[]],this.codeSamples.forEach(t=>{[...Object.values(Yj.api.v1.read.SupportedLanguage),"Kotlin","Swift","PHP"].map(r=>r.toLowerCase()).includes(t.lang.toLowerCase())||this.context.errors.warning({message:`Unsupported language: ${t.lang}. This may not render correctly.`,path:this.accessPath})})}convert(){let t={};if(this.codeSamples?.forEach(r=>{t[r.lang.toLowerCase()]??=[],t[r.lang.toLowerCase()]?.push({name:r.label,language:r.lang,code:r.source,install:void 0,generated:!1,description:void 0})}),Object.keys(t).length!==0)return t}};var Sda=$i(AJ());function xUf(e,t){return xx(e)?pbe(e,t,void 0):e}function KPv(e,t){return e.replace(/{(\w+)}/g,(r,n)=>t[n]!=null&&typeof t[n]=="string"||typeof t[n]=="number"||typeof t[n]=="boolean"?`${t[n]}`:r)}var Ade="",hWr=class extends UO{path;responseStatusCode;name;shapes;resolvedRequestInput;resolvedResponseInput;summary;constructor(t,r,n,i,a){super(t),this.path=r,this.responseStatusCode=n,this.name=i,this.shapes=a,this.safeParse()}validateFormDataRequestExample(){return typeof this.resolvedRequestInput?.value!="object"?!1:Object.entries(this.shapes.requestBody?.fields??{}).reduce((t,[r,n])=>{let i=this.resolvedRequestInput?.value[r];switch(n.multipartType){case"file":return t&&(G8i(i)||typeof i=="string");case"files":return t&&Array.isArray(i)&&i.every(a=>G8i(a)||typeof a=="string");case"property":return t;case void 0:return t&&!1;default:return new Sda.UnreachableCaseError(n.multipartType),t}},!0)}parse(){let t=this.shapes.requestBody?.schema?.example({includeOptionals:!1,override:void 0});this.resolvedRequestInput=xUf(this.input?.requestExample,this.context.document)??(t!=null?{value:t}:void 0);let r=this.shapes.responseBody?.schema?.example({includeOptionals:!1,override:void 0});if(this.resolvedResponseInput=xUf(this.input?.responseExample,this.context.document)??(r!=null?{value:r}:void 0),this.summary=this.input?.requestExample?.summary??this.input?.responseExample?.summary,this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody?.contentType){case"json":{if(typeof this.resolvedRequestInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break}case"bytes":{if(typeof this.resolvedRequestInput.value!="string"){this.context.errors.error({message:"Invalid example, expected string for bytes",path:this.accessPath});return}break}case"form-data":{if(!this.validateFormDataRequestExample()){this.context.errors.error({message:"Invalid example, expected valid form-data",path:this.accessPath});return}break}case void 0:break;default:new Sda.UnreachableCaseError(this.shapes.requestBody?.contentType),this.context.errors.error({message:"Invalid example, unsupported content type",path:this.accessPath});return}if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody?.contentType){case"application/json":if(this.resolvedResponseInput!=null&&typeof this.resolvedResponseInput!="object"||this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="object"){this.context.errors.error({message:"Invalid example, expected object for json",path:this.accessPath});return}break;case"text/event-stream":if(this.resolvedResponseInput.value!=null&&!Array.isArray(this.resolvedResponseInput.value)&&!this.resolvedResponseInput.value.every(jUu)){this.context.errors.error({message:"Invalid example, expected array of SSE events for event-stream",path:this.accessPath});return}break;case"application/octet-stream":if(this.resolvedResponseInput.value!=null&&typeof this.resolvedResponseInput.value!="string"&&!Array.isArray(this.resolvedResponseInput.value)){this.context.errors.error({message:"Invalid example, expected string or array for octet-stream",path:this.accessPath});return}break;case void 0:break;default:new Sda.UnreachableCaseError(this.shapes.responseBody?.contentType);return}}convertFormDataExampleRequest(){if(!(this.resolvedRequestInput==null||this.shapes.requestBody?.fields==null))switch(this.shapes.requestBody?.contentType){case"form-data":return{type:"form",value:Object.fromEntries(Object.entries(this.shapes.requestBody.fields).map(([r,n])=>{let i=this.resolvedRequestInput?.value?.[r];switch(n.multipartType){case"file":return G8i(i)?[r,{type:"filenameWithData",filename:i.filename,data:Yj.FileId(i.data)}]:[r,{type:"filename",value:i}];case"files":{if(Array.isArray(i)){if(i.every(a=>G8i(a)))return[r,{type:"filenamesWithData",value:i.map(a=>({filename:a.filename,data:Yj.FileId(a.data)}))}];if(i.every(a=>typeof a=="string"))return[r,{type:"filenames",value:i}]}return}case"property":return[r,{type:"json",value:i}];case void 0:return;default:new Sda.UnreachableCaseError(n.multipartType);return}}).filter(OA))};case"json":return{type:"json",value:this.resolvedRequestInput.value};case"bytes":return typeof this.resolvedRequestInput.value=="string"?{type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}}:void 0;default:return}}convertDescription(){if(this.resolvedRequestInput!=null&&this.resolvedResponseInput!=null)return this.resolvedResponseInput.description;if(this.resolvedRequestInput!=null)return this.resolvedRequestInput.description;if(this.resolvedResponseInput!=null)return this.resolvedResponseInput.description}convert(){let t;if(this.shapes.requestBody!=null&&this.resolvedRequestInput!=null)switch(this.shapes.requestBody.contentType){case"form-data":t=this.convertFormDataExampleRequest();break;case"json":t={type:"json",value:this.resolvedRequestInput.value};break;case"bytes":t={type:"bytes",value:{type:"base64",value:this.resolvedRequestInput.value}};break;case void 0:break;default:new Sda.UnreachableCaseError(this.shapes.requestBody?.contentType);break}let r;if(this.shapes.responseBody!=null&&this.resolvedResponseInput!=null)switch(this.shapes.responseBody.contentType){case"application/json":{r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break}case"text/event-stream":r={type:"sse",value:this.resolvedResponseInput?.value};break;case"application/octet-stream":r={type:typeof this.resolvedResponseInput?.value=="string"?"filename":"stream",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;case void 0:r={type:"json",value:this.resolvedResponseInput?.value??this.resolvedResponseInput};break;default:new Sda.UnreachableCaseError(this.shapes.responseBody?.contentType);break}let n=Object.fromEntries(Object.entries(this.shapes.pathParameters??{}).map(([o,c])=>[o,c.example({includeOptionals:!1,override:o})]));n=Object.keys(n).length>0?n:void 0;let i=Object.fromEntries(Object.entries(this.shapes.queryParameters??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(OA));i=Object.keys(i).length>0?i:void 0;let a=Object.fromEntries(Object.entries(this.shapes.requestHeaders??{}).map(([o,c])=>c.required||c.inputExample!=null?[o,c.example({includeOptionals:!1,override:o})]:void 0).filter(OA));if(a=Object.keys(a).length>0?a:void 0,!(this.path==null&&t==null&&r==null&&a==null&&i==null&&n==null))return{path:KPv(this.path,n??{}),responseStatusCode:this.responseStatusCode,name:this.name!=null?_Wr(this.name):this.summary!=null?_Wr(this.summary):void 0,description:this.convertDescription(),pathParameters:n,queryParameters:i,headers:a,requestBody:t,responseBody:r,snippets:void 0}}};function $Pv(e,t){return xx(e)?pbe(e,t,void 0):e}var uwv=$i(AJ());var YPv="#/components/schemas/";function yoo(e){if(e.$ref.startsWith(YPv))return e.$ref.replace(YPv,"")}function Nwi(e){if(e!=null)return{type:"alias",value:{type:"nullable",shape:e}}}function H8i(e){return typeof e.type=="string"&&e.type==="array"}function XPv(e){return e.type==="boolean"}function ZPv(e){return e.type==="integer"}function J8i(e){return!Array.isArray(e.type)&&!H8i(e)}function kPv(e){return e!=null&&Array.isArray(e)&&e.every(t=>t.type==="null"||J8i(t)||H8i(t))}function ewv(e){return"nullable"in e&&typeof e.nullable=="boolean"}function twv(e){return e.type==="null"}function rwv(e){return e.type==="number"}function zUf(e){return e.type==null||typeof e.type=="string"&&e.type==="object"}function nwv(e){return e.type==="string"}var MUu=class extends Kxe{item;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.item=new yU({input:this.input.items,context:this.context,accessPath:this.accessPath,pathId:"items",seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}),this.input.items==null&&this.context.errors.error({message:"Expected 'items' property to be specified",path:this.accessPath})}convert(){return TQ(this.item?.convert())?.map(r=>({type:"alias",value:{type:"list",itemShape:r}}))}example(t){return this.input.example??this.input.examples?.[0]??[this.item?.example(t)]}};var BUu=class extends Bee{constValue;description;availability;constructor(t){super(t),this.safeParse()}parse(){this.input.const!=null&&(typeof this.input.const=="string"||typeof this.input.const=="number"||typeof this.input.const=="boolean")?this.constValue=this.input.const.toString():this.context.errors.warning({message:`Unsupported const type: ${typeof this.input}`,path:this.accessPath}),this.description=this.input.description,this.availability=new tyt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"})}convert(){if(this.constValue!=null)return{type:"enum",default:this.constValue,values:[{value:this.constValue,description:this.description,availability:this.availability?.convert()}]}}example(){return this.input.example??this.input.examples?.[0]??this.constValue}};var TUu=class extends Kxe{typeNodes;nullable;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.parse()}parse(){this.typeNodes=this.input.map(t=>{if(t.type==="null")this.nullable=!0;else return new yU({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName})}).filter(OA)}convert(){if(this.typeNodes==null)return;let n=this.typeNodes.map(i=>TQ(i.convert())?.map(o=>({displayName:i.name,shape:o,description:i.description,availability:i.availability?.convert()}))).filter(OA).reduce((i,a)=>i.flatMap(o=>a.length>0?a.map(c=>[...o,c]):[[...o]]),[[]]).map(i=>({type:"undiscriminatedUnion",variants:i}));return this.nullable?n.map(Nwi).filter(OA):n}example(t){return this.nullable?null:this.typeNodes?.[0]?.example(t)}};function qUu(e){return e!=null&&e.length>0?e:[void 0]}var voo=class extends Kxe{description;extends=[];properties;extraProperties;requiredProperties;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){this.extends=[],this.requiredProperties=this.input.required,this.properties=Object.fromEntries(Object.entries(this.input.properties??{}).map(([t,r])=>[t,new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:["properties",t],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})])),this.extraProperties=this.input.additionalProperties!=null?typeof this.input.additionalProperties=="boolean"?this.input.additionalProperties?this.input.title:void 0:new yU({input:this.input.additionalProperties,context:this.context,accessPath:this.accessPath,pathId:["additionalProperties"],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0,this.input.allOf!=null&&(this.extends=this.extends.concat(this.input.allOf.map((t,r)=>{if(xx(t))return yoo(t);this.properties={...this.properties,...Object.fromEntries(Object.entries(t.properties??{}).map(([n,i])=>[n,new yU({input:i,context:this.context,accessPath:this.accessPath,pathId:["allOf",r.toString(),"properties",n],seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))}}).filter(OA))),this.description=this.input.description}convertProperties(){if(this.properties!=null)return hoo(this.properties,this.requiredProperties)}convertExtraProperties(){return this.extraProperties==null?void 0:typeof this.extraProperties=="string"?[{type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:{type:"alias",value:{type:"unknown",displayName:this.extraProperties}}}]:TQ(this.extraProperties.convert())?.map(r=>({type:"map",keyShape:{type:"alias",value:{type:"primitive",value:{type:"string",format:void 0,regex:void 0,minLength:void 0,maxLength:void 0,default:void 0}}},valueShape:r})).filter(OA)}convert(){let t=this.convertProperties();if(t==null)return;let r=this.convertExtraProperties();return t.flatMap(n=>qUu(r).map(i=>(this.extends==null||this.extends.length===0)&&n.length===0&&i!=null?{type:"alias",value:i}:{type:"object",extends:this.extends.map(a=>Yj.TypeId(a)),properties:n,extraProperties:i}))}example({includeOptionals:t}){let r={...this.properties};return this.input.allOf?.forEach(n=>{let i=Tee(n,this.context.document);i!=null&&(r={...r,...Object.fromEntries(Object.entries(i.properties??{}).map(([a,o])=>[a,new yU({input:o,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})]))})}),this.input.example??this.input.examples?.[0]??(!t&&this.requiredProperties!=null&&this.requiredProperties.length>0?this.requiredProperties?.reduce((n,i)=>{let a=r?.[i];return n[i]=a?.example({includeOptionals:t,override:i}),n},{}):Object.entries(r).reduce((n,[i,a])=>(n[i]=a?.example({includeOptionals:t,override:i}),n),{}))}};var RUu=class extends Kxe{isNullable;discriminated;discriminant;discriminatedMapping;undiscriminatedMapping;schemaName;constructor(t){super(t),this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.input.oneOf!=null||this.input.anyOf!=null)if(this.isNullable=(this.input.oneOf??this.input.anyOf)?.some(t=>Tee(t,this.context.document)?.type==="null"),this.input.discriminator==null)this.discriminated=!1,this.undiscriminatedMapping=(this.input.oneOf??this.input.anyOf)?.map(t=>Tee(t,this.context.document)?.type!=="null"?new yU({input:t,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName}):void 0).filter(OA);else{let t=this.input.discriminator.mapping;if(t!=null){this.discriminated=!0,this.discriminant=this.input.discriminator.propertyName,this.discriminatedMapping={};let r=this.discriminatedMapping;Object.entries(t).map(([n,i])=>{let a=Tee({$ref:i},this.context.document);if(a==null){this.context.errors.warning({message:`Expected schema reference. Received undefined reference: ${i}`,path:[...this.accessPath,"discriminator","mapping",n]});return}r[n]=new yU({input:a,context:this.context,accessPath:[...this.accessPath,"discriminator","mapping",n],pathId:n,seenSchemas:this.seenSchemas,nullable:void 0,schemaName:this.schemaName})})}}}convert(){if(!this.discriminated&&this.undiscriminatedMapping?.length===1){let i=this.undiscriminatedMapping?.flatMap(a=>a.convert()).filter(OA);return this.isNullable&&i!=null?i.map(Nwi).filter(OA):i}let t=0,r=this.discriminated&&this.discriminant!=null&&this.discriminatedMapping!=null?{type:"discriminatedUnion",discriminant:Yj.PropertyKey(this.discriminant),variants:Object.entries(this.discriminatedMapping).flatMap(([i,a])=>TQ(a.convert())?.map(c=>{if(!(c==null||c.type!=="object"))return{discriminantValue:i,displayName:a.name??_Wr(i),availability:a.availability?.convert(),description:a.description,...c}}).filter(OA)).filter(OA)}:this.undiscriminatedMapping!=null?{type:"undiscriminatedUnion",variants:this.undiscriminatedMapping.flatMap(i=>TQ(i.convert())?.map(o=>{if(o==null)return;t+=1;let c=o.type==="object"?_Wr(`${this.schemaName??"Variant"} ${t}`):void 0;return{displayName:i.name??(o.type==="alias"&&o.value.type==="id"?_Wr(o.value.id):c),shape:o,description:i.description,availability:i.availability?.convert()}}).filter(OA)).filter(OA)}:void 0,n=this.isNullable?Nwi(r):r;return n!=null?[n]:void 0}example(t){return this.input.example??this.input.examples?.[0]??this.undiscriminatedMapping?.[0]?.example(t)??Object.values(this.discriminatedMapping??{})[0]?.example(t)}};var NUu=class extends Bee{default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.input.default!=null&&typeof this.input.default!="boolean"&&this.context.errors.warning({message:`Expected default value to be a boolean. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default}convert(){return{type:"alias",value:{type:"primitive",value:{type:"boolean",default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:!1)}};var K8i=class extends Bee{default;values=[];nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){if(this.input.enum!=null){let t=!0;this.values=this.input.enum.map((r,n)=>{if(t){if(xx(r)){let i=Tee(r,this.context.document);r=typeof i=="string"?i:typeof i?.default=="string"?i?.default:typeof i?.example=="string"?i.example:void 0}if(typeof r!="string"){this.context.errors.error({message:`Expected enum values to be strings. Received ${r}`,path:[...this.accessPath,`enum[${n}]`]}),t=!1;return}return r}}).filter(OA),this.values=Array.from(new Set(this.values))}this.default=this.input.default}convert(){return{type:"enum",values:this.values.map(t=>({value:t,description:void 0,availability:void 0})),default:this.default}}example(){return this.input.example??this.input.examples?.[0]??this.default??this.values[0]??(this.nullable?null:void 0)}};var iwv=$i(AJ());function PXI(e){return qUf.includes(e)}var FUu=class extends Bee{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be an integer. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(PXI(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${qUf.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="integer";if(this.format!=null)switch(this.format){case"int64":t="long";break;case"int8":case"int16":case"int32":case"uint8":case"sf-integer":case void 0:t="integer";break;default:new iwv.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var xUu=class extends Bee{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){this.displayName=this.input.title}convert(){return Nwi({type:"alias",value:{type:"unknown",displayName:this.displayName}})}example(){return null}};var awv=$i(AJ());function wXI(e){return TUf.includes(e)}var zUu=class extends Bee{format;minimum;maximum;default;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}parse(){this.minimum=this.input.minimum,this.maximum=this.input.maximum,this.input.default!=null&&typeof this.input.default!="number"&&this.context.errors.warning({message:`Expected default value to be a number. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(wXI(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${TUf.join(", ")}. Received ${this.input.format}`,path:this.accessPath}))}convert(){let t="double";if(this.format!=null)switch(this.format){case"decimal":case"decimal128":case"double-int":case"double":case"float":case"sf-decimal":case void 0:t="double";break;default:new awv.UnreachableCaseError(this.format);break}return{type:"alias",value:{type:"primitive",value:{type:t,minimum:this.minimum,maximum:this.maximum,default:this.default}}}}example(){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:0)}};var owv=$i(AJ());function jXI(e){return RUf.includes(e)}var QUu=class extends Bee{format;regex;default;minLength;maxLength;enum;mimeType;nullable;constructor(t){super(t),this.nullable=t.nullable,this.safeParse()}mapToFdrType(t){switch(t){case"base64url":case"binary":case"byte":case"sf-binary":return"base64";case"date-time":return"datetime";case"int64":return"bigInteger";case"date":return"date";case"uuid":return"uuid";case"char":case"commonmark":case"decimal":case"decimal128":case"duration":case"email":case"hostname":case"html":case"http-date":case"idn-email":case"idn-hostname":case"ipv4":case"ipv6":case"iri-reference":case"iri":case"json-pointer":case"media-range":case"password":case"regex":case"relative-json-pointer":case"sf-boolean":case"sf-string":case"sf-token":case"time":case"uri-reference":case"uri-template":case"uri":case void 0:return"string";default:return new owv.UnreachableCaseError(t),"string"}}parse(){this.regex=this.input.pattern,this.minLength=this.input.minLength,this.maxLength=this.input.maxLength,this.mimeType=this.input.contentMediaType,this.input.default!=null&&typeof this.input.default!="string"&&this.context.errors.warning({message:`Expected default value to be a string. Received ${this.input.default}`,path:this.accessPath}),this.default=this.input.default,this.input.format!=null&&(jXI(this.input.format)?this.format=this.input.format:this.context.errors.warning({message:`Expected format to be one of ${RUf.join(", ")}. Received ${this.input.format}`,path:this.accessPath})),this.input.enum!=null&&(this.enum=new K8i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"enum",nullable:this.nullable}))}convert(){if(this.enum!=null)return this.enum.convert();let t="string";return this.format!=null&&(t=this.mapToFdrType(this.format)),{type:"alias",value:{type:"primitive",value:t==="base64"?{type:t,mimeType:this.mimeType,default:this.default}:{type:t,format:t==="string"?this.format:void 0,regex:this.regex,minLength:this.minLength,maxLength:this.maxLength,default:this.default}}}}example({override:t}){return this.input.example??this.input.examples?.[0]??this.default??(this.nullable?null:t??"string")}};var swv=$i(AJ());var LUu=class extends Bee{displayName;shape;constructor(t){super(t),this.safeParse()}parse(){(0,swv.noop)()}convert(){return{type:"alias",value:{type:"unknown",displayName:void 0}}}example(){}};var Dda=class extends Kxe{description;availability;schemaId;maybeEnumConverterNode;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.description=t.description,this.availability=t.availability,this.safeParse()}parse(){this.schemaId=yoo(this.input);let t=Tee(this.input,this.context.document);t?.enum!=null&&J8i(t)&&(this.maybeEnumConverterNode=new K8i({input:t,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",nullable:this.nullable})),this.schemaId==null&&this.context.errors.error({message:`Unprocessable reference: ${this.input.$ref}`,path:this.accessPath})}convert(){if(this.schemaId!=null)return{type:"alias",value:{type:"id",id:Yj.TypeId(this.schemaId),default:this.maybeEnumConverterNode?.default!=null?{type:"enum",value:this.maybeEnumConverterNode.default}:void 0}}}example(t){let r=Tee(this.input,this.context.document);if(r!=null)return new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:this.schemaId??"",seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName}).example(t)}};var yU=class e extends Kxe{typeShapeNode;description;name;examples;availability;nullable;schemaName;constructor(t){super(t),this.nullable=t.nullable,this.schemaName=t.schemaName,this.safeParse()}parse(){if(this.description=this.input.description,this.availability=new tyt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),J8i(this.input)&&ewv(this.input)&&(this.nullable=this.input.nullable!=null?this.input.nullable:this.nullable),xx(this.input)){let t=yoo(this.input);if(t==null){this.context.errors.error({message:"Reference object does not have a valid schema ID",path:this.accessPath});return}if(this.seenSchemas.has(t)){this.context.errors.warning({message:"Circular or deeply nested schema found, terminating",path:this.accessPath});return}this.seenSchemas.add(t),this.typeShapeNode=new Dda({input:this.input,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:this.seenSchemas,nullable:this.nullable,schemaName:this.schemaName,description:this.description,availability:this.availability})}else if(this.name=this.input.title,this.examples=this.input.example,this.input.const!=null)this.typeShapeNode=new BUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});else if(kPv(this.input))this.typeShapeNode=new TUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(J8i(this.input)&&(this.input.oneOf!=null||this.input.anyOf!=null))this.typeShapeNode=new RUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(zUf(this.input)&&this.input.allOf!=null)this.typeShapeNode=new voo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName});else if(J8i(this.input)&&this.input.enum!=null)this.typeShapeNode=new K8i({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable});else if(typeof this.input.type=="string"||Array.isArray(this.input.type)&&this.input.type.length===1){if(this.input.type=Array.isArray(this.input.type)?this.input.type[0]:this.input.type,!Array.isArray(this.input.type))switch(this.input.type){case"object":zUf(this.input)&&(this.typeShapeNode=new voo({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"array":H8i(this.input)&&(this.typeShapeNode=new MUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));break;case"boolean":XPv(this.input)&&(this.typeShapeNode=new NUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"integer":ZPv(this.input)&&(this.typeShapeNode=new FUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"number":rwv(this.input)&&(this.typeShapeNode=new zUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"string":nwv(this.input)&&(this.typeShapeNode=new QUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId,nullable:this.nullable}));break;case"null":twv(this.input)&&(this.typeShapeNode=new xUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}));break;case void 0:break;default:new uwv.UnreachableCaseError(this.input.type);break}}else if(Array.isArray(this.input.type)&&this.input.type.includes("null")&&this.input.type.length===2){let t=this.input.type.filter(r=>r!=="null")[0];t!=="array"&&(this.typeShapeNode=new e({input:{...this.input,type:t},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,nullable:!0,schemaName:this.schemaName}))}else this.input.properties!=null&&(this.typeShapeNode=new voo({input:{...this.input,type:"object"},context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:this.seenSchemas,schemaName:this.schemaName}));this.typeShapeNode==null&&(this.typeShapeNode=new LUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}),!xx(this.input)&&(!H8i(this.input)&&this.input==null||H8i(this.input)&&this.input.items==null)&&this.context.errors.error({message:"Expected type declaration. Received: null",path:this.accessPath}))}convert(){let t=this.typeShapeNode?.convert();if(t==null)return;let r=TQ(t)?.map(n=>this.nullable?Nwi(n):n).filter(OA);return Array.isArray(t)&&t.length>1?r:r?.[0]}example(t){return this.availability?.availability!=="deprecated"?this.typeShapeNode?.example(t):void 0}};function $8i(e){if(e!=null)return hoo(e,Object.entries(e??{}).map(([t,r])=>r.required?t:void 0).filter(OA))}var yWr=class extends Bee{availability;required;schema;description;inputExample;constructor(t){super(t),this.safeParse(t.parameterName)}parse(t){this.description=this.input.description;let r;xx(this.input)?r=this.input:this.input.schema!=null?(r=this.input.schema,this.required=this.input.required):(r={type:"string"},this.required=!1),this.availability=new tyt({input:r,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:t});let n=$Pv(this.input,this.context.document);this.inputExample=n?.example??Object.values(n?.examples??{})[0]}convert(){return this.schema?.convert()}example(t){return this.inputExample??this.schema?.example(t)}};function cwv(e,t){return xx(e)?pbe(e,t,void 0):e}var QUf=$i(AJ());function UUu(e){let{uniqueId:t,type:r,contextTypes:n,description:i,availability:a}=e;n[Yj.TypeId(t)]={name:t,shape:r,description:i,availability:a}}var lwv=$i(YJl(),1),boo=class e{type;subtype;essence;parameters;mimeType;input;constructor(t,r,n,i,a,o){this.type=t,this.subtype=r,this.essence=n,this.parameters=i,this.mimeType=a,this.input=o}static APPLICATION_JSON="application/json";static APPLICATION_OCTET_STREAM="application/octet-stream";static MULTIPART_FORM_DATA="multipart/form-data";static parse(t){if(t==null)return null;let r=lwv.default.parse(t);return r==null?null:new e(r.type,r.subtype,r.essence,r.parameters,r,t)}toString(){return this.input}isText(){return this.type==="text"}isImage(){return this.type==="image"}isAudio(){return this.type==="audio"}isVideo(){return this.type==="video"}isFont(){return this.type==="font"}isMultipart(){return this.type==="multipart"}isApplication(){return this.type==="application"}isMessage(){return this.type==="message"}isModel(){return this.type==="model"}isCSS(){return this.isText()&&this.subtype==="css"}isCSV(){return this.isText()&&this.subtype==="csv"}isMarkdown(){return this.isText()&&this.subtype==="markdown"}isPlainText(){return this.isText()&&this.subtype==="plain"}isEventStream(){return this.isText()&&this.subtype==="event-stream"}isMultiPartFormData(){return this.isMultipart()&&this.subtype==="form-data"}isJSON(){return this.isApplication()&&this.subtype==="json"}containsJSON(){return this.isApplication()&&this.subtype.includes("json")}isURLEncoded(){return this.isApplication()&&this.subtype==="x-www-form-urlencoded"}isOctetStream(){return this.isApplication()&&this.subtype==="octet-stream"}isPDF(){return this.isApplication()&&this.subtype==="pdf"}isZip(){return this.isApplication()&&this.subtype==="zip"}isGzip(){return this.isApplication()&&this.subtype==="gzip"}isTar(){return this.isApplication()&&this.subtype==="tar"}isBrotli(){return this.isApplication()&&this.subtype==="br"}isDeflate(){return this.isApplication()&&this.subtype==="deflate"}isProtobuf(){return this.isApplication()&&this.subtype==="protobuf"}isAvif(){return this.isImage()&&this.subtype==="avif"}isWebP(){return this.isImage()&&this.subtype==="webp"}isSVG(){return this.isImage()&&this.subtype==="svg+xml"}isPNG(){return this.isImage()&&this.subtype==="png"}isJPEG(){return this.isImage()&&this.subtype==="jpeg"}isGIF(){return this.isImage()&&this.subtype==="gif"}isMPEG(){return this.isAudio()&&this.subtype==="mpeg"}isWAV(){return this.isAudio()&&this.subtype==="wav"}isHTML(){return this.mimeType.isHTML()}isXML(){return this.mimeType.isXML()}isJavaScript(){return this.mimeType.isJavaScript()}};function EXI(e){return typeof e.securitySchemes=="object"&&e.securitySchemes!=null}var VUu=class extends UO{typeSchemas;securitySchemes;constructor(t){super(t),this.safeParse()}parse(){this.input.schemas!=null&&(this.typeSchemas=Object.fromEntries(Object.entries(this.input.schemas).map(([t,r])=>[t,new yU({input:r,context:this.context,accessPath:this.accessPath,pathId:t,seenSchemas:new Set,nullable:void 0,schemaName:t})]))),EXI(this.input)&&this.input.securitySchemes!=null&&(this.securitySchemes=Object.fromEntries(Object.entries(this.input.securitySchemes??{}).map(([t,r],n)=>{let i;if(xx(r)?i=k9u(r.$ref,this.context.document):i=r,i!=null)return[t,new poo({input:i,context:this.context,accessPath:this.accessPath,pathId:["securitySchemes",`${n}`]})]}).filter(OA)))}convert(){return{auths:this.securitySchemes!=null?Object.fromEntries(Object.entries(this.securitySchemes??{}).map(([t,r])=>{let n=r.convert();if(n!=null)return[Yj.api.latest.AuthSchemeId(t),n]}).filter(OA)):void 0,types:this.typeSchemas!=null?Object.fromEntries(Object.entries(this.typeSchemas).map(([t,r])=>{let n=r.name??t,i=TQ(r.convert());return i==null?[t,void 0]:[Yj.TypeId(t),{name:n,shape:i[0],description:r.description,availability:void 0}]}).filter(([t,r])=>OA(r))):void 0}}};var WUu=class extends yU{multipartType;contentType;constructor(t){super(t),this.safeParse()}parse(){super.parse();let t=Tee(this.input,this.context.document);if(t==null){this.context.errors.error({message:`Expected multipart form data property definition. ${xx(this.input)?`Received undefined reference: ${this.input.$ref}`:""}`,path:this.accessPath});return}if(t.type==="string"&&t.format==="binary")this.multipartType="file",this.contentType=t.contentMediaType;else if(t.type==="array"){let r=Tee(t.items,this.context.document);r?.type==="string"&&r?.format==="binary"?(this.multipartType="files",this.contentType=r?.contentMediaType):(this.context.errors.warning({message:"Expected multipart form data files definition with array type with internal string type and binary format.",path:this.accessPath}),this.multipartType=void 0,this.contentType=void 0)}else this.multipartType="property",this.contentType=t.contentMediaType}};var GUu=class extends UO{description;method;path;schema;isOptional;contentType;availability;requiredFields;fields;examples;constructor(t){super(t),this.method=t.method,this.path=t.path,this.safeParse(t)}parse({contentType:t}){if(this.input.schema!=null){let n=Tee(this.input.schema,this.context.document);this.availability=new tyt({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"availability"}),this.schema=xx(this.input.schema)?new Dda({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:!1,schemaName:"Request Body",description:this.input.schema.description,availability:this.availability}):void 0;let i=boo.parse(t);i?.containsJSON()?(this.contentType="json",this.schema=this.schema??new yU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"schema",seenSchemas:new Set,nullable:void 0,schemaName:"Request Body"})):i?.isOctetStream()?(this.contentType="bytes",this.isOptional=n?.required==null):i?.isMultiPartFormData()?(this.contentType="form-data",this.requiredFields=n?.required,this.fields=Object.fromEntries(Object.entries(n?.properties??{}).map(([a,o])=>{if(o!=null)return[a,new WUu({input:o,context:this.context,accessPath:this.accessPath,pathId:`schema.${a}`,seenSchemas:new Set,nullable:void 0,schemaName:a})]}).filter(OA))):this.context.errors.warning({message:`Expected request body of reference or object with json, streaming or form-data content types. Received: ${t}`,path:this.accessPath})}let r=this.schema?.example({includeOptionals:!0,override:void 0});this.examples={...this.input.example!=null?{[Ade]:{value:this.input.example}}:{},...this.input.examples},r!=null&&Object.keys(this.examples).length===0&&(this.examples={[Ade]:{value:r}})}convertJsonLike(){let t=this.schema?.convert();return t==null?void 0:TQ(t)?.map(n=>{let i=n.type;switch(i){case"object":case"alias":return n;case"enum":case"undiscriminatedUnion":case"discriminatedUnion":{let a=Jqr([this.method,this.path,this.contentType,"request"].join("_"));return UUu({uniqueId:a,type:n,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Yj.TypeId(a),default:n.type==="enum"&&n.default!=null?{type:"enum",value:n.default}:void 0}}}case void 0:return;default:new QUf.UnreachableCaseError(i);return}}).filter(OA)}convert(){if(this.schema instanceof Dda)return this.schema.convert();switch(this.contentType){case"json":return this.convertJsonLike();case"bytes":return{type:"bytes",isOptional:this.isOptional??!1,contentType:this.contentType};case"form-data":return Object.entries(this.fields??{}).map(([n,i])=>{switch(i.multipartType){case"file":return[{type:i.multipartType,key:Yj.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"files":return[{type:i.multipartType,key:Yj.PropertyKey(n),isOptional:this.requiredFields?.includes(n)==null,contentType:i.contentType,description:i.description,availability:i.availability?.convert()}];case"property":{let a=TQ(i.convert()),o=i.multipartType;return a?.map(c=>({type:o,key:Yj.PropertyKey(n),contentType:i.contentType,exploded:void 0,valueShape:c,description:i.description,availability:i.availability?.convert()}))}case void 0:return[];default:return new QUf.UnreachableCaseError(i.multipartType),[]}}).filter(OA).reduce((n,i)=>n.flatMap(a=>i.length>0?i.map(o=>[...a,o]):[[...a]]),[[]]).map(n=>({type:"formData",fields:n,availability:this.availability?.convert(),description:this.description}));case void 0:return this.convertJsonLike();default:return}}};var HUu=class extends UO{description;requestBodiesByContentType;constructor(t){super(t),this.safeParse(t)}parse({method:t,path:r}){let n=cwv(this.input,this.context.document);if(n==null){this.context.errors.error({message:"Expected request body. Received: null",path:this.accessPath});return}Object.entries(n.content).forEach(([i,a])=>{this.requestBodiesByContentType??={},this.requestBodiesByContentType[i]=new GUu({input:a,context:this.context,accessPath:this.accessPath,pathId:"content",contentType:i,method:t,path:r})})}convert(){return Object.entries(this.requestBodiesByContentType??{}).flatMap(([t,r])=>TQ(r.convert())?.map(i=>({description:this.description,contentType:t,body:i}))).filter(OA)}convertToWebhookPayload(){return Object.values(this.requestBodiesByContentType??{}).flatMap(t=>TQ(t.convert())?.map(n=>{if(!(n.type!=="alias"&&n.type!=="object"))return{description:this.description,shape:n}})).filter(OA)}webhookExample(){return{payload:this.requestBodiesByContentType?.["application/json"]?.schema?.example({includeOptionals:!0,override:void 0})}}};var fwv={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",306:"Switch Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required"};function dwv(e,t){if(xx(e)){let r=pbe(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var JUu=$i(AJ());var pwv="application/json";var _wv="application/octet-stream";function hwv(e,t){return e===t||t===Ade||e===Ade}var Ons=class extends UO{streamingFormat;path;method;statusCode;requests;shapes;schema;contentType;unsupportedContentType;contentSubtype;examples;empty;constructor(t,r,n,i,a,o,c,f){super(t),this.streamingFormat=n,this.path=i,this.method=a,this.statusCode=o,this.requests=c,this.shapes=f,this.safeParse(r)}matchRequestResponseExamplesByName(t,r,n){for(let i of t)for(let[a,o]of Object.entries(i?.examples??{}))for(let[c,f]of Object.entries(r))for(let u of f)hwv(c,a)&&(n.add(c),this.examples?.push(new hWr({input:{requestExample:o,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,W8i(a,c),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}matchExamplesByIndex(t,r){let n=0;for(let i of t){let a=0;for(let[o,c]of r){if(a===n){let[f,u,s]=i??[void 0,void 0,void 0];this.examples?.push(...c.map(l=>new hWr({input:{requestExample:s,responseExample:l},context:this.context,accessPath:this.accessPath,pathId:u!=null&&u!==""?["examples",u]:"examples"},this.path,this.statusCode,W8i(u,o),{requestBody:f,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}a++}n++}if(t.length>r.length)for(let i of t.slice(r.length)){let[a,o]=r[r.length-1]??[void 0,void 0],[c,f,u]=i??[void 0,void 0,void 0];this.examples?.push(...(o??[void 0]).map(s=>new hWr({input:{requestExample:u,responseExample:s},context:this.context,accessPath:this.accessPath,pathId:f!=null&&f!==""?["examples",f]:"examples"},this.path,this.statusCode,W8i(f,a),{requestBody:c,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}if(r.length>t.length){let[i,a,o]=t[t.length-1]??[void 0,void 0,void 0];for(let[c,f]of r.slice(t.length))this.examples?.push(...f.map(u=>new hWr({input:{requestExample:o,responseExample:u},context:this.context,accessPath:this.accessPath,pathId:a!=null&&a!==""?["examples",a]:"examples"},this.path,this.statusCode,W8i(a,c),{requestBody:i,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders})))}}pushResponseExample(t,r,n,i){let a=t[Ade];if(a!=null)for(let o of a)this.examples?.push(new hWr({input:{requestExample:i,responseExample:o},context:this.context,accessPath:this.accessPath,pathId:n!=null&&n!==""?["examples",n]:"examples"},this.path,this.statusCode,W8i(n,void 0),{requestBody:r,responseBody:this,pathParameters:this.shapes.pathParameters,queryParameters:this.shapes.queryParameters,requestHeaders:this.shapes.requestHeaders}))}addGlobalFallbackExample(t,r){if(t==null||t.length===0)this.pushResponseExample(r,void 0,void 0,void 0);else for(let n of t)if(Object.keys(n.examples??{}).length===0)this.pushResponseExample(r,n,void 0,void 0);else for(let[i,a]of Object.entries(n.examples??{}))this.pushResponseExample(r,n,i,a)}parse(t){if(t==="empty")this.empty=!0;else{let c=boo.parse(t);if(c?.isJSON()||c?.isEventStream())this.contentType=pwv,this.input.schema==null?(this.streamingFormat==null||this.streamingFormat==="json")&&this.context.errors.error({message:"Expected schema for JSON response body. Received null",path:this.accessPath}):this.schema=new yU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:"type",seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"});else if(c?.isOctetStream())this.contentType=_wv,this.contentSubtype=Tee(this.input.schema,this.context.document)?.contentMediaType;else if(this.unsupportedContentType=t,this.input.schema==null){this.context.errors.error({message:"Expected schema for plain text response body. Received null",path:this.accessPath});return}else this.schema=new yU({input:this.input.schema,context:this.context,accessPath:this.accessPath,pathId:this.pathId,seenSchemas:new Set,nullable:void 0,schemaName:"Response Body"})}let r={};this.input.examples!=null&&(r=gUu(this.input.examples,c=>[c])),this.input.example!=null&&Object.keys(r).length===0&&(r[Ade]??=[],r[Ade]=[{value:this.input.example}]);let n=Tee(this.input.schema,this.context.document);if(n!=null&&(n.examples!=null&&Object.keys(r).length===0&&(r=gUu(n.examples,c=>[c])),n.example!=null&&Object.keys(r).length===0&&(r[Ade]??=[],r[Ade]?.push({value:n.example}))),Object.keys(r).length===0){let c=this.schema?.example({includeOptionals:!0,override:void 0});r[Ade]??=[],r[Ade]?.push(c!=null?{value:c}:void 0)}this.examples??=[];let i=new Set;this.matchRequestResponseExamplesByName(this.requests,r,i);let a=[];for(let c of this.requests)a.push(...Object.entries(c.examples??{}).filter(([f])=>!i.has(f)&&f!==Ade).map(([f,u])=>[c,f,u]));let o=Object.entries(r).filter(([c,f])=>!i.has(c)&&OA(f)&&c!==Ade);Object.keys(r).every(c=>c===Ade)||this.matchExamplesByIndex(a,o),!i.has(Ade)&&this.examples.length===0&&this.addGlobalFallbackExample(this.requests,r),this.examples.length===0&&(this.examples=void 0)}convertStreamingFormat(){switch(this.streamingFormat){case"json":return TQ(this.schema?.convert())?.map(r=>({type:"stream",terminator:"[DATA]",shape:r}));case"sse":return{type:"streamingText"};case void 0:return;default:new JUu.UnreachableCaseError(this.streamingFormat);return}}convertJsonLike(){return TQ(this.schema?.convert())?.map(r=>{let n=r.type;switch(n){case"alias":return r;case"discriminatedUnion":case"undiscriminatedUnion":case"enum":{let i=Jqr([this.method,this.path,this.statusCode,"response"].join("_"));return UUu({uniqueId:i,type:r,contextTypes:this.context.generatedTypes,description:this.schema?.description,availability:this.schema?.availability?.convert()}),{type:"alias",value:{type:"id",id:Yj.TypeId(i),default:r.type==="enum"&&r.default!=null?{type:"enum",value:r.default}:void 0}}}case"object":return r;default:new JUu.UnreachableCaseError(n);return}}).filter(OA)}convert(){if(this.empty)return{type:"empty"};if(this.contentType!=null)switch(this.contentType){case"application/json":return this.streamingFormat==null?this.convertJsonLike():this.convertStreamingFormat();case"application/octet-stream":return{type:"fileDownload",contentType:this.contentSubtype};case"text/event-stream":return this.convertStreamingFormat();case void 0:return;default:new JUu.UnreachableCaseError(this.contentType);return}else return this.unsupportedContentType!=null?this.convertJsonLike():void 0}};var Ans=class extends UO{path;method;statusCode;requests;shapes;headers;responses;description;constructor(t,r,n,i,a,o){super(t),this.path=r,this.method=n,this.statusCode=i,this.requests=a,this.shapes=o,this.safeParse()}parse(t){this.description=this.input.description;let r=dwv(this.input,this.context.document);if(r==null){this.context.errors.error({message:xx(this.input)?`Undefined reference: ${this.input.$ref}`:"Expected response, received null",path:this.accessPath});return}Object.entries(r.headers??{}).forEach(([n,i])=>{this.headers??={},this.headers[n]=new yWr({input:i,context:this.context,accessPath:this.accessPath,pathId:"headers",parameterName:n})}),r.content==null?(this.responses??=[],this.responses.push(new Ons({input:{},context:this.context,accessPath:this.accessPath,pathId:["content"]},"empty",t,this.path,this.method,this.statusCode,this.requests,this.shapes))):Object.entries(r.content??{}).forEach(([n,i])=>{this.responses??=[],this.responses.push(new Ons({input:i,context:this.context,accessPath:this.accessPath,pathId:["content",n]},n,t,this.path,this.method,this.statusCode,this.requests,this.shapes))})}convert(){return this.responses?.flatMap(t=>t.convert()).filter(OA)}};var KUu=class extends UO{path;method;requests;shapes;responsesByStatusCode;errorsByStatusCode;constructor(t,r,n,i,a){super(t),this.path=r,this.method=n,this.requests=i,this.shapes=a,this.safeParse()}parse(){let t=this.input.default;Object.entries(this.input).forEach(([r,n])=>{r!=="default"&&(parseInt(r)>=400?(this.errorsByStatusCode??={},this.errorsByStatusCode[r]=new Ans({input:{...t,...n},context:this.context,accessPath:this.accessPath,pathId:"errors"},this.path,this.method,parseInt(r),[],this.shapes)):(this.responsesByStatusCode??={},this.responsesByStatusCode[r]=new Ans({input:n,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,parseInt(r),this.requests,this.shapes)))})}convertResponseObjectToHttpResponses(){return Object.entries(this.responsesByStatusCode??{}).flatMap(([t,r])=>{let n=r.convert();if(n!=null)return qUu($8i(r.headers)).flatMap(i=>n?.map(a=>({headers:i,response:{statusCode:parseInt(t),body:a,description:r.description},examples:(r.responses??[]).flatMap(o=>(o.examples??[]).map(c=>c.convert()).filter(OA))})))}).filter(OA)}convertResponseObjectToErrors(){return Object.entries(this.errorsByStatusCode??{}).flatMap(([t,r])=>r.responses?.flatMap(n=>{let i=n.schema,a=TQ(i?.convert());if(i!=null)return a?.map(o=>({statusCode:parseInt(t),shape:o,description:r.description??i.description,availability:i.availability?.convert(),name:i.name??fwv[parseInt(t)]??"UNKNOWN ERROR",examples:n.examples?.map(c=>{let f=c.convert();if(f!=null&&f.responseBody?.type==="json")return{name:f.name,description:f.description,responseBody:f.responseBody}}).filter(OA)})).filter(OA)})).filter(OA)}convert(){return{responses:this.convertResponseObjectToHttpResponses(),errors:this.convertResponseObjectToErrors()}}};var Y8i=class extends UO{servers;globalAuth;path;method;basePath;isWebhook;endpointIds;description;displayName;operationId;pathParameters;queryParameters;requestHeaders;requests;responses;availability;auth;namespaces;xFernExamplesNode;redocExamplesNode;emptyResponseExamples;constructor(t){super(t),this.servers=t.servers,this.globalAuth=t.globalAuth,this.path=t.path,this.method=t.method,this.basePath=t.basePath,this.isWebhook=t.isWebhook,this.safeParse()}pushEmptyResponseExample(t,r,n){this.emptyResponseExamples??=[],this.emptyResponseExamples.push(new hWr({input:{requestExample:t,responseExample:void 0},context:this.context,accessPath:this.accessPath,pathId:"examples"},this.path,200,W8i(n,void 0),{requestBody:r,pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}))}parse(){if(this.isWebhook&&this.method!=="POST"&&this.method!=="GET"){this.context.errors.error({message:`Webhook method must be POST or GET. Received: ${this.method}`,path:this.accessPath});return}this.description=this.input.description,this.displayName=this.input.summary,this.operationId=this.input.operationId,this.availability=new tyt({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-availability"}),this.servers=L8i(this.servers,this.input.servers,this.context,this.accessPath),this.isWebhook=new CUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId}).isWebhook||this.isWebhook,this.input.parameters?.map((n,i)=>{if(xx(n)){let a=wUu(n,this.context.document);if(a!=null)n=a;else{this.context.errors.warning({message:`Expected parameter reference to resolve to an object. Received undefined reference: ${n.$ref}`,path:[...this.accessPath,`parameters[${i}]`]});return}}n.in==="path"?n.schema!=null&&(this.pathParameters??={},this.pathParameters[n.name]=new yWr({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="query"?n.schema!=null&&(this.queryParameters??={},this.queryParameters[n.name]=new yWr({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name})):n.in==="header"&&n.schema!=null&&(this.requestHeaders??={},this.requestHeaders[n.name]=new yWr({input:n,context:this.context,accessPath:this.accessPath,pathId:["parameters",`${i}`],parameterName:n.name}))});for(let n of this.extractPathParameterIds()??[])this.pathParameters?.[n]==null&&this.context.errors.warning({message:`Path parameter not defined: ${n}`,path:[...this.accessPath,"parameters"]});if(this.redocExamplesNode=new IUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-code-samples"}),this.requests=this.input.requestBody!=null?new HUu({input:this.input.requestBody,context:this.context,accessPath:this.accessPath,pathId:"requestBody",method:this.method,path:this.path}):void 0,this.responses=this.input.responses!=null?new KUu({input:this.input.responses,context:this.context,accessPath:this.accessPath,pathId:"responses"},this.path,this.method,Object.values(this.requests?.requestBodiesByContentType??{}),{pathParameters:this.pathParameters,queryParameters:this.queryParameters,requestHeaders:this.requestHeaders}):void 0,this.responses==null){let n=this.requests?.requestBodiesByContentType;n==null||Object.keys(n).length===0?this.pushEmptyResponseExample(void 0,void 0,void 0):Object.values(n).forEach(i=>{if(Object.keys(i.examples??{}).length===0){let a=i.schema?.example({includeOptionals:!1,override:void 0});a!=null&&this.pushEmptyResponseExample({value:a},i,void 0)}else Object.entries(i.examples??{}).forEach(([a,o])=>{this.pushEmptyResponseExample(o,i,a)})})}let t=200;this.responses?.responsesByStatusCode!=null&&(t=Number(Object.keys(this.responses.responsesByStatusCode)?.filter(n=>Number(n)>=200&&Number(n)<300)[0])),this.globalAuth!=null&&(this.auth=this.globalAuth),this.input.security!=null&&(this.auth=new _oo({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"})),this.namespaces=[new mns({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-group-name"})],this.namespaces?.every(n=>n.groupName==null)&&this.input.tags!=null&&(this.namespaces=this.input.tags.slice(0,1).map((n,i)=>new mns({input:{[Y9u]:n},context:this.context,accessPath:this.accessPath,pathId:["tags",`${i}`]})));let r=new DUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-sdk-method-name"});this.endpointIds=this.namespaces.map(n=>mUu({namespace:TQ(n?.groupName),path:this.path,method:this.method,sdkMethodName:r.sdkMethodName,operationId:this.input.operationId,displayName:this.displayName,isWebhook:this.isWebhook})).filter(OA),this.xFernExamplesNode=new SUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-examples"},this.path,t,this.requests?.requestBodiesByContentType,this.responses?.responsesByStatusCode?.[t]?.responses)}extractPathParameterIds(){if(this.path!=null)return this.path.split("/").map(t=>{if(t.startsWith("{")&&t.endsWith("}"))return t.slice(1,-1).trim()}).filter(OA)}convertPathToPathParts(){if(this.path===void 0)return;let t=this.path.startsWith("/")?this.path.slice(1):this.path,r=this.basePath?.convert();return(r?[r,...t.split("/")]:t.split("/")).reduce((i,a)=>(i.push({type:"literal",value:"/"}),a.startsWith("{")&&a.endsWith("}")?i.push({type:"pathParameter",value:Yj.PropertyKey(a.slice(1,-1).trim())}):i.push({type:"literal",value:a}),i),[])}convert(){if(this.path==null||this.endpointIds==null)return;let{responses:t,errors:r}=this.responses?.convert()??{responses:void 0,errors:void 0},n=this.emptyResponseExamples?.map(s=>s.convert()).filter(OA),i=LPv(this.xFernExamplesNode?.convert(),[...n??[],...t?.flatMap(s=>s.examples)??[]])?.map(s=>({...s,snippets:QPv(s.snippets,this.redocExamplesNode?.convert())}));if(this.isWebhook)return this.endpointIds.map((s,l)=>{if(!(this.method!=="POST"&&this.method!=="GET"))return{id:Yj.WebhookId(s),description:this.description,availability:this.availability?.convert(),displayName:this.displayName,operationId:this.operationId,namespace:this.namespaces?.[l]?.convert(),method:this.method,path:this.convertPathToPathParts()?.map(m=>m.value.toString())??[],queryParameters:$8i(this.queryParameters)?.flat(),headers:$8i(this.requestHeaders)?.flat(),payloads:this.requests?.convertToWebhookPayload(),examples:[this.requests?.webhookExample()].filter(OA)}}).filter(OA);let a=this.servers?.map(s=>s.convert()).filter(OA),o=this.convertPathToPathParts();if(o==null)return;let c,f=this.auth?.convert();f!=null&&(c=Object.keys(f));let u=t?.flatMap(s=>s.headers).filter(OA);return this.endpointIds.map((s,l)=>({id:Yj.EndpointId(s),description:this.description,availability:this.availability?.convert(),namespace:this.namespaces?.[l]?.convert()?.map(m=>Yj.api.v1.SubpackageId(m)),displayName:this.displayName,operationId:this.operationId,method:this.method,path:o,auth:c?.map(m=>Yj.api.latest.AuthSchemeId(m)),defaultEnvironment:a?.[0]?.id,environments:a,pathParameters:$8i(this.pathParameters)?.flat(),queryParameters:$8i(this.queryParameters)?.flat(),requestHeaders:$8i(this.requestHeaders)?.flat(),responseHeaders:u!=null&&u.length>0?u:void 0,requests:this.requests?.convert(),responses:t?.map(m=>m.response),errors:r,examples:i,snippetTemplates:void 0,protocol:{type:"rest"}}))}};var goo=class extends UO{description;get;post;put;patch;delete;path;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n,isWebhook:i}){this.description=this.input.description;let a=L8i(t,this.input.servers,this.context,this.accessPath),o=Array.isArray(this.pathId)?this.pathId.join("/"):this.pathId;this.input.get!=null&&(this.get=new Y8i({input:this.input.get,context:this.context,accessPath:this.accessPath,pathId:"get",servers:a,globalAuth:r,path:o,method:"GET",basePath:n,isWebhook:i})),this.input.post!=null&&(this.post=new Y8i({input:this.input.post,context:this.context,accessPath:this.accessPath,pathId:"post",servers:a,globalAuth:r,path:o,method:"POST",basePath:n,isWebhook:i})),this.input.put!=null&&(this.put=new Y8i({input:this.input.put,context:this.context,accessPath:this.accessPath,pathId:"put",servers:a,globalAuth:r,path:o,method:"PUT",basePath:n,isWebhook:!1})),this.input.patch!=null&&(this.patch=new Y8i({input:this.input.patch,context:this.context,accessPath:this.accessPath,pathId:"patch",servers:a,globalAuth:r,path:o,method:"PATCH",basePath:n,isWebhook:!1})),this.input.delete!=null&&(this.delete=new Y8i({input:this.input.delete,context:this.context,accessPath:this.accessPath,pathId:"delete",servers:a,globalAuth:r,path:o,method:"DELETE",basePath:n,isWebhook:!1}))}convert(){return[...this.get?.convert()??[],...this.post?.convert()??[],...this.put?.convert()??[],...this.patch?.convert()??[],...this.delete?.convert()??[]].filter(OA)}};function $Uu(e){return"payloads"in e}var YUu=class extends UO{paths;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.paths=Object.entries(this.input).map(([i,a])=>{if(a!=null)return new goo({input:a,context:this.context,accessPath:this.accessPath,pathId:i,servers:L8i(t,a.servers,this.context,this.accessPath),globalAuth:r,basePath:n,isWebhook:void 0})}).filter(OA)}convert(){if(this.paths==null)return;let t={},r={};return this.paths.forEach(n=>{let i=n.convert();i?.forEach(a=>{$Uu(a)?r[Yj.WebhookId(a.id)]=a:t[Yj.EndpointId(a.id)]=a})}),{endpoints:t,webhookEndpoints:r}}};var XUu=class extends UO{globalHeaders;requiredProperties;constructor(t){super(t),this.safeParse()}parse(){let t=this.input[TAv]?.map(r=>{let{header:n,...i}=r;return(i.optional!=null&&!i.optional||wUu(i,this.context.document)?.required)&&(this.requiredProperties??=[],this.requiredProperties?.push(n)),[n,new yWr({input:i,context:this.context,accessPath:this.accessPath,pathId:this.pathId,parameterName:n})]});t!=null&&(this.globalHeaders=Object.fromEntries(t))}convert(){return hoo(this.globalHeaders,this.requiredProperties)?.flat()}};function ywv(e,t){if(xx(e)){let r=pbe(e,t,void 0);return r==null?void 0:{...r,...e}}return e}var ZUu=class extends UO{webhooks;constructor(t){super(t),this.safeParse(t)}parse({servers:t,globalAuth:r,basePath:n}){this.webhooks=Object.entries(this.input??{}).map(([i,a])=>{let o=ywv(a,this.context.document);if(o!=null)return new goo({input:o,context:this.context,accessPath:this.accessPath,pathId:i,servers:t,globalAuth:r,basePath:n,isWebhook:!0})}).filter(OA)}convert(){return this.webhooks?.reduce((t,r)=>(r.convert()?.forEach(n=>{$Uu(n)&&(t[Yj.WebhookId(n.id)]=n)}),t),{})}};var kUu=class extends UO{paths;webhooks;components;auth;globalHeaders;constructor(t){super(t),this.safeParse()}parse(){let t=L8i(void 0,this.input.servers,this.context,this.accessPath);this.input.security!=null&&(this.auth=new _oo({input:this.input.security,context:this.context,accessPath:this.accessPath,pathId:"security"}));let r=new PUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:this.pathId});this.input.paths==null&&this.input.webhooks==null&&this.context.errors.warning({message:"Expected 'paths' or 'webhooks' property to be specified",path:this.accessPath}),this.input.paths!=null&&(this.paths=new YUu({input:this.input.paths,context:this.context,accessPath:this.accessPath,pathId:"paths",basePath:r,servers:t,globalAuth:this.auth})),this.input.webhooks!=null&&(this.webhooks=new ZUu({input:this.input.webhooks,context:this.context,accessPath:this.accessPath,pathId:"webhooks",basePath:r,servers:t,globalAuth:this.auth})),this.input.components!=null&&(this.components=new VUu({input:this.input.components,context:this.context,accessPath:this.accessPath,pathId:"components"})),this.globalHeaders=new XUu({input:this.input,context:this.context,accessPath:this.accessPath,pathId:"x-fern-global-headers"})}convert(){let t=xrt(),{webhookEndpoints:r,endpoints:n}=this.paths?.convert()??{},i={...this.webhooks?.convert()??{},...r??{}},a=CAv({endpoints:n,webhookEndpoints:i}),{types:o,auths:c}=this.components?.convert()??{};return{id:Yj.ApiDefinitionId(t),endpoints:n??{},websockets:{},webhooks:i,types:{...o,...this.context.generatedTypes},subpackages:a,auths:{...c,...this.auth?.convert()??{}},globalHeaders:this.globalHeaders?.convert(),snippetsConfiguration:void 0}}};async function LUf(e,t){if(e instanceof XVr){t.logger.info("Skipping, API is specified as a Fern Definition.");return}else if(!(e instanceof E$))return;let r=new zqr(e.absoluteFilePath),n=await Ght({context:t,specs:e.specs}),i=await r.loadDocuments({context:t,specs:n}),a;for(let o of i){if(o.type!=="openapi")continue;let c={document:o.value,logger:t.logger,errors:new K9u,generatedTypes:{}},f=new kUu({input:o.value,context:c,accessPath:[],pathId:e.workspaceName??"openapi parser"});a=dKl(a,f.convert())}return a}var eqv=$i(WUf(),1),tqv=$i(QVu(),1),rqv=require("fs/promises"),nqv=$i(require("http"),1),iqv=$i(require("path"),1);var yDv=require("events"),GVu=$i(require("fs"),1),xda=$i(require("path"),1);var ZSv=$i(require("os"),1),kSv=300,n2i=20,Hns=1e7,eDv=ZSv.default.platform();var WiM=eDv==="darwin",cWf=eDv==="win32",i2i=WiM||cWf,tDv=3e3,rDv=2e4,lWf=1250;var mWr;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})(mWr||(mWr={}));var Fda;(function(e){e.CHANGE="change",e.RENAME="rename"})(Fda||(Fda={}));var Jns;(function(e){e.CHANGE="change",e.ERROR="error"})(Jns||(Jns={}));var QS;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(QS||(QS={}));var WCe;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(WCe||(WCe={}));var GiM=(e,t=1,r)=>{t=Math.max(1,t);let n=r?.leading??!1,i=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,f=0,u=0,s=()=>{let q=Date.now(),V=q-f,$=q-u,re=V>=t||$>=a;return[q,re]},l=q=>{if(u=q,!o)return;let V=o;o=void 0,e.apply(void 0,V)},m=()=>{z(0)},O=()=>{c&&(m(),l(Date.now()))},P=q=>{if(u=q,n)return l(q)},C=q=>{if(i&&o)return l(q);o=void 0},I=()=>{c=void 0;let[q,V]=s();return V?C(q):T(q)},T=q=>{let V=q-f,$=q-u,re=t-V,Y=a-$,k=Math.min(re,Y);return z(k)},z=q=>{c&&clearTimeout(c),!(q<=0)&&(c=setTimeout(I,q))},U=(...q)=>{let[V,$]=s(),re=!!c;if(o=q,f=V,($||!c)&&z(t),$)return re?l(V):P(V)};return U.cancel=m,U.flush=O,U},LVu=GiM;var _Wf=$i(require("fs"),1),VVu=$i(require("path"),1);var $4=$i(require("fs"),1),_be=require("util");var xwi=(e,t)=>function(...n){return e.apply(void 0,n).catch(t)},OWr=(e,t)=>function(...n){try{return e.apply(void 0,n)}catch(i){return t(i)}};var fWf=$i(require("process"),1),nDv=fWf.default.getuid?!fWf.default.getuid():!1,iDv=1e4,Zxe=()=>{};var Kns={isChangeErrorOk:e=>{if(!Kns.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!nDv&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!Kns.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!Kns.isNodeError(e))throw e;if(!Kns.isChangeErrorOk(e))throw e}},qee=Kns;var dWf=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=iDv,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(n),n=()=>t(r);this.add(n)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},aDv=new dWf;var zwi=(e,t)=>function(n){return function i(...a){return aDv.schedule().then(o=>{let c=u=>(o(),u),f=u=>{if(o(),Date.now()>=n)throw u;if(t(u)){let s=Math.round(100*Math.random());return new Promise(m=>setTimeout(m,s)).then(()=>i.apply(void 0,a))}throw u};return e.apply(void 0,a).then(c,f)})}},Qwi=(e,t)=>function(n){return function i(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>n)throw o;if(t(o))return i.apply(void 0,a);throw o}}};var HiM={attempt:{chmod:xwi((0,_be.promisify)($4.default.chmod),qee.onChangeError),chown:xwi((0,_be.promisify)($4.default.chown),qee.onChangeError),close:xwi((0,_be.promisify)($4.default.close),Zxe),fsync:xwi((0,_be.promisify)($4.default.fsync),Zxe),mkdir:xwi((0,_be.promisify)($4.default.mkdir),Zxe),realpath:xwi((0,_be.promisify)($4.default.realpath),Zxe),stat:xwi((0,_be.promisify)($4.default.stat),Zxe),unlink:xwi((0,_be.promisify)($4.default.unlink),Zxe),chmodSync:OWr($4.default.chmodSync,qee.onChangeError),chownSync:OWr($4.default.chownSync,qee.onChangeError),closeSync:OWr($4.default.closeSync,Zxe),existsSync:OWr($4.default.existsSync,Zxe),fsyncSync:OWr($4.default.fsync,Zxe),mkdirSync:OWr($4.default.mkdirSync,Zxe),realpathSync:OWr($4.default.realpathSync,Zxe),statSync:OWr($4.default.statSync,Zxe),unlinkSync:OWr($4.default.unlinkSync,Zxe)},retry:{close:zwi((0,_be.promisify)($4.default.close),qee.isRetriableError),fsync:zwi((0,_be.promisify)($4.default.fsync),qee.isRetriableError),open:zwi((0,_be.promisify)($4.default.open),qee.isRetriableError),readFile:zwi((0,_be.promisify)($4.default.readFile),qee.isRetriableError),rename:zwi((0,_be.promisify)($4.default.rename),qee.isRetriableError),stat:zwi((0,_be.promisify)($4.default.stat),qee.isRetriableError),write:zwi((0,_be.promisify)($4.default.write),qee.isRetriableError),writeFile:zwi((0,_be.promisify)($4.default.writeFile),qee.isRetriableError),closeSync:Qwi($4.default.closeSync,qee.isRetriableError),fsyncSync:Qwi($4.default.fsyncSync,qee.isRetriableError),openSync:Qwi($4.default.openSync,qee.isRetriableError),readFileSync:Qwi($4.default.readFileSync,qee.isRetriableError),renameSync:Qwi($4.default.renameSync,qee.isRetriableError),statSync:Qwi($4.default.statSync,qee.isRetriableError),writeSync:Qwi($4.default.writeSync,qee.isRetriableError),writeFileSync:Qwi($4.default.writeFileSync,qee.isRetriableError)}},oDv=HiM;var UVu=$i(require("fs"),1),$ns=$i(require("path"),1);var pWf=()=>{};var JiM=()=>{let e=pWf,t=pWf,r=!1,n=!1;return{promise:new Promise((f,u)=>{e=s=>(r=!0,f(s)),t=s=>(n=!0,u(s))}),resolve:e,reject:t,isPending:()=>!r&&!n,isResolved:()=>r,isRejected:()=>n}},sDv=JiM;var KiM=()=>{let{promise:e,resolve:t,isPending:r}=sDv(),n=0,i=()=>{n+=1},a=()=>{n-=1,!n&&t()};return(()=>{i(),queueMicrotask(a)})(),{promise:e,isPending:r,increment:i,decrement:a}},uDv=KiM;var cDv={then:e=>{e()}};var lDv=e=>Array.isArray(e)?e:[e],fDv=e=>typeof e=="function";var $iM=(e,t)=>{let r=t?.followSymlinks??!1,n=t?.depth??1/0,i=t?.limit??1/0,a=t?.ignore??[],o=lDv(a).map(xe=>fDv(xe)?xe:Be=>xe.test(Be)),c=xe=>o.some(Be=>Be(xe)),f=t?.signal??{aborted:!1},u=t?.onDirents||(()=>{}),s=[],l=new Set,m={},O=[],P=new Set,C={},I=[],T=new Set,z={},U={},q=new Set,V={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},$={directories:s,directoriesNames:l,directoriesNamesToPaths:m,files:O,filesNames:P,filesNamesToPaths:C,symlinks:I,symlinksNames:T,symlinksNamesToPaths:z,map:U},{promise:re,increment:Y,decrement:k}=uDv(),ne=0,me=(xe,Be,Jt,pt)=>{q.has(Be)||ne>=i||(ne+=1,xe.directories.push(Be),xe.directoriesNames.add(Jt),s.push(Be),l.add(Jt),m.propertyIsEnumerable(Jt)||(m[Jt]=[]),m[Jt].push(Be),q.add(Be),!(pt>=n)&&(ne>=i||Ee(Be,pt+1)))},_e=(xe,Be,Jt)=>{q.has(Be)||ne>=i||(ne+=1,xe.files.push(Be),xe.filesNames.add(Jt),O.push(Be),P.add(Jt),C.propertyIsEnumerable(Jt)||(C[Jt]=[]),C[Jt].push(Be),q.add(Be))},ve=(xe,Be,Jt,pt)=>{q.has(Be)||ne>=i||(ne+=1,xe.symlinks.push(Be),xe.symlinksNames.add(Jt),I.push(Be),T.add(Jt),z.propertyIsEnumerable(Jt)||(z[Jt]=[]),z[Jt].push(Be),q.add(Be),r&&(pt>=n||ne>=i||Ot(Be,pt+1)))},pe=(xe,Be,Jt,pt,vr)=>{f.aborted||c(Be)||(pt.isDirectory()?me(xe,Be,Jt,vr):pt.isFile()?_e(xe,Be,Jt):pt.isSymbolicLink()&&ve(xe,Be,Jt,vr))},De=(xe,Be,Jt,pt)=>{if(f.aborted)return;let vr=Be===$ns.default.sep?"":$ns.default.sep,Gt=Jt.name,Xe=`${Be}${vr}${Gt}`;c(Xe)||(Jt.isDirectory()?me(xe,Xe,Gt,pt):Jt.isFile()?_e(xe,Xe,Gt):Jt.isSymbolicLink()&&ve(xe,Xe,Gt,pt))},Ce=(xe,Be,Jt,pt)=>{for(let vr=0,Gt=Jt.length;vr<Gt;vr++)De(xe,Be,Jt[vr],pt)},Ee=(xe,Be)=>{f.aborted||Be>n||ne>=i||(Y(),UVu.default.readdir(xe,{withFileTypes:!0},(Jt,pt)=>{if(Jt||f.aborted||!pt.length)return k();(u(pt)||cDv).then(()=>{let Gt=U[xe]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};Ce(Gt,xe,pt,Be),k()})}))},Ot=(xe,Be)=>{Y(),UVu.default.realpath(xe,(Jt,pt)=>{if(Jt||f.aborted)return k();UVu.default.stat(pt,(vr,Gt)=>{if(vr||f.aborted)return k();let Xe=$ns.default.basename(pt),dt=U[xe]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};pe(dt,pt,Xe,Gt,Be),k()})})};return(async(xe,Be=1)=>(xe=$ns.default.normalize(xe),q.add(xe),Ee(xe,Be),await re,f.aborted?V:$))(e)},dDv=$iM;var AWr={lang:{debounce:LVu,attempt:e=>{try{return e()}catch(t){return AWr.lang.castError(t)}},castArray:e=>AWr.lang.isArray(e)?e:[e],castError:e=>AWr.lang.isError(e)?e:AWr.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(AWr.lang.isNaN(e))return AWr.lang.isNaN(t);if(AWr.lang.isPrimitive(e)||AWr.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(VVu.default.sep).length-1),getRealPath:(e,t)=>{try{return t?_Wf.default.realpathSync.native(e):_Wf.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===VVu.default.sep&&t.length-e.length>VVu.default.sep.length,poll:(e,t=rDv)=>oDv.retry.stat(t)(e,{bigint:!0}).catch(AWr.lang.noop),readdir:async(e,t,r=1/0,n=1/0,i,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await dDv(e,{depth:r,limit:n,ignore:t,signal:i});return[o.directories,o.files]}}}},gB=AWr;var WVu=$i(require("path"),1);var hWf=class{constructor(t,r,n){this.base=n,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||gB.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=kSv){return(()=>{let r=this.watcher._readyWait,n=[],i=new Set,a=async(c,f)=>{let u=this.options.ignoreInitial?[]:c,s=await this.eventsPopulate([...f]),l=this.eventsDeduplicate([...u,...s]);this.onTargetEvents(l)},o=gB.lang.debounce(()=>{this.watcher.isClosed()||(r=a(n,i),n=[],i=new Set)},t);return async(c,f="",u=!1)=>{u?await this.eventsPopulate([f],n,!0):i.add(f),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((n,i)=>{let[a,o]=i,c=r[o];return a===c||a===QS.CHANGE&&c===QS.ADD||(r[o]=a,n.push(i)),n},[])}async eventsPopulate(t,r=[],n=!1){return await Promise.all(t.map(async i=>{let a=await this.watcher._poller.update(i,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,i]),o===QS.ADD_DIR?await this.eventsPopulateAddDir(t,i,r,n):o===QS.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,i,r,n)}))})),r}async eventsPopulateAddDir(t,r,n=[],i=!1){if(i)return n;let a=this.options.recursive?this.options.depth??n2i:Math.min(1,this.options.depth??n2i),o=this.options.limit??Hns,[c,f]=await gB.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),u=[...c,...f];return await Promise.all(u.map(s=>{if(!this.watcher.isIgnored(s,this.options.ignore)&&!t.includes(s))return this.eventsPopulate([s],n,!0)})),n}async eventsPopulateUnlinkDir(t,r,n=[],i=!1){if(i)return n;for(let a of this.watcher._poller.stats.keys())gB.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],n,!0));return n}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(QS.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!i2i&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(QS.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(QS.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(WVu.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(QS.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(WVu.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(QS.UNLINK_DIR,t))}onTargetEvent(t){let[r,n]=t;r===QS.ADD?this.onTargetAdd(n):r===QS.ADD_DIR?this.onTargetAddDir(n):r===QS.CHANGE?this.onTargetChange(n):r===QS.UNLINK?this.onTargetUnlink(n):r===QS.UNLINK_DIR&&this.onTargetUnlinkDir(n)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,n=!1){return this.handlerBatched(t,r,n)}onWatcherChange(t=Fda.CHANGE,r){if(this.watcher.isClosed())return;let n=WVu.default.resolve(this.folderPath,r||"");this.filePath&&n!==this.folderPath&&n!==this.filePath||this.watcher.isIgnored(n,this.options.ignore)||this.onWatcherEvent(t,n)}onWatcherError(t){cWf&&t.code==="EPERM"?this.onWatcherChange(Fda.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(Jns.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(Jns.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(Fda.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&i2i&&this.options.native!==!1?this.options.depth??n2i:Math.min(1,this.options.depth??n2i),n=this.options.limit??Hns,[i,a]=await gB.fs.readdir(this.folderPath,this.options.ignore,r,n,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...i,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(Fda.CHANGE,c,t)}))}}},pDv=hWf;var GCe={interval:100,intervalId:void 0,fns:new Map,init:()=>{GCe.intervalId||(GCe.intervalId=setInterval(GCe.resolve,GCe.interval))},reset:()=>{GCe.intervalId&&(clearInterval(GCe.intervalId),delete GCe.intervalId)},add:(e,t)=>{GCe.fns.set(e,Date.now()+t),GCe.init()},remove:e=>{GCe.fns.delete(e)},resolve:()=>{if(!GCe.fns.size)return GCe.reset();let e=Date.now();for(let[t,r]of GCe.fns)r>=e||(GCe.remove(t),t())}},Yns=GCe;var Xns=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=lWf){let{ino:n,targetPath:i,events:a,locks:o}=t,c=()=>{let l=this._watcher._poller.paths.find(n||-1,m=>m!==i);if(l&&l!==i){if(gB.fs.getRealPath(i,!0)===l)return;this._watcher.event(a.rename,l,i)}else this._watcher.event(a.add,i)};if(!n)return c();let f=()=>{o.add.delete(n),Yns.remove(u)},u=()=>{f(),c()};Yns.add(u,r);let s=()=>{let l=o.unlink.get(n);if(!l)return;f();let m=l();i===m?a.change&&this._watcher._poller.stats.has(i)&&this._watcher.event(a.change,i):this._watcher.event(a.rename,m,i)};o.add.set(n,s),s()}getLockUnlink(t,r=lWf){let{ino:n,targetPath:i,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,i)};if(!n)return c();let f=()=>{o.unlink.delete(n),Yns.remove(u)},u=()=>{f(),c()};Yns.add(u,r);let s=()=>(f(),i);o.unlink.set(n,s),o.add.get(n)?.()}getLockTargetAdd(t,r){let n=this._watcher._poller.getIno(t,QS.ADD,mWr.FILE);return this.getLockAdd({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let n=this._watcher._poller.getIno(t,QS.ADD_DIR,mWr.DIR);return this.getLockAdd({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let n=this._watcher._poller.getIno(t,QS.UNLINK,mWr.FILE);return this.getLockUnlink({ino:n,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let n=this._watcher._poller.getIno(t,QS.UNLINK_DIR,mWr.DIR);return this.getLockUnlink({ino:n,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};Xns.DIR_EVENTS={add:QS.ADD_DIR,rename:QS.RENAME_DIR,unlink:QS.UNLINK_DIR};Xns.FILE_EVENTS={add:QS.ADD,change:QS.CHANGE,rename:QS.RENAME,unlink:QS.UNLINK};var _Dv=Xns;var yWf=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(gB.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let n=this.map.get(t);if(gB.lang.isSet(n)){let i=n.delete(r);return n.size||this.map.delete(t),i}else if(n===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let n=this.map.get(t);if(gB.lang.isSet(n))return Array.from(n).find(r);if(r(n))return n}}get(t){return this.map.get(t)}has(t,r){if(gB.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let n=this.map.get(t);return gB.lang.isSet(n)?n.has(r):n===r}return!1}set(t,r){if(this.map.has(t)){let n=this.map.get(t);gB.lang.isSet(n)?n.add(r):n!==r&&this.map.set(t,new Set([n,r]))}else this.map.set(t,r);return this}},vWf=yWf;var bWf=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},hDv=bWf;var gWf=class{constructor(){this.inos={},this.paths=new vWf,this.stats=new Map}getIno(t,r,n){let i=this.inos[r];if(!i)return;let a=i[t];if(a&&!(n&&a[1]!==n))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let n=await gB.fs.poll(t,r);if(!(!n||!(n.isFile()||n.isDirectory())))return new hDv(n)}reset(){this.inos={},this.paths=new vWf,this.stats=new Map}async update(t,r){let n=this.getStats(t),i=await this.poll(t,r);if(this.updateStats(t,i),!n&&i){if(i.isFile())return this.updateIno(t,QS.ADD,i),[QS.ADD];if(i.isDirectory())return this.updateIno(t,QS.ADD_DIR,i),[QS.ADD_DIR]}else if(n&&!i){if(n.isFile())return this.updateIno(t,QS.UNLINK,n),[QS.UNLINK];if(n.isDirectory())return this.updateIno(t,QS.UNLINK_DIR,n),[QS.UNLINK_DIR]}else if(n&&i){if(n.isFile()){if(i.isFile())return n.ino===i.ino&&!n.size&&!i.size?[]:(this.updateIno(t,QS.CHANGE,i),[QS.CHANGE]);if(i.isDirectory())return this.updateIno(t,QS.UNLINK,n),this.updateIno(t,QS.ADD_DIR,i),[QS.UNLINK,QS.ADD_DIR]}else if(n.isDirectory()){if(i.isFile())return this.updateIno(t,QS.UNLINK_DIR,n),this.updateIno(t,QS.ADD,i),[QS.UNLINK_DIR,QS.ADD];if(i.isDirectory())return n.ino===i.ino?[]:(this.updateIno(t,QS.UNLINK_DIR,n),this.updateIno(t,QS.ADD_DIR,i),[QS.UNLINK_DIR,QS.ADD_DIR])}}return[]}updateIno(t,r,n){let i=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=n.isFile()?mWr.FILE:mWr.DIR;i[t]=[n.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let n=this.stats.get(t)?.ino||-1;this.paths.delete(n,t),this.stats.delete(t)}}},mWf=gWf;var OWf=class e extends yDv.EventEmitter{constructor(t,r,n){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(WCe.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(i=>this.on(WCe.CLOSE,i)),this._readyWait=new Promise(i=>this.on(WCe.READY,i)),this._locker=new _Dv(this),this._roots=new Set,this._poller=new mWf,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,n)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(gB.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(WCe.CLOSE))}error(t){if(this.isClosed())return!1;let r=gB.lang.castError(t);return this.emit(WCe.ERROR,r)}event(t,r,n){return this.isClosed()?!1:(this.emit(WCe.ALL,t,r,n),this.emit(t,r,n))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(WCe.READY))}pollerExists(t,r){for(let n of this._pollers)if(n.targetPath===t&&gB.lang.isShallowEqual(n.options,r))return!0;return!1}subwatcherExists(t,r){for(let n of this._subwatchers)if(n.targetPath===t&&gB.lang.isShallowEqual(n.options,r))return!0;return!1}watchersClose(t,r,n=!0){if(t){let i=this._watchers[t];if(i)for(let a of[...i])r&&a.filePath!==r||this.watcherClose(a);if(n)for(let a in this._watchers)gB.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let i in this._watchers)this.watchersClose(i,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,n]of t)this.watchPath(r,n.options,n.handler)}async watcherAdd(t,r){let{folderPath:n}=t;(this._watchers[n]=this._watchers[n]||[]).push(t);let a=new pDv(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let n=t.filePath||t.folderPath;this._roots.has(n)&&(this._watchersRestorable[n]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=gB.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,n,i){if(this._watchers[t]?.find(c=>c.handler===n&&(!c.filePath||c.filePath===i)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=xda.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(s=>(c===1||s.options.recursive&&c<=(s.options.depth??n2i))&&s.handler===n&&(!s.filePath||s.filePath===i)&&s.options.ignore===r.ignore&&!!s.options.native==!!r.native&&(!r.recursive||s.options.recursive&&i2i&&s.options.native!==!1)))return!0;if(!i2i)break;let u=xda.default.dirname(t);if(o===u)break;o=u}return!1}async watchDirectories(t,r,n,i,a){if(this.isClosed())return;t=gB.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,n,i))try{let f=!r.recursive||i2i&&r.native!==!1?r:{...r,recursive:!1},s={watcher:GVu.default.watch(c,f),handler:n,options:r,folderPath:c,filePath:i},l=o=await this.watcherAdd(s,a);if(this._roots.has(i||c)){let O={...r,ignoreInitial:!0,recursive:!1},P=xda.default.dirname(c),C=c;await this.watchDirectories([P],O,n,C,l)}}catch(f){this.error(f)}return o}async watchDirectory(t,r,n,i,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||i2i&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,n,i,a));{r={...r,recursive:!0};let o=r.depth??n2i,c=r.limit??Hns,[f]=await gB.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let u=await this.watchDirectories([t],r,n,i,a);if(f.length){let s=gB.fs.getDepth(t);for(let l of f){let m=gB.fs.getDepth(l),O=Math.max(0,o-(m-s)),P={...r,depth:O};await this.watchDirectories([l],P,n,i,a||u)}}})}}}async watchFileOnce(t,r,n){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let i={targetPath:t,options:r},a=(u,s)=>{s===t&&(f(),n())},o=new e(a),c=()=>{this._subwatchers.add(i),this.on(WCe.CLOSE,f),o.watchFile(t,r,a)},f=()=>{this._subwatchers.delete(i),this.removeListener(WCe.CLOSE,f),o.close()};return c()}async watchFile(t,r,n){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let i=xda.default.dirname(t);return this.watchDirectory(i,r,n,t)}async watchPollingOnce(t,r,n){if(this.isClosed())return;let i=!1,a=new mWf,o=await this.watchPolling(t,r,async()=>{i||!(await a.update(t,r.pollingTimeout)).length||i||(i=!0,o(),n())})}async watchPolling(t,r,n){if(this.isClosed())return gB.lang.noop;if(this.pollerExists(t,r))return gB.lang.noop;let i={...r,interval:r.pollingInterval??tDv},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(WCe.CLOSE,c),GVu.default.watchFile(t,i,n)},c=()=>{this._pollers.delete(a),this.removeListener(WCe.CLOSE,c),GVu.default.unwatchFile(t,n)};return gB.lang.attempt(o),()=>gB.lang.attempt(c)}async watchUnknownChild(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchFileOnce(t,r,i)}async watchUnknownTarget(t,r,n){if(this.isClosed())return;let i=()=>this.watchPath(t,r,n);return this.watchPollingOnce(t,r,i)}async watchPaths(t,r,n){if(this.isClosed())return;if(t=gB.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,f)=>f===o||!gB.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,n)));else for(let a of t)await this.watchPath(a,r,n)}async watchPath(t,r,n){if(this.isClosed()||(t=xda.default.resolve(t),this.isIgnored(t,r.ignore)))return;let i=await gB.fs.poll(t,r.pollingTimeout);if(i){if(i.isFile())return this.watchFile(t,r,n);if(i.isDirectory())return this.watchDirectory(t,r,n);this.error(`"${t}" is not supported`)}else{let a=xda.default.dirname(t);return(await gB.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,n):this.watchUnknownTarget(t,r,n)}}async watch(t,r,n=gB.lang.noop){if(gB.lang.isFunction(t))return this.watch([],{},t);if(gB.lang.isUndefined(t))return this.watch([],r,n);if(gB.lang.isFunction(r))return this.watch(t,{},r);if(gB.lang.isUndefined(r))return this.watch(t,{},n);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let i=gB.lang.castArray(t);i.forEach(a=>this._roots.add(a)),await this.watchPaths(i,r,n),!this.isClosed()&&(n!==gB.lang.noop&&this.on(WCe.ALL,n),r.readdirMap=void 0,this.ready())}},HVu=OWf;kTu();var NTv=$i(NWu(),1),kxe=require("fs/promises"),FTv=require("os"),xTv=$i(RDe(),1),zTv=$i(RTv(),1),kWu=process.platform==="win32",GuM="etag",HuM="preview",JuM="app-preview",KuM="bundle",$uM=".next",YuM="standalone",XuM=".fern",ZuM="packages/fern-docs/bundle/.next/server/instrumentation.js",kuM=".npmrc",ecM=".pnpmfile.cjs",tcM="pnpm-workspace.yaml",rcM='Cannot find matching keyid: {"signatures":';function ncM(){return Ql(F_.of((0,FTv.homedir)()),ru.of(XuM))}function eGu({app:e=!1}){return Ql(ncM(),ru.of(e?JuM:HuM))}function p2i({app:e=!1}){return Ql(eGu({app:e}),ru.of(e?$uM:KuM))}function Ois({app:e=!1}){return Ql(p2i({app:e}),ru.of(YuM))}function icM({app:e=!1}){return Ql(Ois({app:e}),ru.of(ZuM))}function acM({app:e=!1}){return Ql(Ois({app:e}),ru.of(tcM))}function ocM({app:e=!1}){return Ql(Ois({app:e}),ru.of(ecM))}function scM({app:e=!1}){return Ql(Ois({app:e}),ru.of(kuM))}function Wda(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function ucM({app:e=!1}){return Ql(eGu({app:e}),ru.of(GuM))}var ccM=`module.exports = {
|
|
3033
3043
|
hooks: {
|
|
3034
3044
|
readPackage(pkg) {
|
|
3035
3045
|
// Remove all workspace:* dependencies
|